aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
authorTomas Henzl <thenzl@redhat.com>2014-07-09 07:51:01 -0400
committerChristoph Hellwig <hch@lst.de>2014-07-25 17:17:04 -0400
commit646cdf0083e3d4a9b995f37b72c3c8a22d9307de (patch)
treef0730421a40f2037a840489a8afdce0e4b2c1598 /drivers/scsi
parent5533abca06e07121697ed1d30863ce03e7c518e5 (diff)
pm8001: add a new spinlock to protect the CCB
Patch adds a new spinlock to protect the ccb management. It may happen that concurrent threads become the same tag value from the 'alloc' function', the spinlock prevents this situation. Signed-off-by: Tomas Henzl <thenzl@redhat.com> Acked-by: Suresh Thiagarajan <Suresh.Thiagarajan@pmcs.com> Acked-by: Jack Wang <xjtuwjp@gmail.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/pm8001/pm8001_init.c1
-rw-r--r--drivers/scsi/pm8001/pm8001_sas.c7
-rw-r--r--drivers/scsi/pm8001/pm8001_sas.h1
3 files changed, 8 insertions, 1 deletions
diff --git a/drivers/scsi/pm8001/pm8001_init.c b/drivers/scsi/pm8001/pm8001_init.c
index aad060aa3c0c..acef7d6a5790 100644
--- a/drivers/scsi/pm8001/pm8001_init.c
+++ b/drivers/scsi/pm8001/pm8001_init.c
@@ -246,6 +246,7 @@ static int pm8001_alloc(struct pm8001_hba_info *pm8001_ha,
246{ 246{
247 int i; 247 int i;
248 spin_lock_init(&pm8001_ha->lock); 248 spin_lock_init(&pm8001_ha->lock);
249 spin_lock_init(&pm8001_ha->bitmap_lock);
249 PM8001_INIT_DBG(pm8001_ha, 250 PM8001_INIT_DBG(pm8001_ha,
250 pm8001_printk("pm8001_alloc: PHY:%x\n", 251 pm8001_printk("pm8001_alloc: PHY:%x\n",
251 pm8001_ha->chip->n_phy)); 252 pm8001_ha->chip->n_phy));
diff --git a/drivers/scsi/pm8001/pm8001_sas.c b/drivers/scsi/pm8001/pm8001_sas.c
index be55859042cd..34cea8291772 100644
--- a/drivers/scsi/pm8001/pm8001_sas.c
+++ b/drivers/scsi/pm8001/pm8001_sas.c
@@ -77,11 +77,16 @@ inline int pm8001_tag_alloc(struct pm8001_hba_info *pm8001_ha, u32 *tag_out)
77{ 77{
78 unsigned int tag; 78 unsigned int tag;
79 void *bitmap = pm8001_ha->tags; 79 void *bitmap = pm8001_ha->tags;
80 unsigned long flags;
80 81
82 spin_lock_irqsave(&pm8001_ha->bitmap_lock, flags);
81 tag = find_first_zero_bit(bitmap, pm8001_ha->tags_num); 83 tag = find_first_zero_bit(bitmap, pm8001_ha->tags_num);
82 if (tag >= pm8001_ha->tags_num) 84 if (tag >= pm8001_ha->tags_num) {
85 spin_unlock_irqrestore(&pm8001_ha->bitmap_lock, flags);
83 return -SAS_QUEUE_FULL; 86 return -SAS_QUEUE_FULL;
87 }
84 set_bit(tag, bitmap); 88 set_bit(tag, bitmap);
89 spin_unlock_irqrestore(&pm8001_ha->bitmap_lock, flags);
85 *tag_out = tag; 90 *tag_out = tag;
86 return 0; 91 return 0;
87} 92}
diff --git a/drivers/scsi/pm8001/pm8001_sas.h b/drivers/scsi/pm8001/pm8001_sas.h
index 14106adec009..f6b2ac59dae4 100644
--- a/drivers/scsi/pm8001/pm8001_sas.h
+++ b/drivers/scsi/pm8001/pm8001_sas.h
@@ -475,6 +475,7 @@ struct pm8001_hba_info {
475 struct list_head list; 475 struct list_head list;
476 unsigned long flags; 476 unsigned long flags;
477 spinlock_t lock;/* host-wide lock */ 477 spinlock_t lock;/* host-wide lock */
478 spinlock_t bitmap_lock;
478 struct pci_dev *pdev;/* our device */ 479 struct pci_dev *pdev;/* our device */
479 struct device *dev; 480 struct device *dev;
480 struct pm8001_hba_memspace io_mem[6]; 481 struct pm8001_hba_memspace io_mem[6];