Commit 940f5efa authored by John Garry's avatar John Garry Committed by Martin K. Petersen

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.comTested-by: default avatarDamien Le Moal <damien.lemoal@opensource.wdc.com>
Signed-off-by: default avatarJohn Garry <john.garry@huawei.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent 98132d84
...@@ -66,7 +66,11 @@ static int pm8001_find_tag(struct sas_task *task, u32 *tag) ...@@ -66,7 +66,11 @@ static int pm8001_find_tag(struct sas_task *task, u32 *tag)
void pm8001_tag_free(struct pm8001_hba_info *pm8001_ha, u32 tag) void pm8001_tag_free(struct pm8001_hba_info *pm8001_ha, u32 tag)
{ {
void *bitmap = pm8001_ha->tags; void *bitmap = pm8001_ha->tags;
clear_bit(tag, bitmap); unsigned long flags;
spin_lock_irqsave(&pm8001_ha->bitmap_lock, flags);
__clear_bit(tag, bitmap);
spin_unlock_irqrestore(&pm8001_ha->bitmap_lock, flags);
} }
/** /**
...@@ -76,9 +80,9 @@ void pm8001_tag_free(struct pm8001_hba_info *pm8001_ha, u32 tag) ...@@ -76,9 +80,9 @@ void pm8001_tag_free(struct pm8001_hba_info *pm8001_ha, u32 tag)
*/ */
int pm8001_tag_alloc(struct pm8001_hba_info *pm8001_ha, u32 *tag_out) int pm8001_tag_alloc(struct pm8001_hba_info *pm8001_ha, u32 *tag_out)
{ {
unsigned int tag;
void *bitmap = pm8001_ha->tags; void *bitmap = pm8001_ha->tags;
unsigned long flags; unsigned long flags;
unsigned int tag;
spin_lock_irqsave(&pm8001_ha->bitmap_lock, 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);
...@@ -86,7 +90,7 @@ int pm8001_tag_alloc(struct pm8001_hba_info *pm8001_ha, u32 *tag_out) ...@@ -86,7 +90,7 @@ int pm8001_tag_alloc(struct pm8001_hba_info *pm8001_ha, u32 *tag_out)
spin_unlock_irqrestore(&pm8001_ha->bitmap_lock, flags); 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); spin_unlock_irqrestore(&pm8001_ha->bitmap_lock, flags);
*tag_out = tag; *tag_out = tag;
return 0; return 0;
......
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