From fa138734b808b98c15f31c38e0b3b3ca3f64a3cd Mon Sep 17 00:00:00 2001 From: Anton Blanchard Date: Fri, 12 Sep 2003 01:25:24 -0400 Subject: [PATCH] [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(-) --- drivers/scsi/hosts.c | 2 ++ drivers/scsi/scsi_scan.c | 15 ++++----------- include/scsi/scsi_host.h | 6 ++++++ 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c index b5b58bd5f22ff..e0ec139030138 100644 --- a/drivers/scsi/hosts.c +++ b/drivers/scsi/hosts.c @@ -214,6 +214,8 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize) INIT_LIST_HEAD(&shost->starved_list); init_waitqueue_head(&shost->host_wait); + init_MUTEX(&shost->scan_mutex); + shost->host_no = scsi_host_next_hn++; /* XXX(hch): still racy */ shost->dma_channel = 0xff; diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c index 65807367d046e..65b0733b6a894 100644 --- a/drivers/scsi/scsi_scan.c +++ b/drivers/scsi/scsi_scan.c @@ -95,13 +95,6 @@ MODULE_PARM_DESC(max_report_luns, " between 1 and 16384)"); #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 * @sreq: used to send the command @@ -1075,11 +1068,11 @@ struct scsi_device *scsi_add_device(struct Scsi_Host *shost, struct scsi_device *sdev; int res; - down(&scsi_scan_mutex); + down(&shost->scan_mutex); res = scsi_probe_and_add_lun(shost, channel, id, lun, NULL, &sdev, 1); if (res != SCSI_SCAN_LUN_PRESENT) sdev = ERR_PTR(-ENODEV); - up(&scsi_scan_mutex); + up(&shost->scan_mutex); return sdev; } @@ -1202,13 +1195,13 @@ int scsi_scan_host_selected(struct Scsi_Host *shost, unsigned int channel, ((lun != SCAN_WILD_CARD) && (lun > shost->max_lun))) return -EINVAL; - down(&scsi_scan_mutex); + down(&shost->scan_mutex); if (channel == SCAN_WILD_CARD) for (channel = 0; channel <= shost->max_channel; channel++) scsi_scan_channel(shost, channel, id, lun, rescan); else scsi_scan_channel(shost, channel, id, lun, rescan); - up(&scsi_scan_mutex); + up(&shost->scan_mutex); return 0; } diff --git a/include/scsi/scsi_host.h b/include/scsi/scsi_host.h index 7a2ccdf81e55d..2a2790b7df70b 100644 --- a/include/scsi/scsi_host.h +++ b/include/scsi/scsi_host.h @@ -479,6 +479,12 @@ struct Scsi_Host { */ 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 * and also because some compilers (m68k) don't automatically force -- 2.53.0