* [PATCH 2/3] scsi: hisi_sas: Remove some useless code in 'hisi_sas_alloc()'
2021-11-26 21:15 [PATCH 1/3] scsi: hisi_sas: Use devm_bitmap_zalloc() when applicable Christophe JAILLET
@ 2021-11-26 21:18 ` Christophe JAILLET
2021-12-06 13:23 ` John Garry
2021-11-26 21:18 ` [PATCH 3/3] scsi: hisi_sas: Use non-atomic bitmap functions when possible Christophe JAILLET
` (3 subsequent siblings)
4 siblings, 1 reply; 8+ messages in thread
From: Christophe JAILLET @ 2021-11-26 21:18 UTC (permalink / raw)
To: john.garry, jejb, martin.petersen
Cc: linux-scsi, linux-kernel, kernel-janitors, Christophe JAILLET
The 'hisi_hba->slot_index_tags' bitmap is allocated with 'bitmap_zalloc()'
so it is already cleared.
There is no need to clear it another time, one bit at a time.
So, remove the corresponding useless code.
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
drivers/scsi/hisi_sas/hisi_sas_main.c | 9 ---------
1 file changed, 9 deletions(-)
diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c
index 6ecb42d5ce81..d4f5d093bde4 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_main.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_main.c
@@ -206,14 +206,6 @@ static int hisi_sas_slot_index_alloc(struct hisi_hba *hisi_hba,
return index;
}
-static void hisi_sas_slot_index_init(struct hisi_hba *hisi_hba)
-{
- int i;
-
- for (i = 0; i < hisi_hba->slot_index_count; ++i)
- hisi_sas_slot_index_clear(hisi_hba, i);
-}
-
void hisi_sas_slot_task_free(struct hisi_hba *hisi_hba, struct sas_task *task,
struct hisi_sas_slot *slot)
{
@@ -2535,7 +2527,6 @@ int hisi_sas_alloc(struct hisi_hba *hisi_hba)
if (!hisi_hba->sata_breakpoint)
goto err_out;
- hisi_sas_slot_index_init(hisi_hba);
hisi_hba->last_slot_index = HISI_SAS_UNRESERVED_IPTT;
hisi_hba->wq = create_singlethread_workqueue(dev_name(dev));
--
2.30.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 3/3] scsi: hisi_sas: Use non-atomic bitmap functions when possible
2021-11-26 21:15 [PATCH 1/3] scsi: hisi_sas: Use devm_bitmap_zalloc() when applicable Christophe JAILLET
2021-11-26 21:18 ` [PATCH 2/3] scsi: hisi_sas: Remove some useless code in 'hisi_sas_alloc()' Christophe JAILLET
@ 2021-11-26 21:18 ` Christophe JAILLET
2021-12-06 14:30 ` John Garry
2021-12-06 13:22 ` [PATCH 1/3] scsi: hisi_sas: Use devm_bitmap_zalloc() when applicable John Garry
` (2 subsequent siblings)
4 siblings, 1 reply; 8+ messages in thread
From: Christophe JAILLET @ 2021-11-26 21:18 UTC (permalink / raw)
To: john.garry, jejb, martin.petersen
Cc: linux-scsi, linux-kernel, kernel-janitors, Christophe JAILLET
All uses of the 'hisi_hba->slot_index_tags' bitmap are protected with the
'hisi_hba->lock' spinlock.
So prefer the non-atomic '__[set|clear]_bit()' functions to save a few
cycles.
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
drivers/scsi/hisi_sas/hisi_sas_main.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/scsi/hisi_sas/hisi_sas_main.c b/drivers/scsi/hisi_sas/hisi_sas_main.c
index d4f5d093bde4..889c36fa9309 100644
--- a/drivers/scsi/hisi_sas/hisi_sas_main.c
+++ b/drivers/scsi/hisi_sas/hisi_sas_main.c
@@ -158,7 +158,7 @@ static void hisi_sas_slot_index_clear(struct hisi_hba *hisi_hba, int slot_idx)
{
void *bitmap = hisi_hba->slot_index_tags;
- clear_bit(slot_idx, bitmap);
+ __clear_bit(slot_idx, bitmap);
}
static void hisi_sas_slot_index_free(struct hisi_hba *hisi_hba, int slot_idx)
@@ -175,7 +175,7 @@ static void hisi_sas_slot_index_set(struct hisi_hba *hisi_hba, int slot_idx)
{
void *bitmap = hisi_hba->slot_index_tags;
- set_bit(slot_idx, bitmap);
+ __set_bit(slot_idx, bitmap);
}
static int hisi_sas_slot_index_alloc(struct hisi_hba *hisi_hba,
--
2.30.2
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 1/3] scsi: hisi_sas: Use devm_bitmap_zalloc() when applicable
2021-11-26 21:15 [PATCH 1/3] scsi: hisi_sas: Use devm_bitmap_zalloc() when applicable Christophe JAILLET
2021-11-26 21:18 ` [PATCH 2/3] scsi: hisi_sas: Remove some useless code in 'hisi_sas_alloc()' Christophe JAILLET
2021-11-26 21:18 ` [PATCH 3/3] scsi: hisi_sas: Use non-atomic bitmap functions when possible Christophe JAILLET
@ 2021-12-06 13:22 ` John Garry
2021-12-07 3:13 ` Martin K. Petersen
2021-12-14 4:40 ` Martin K. Petersen
4 siblings, 0 replies; 8+ messages in thread
From: John Garry @ 2021-12-06 13:22 UTC (permalink / raw)
To: Christophe JAILLET, jejb, martin.petersen
Cc: linux-scsi, linux-kernel, kernel-janitors
On 26/11/2021 21:15, Christophe JAILLET wrote:
> 'hisi_hba->slot_index_tags' is a bitmap. So use 'devm_bitmap_zalloc()' to
> simplify code, improve the semantic and avoid some open-coded arithmetic
> in allocator arguments.
>
> Signed-off-by: Christophe JAILLET<christophe.jaillet@wanadoo.fr>
Acked-by: John Garry <john.garry@huawei.com>
> ---
> The use of 's' is questionable here. I've left it because it looks more
> consistent this way with the surrounding code.
>
> Can it be an issue to have the length of the allocated bitmap not being
> a multiple of sizeof(long)?
The driver does not rely on that (allocated bitmap being a multiple of
sizeof(long)), but the size is 4096 bits, which would be a multiple of
sizeof(long)
Thanks,
John
> I guess that there is some kind of 'rounding' done by the memory allocator
> to keep some alignment, so I think that the previous code is safe (but not
> logical).
> If this is not the case, there is a potential out of bound bug related to
> the bitmap API that expect to access only longs (which is not necessarily
> the case here).
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/3] scsi: hisi_sas: Use devm_bitmap_zalloc() when applicable
2021-11-26 21:15 [PATCH 1/3] scsi: hisi_sas: Use devm_bitmap_zalloc() when applicable Christophe JAILLET
` (2 preceding siblings ...)
2021-12-06 13:22 ` [PATCH 1/3] scsi: hisi_sas: Use devm_bitmap_zalloc() when applicable John Garry
@ 2021-12-07 3:13 ` Martin K. Petersen
2021-12-14 4:40 ` Martin K. Petersen
4 siblings, 0 replies; 8+ messages in thread
From: Martin K. Petersen @ 2021-12-07 3:13 UTC (permalink / raw)
To: Christophe JAILLET
Cc: john.garry, jejb, martin.petersen, linux-scsi, linux-kernel,
kernel-janitors
Christophe,
> 'hisi_hba->slot_index_tags' is a bitmap. So use 'devm_bitmap_zalloc()' to
> simplify code, improve the semantic and avoid some open-coded arithmetic
> in allocator arguments.
Applied to 5.17/scsi-staging, thanks!
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 1/3] scsi: hisi_sas: Use devm_bitmap_zalloc() when applicable
2021-11-26 21:15 [PATCH 1/3] scsi: hisi_sas: Use devm_bitmap_zalloc() when applicable Christophe JAILLET
` (3 preceding siblings ...)
2021-12-07 3:13 ` Martin K. Petersen
@ 2021-12-14 4:40 ` Martin K. Petersen
4 siblings, 0 replies; 8+ messages in thread
From: Martin K. Petersen @ 2021-12-14 4:40 UTC (permalink / raw)
To: jejb, john.garry, Christophe JAILLET
Cc: Martin K . Petersen, linux-scsi, kernel-janitors, linux-kernel
On Fri, 26 Nov 2021 22:15:21 +0100, Christophe JAILLET wrote:
> 'hisi_hba->slot_index_tags' is a bitmap. So use 'devm_bitmap_zalloc()' to
> simplify code, improve the semantic and avoid some open-coded arithmetic
> in allocator arguments.
>
>
Applied to 5.17/scsi-queue, thanks!
[1/3] scsi: hisi_sas: Use devm_bitmap_zalloc() when applicable
https://git.kernel.org/mkp/scsi/c/54585ec62fbd
[2/3] scsi: hisi_sas: Remove some useless code in 'hisi_sas_alloc()'
https://git.kernel.org/mkp/scsi/c/d43efddf6271
[3/3] scsi: hisi_sas: Use non-atomic bitmap functions when possible
https://git.kernel.org/mkp/scsi/c/4d6942e2666e
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 8+ messages in thread