summaryrefslogtreecommitdiff
path: root/sys/dev/pci/mfii.c
AgeCommit message (Collapse)Author
2020-09-22Since dlg@'s 2009 scsi midlayer refactoring the 'struct scsi_generic *cmd'Kenneth R Westerback
member of 'struct scsi_xfer' has always been pointed at the 'struct scsi_generic cmdstore' member of the same instance. So nuke 'cmdstore' and remove the '*' from cmd. Take the address of cmd as required by the various casts. No intentional functional change. luna88k test by aoyama@, sparc64 test by jmatthew@ Identification of 2009's last *cmd use and ok jmatthew@
2020-09-01Rename [READ|WRITE]_BIG to [READ|WRITE]_10. Rename struct scsi_rw_big toKenneth R Westerback
struct scsi_rw_10. ok gnezdo@ jmatthew@ (who also did sparc64 compile test)
2020-07-22Nuke unused struct scsi_link members of adapter softc's where theKenneth R Westerback
driver successfully compiles on one or more of amd64, i386, hppa.
2020-07-20Move remaining scsi bus initialization info from "prototype scsi link"Kenneth R Westerback
fields to struct scsibus_attach_args. Nuke the struct scsi_link * (saa_sc_link) in scaibus_attach_args. Explicitly initialize each field in scsibus_attach_args variables.
2020-07-19Move the adapter related items (luns, adapter, adapter_target,Kenneth R Westerback
adapter_buswidth, adapter_softc) from struct scsi_link to struct scsibus_attach_args. Additional compile tests by jmatthew@ (sparc64) and aoyam@ (luna88k).
2020-07-16Access adapter softc via link->bus->sb_adapter_softc.Kenneth R Westerback
In sparc64 autoconf access 'luns' via sb_luns and 'adapter_buswidth' via sb_adapter_buswidth. Removes last post-config uses of the copies of bus related information in scsi_link.
2020-07-13Where we have a pointer (sc) to the relevant adapter_softc, useKenneth R Westerback
&sc->sc_dev to get a device pointer rather than using the void * whence we obtained 'sc'.
2020-07-13Remove some pointless casting of void * when assigning oneKenneth R Westerback
(scsi_link.adapter_softc) to a pointer of a particular softc type.
2020-07-11Expunge some Captain Obvious comments, tweak whitespace a bit, move a debugKenneth R Westerback
statement. All to make upcoming diff(s) smaller and easier to read.
2020-06-27Nuke trailing whitespace.Kenneth R Westerback
2020-06-27No need to bzero()/memset() 'struct scsibus_attach_args' variablesKenneth R Westerback
immediately before initializing the only field in the struct.
2020-06-24kernel: use gettime(9)/getuptime(9) in lieu of time_second(9)/time_uptime(9)cheloha
time_second(9) and time_uptime(9) are widely used in the kernel to quickly get the system UTC or system uptime as a time_t. However, time_t is 64-bit everywhere, so it is not generally safe to use them on 32-bit platforms: you have a split-read problem if your hardware cannot perform atomic 64-bit reads. This patch replaces time_second(9) with gettime(9), a safer successor interface, throughout the kernel. Similarly, time_uptime(9) is replaced with getuptime(9). There is a performance cost on 32-bit platforms in exchange for eliminating the split-read problem: instead of two register reads you now have a lockless read loop to pull the values from the timehands. This is really not *too* bad in the grand scheme of things, but compared to what we were doing before it is several times slower. There is no performance cost on 64-bit (__LP64__) platforms. With input from visa@, dlg@, and tedu@. Several bugs squashed by visa@. ok kettenis@
2020-06-24Use SDEV_NO_ADAPTER_TARGET instead of the value that is beingKenneth R Westerback
aassigned to adapter_buswidth to indicate the adapter is not a target on the bus. ok dlg@ as part of a larger diff.
2020-06-24Use SDEV_NO_ADAPTER_TARGET instead of -1 to indicateKenneth R Westerback
the adapter is not a target on the bus. ok dlg@ as part of a larger diff.
2020-03-21Simplify some goto'ing that jumps a single line orKenneth R Westerback
does nothing at all. The first one spotted as CID 1452976. Reads good to millert@ ok mpi@
2020-02-05Nuke unnecessary abstraction 'scsi_minphys()' which just callsKenneth R Westerback
'minphys()'. Just use & check for NULL instead, since 'minphys()' is always called on the code path ([cd|sd|st]minphys) that calls physio().
2020-01-25use SMR rather than SRP to protect the device handle arrayJonathan Matthew
ok dlg@
2020-01-23Use a consistant idiom/format when declaring scsi_adapter structuresKenneth R Westerback
in drivers. Terse one liners, NULLs instead of 0's, explicitly specify all members, etc. Nuke #ifdef notyet blocks related to the scsi_adapter in aic. No intentional functional change. ok tedu@
2019-12-31Convert infinite sleeps to {m,t}sleep_nsec(9).Martin Pieuchot
ok kn@
2019-09-09revert back to using 0x6c for the reply post index register.David Gwynne
this was mistakenly committed as part of the powerdown hook stuff, and caused "older" chips like SAS2208s to get stuck in biowait. reported by Mischa <obsdml at high5 dot nl> and hrvoje popovski discussed with jmatthew@ and alex wilson. fix tested by me on a SAS3508 and SAS2208
2019-08-28implement a DV_POWERDOWN handler to flush cache and shutdown the controllerDavid Gwynne
this has been in snaps for the last week without issue, and has been running in production on a bunch of my boxes for a week before that, also without issue.
2019-08-20Trailing whitespace.Kenneth R Westerback
2019-03-05swap MFI_LD_PROG_BGI and MFI_LD_PROG_CC cases to match value orderJonathan Matthew
ok dlg@
2019-03-01Background init progress and consistency check progress are reported inJonathan Matthew
different fields. Use the background init progress when that's the active task. lack of progress data noticed by deraadt@ tested on SAS2208 and SAS3508 ok dlg@
2018-08-14return ENOTTY rather than EINVAL to indicate an ioctl hasn't been handledJonathan Matthew
ok dlg@ deraadt@ kettenis@
2018-06-08Handle AENs for logical disk creation and deletion.Jonathan Matthew
SAS3 and newer controllers allow these operations at any time through the server management interface - tested on a SAS3108 (Lenovo x3650 M5) and SAS3508 (Dell R6415). ok dlg@
2018-06-08Rework sensors and bio(4) support to use the target number from the logicalJonathan Matthew
disk list, rather than assuming target numbers match the position in the list. Now we always allocate enough sensors for the maximum number of logical disks, so we can store sensor information indexed by target number. While here, split up the logical disk sensor code simplify adding and removing sensors for logical disks as they're created and destroyed. ok dlg@
2018-05-18Use SCSI_NOSLEEP for management commands issued during attach.Jonathan Matthew
No real change because we'll never run out of ccbs that early. Noticed during review of the preceding changes. ok dlg@
2018-05-18Add bio(4) and sensors for mfii(4), based on code from mfi(4). Most of theJonathan Matthew
work was done by Naoki Fukaumi, some tweaks and adjustment to match the preceding changes by me. Tested on SAS2208, SAS3008, SAS3108, SAS3508. ok dlg@
2018-05-18Make mfii_mgmt() allocate and release a ccb to simplify the most common useJonathan Matthew
case. Based on a diff from Naoki Fukaumi. We decided to keep using scsi flags rather than switching to MFII_DATA_IN/OUT (as done in mfi(4)) so callers can include SCSI_NOSLEEP if required. ok dlg@
2018-05-18Add DPRINTF/DNPRINTF for debug output as in mfi(4) and convert existingJonathan Matthew
debug output to use them. ok dlg@
2018-05-18Use passthrough IO rather than MFA for management commands.Jonathan Matthew
Investigation by Naoki Fukaumi determined that this is necessary on some controllers and works on all of them. Tested on SAS2208, SAS3008, SAS3108, SAS3508. ok dlg@
2018-03-16Improve calculation of the number of commands and sges available.Jonathan Matthew
The maximum number of commands may be specified in outbound scratch register 3, should be limited to 1024, and should further be reduced by one to ensure the reply queue doesn't overflow. The maximum number of sges in a command should be the highest power of two that fits in the space available in the io frame and in a chained sge frame. The maximum size of a chained frame is specified in outbound scratch register 2. part of a diff from Naoki Fukaumi ok dlg@
2018-03-16use MFI_STAT_INVALID_STATUS where appropriateJonathan Matthew
part of a diff from Naoki Fukaumi ok dlg@
2018-03-16Allocate an mfi frame for each ccb, to be used to submit passthroughJonathan Matthew
commands later. part of a diff from Naoki Fukaumi ok dlg@
2018-02-20Set the chain_offset field (same as sgl_offset0, only in 16 byte units)Jonathan Matthew
in passthrough IO requests, which makes AEN processing work on SAS2208 controllers, and since AEN processing works now, enable it again. tested on SAS2208 (PERC H710P) and SAS3108 (PERC H730), SAS3.5 parts should work too. ok dlg@
2018-02-02use the same bar used to determine memory type when mapping memoryJonathan Gray
should resolve mapping error on SAS3508 encountered by claudio@ ok jmatthew@
2017-11-27Add support for SAS3.5 megaraids, which are sold as Dell PERC H740P/840 andJonathan Matthew
Lenovo ThinkSystem RAID 530/930. The main differences are in fast path IO, which we don't use, so all we have to deal with is some changes in the raid context layout and different PCI BARs. The mfii_iop structure gets rearranged a bit to accommodate these. tested on a perc h740p and a h730 (by dlg@) ok dlg@
2017-09-08If you use sys/param.h, you don't need sys/types.hTheo de Raadt
2017-04-08A pile of sizes to free(9). In test for a few days in snapshots.Theo de Raadt
Errors will result in nice clean panic messages so we know what's wrong. Reviewed by dhill visa natano jsg.
2017-02-11disable aen handling.David Gwynne
on some or all original mfii boards (2208) the aen path fires repeatedly without reporting anything, causes enough load to start actual io. found by naddy@
2017-02-08fix a mixup of lengths of addresses and lengths in the aen_start sglDavid Gwynne
basically use htolem64 to set the address and htolem32 for the length, not the other way round. lucky this is mostly run on x86. found by Jon Kloske
2017-02-07handle physical disk state changes.David Gwynne
more specificially we probe the disk if it goes from UNCONFIGURED_GOOD to a SYSTEM disk, and detach it if goes from being a SYSTEM disk to anything else. this semantic comes from the lsi^Wavago code in the illumos mr_sas driver. seems to work fine. i think this covers all the ways a passthru disk can transition on these boards.
2017-02-07i got the MFII_TASK_MGMT flags round the wrong way.David Gwynne
2017-02-07support hotplug of physical disks.David Gwynne
this only handles MFI_EVT_PD_INSERTED_EXT and MFI_EVT_PD_REMOVED_EXT so far. if this code is to be reused in mfi, it should probably change to use MFI_EVT_PD_INSERTED and MFI_EVT_PD_REMOVED instead. unlike mpii and mpi, it looks like the firmware aborts outstanding commands against a disk when it's physically removed, so we dont have to explicitly abort them. this is probably a carry over from mfi generation boards which dont have an explicit abort command they can use.
2017-02-07add the framework around asynchronous event notifications.David Gwynne
this submits MR_DCMD_CTRL_EVENT_WAIT commands via the async dcmd path to read all events from boot onward, and eventually ends up waiting after the boot messages are consumed. right now none of the events are handled, but this can be added now this framework is in place. the board does generate human readable log messages for every event. we can send them somewhere (dmesg or syslog for example), but for now theyre masked by #if 0.
2017-02-07provide support for submitting async dcmd frames.David Gwynne
async dcmds are submitted via an mpii request (like the scsi commands are) which uses the ccb_request buffer, meaning that the dcmd itself has to go somewhere else. this reuses the sense buffer on the ccb for the dcmd, and provides wrappers for accessing that space and submitting a dcmd via the passthru command.
2017-02-07whitespace fixes. no functional change.David Gwynne
2017-02-06implement scsi command timeouts.David Gwynne
there's a struct timeout in scsi_xfer for this purpose, which is used to schedule a timeout of the command in the future. the timeout adds the xs to a list in mfii_softc of outstanding commands that are to be aborted. this list is processed in a task so we can sleep for an mfii_ccb. the new ccb is used to issue an abort against the specific command that timed out. to avoid having a timeout complete at the same time as a command on the chip, a refcnt is added to ccbs. the chip and the timeout get a ref each. the mfii completion path will attempt to timeout_del, and if that's succesful it will subtract the timeouts ref as well as its own. if it fails, the abort path owns the ccb and becomes responsible for calling scsi_done on behalf of the mfii completion path.
2017-02-06megaraid sas fusion chips have their own command for aborting tasksDavid Gwynne