linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] scsi: qedf: Fix a return value + some cleanups
@ 2017-06-11  6:16 Christophe JAILLET
  2017-06-11  6:16 ` [PATCH 1/3] scsi: qedf: Fix a return value in case of error in 'qedf_alloc_global_queues' Christophe JAILLET
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Christophe JAILLET @ 2017-06-11  6:16 UTC (permalink / raw)
  To: QLogic-Storage-Upstream, jejb, martin.petersen
  Cc: linux-scsi, linux-kernel, kernel-janitors, Christophe JAILLET

This patch serie first fixes a case where an error code was missing.
The 2 other patches are just cleanups in the same area.

Christophe JAILLET (3):
  scsi: qedf: Fix a return value in case of error in
    'qedf_alloc_global_queues'
  scsi: qedf: Use 'dma_zalloc_coherent' to reduce code verbosity.
  scsi: qedf: Merge a few quoted strings split across lines

 drivers/scsi/qedf/qedf_main.c | 38 +++++++++++++-------------------------
 1 file changed, 13 insertions(+), 25 deletions(-)

-- 
2.11.0

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

* [PATCH 1/3] scsi: qedf: Fix a return value in case of error in 'qedf_alloc_global_queues'
  2017-06-11  6:16 [PATCH 0/3] scsi: qedf: Fix a return value + some cleanups Christophe JAILLET
@ 2017-06-11  6:16 ` Christophe JAILLET
  2017-06-11  8:33   ` walter harms
  2017-06-11  6:16 ` [PATCH 2/3] scsi: qedf: Use 'dma_zalloc_coherent' to reduce code verbosity Christophe JAILLET
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 7+ messages in thread
From: Christophe JAILLET @ 2017-06-11  6:16 UTC (permalink / raw)
  To: QLogic-Storage-Upstream, jejb, martin.petersen
  Cc: linux-scsi, linux-kernel, kernel-janitors, Christophe JAILLET

We should return -ENOMEM in case of memory allocation error, as done
elsewhere in this function.

Fixes: 61d8658b4a435 ("scsi: qedf: Add QLogic FastLinQ offload FCoE driver framework.")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/scsi/qedf/qedf_main.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c
index aab3e2bd26a0..52a27100ca6d 100644
--- a/drivers/scsi/qedf/qedf_main.c
+++ b/drivers/scsi/qedf/qedf_main.c
@@ -2673,6 +2673,7 @@ static int qedf_alloc_global_queues(struct qedf_ctx *qedf)
 		if (!qedf->global_queues[i]) {
 			QEDF_WARN(&(qedf->dbg_ctx), "Unable to allocation "
 				   "global queue %d.\n", i);
+			status = -ENOMEM;
 			goto mem_alloc_failure;
 		}
 
-- 
2.11.0

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

* [PATCH 2/3] scsi: qedf: Use 'dma_zalloc_coherent' to reduce code verbosity.
  2017-06-11  6:16 [PATCH 0/3] scsi: qedf: Fix a return value + some cleanups Christophe JAILLET
  2017-06-11  6:16 ` [PATCH 1/3] scsi: qedf: Fix a return value in case of error in 'qedf_alloc_global_queues' Christophe JAILLET
@ 2017-06-11  6:16 ` Christophe JAILLET
  2017-06-11  6:16 ` [PATCH 3/3] scsi: qedf: Merge a few quoted strings split across lines Christophe JAILLET
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 7+ messages in thread
From: Christophe JAILLET @ 2017-06-11  6:16 UTC (permalink / raw)
  To: QLogic-Storage-Upstream, jejb, martin.petersen
  Cc: linux-scsi, linux-kernel, kernel-janitors, Christophe JAILLET

Replace some 'dma_alloc_coherent+memset' by some quivalent
'dma_zalloc_coherent' in order to reduce code verbosity

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/scsi/qedf/qedf_main.c | 19 ++++++-------------
 1 file changed, 6 insertions(+), 13 deletions(-)

diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c
index 52a27100ca6d..19a2bbc65f54 100644
--- a/drivers/scsi/qedf/qedf_main.c
+++ b/drivers/scsi/qedf/qedf_main.c
@@ -972,17 +972,16 @@ static int qedf_alloc_sq(struct qedf_ctx *qedf, struct qedf_rport *fcport)
 	    sizeof(void *);
 	fcport->sq_pbl_size = fcport->sq_pbl_size + QEDF_PAGE_SIZE;
 
-	fcport->sq = dma_alloc_coherent(&qedf->pdev->dev, fcport->sq_mem_size,
-	    &fcport->sq_dma, GFP_KERNEL);
+	fcport->sq = dma_zalloc_coherent(&qedf->pdev->dev,
+	    fcport->sq_mem_size, &fcport->sq_dma, GFP_KERNEL);
 	if (!fcport->sq) {
 		QEDF_WARN(&(qedf->dbg_ctx), "Could not allocate send "
 			   "queue.\n");
 		rval = 1;
 		goto out;
 	}
-	memset(fcport->sq, 0, fcport->sq_mem_size);
 
-	fcport->sq_pbl = dma_alloc_coherent(&qedf->pdev->dev,
+	fcport->sq_pbl = dma_zalloc_coherent(&qedf->pdev->dev,
 	    fcport->sq_pbl_size, &fcport->sq_pbl_dma, GFP_KERNEL);
 	if (!fcport->sq_pbl) {
 		QEDF_WARN(&(qedf->dbg_ctx), "Could not allocate send "
@@ -990,7 +989,6 @@ static int qedf_alloc_sq(struct qedf_ctx *qedf, struct qedf_rport *fcport)
 		rval = 1;
 		goto out_free_sq;
 	}
-	memset(fcport->sq_pbl, 0, fcport->sq_pbl_size);
 
 	/* Create PBL */
 	num_pages = fcport->sq_mem_size / QEDF_PAGE_SIZE;
@@ -2597,14 +2595,13 @@ static int qedf_alloc_bdq(struct qedf_ctx *qedf)
 	}
 
 	/* Allocate list of PBL pages */
-	qedf->bdq_pbl_list = dma_alloc_coherent(&qedf->pdev->dev,
+	qedf->bdq_pbl_list = dma_zalloc_coherent(&qedf->pdev->dev,
 	    QEDF_PAGE_SIZE, &qedf->bdq_pbl_list_dma, GFP_KERNEL);
 	if (!qedf->bdq_pbl_list) {
 		QEDF_ERR(&(qedf->dbg_ctx), "Could not allocate list of PBL "
 		    "pages.\n");
 		return -ENOMEM;
 	}
-	memset(qedf->bdq_pbl_list, 0, QEDF_PAGE_SIZE);
 
 	/*
 	 * Now populate PBL list with pages that contain pointers to the
@@ -2689,7 +2686,7 @@ static int qedf_alloc_global_queues(struct qedf_ctx *qedf)
 		    ALIGN(qedf->global_queues[i]->cq_pbl_size, QEDF_PAGE_SIZE);
 
 		qedf->global_queues[i]->cq =
-		    dma_alloc_coherent(&qedf->pdev->dev,
+		    dma_zalloc_coherent(&qedf->pdev->dev,
 			qedf->global_queues[i]->cq_mem_size,
 			&qedf->global_queues[i]->cq_dma, GFP_KERNEL);
 
@@ -2699,11 +2696,9 @@ static int qedf_alloc_global_queues(struct qedf_ctx *qedf)
 			status = -ENOMEM;
 			goto mem_alloc_failure;
 		}
-		memset(qedf->global_queues[i]->cq, 0,
-		    qedf->global_queues[i]->cq_mem_size);
 
 		qedf->global_queues[i]->cq_pbl =
-		    dma_alloc_coherent(&qedf->pdev->dev,
+		    dma_zalloc_coherent(&qedf->pdev->dev,
 			qedf->global_queues[i]->cq_pbl_size,
 			&qedf->global_queues[i]->cq_pbl_dma, GFP_KERNEL);
 
@@ -2713,8 +2708,6 @@ static int qedf_alloc_global_queues(struct qedf_ctx *qedf)
 			status = -ENOMEM;
 			goto mem_alloc_failure;
 		}
-		memset(qedf->global_queues[i]->cq_pbl, 0,
-		    qedf->global_queues[i]->cq_pbl_size);
 
 		/* Create PBL */
 		num_pages = qedf->global_queues[i]->cq_mem_size /
-- 
2.11.0

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

* [PATCH 3/3] scsi: qedf: Merge a few quoted strings split across lines
  2017-06-11  6:16 [PATCH 0/3] scsi: qedf: Fix a return value + some cleanups Christophe JAILLET
  2017-06-11  6:16 ` [PATCH 1/3] scsi: qedf: Fix a return value in case of error in 'qedf_alloc_global_queues' Christophe JAILLET
  2017-06-11  6:16 ` [PATCH 2/3] scsi: qedf: Use 'dma_zalloc_coherent' to reduce code verbosity Christophe JAILLET
@ 2017-06-11  6:16 ` Christophe JAILLET
  2017-06-12 14:03 ` [PATCH 0/3] scsi: qedf: Fix a return value + some cleanups Chad Dupuis
  2017-06-13  1:22 ` Martin K. Petersen
  4 siblings, 0 replies; 7+ messages in thread
From: Christophe JAILLET @ 2017-06-11  6:16 UTC (permalink / raw)
  To: QLogic-Storage-Upstream, jejb, martin.petersen
  Cc: linux-scsi, linux-kernel, kernel-janitors, Christophe JAILLET

Merge some quoted strings to improve readability and to save some lines
of code.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
 drivers/scsi/qedf/qedf_main.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)

diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c
index 19a2bbc65f54..d1e8b167a117 100644
--- a/drivers/scsi/qedf/qedf_main.c
+++ b/drivers/scsi/qedf/qedf_main.c
@@ -975,8 +975,7 @@ static int qedf_alloc_sq(struct qedf_ctx *qedf, struct qedf_rport *fcport)
 	fcport->sq = dma_zalloc_coherent(&qedf->pdev->dev,
 	    fcport->sq_mem_size, &fcport->sq_dma, GFP_KERNEL);
 	if (!fcport->sq) {
-		QEDF_WARN(&(qedf->dbg_ctx), "Could not allocate send "
-			   "queue.\n");
+		QEDF_WARN(&(qedf->dbg_ctx), "Could not allocate send queue.\n");
 		rval = 1;
 		goto out;
 	}
@@ -984,8 +983,7 @@ static int qedf_alloc_sq(struct qedf_ctx *qedf, struct qedf_rport *fcport)
 	fcport->sq_pbl = dma_zalloc_coherent(&qedf->pdev->dev,
 	    fcport->sq_pbl_size, &fcport->sq_pbl_dma, GFP_KERNEL);
 	if (!fcport->sq_pbl) {
-		QEDF_WARN(&(qedf->dbg_ctx), "Could not allocate send "
-			   "queue PBL.\n");
+		QEDF_WARN(&(qedf->dbg_ctx), "Could not allocate send queue PBL.\n");
 		rval = 1;
 		goto out_free_sq;
 	}
@@ -2598,8 +2596,7 @@ static int qedf_alloc_bdq(struct qedf_ctx *qedf)
 	qedf->bdq_pbl_list = dma_zalloc_coherent(&qedf->pdev->dev,
 	    QEDF_PAGE_SIZE, &qedf->bdq_pbl_list_dma, GFP_KERNEL);
 	if (!qedf->bdq_pbl_list) {
-		QEDF_ERR(&(qedf->dbg_ctx), "Could not allocate list of PBL "
-		    "pages.\n");
+		QEDF_ERR(&(qedf->dbg_ctx), "Could not allocate list of PBL pages.\n");
 		return -ENOMEM;
 	}
 
@@ -2691,8 +2688,7 @@ static int qedf_alloc_global_queues(struct qedf_ctx *qedf)
 			&qedf->global_queues[i]->cq_dma, GFP_KERNEL);
 
 		if (!qedf->global_queues[i]->cq) {
-			QEDF_WARN(&(qedf->dbg_ctx), "Could not allocate "
-				   "cq.\n");
+			QEDF_WARN(&(qedf->dbg_ctx), "Could not allocate cq.\n");
 			status = -ENOMEM;
 			goto mem_alloc_failure;
 		}
@@ -2703,8 +2699,7 @@ static int qedf_alloc_global_queues(struct qedf_ctx *qedf)
 			&qedf->global_queues[i]->cq_pbl_dma, GFP_KERNEL);
 
 		if (!qedf->global_queues[i]->cq_pbl) {
-			QEDF_WARN(&(qedf->dbg_ctx), "Could not allocate "
-				   "cq PBL.\n");
+			QEDF_WARN(&(qedf->dbg_ctx), "Could not allocate cq PBL.\n");
 			status = -ENOMEM;
 			goto mem_alloc_failure;
 		}
@@ -2800,8 +2795,7 @@ static int qedf_set_fcoe_pf_param(struct qedf_ctx *qedf)
 	cq_mem_size = ALIGN(cq_mem_size, QEDF_PAGE_SIZE);
 	cq_num_entries = cq_mem_size / sizeof(struct fcoe_cqe);
 
-	memset(&(qedf->pf_params), 0,
-	    sizeof(qedf->pf_params));
+	memset(&(qedf->pf_params), 0, sizeof(qedf->pf_params));
 
 	/* Setup the value for fcoe PF */
 	qedf->pf_params.fcoe_pf_params.num_cons = QEDF_MAX_SESSIONS;
-- 
2.11.0

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

* Re: [PATCH 1/3] scsi: qedf: Fix a return value in case of error in 'qedf_alloc_global_queues'
  2017-06-11  6:16 ` [PATCH 1/3] scsi: qedf: Fix a return value in case of error in 'qedf_alloc_global_queues' Christophe JAILLET
@ 2017-06-11  8:33   ` walter harms
  0 siblings, 0 replies; 7+ messages in thread
From: walter harms @ 2017-06-11  8:33 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: QLogic-Storage-Upstream, jejb, martin.petersen, linux-scsi,
	linux-kernel, kernel-janitors



Am 11.06.2017 08:16, schrieb Christophe JAILLET:
> We should return -ENOMEM in case of memory allocation error, as done
> elsewhere in this function.
> 
> Fixes: 61d8658b4a435 ("scsi: qedf: Add QLogic FastLinQ offload FCoE driver framework.")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
>  drivers/scsi/qedf/qedf_main.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c
> index aab3e2bd26a0..52a27100ca6d 100644
> --- a/drivers/scsi/qedf/qedf_main.c
> +++ b/drivers/scsi/qedf/qedf_main.c
> @@ -2673,6 +2673,7 @@ static int qedf_alloc_global_queues(struct qedf_ctx *qedf)
>  		if (!qedf->global_queues[i]) {
>  			QEDF_WARN(&(qedf->dbg_ctx), "Unable to allocation "
>  				   "global queue %d.\n", i);
> +			status = -ENOMEM;
>  			goto mem_alloc_failure;
>  		}
>  

I am not native english but the error msg sounds strange ...

re,
 wh

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

* Re: [PATCH 0/3] scsi: qedf: Fix a return value + some cleanups
  2017-06-11  6:16 [PATCH 0/3] scsi: qedf: Fix a return value + some cleanups Christophe JAILLET
                   ` (2 preceding siblings ...)
  2017-06-11  6:16 ` [PATCH 3/3] scsi: qedf: Merge a few quoted strings split across lines Christophe JAILLET
@ 2017-06-12 14:03 ` Chad Dupuis
  2017-06-13  1:22 ` Martin K. Petersen
  4 siblings, 0 replies; 7+ messages in thread
From: Chad Dupuis @ 2017-06-12 14:03 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: QLogic-Storage-Upstream, jejb, martin.petersen, linux-scsi,
	linux-kernel, kernel-janitors


On Sun, 11 Jun 2017, 2:16am, Christophe JAILLET wrote:

> This patch serie first fixes a case where an error code was missing.
> The 2 other patches are just cleanups in the same area.
> 
> Christophe JAILLET (3):
>   scsi: qedf: Fix a return value in case of error in
>     'qedf_alloc_global_queues'
>   scsi: qedf: Use 'dma_zalloc_coherent' to reduce code verbosity.
>   scsi: qedf: Merge a few quoted strings split across lines
> 
>  drivers/scsi/qedf/qedf_main.c | 38 +++++++++++++-------------------------
>  1 file changed, 13 insertions(+), 25 deletions(-)
> 
> 

All are sensible small improvements.  Ack the series.

series-acked-by: Chad Dupuis <chad.dupuis@cavium.com>

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

* Re: [PATCH 0/3] scsi: qedf: Fix a return value + some cleanups
  2017-06-11  6:16 [PATCH 0/3] scsi: qedf: Fix a return value + some cleanups Christophe JAILLET
                   ` (3 preceding siblings ...)
  2017-06-12 14:03 ` [PATCH 0/3] scsi: qedf: Fix a return value + some cleanups Chad Dupuis
@ 2017-06-13  1:22 ` Martin K. Petersen
  4 siblings, 0 replies; 7+ messages in thread
From: Martin K. Petersen @ 2017-06-13  1:22 UTC (permalink / raw)
  To: Christophe JAILLET
  Cc: QLogic-Storage-Upstream, jejb, martin.petersen, linux-scsi,
	linux-kernel, kernel-janitors


Christophe,

> This patch serie first fixes a case where an error code was missing.
> The 2 other patches are just cleanups in the same area.

Applied to 4.13/scsi-queue with fixed typo.

-- 
Martin K. Petersen	Oracle Linux Engineering

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

end of thread, other threads:[~2017-06-13  1:22 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-11  6:16 [PATCH 0/3] scsi: qedf: Fix a return value + some cleanups Christophe JAILLET
2017-06-11  6:16 ` [PATCH 1/3] scsi: qedf: Fix a return value in case of error in 'qedf_alloc_global_queues' Christophe JAILLET
2017-06-11  8:33   ` walter harms
2017-06-11  6:16 ` [PATCH 2/3] scsi: qedf: Use 'dma_zalloc_coherent' to reduce code verbosity Christophe JAILLET
2017-06-11  6:16 ` [PATCH 3/3] scsi: qedf: Merge a few quoted strings split across lines Christophe JAILLET
2017-06-12 14:03 ` [PATCH 0/3] scsi: qedf: Fix a return value + some cleanups Chad Dupuis
2017-06-13  1:22 ` Martin K. Petersen

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).