linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] RDMA/qib: Use the bitmap API when applicable
@ 2022-07-03  7:42 Christophe JAILLET
  2022-07-17 18:05 ` Leon Romanovsky
  0 siblings, 1 reply; 3+ messages in thread
From: Christophe JAILLET @ 2022-07-03  7:42 UTC (permalink / raw)
  To: Dennis Dalessandro, Jason Gunthorpe, Leon Romanovsky,
	Roland Dreier, Ralph Campbell
  Cc: linux-kernel, kernel-janitors, Christophe JAILLET, linux-rdma

Using the bitmap API is less verbose than hand writing them.
It also improves the semantic.

While at it, initialize the bitmaps. It can't hurt.

Fixes: f931551bafe1 ("IB/qib: Add new qib driver for QLogic PCIe InfiniBand adapters")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/infiniband/hw/qib/qib_iba7322.c | 23 ++++++++---------------
 1 file changed, 8 insertions(+), 15 deletions(-)

diff --git a/drivers/infiniband/hw/qib/qib_iba7322.c b/drivers/infiniband/hw/qib/qib_iba7322.c
index ceed302cf6a0..6861c6384f18 100644
--- a/drivers/infiniband/hw/qib/qib_iba7322.c
+++ b/drivers/infiniband/hw/qib/qib_iba7322.c
@@ -2850,9 +2850,9 @@ static void qib_setup_7322_cleanup(struct qib_devdata *dd)
 
 	qib_7322_free_irq(dd);
 	kfree(dd->cspec->cntrs);
-	kfree(dd->cspec->sendchkenable);
-	kfree(dd->cspec->sendgrhchk);
-	kfree(dd->cspec->sendibchk);
+	bitmap_free(dd->cspec->sendchkenable);
+	bitmap_free(dd->cspec->sendgrhchk);
+	bitmap_free(dd->cspec->sendibchk);
 	kfree(dd->cspec->msix_entries);
 	for (i = 0; i < dd->num_pports; i++) {
 		unsigned long flags;
@@ -6383,18 +6383,11 @@ static int qib_init_7322_variables(struct qib_devdata *dd)
 	features = qib_7322_boardname(dd);
 
 	/* now that piobcnt2k and 4k set, we can allocate these */
-	sbufcnt = dd->piobcnt2k + dd->piobcnt4k +
-		NUM_VL15_BUFS + BITS_PER_LONG - 1;
-	sbufcnt /= BITS_PER_LONG;
-	dd->cspec->sendchkenable =
-		kmalloc_array(sbufcnt, sizeof(*dd->cspec->sendchkenable),
-			      GFP_KERNEL);
-	dd->cspec->sendgrhchk =
-		kmalloc_array(sbufcnt, sizeof(*dd->cspec->sendgrhchk),
-			      GFP_KERNEL);
-	dd->cspec->sendibchk =
-		kmalloc_array(sbufcnt, sizeof(*dd->cspec->sendibchk),
-			      GFP_KERNEL);
+	sbufcnt = dd->piobcnt2k + dd->piobcnt4k + NUM_VL15_BUFS;
+
+	dd->cspec->sendchkenable = bitmap_zalloc(sbufcnt, GFP_KERNEL);
+	dd->cspec->sendgrhchk = bitmap_zalloc(sbufcnt, GFP_KERNEL);
+	dd->cspec->sendibchk = bitmap_zalloc(sbufcnt, GFP_KERNEL);
 	if (!dd->cspec->sendchkenable || !dd->cspec->sendgrhchk ||
 		!dd->cspec->sendibchk) {
 		ret = -ENOMEM;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] RDMA/qib: Use the bitmap API when applicable
  2022-07-03  7:42 [PATCH] RDMA/qib: Use the bitmap API when applicable Christophe JAILLET
@ 2022-07-17 18:05 ` Leon Romanovsky
  2022-07-19  5:48   ` Christophe JAILLET
  0 siblings, 1 reply; 3+ messages in thread
From: Leon Romanovsky @ 2022-07-17 18:05 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: Dennis Dalessandro, Jason Gunthorpe, Roland Dreier,
	Ralph Campbell, linux-kernel, kernel-janitors, linux-rdma

On Sun, Jul 03, 2022 at 09:42:48AM +0200, Christophe JAILLET wrote:
> Using the bitmap API is less verbose than hand writing them.
> It also improves the semantic.
> 
> While at it, initialize the bitmaps. It can't hurt.
> 
> Fixes: f931551bafe1 ("IB/qib: Add new qib driver for QLogic PCIe InfiniBand adapters")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
>  drivers/infiniband/hw/qib/qib_iba7322.c | 23 ++++++++---------------
>  1 file changed, 8 insertions(+), 15 deletions(-)
> 

I removed the Fixes line as there is no bug in changed code, just update
to use better in-kernel API.

Thanks, applied.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] RDMA/qib: Use the bitmap API when applicable
  2022-07-17 18:05 ` Leon Romanovsky
@ 2022-07-19  5:48   ` Christophe JAILLET
  0 siblings, 0 replies; 3+ messages in thread
From: Christophe JAILLET @ 2022-07-19  5:48 UTC (permalink / raw)
  To: Leon Romanovsky
  Cc: Dennis Dalessandro, Jason Gunthorpe, Roland Dreier,
	Ralph Campbell, linux-kernel, kernel-janitors, linux-rdma

Le 17/07/2022 à 20:05, Leon Romanovsky a écrit :
> On Sun, Jul 03, 2022 at 09:42:48AM +0200, Christophe JAILLET wrote:
>> Using the bitmap API is less verbose than hand writing them.
>> It also improves the semantic.
>>
>> While at it, initialize the bitmaps. It can't hurt.
>>
>> Fixes: f931551bafe1 ("IB/qib: Add new qib driver for QLogic PCIe InfiniBand adapters")
>> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
>> ---
>>   drivers/infiniband/hw/qib/qib_iba7322.c | 23 ++++++++---------------
>>   1 file changed, 8 insertions(+), 15 deletions(-)
>>
> 
> I removed the Fixes line as there is no bug in changed code, just update
> to use better in-kernel API.

NP for me.

I added the Fixes tag in case the apparently missing zeroing of the 
bitmaps was a potential issue. I've not looked enough at the code to 
make sure if it was needed or not.

CJ

> 
> Thanks, applied.
> 


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-07-19  5:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-03  7:42 [PATCH] RDMA/qib: Use the bitmap API when applicable Christophe JAILLET
2022-07-17 18:05 ` Leon Romanovsky
2022-07-19  5:48   ` Christophe JAILLET

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).