Changeset View
Changeset View
Standalone View
Standalone View
sys/cam/ata/ata_da.c
Show First 20 Lines • Show All 291 Lines • ▼ Show 20 Lines | #ifdef CAM_IO_STATS | ||||
u_int invalidations; | u_int invalidations; | ||||
#endif | #endif | ||||
#define ADA_ANNOUNCETMP_SZ 80 | #define ADA_ANNOUNCETMP_SZ 80 | ||||
char announce_temp[ADA_ANNOUNCETMP_SZ]; | char announce_temp[ADA_ANNOUNCETMP_SZ]; | ||||
#define ADA_ANNOUNCE_SZ 400 | #define ADA_ANNOUNCE_SZ 400 | ||||
char announce_buffer[ADA_ANNOUNCE_SZ]; | char announce_buffer[ADA_ANNOUNCE_SZ]; | ||||
}; | }; | ||||
static uma_zone_t ada_ccb_zone; | |||||
struct ada_quirk_entry { | struct ada_quirk_entry { | ||||
struct scsi_inquiry_pattern inq_pat; | struct scsi_inquiry_pattern inq_pat; | ||||
ada_quirks quirks; | ada_quirks quirks; | ||||
}; | }; | ||||
static struct ada_quirk_entry ada_quirk_table[] = | static struct ada_quirk_entry ada_quirk_table[] = | ||||
{ | { | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 589 Lines • ▼ Show 20 Lines | |||||
static int ada_retry_count = ADA_DEFAULT_RETRY; | static int ada_retry_count = ADA_DEFAULT_RETRY; | ||||
static int ada_default_timeout = ADA_DEFAULT_TIMEOUT; | static int ada_default_timeout = ADA_DEFAULT_TIMEOUT; | ||||
static int ada_send_ordered = ADA_DEFAULT_SEND_ORDERED; | static int ada_send_ordered = ADA_DEFAULT_SEND_ORDERED; | ||||
static int ada_spindown_shutdown = ADA_DEFAULT_SPINDOWN_SHUTDOWN; | static int ada_spindown_shutdown = ADA_DEFAULT_SPINDOWN_SHUTDOWN; | ||||
static int ada_spindown_suspend = ADA_DEFAULT_SPINDOWN_SUSPEND; | static int ada_spindown_suspend = ADA_DEFAULT_SPINDOWN_SUSPEND; | ||||
static int ada_read_ahead = ADA_DEFAULT_READ_AHEAD; | static int ada_read_ahead = ADA_DEFAULT_READ_AHEAD; | ||||
static int ada_write_cache = ADA_DEFAULT_WRITE_CACHE; | static int ada_write_cache = ADA_DEFAULT_WRITE_CACHE; | ||||
static int ada_enable_biospeedup = 1; | static int ada_enable_biospeedup = 1; | ||||
static int ada_enable_uma_ccbs = 0; | |||||
static SYSCTL_NODE(_kern_cam, OID_AUTO, ada, CTLFLAG_RD | CTLFLAG_MPSAFE, 0, | static SYSCTL_NODE(_kern_cam, OID_AUTO, ada, CTLFLAG_RD | CTLFLAG_MPSAFE, 0, | ||||
"CAM Direct Access Disk driver"); | "CAM Direct Access Disk driver"); | ||||
SYSCTL_INT(_kern_cam_ada, OID_AUTO, retry_count, CTLFLAG_RWTUN, | SYSCTL_INT(_kern_cam_ada, OID_AUTO, retry_count, CTLFLAG_RWTUN, | ||||
&ada_retry_count, 0, "Normal I/O retry count"); | &ada_retry_count, 0, "Normal I/O retry count"); | ||||
SYSCTL_INT(_kern_cam_ada, OID_AUTO, default_timeout, CTLFLAG_RWTUN, | SYSCTL_INT(_kern_cam_ada, OID_AUTO, default_timeout, CTLFLAG_RWTUN, | ||||
&ada_default_timeout, 0, "Normal I/O timeout (in seconds)"); | &ada_default_timeout, 0, "Normal I/O timeout (in seconds)"); | ||||
SYSCTL_INT(_kern_cam_ada, OID_AUTO, send_ordered, CTLFLAG_RWTUN, | SYSCTL_INT(_kern_cam_ada, OID_AUTO, send_ordered, CTLFLAG_RWTUN, | ||||
&ada_send_ordered, 0, "Send Ordered Tags"); | &ada_send_ordered, 0, "Send Ordered Tags"); | ||||
SYSCTL_INT(_kern_cam_ada, OID_AUTO, spindown_shutdown, CTLFLAG_RWTUN, | SYSCTL_INT(_kern_cam_ada, OID_AUTO, spindown_shutdown, CTLFLAG_RWTUN, | ||||
&ada_spindown_shutdown, 0, "Spin down upon shutdown"); | &ada_spindown_shutdown, 0, "Spin down upon shutdown"); | ||||
SYSCTL_INT(_kern_cam_ada, OID_AUTO, spindown_suspend, CTLFLAG_RWTUN, | SYSCTL_INT(_kern_cam_ada, OID_AUTO, spindown_suspend, CTLFLAG_RWTUN, | ||||
&ada_spindown_suspend, 0, "Spin down upon suspend"); | &ada_spindown_suspend, 0, "Spin down upon suspend"); | ||||
SYSCTL_INT(_kern_cam_ada, OID_AUTO, read_ahead, CTLFLAG_RWTUN, | SYSCTL_INT(_kern_cam_ada, OID_AUTO, read_ahead, CTLFLAG_RWTUN, | ||||
&ada_read_ahead, 0, "Enable disk read-ahead"); | &ada_read_ahead, 0, "Enable disk read-ahead"); | ||||
SYSCTL_INT(_kern_cam_ada, OID_AUTO, write_cache, CTLFLAG_RWTUN, | SYSCTL_INT(_kern_cam_ada, OID_AUTO, write_cache, CTLFLAG_RWTUN, | ||||
&ada_write_cache, 0, "Enable disk write cache"); | &ada_write_cache, 0, "Enable disk write cache"); | ||||
SYSCTL_INT(_kern_cam_ada, OID_AUTO, enable_biospeedup, CTLFLAG_RDTUN, | SYSCTL_INT(_kern_cam_ada, OID_AUTO, enable_biospeedup, CTLFLAG_RDTUN, | ||||
&ada_enable_biospeedup, 0, "Enable BIO_SPEEDUP processing"); | &ada_enable_biospeedup, 0, "Enable BIO_SPEEDUP processing"); | ||||
SYSCTL_INT(_kern_cam_ada, OID_AUTO, enable_uma_ccbs, CTLFLAG_RWTUN, | |||||
&ada_enable_uma_ccbs, 0, "Use UMA for CCBs"); | |||||
/* | /* | ||||
* ADA_ORDEREDTAG_INTERVAL determines how often, relative | * ADA_ORDEREDTAG_INTERVAL determines how often, relative | ||||
* to the default timeout, we check to see whether an ordered | * to the default timeout, we check to see whether an ordered | ||||
* tagged transaction is appropriate to prevent simple tag | * tagged transaction is appropriate to prevent simple tag | ||||
* starvation. Since we'd like to ensure that there is at least | * starvation. Since we'd like to ensure that there is at least | ||||
* 1/2 of the timeout length left for a starved transaction to | * 1/2 of the timeout length left for a starved transaction to | ||||
* complete after we've sent an ordered tag, we must poll at least | * complete after we've sent an ordered tag, we must poll at least | ||||
▲ Show 20 Lines • Show All 241 Lines • ▼ Show 20 Lines | adadump(void *arg, void *virtual, vm_offset_t physical, off_t offset, size_t length) | ||||
return (error); | return (error); | ||||
} | } | ||||
static void | static void | ||||
adainit(void) | adainit(void) | ||||
{ | { | ||||
cam_status status; | cam_status status; | ||||
ada_ccb_zone = uma_zcreate("ada_ccb", | |||||
sizeof(struct ccb_ataio), NULL, NULL, NULL, NULL, | |||||
UMA_ALIGN_PTR, 0); | |||||
/* | /* | ||||
* Install a global async callback. This callback will | * Install a global async callback. This callback will | ||||
* receive async callbacks like "new device found". | * receive async callbacks like "new device found". | ||||
*/ | */ | ||||
status = xpt_register_async(AC_FOUND_DEVICE, adaasync, NULL, NULL); | status = xpt_register_async(AC_FOUND_DEVICE, adaasync, NULL, NULL); | ||||
if (status != CAM_REQ_CMP) { | if (status != CAM_REQ_CMP) { | ||||
printf("ada: Failed to attach master async callback " | printf("ada: Failed to attach master async callback " | ||||
▲ Show 20 Lines • Show All 660 Lines • ▼ Show 20 Lines | adaregister(struct cam_periph *periph, void *arg) | ||||
softc->read_ahead = -1; | softc->read_ahead = -1; | ||||
snprintf(announce_buf, ADA_ANNOUNCETMP_SZ, | snprintf(announce_buf, ADA_ANNOUNCETMP_SZ, | ||||
"kern.cam.ada.%d.read_ahead", periph->unit_number); | "kern.cam.ada.%d.read_ahead", periph->unit_number); | ||||
TUNABLE_INT_FETCH(announce_buf, &softc->read_ahead); | TUNABLE_INT_FETCH(announce_buf, &softc->read_ahead); | ||||
softc->write_cache = -1; | softc->write_cache = -1; | ||||
snprintf(announce_buf, ADA_ANNOUNCETMP_SZ, | snprintf(announce_buf, ADA_ANNOUNCETMP_SZ, | ||||
"kern.cam.ada.%d.write_cache", periph->unit_number); | "kern.cam.ada.%d.write_cache", periph->unit_number); | ||||
TUNABLE_INT_FETCH(announce_buf, &softc->write_cache); | TUNABLE_INT_FETCH(announce_buf, &softc->write_cache); | ||||
/* | |||||
* Let XPT know we can use UMA-allocated CCBs. | |||||
*/ | |||||
imp: Can you get a traceback of where it's called from before adainit()? I'd think it was only… | |||||
Done Inline ActionsIt is; the problem was, adainit was called before adaregister, as expected, but it didn't finish until after adaregister() was already running. Moving the UMA zone initialization to run earlier fixes the problem. trasz: It is; the problem was, adainit was called before adaregister, as expected, but it didn't… | |||||
KASSERT(ada_ccb_zone != NULL, ("%s: NULL ada_ccb_zone", __func__)); | |||||
impUnsubmitted Done Inline ActionsYou only need to kassert this when ada_enable_uma_ccbs is true. imp: You only need to kassert this when ada_enable_uma_ccbs is true.
| |||||
if (ada_enable_uma_ccbs) | |||||
periph->ccb_zone = ada_ccb_zone; | |||||
/* | /* | ||||
* Set support flags based on the Identify data and quirks. | * Set support flags based on the Identify data and quirks. | ||||
*/ | */ | ||||
adasetflags(softc, cgd); | adasetflags(softc, cgd); | ||||
if (softc->cpi.hba_misc & PIM_ATA_EXT) | if (softc->cpi.hba_misc & PIM_ATA_EXT) | ||||
softc->flags |= ADA_FLAG_PIM_ATA_EXT; | softc->flags |= ADA_FLAG_PIM_ATA_EXT; | ||||
▲ Show 20 Lines • Show All 1,834 Lines • Show Last 20 Lines |
Can you get a traceback of where it's called from before adainit()? I'd think it was only enterable after atainit() completes, but maybe the 'master callback' races this and we should do all the init prior to establishing that?