All of lore.kernel.org
 help / color / mirror / Atom feed
From: keith.busch@intel.com (Keith Busch)
Subject: [PATCH] nvme/pci: Print invalid SGL only once
Date: Thu, 14 Sep 2017 15:06:14 -0400	[thread overview]
Message-ID: <1505415974-13489-1-git-send-email-keith.busch@intel.com> (raw)

The WARN_ONCE macro returns true if the condition is true, not if the
warn was raised, so we're printing the scatter list every time it's
invalid. This is excessive and makes debugging harder, so this patch
prints it just once.

Signed-off-by: Keith Busch <keith.busch at intel.com>
---
 drivers/nvme/host/pci.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c
index df96562..33d66da 100644
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -554,6 +554,8 @@ static blk_status_t nvme_setup_prps(struct nvme_dev *dev, struct request *req)
 	dma_addr_t prp_dma;
 	int nprps, i;
 
+	static bool sgl_warned = false;
+
 	length -= (page_size - offset);
 	if (length <= 0)
 		return BLK_STS_OK;
@@ -619,8 +621,9 @@ static blk_status_t nvme_setup_prps(struct nvme_dev *dev, struct request *req)
 	return BLK_STS_OK;
 
  bad_sgl:
-	if (WARN_ONCE(1, "Invalid SGL for payload:%d nents:%d\n",
+	if (!sgl_warned && WARN_ONCE(1, "Invalid SGL for payload:%d nents:%d\n",
 				blk_rq_payload_bytes(req), iod->nents)) {
+		sgl_warned = true;
 		for_each_sg(iod->sg, sg, iod->nents, i) {
 			dma_addr_t phys = sg_phys(sg);
 			pr_warn("sg[%d] phys_addr:%pad offset:%d length:%d "
-- 
2.5.5

             reply	other threads:[~2017-09-14 19:06 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-14 19:06 Keith Busch [this message]
2017-09-15  7:36 ` [PATCH] nvme/pci: Print invalid SGL only once Johannes Thumshirn
2017-09-15 14:55 ` Christoph Hellwig
2017-09-15 15:17   ` Keith Busch
2017-09-15 15:44     ` Keith Busch
2017-09-15 15:42       ` Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1505415974-13489-1-git-send-email-keith.busch@intel.com \
    --to=keith.busch@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.