Commit fa138734 authored by Anton Blanchard's avatar Anton Blanchard

[PATCH] serialize bus scanning

Change scsi_scan_mutex from global to per host, which is needed for
parallel SCSI probe.


 gr16_work-anton/drivers/scsi/hosts.c     |    2 ++
 gr16_work-anton/drivers/scsi/scsi_scan.c |   15 ++++-----------
 gr16_work-anton/include/scsi/scsi_host.h |    6 ++++++
 3 files changed, 12 insertions(+), 11 deletions(-)
parent dba5578d
...@@ -214,6 +214,8 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize) ...@@ -214,6 +214,8 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
INIT_LIST_HEAD(&shost->starved_list); INIT_LIST_HEAD(&shost->starved_list);
init_waitqueue_head(&shost->host_wait); init_waitqueue_head(&shost->host_wait);
init_MUTEX(&shost->scan_mutex);
shost->host_no = scsi_host_next_hn++; /* XXX(hch): still racy */ shost->host_no = scsi_host_next_hn++; /* XXX(hch): still racy */
shost->dma_channel = 0xff; shost->dma_channel = 0xff;
......
...@@ -95,13 +95,6 @@ MODULE_PARM_DESC(max_report_luns, ...@@ -95,13 +95,6 @@ MODULE_PARM_DESC(max_report_luns,
" between 1 and 16384)"); " between 1 and 16384)");
#endif #endif
/*
* This mutex serializes all scsi scanning activity from kernel- and
* userspace. It could easily be made per-host but I'd like to avoid
* the overhead for now.
*/
static DECLARE_MUTEX(scsi_scan_mutex);
/** /**
* scsi_unlock_floptical - unlock device via a special MODE SENSE command * scsi_unlock_floptical - unlock device via a special MODE SENSE command
* @sreq: used to send the command * @sreq: used to send the command
...@@ -1075,11 +1068,11 @@ struct scsi_device *scsi_add_device(struct Scsi_Host *shost, ...@@ -1075,11 +1068,11 @@ struct scsi_device *scsi_add_device(struct Scsi_Host *shost,
struct scsi_device *sdev; struct scsi_device *sdev;
int res; int res;
down(&scsi_scan_mutex); down(&shost->scan_mutex);
res = scsi_probe_and_add_lun(shost, channel, id, lun, NULL, &sdev, 1); res = scsi_probe_and_add_lun(shost, channel, id, lun, NULL, &sdev, 1);
if (res != SCSI_SCAN_LUN_PRESENT) if (res != SCSI_SCAN_LUN_PRESENT)
sdev = ERR_PTR(-ENODEV); sdev = ERR_PTR(-ENODEV);
up(&scsi_scan_mutex); up(&shost->scan_mutex);
return sdev; return sdev;
} }
...@@ -1202,13 +1195,13 @@ int scsi_scan_host_selected(struct Scsi_Host *shost, unsigned int channel, ...@@ -1202,13 +1195,13 @@ int scsi_scan_host_selected(struct Scsi_Host *shost, unsigned int channel,
((lun != SCAN_WILD_CARD) && (lun > shost->max_lun))) ((lun != SCAN_WILD_CARD) && (lun > shost->max_lun)))
return -EINVAL; return -EINVAL;
down(&scsi_scan_mutex); down(&shost->scan_mutex);
if (channel == SCAN_WILD_CARD) if (channel == SCAN_WILD_CARD)
for (channel = 0; channel <= shost->max_channel; channel++) for (channel = 0; channel <= shost->max_channel; channel++)
scsi_scan_channel(shost, channel, id, lun, rescan); scsi_scan_channel(shost, channel, id, lun, rescan);
else else
scsi_scan_channel(shost, channel, id, lun, rescan); scsi_scan_channel(shost, channel, id, lun, rescan);
up(&scsi_scan_mutex); up(&shost->scan_mutex);
return 0; return 0;
} }
......
...@@ -479,6 +479,12 @@ struct Scsi_Host { ...@@ -479,6 +479,12 @@ struct Scsi_Host {
*/ */
struct list_head sht_legacy_list; struct list_head sht_legacy_list;
/*
* This mutex serializes all scsi scanning activity from kernel- and
* userspace.
*/
struct semaphore scan_mutex;
/* /*
* We should ensure that this is aligned, both for better performance * We should ensure that this is aligned, both for better performance
* and also because some compilers (m68k) don't automatically force * and also because some compilers (m68k) don't automatically force
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment