提交 646cdf00 编写于 作者: T Tomas Henzl 提交者: Christoph Hellwig

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: NTomas Henzl <thenzl@redhat.com>
Acked-by: NSuresh Thiagarajan <Suresh.Thiagarajan@pmcs.com>
Acked-by: NJack Wang <xjtuwjp@gmail.com>
Signed-off-by: NChristoph Hellwig <hch@lst.de>
上级 5533abca
...@@ -246,6 +246,7 @@ static int pm8001_alloc(struct pm8001_hba_info *pm8001_ha, ...@@ -246,6 +246,7 @@ static int pm8001_alloc(struct pm8001_hba_info *pm8001_ha,
{ {
int i; int i;
spin_lock_init(&pm8001_ha->lock); spin_lock_init(&pm8001_ha->lock);
spin_lock_init(&pm8001_ha->bitmap_lock);
PM8001_INIT_DBG(pm8001_ha, PM8001_INIT_DBG(pm8001_ha,
pm8001_printk("pm8001_alloc: PHY:%x\n", pm8001_printk("pm8001_alloc: PHY:%x\n",
pm8001_ha->chip->n_phy)); pm8001_ha->chip->n_phy));
......
...@@ -77,11 +77,16 @@ inline int pm8001_tag_alloc(struct pm8001_hba_info *pm8001_ha, u32 *tag_out) ...@@ -77,11 +77,16 @@ inline int pm8001_tag_alloc(struct pm8001_hba_info *pm8001_ha, u32 *tag_out)
{ {
unsigned int tag; unsigned int tag;
void *bitmap = pm8001_ha->tags; void *bitmap = pm8001_ha->tags;
unsigned long flags;
spin_lock_irqsave(&pm8001_ha->bitmap_lock, flags);
tag = find_first_zero_bit(bitmap, pm8001_ha->tags_num); tag = find_first_zero_bit(bitmap, pm8001_ha->tags_num);
if (tag >= pm8001_ha->tags_num) if (tag >= pm8001_ha->tags_num) {
spin_unlock_irqrestore(&pm8001_ha->bitmap_lock, flags);
return -SAS_QUEUE_FULL; return -SAS_QUEUE_FULL;
}
set_bit(tag, bitmap); set_bit(tag, bitmap);
spin_unlock_irqrestore(&pm8001_ha->bitmap_lock, flags);
*tag_out = tag; *tag_out = tag;
return 0; return 0;
} }
......
...@@ -475,6 +475,7 @@ struct pm8001_hba_info { ...@@ -475,6 +475,7 @@ struct pm8001_hba_info {
struct list_head list; struct list_head list;
unsigned long flags; unsigned long flags;
spinlock_t lock;/* host-wide lock */ spinlock_t lock;/* host-wide lock */
spinlock_t bitmap_lock;
struct pci_dev *pdev;/* our device */ struct pci_dev *pdev;/* our device */
struct device *dev; struct device *dev;
struct pm8001_hba_memspace io_mem[6]; struct pm8001_hba_memspace io_mem[6];
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册