From: Eddie James <eajames@linux.ibm.com>
To: linux-fsi@lists.ozlabs.org
Cc: linux-hwmon@vger.kernel.org, jdelvare@suse.com,
openbmc@lists.ozlabs.org, eajames@linux.ibm.com,
linux-kernel@vger.kernel.org, linux@roeck-us.net
Subject: [PATCH v2 3/3] fsi: occ: Add dynamic debug to dump command and response
Date: Wed, 21 Jul 2021 14:02:31 -0500 [thread overview]
Message-ID: <20210721190231.117185-4-eajames@linux.ibm.com> (raw)
In-Reply-To: <20210721190231.117185-1-eajames@linux.ibm.com>
Use the dynamic branching capability of the dynamic debug subsystem
to dump the command and response with the correct OCC device name.
Signed-off-by: Eddie James <eajames@linux.ibm.com>
---
Changes since v1:
- include dynamic_debug to make sure the dynamic branching stuff is
included on all platforms/configs
drivers/fsi/fsi-occ.c | 45 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 45 insertions(+)
diff --git a/drivers/fsi/fsi-occ.c b/drivers/fsi/fsi-occ.c
index ecf738411fe2..2bc53ea8f54f 100644
--- a/drivers/fsi/fsi-occ.c
+++ b/drivers/fsi/fsi-occ.c
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0
#include <linux/device.h>
+#include <linux/dynamic_debug.h>
#include <linux/err.h>
#include <linux/errno.h>
#include <linux/fs.h>
@@ -21,6 +22,15 @@
#include <linux/uaccess.h>
#include <asm/unaligned.h>
+#if !defined(CONFIG_DYNAMIC_DEBUG_CORE)
+#define DEFINE_DYNAMIC_DEBUG_METADATA(name, fmt)
+#if defined(DEBUG)
+#define DYNAMIC_DEBUG_BRANCH(descriptor) true
+#else /* DEBUG */
+#define DYNAMIC_DEBUG_BRANCH(descriptor) false
+#endif /* DEBUG */
+#endif /* CONFIG_DYNAMIC_DEBUG_CORE */
+
#define OCC_SRAM_BYTES 4096
#define OCC_CMD_DATA_BYTES 4090
#define OCC_RESP_DATA_BYTES 4089
@@ -359,6 +369,20 @@ static int occ_putsram(struct occ *occ, const void *data, ssize_t len,
byte_buf[len - 2] = checksum >> 8;
byte_buf[len - 1] = checksum & 0xff;
+ {
+ DEFINE_DYNAMIC_DEBUG_METADATA(ddm_occ_cmd, "OCC command");
+
+ if (DYNAMIC_DEBUG_BRANCH(ddm_occ_cmd)) {
+ char prefix[64];
+
+ snprintf(prefix, sizeof(prefix), "%s %s: cmd ",
+ dev_driver_string(occ->dev),
+ dev_name(occ->dev));
+ print_hex_dump(KERN_DEBUG, prefix, DUMP_PREFIX_OFFSET,
+ 16, 4, byte_buf, len, false);
+ }
+ }
+
rc = sbefifo_submit(occ->sbefifo, buf, cmd_len, buf, &resp_len);
if (rc)
goto free;
@@ -556,6 +580,27 @@ int fsi_occ_submit(struct device *dev, const void *request, size_t req_len,
}
*resp_len = resp_data_length + 7;
+
+ {
+ DEFINE_DYNAMIC_DEBUG_METADATA(ddm_occ_rsp,
+ "OCC response");
+ DEFINE_DYNAMIC_DEBUG_METADATA(ddm_occ_full_rsp,
+ "OCC full response");
+
+ if (DYNAMIC_DEBUG_BRANCH(ddm_occ_full_rsp) ||
+ DYNAMIC_DEBUG_BRANCH(ddm_occ_rsp)) {
+ char prefix[64];
+ size_t l = DYNAMIC_DEBUG_BRANCH(ddm_occ_full_rsp) ?
+ *resp_len : 16;
+
+ snprintf(prefix, sizeof(prefix), "%s %s: rsp ",
+ dev_driver_string(occ->dev),
+ dev_name(occ->dev));
+ print_hex_dump(KERN_DEBUG, prefix, DUMP_PREFIX_OFFSET,
+ 16, 4, resp, l, false);
+ }
+ }
+
rc = occ_verify_checksum(occ, resp, resp_data_length);
done:
--
2.27.0
prev parent reply other threads:[~2021-07-21 19:04 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-21 19:02 [PATCH v2 0/3] OCC: fsi and hwmon: Set sequence number in submit interface Eddie James
2021-07-21 19:02 ` [PATCH v2 1/3] fsi: occ: Force sequence numbering per OCC Eddie James
2021-07-21 19:02 ` [PATCH v2 2/3] hwmon: (occ) Remove sequence numbering and checksum calculation Eddie James
2021-07-21 19:02 ` Eddie James [this message]
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=20210721190231.117185-4-eajames@linux.ibm.com \
--to=eajames@linux.ibm.com \
--cc=jdelvare@suse.com \
--cc=linux-fsi@lists.ozlabs.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=openbmc@lists.ozlabs.org \
/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 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).