Skip to content

Commit 940f5ef

Browse files
John Garrymartinkpetersen
authored andcommitted
scsi: pm8001: Use non-atomic bitmap ops for tag alloc + free
In pm8001_tag_alloc() we don't require atomic set_bit() as we are already in atomic context. In pm8001_tag_free() we should use the same host spinlock to protect clearing the tag (and then don't require the atomic clear_bit()). Link: https://lore.kernel.org/r/1654879602-33497-4-git-send-email-john.garry@huawei.com Tested-by: Damien Le Moal <damien.lemoal@opensource.wdc.com> Signed-off-by: John Garry <john.garry@huawei.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 98132d8 commit 940f5ef

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

drivers/scsi/pm8001/pm8001_sas.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,11 @@ static int pm8001_find_tag(struct sas_task *task, u32 *tag)
6666
void pm8001_tag_free(struct pm8001_hba_info *pm8001_ha, u32 tag)
6767
{
6868
void *bitmap = pm8001_ha->tags;
69-
clear_bit(tag, bitmap);
69+
unsigned long flags;
70+
71+
spin_lock_irqsave(&pm8001_ha->bitmap_lock, flags);
72+
__clear_bit(tag, bitmap);
73+
spin_unlock_irqrestore(&pm8001_ha->bitmap_lock, flags);
7074
}
7175

7276
/**
@@ -76,17 +80,17 @@ void pm8001_tag_free(struct pm8001_hba_info *pm8001_ha, u32 tag)
7680
*/
7781
int pm8001_tag_alloc(struct pm8001_hba_info *pm8001_ha, u32 *tag_out)
7882
{
79-
unsigned int tag;
8083
void *bitmap = pm8001_ha->tags;
8184
unsigned long flags;
85+
unsigned int tag;
8286

8387
spin_lock_irqsave(&pm8001_ha->bitmap_lock, flags);
8488
tag = find_first_zero_bit(bitmap, pm8001_ha->tags_num);
8589
if (tag >= pm8001_ha->tags_num) {
8690
spin_unlock_irqrestore(&pm8001_ha->bitmap_lock, flags);
8791
return -SAS_QUEUE_FULL;
8892
}
89-
set_bit(tag, bitmap);
93+
__set_bit(tag, bitmap);
9094
spin_unlock_irqrestore(&pm8001_ha->bitmap_lock, flags);
9195
*tag_out = tag;
9296
return 0;

0 commit comments

Comments
 (0)