From patchwork Tue Nov 9 12:02:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 1552948 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HpRV46Rl2z9sCD for ; Tue, 9 Nov 2021 23:04:11 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 68A8F83928; Tue, 9 Nov 2021 13:04:05 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=linux.intel.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 3DC3083928; Tue, 9 Nov 2021 13:04:03 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 33AF383911 for ; Tue, 9 Nov 2021 13:03:59 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=linux.intel.com Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=andriy.shevchenko@linux.intel.com X-IronPort-AV: E=McAfee;i="6200,9189,10162"; a="231151834" X-IronPort-AV: E=Sophos;i="5.87,220,1631602800"; d="scan'208";a="231151834" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Nov 2021 04:03:02 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,220,1631602800"; d="scan'208";a="451895051" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga003.jf.intel.com with ESMTP; 09 Nov 2021 04:02:56 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 946DD155; Tue, 9 Nov 2021 14:02:58 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , Simon Glass , u-boot@lists.denx.de Cc: Bin Meng Subject: [PATCH v1 1/2] hexdump: Introduce debug APIs Date: Tue, 9 Nov 2021 15:02:54 +0300 Message-Id: <20211109120255.77679-1-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.33.0 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean debug_hex_dump() and debug_hex_dump_bytes() conditionally print the dump based on DEBUG definition. Signed-off-by: Andy Shevchenko --- include/hexdump.h | 4 ++++ lib/hexdump.c | 60 ++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 56 insertions(+), 8 deletions(-) diff --git a/include/hexdump.h b/include/hexdump.h index f2ca4793d699..390af4c8da1e 100644 --- a/include/hexdump.h +++ b/include/hexdump.h @@ -147,6 +147,8 @@ int hex_dump_to_buffer(const void *buf, size_t len, int rowsize, int groupsize, */ int print_hex_dump(const char *prefix_str, int prefix_type, int rowsize, int groupsize, const void *buf, size_t len, bool ascii); +int debug_hex_dump(const char *prefix_str, int prefix_type, int rowsize, + int groupsize, const void *buf, size_t len, bool ascii); /** * print_hex_dump_bytes - shorthand form of print_hex_dump() with default params @@ -162,5 +164,7 @@ int print_hex_dump(const char *prefix_str, int prefix_type, int rowsize, */ void print_hex_dump_bytes(const char *prefix_str, int prefix_type, const void *buf, size_t len); +void debug_hex_dump_bytes(const char *prefix_str, int prefix_type, + const void *buf, size_t len); #endif /* HEXDUMP_H */ diff --git a/lib/hexdump.c b/lib/hexdump.c index 149c93ead8b8..39c9e86649a0 100644 --- a/lib/hexdump.c +++ b/lib/hexdump.c @@ -125,8 +125,9 @@ overflow1: return ascii ? ascii_column + len : (groupsize * 2 + 1) * ngroups - 1; } -int print_hex_dump(const char *prefix_str, int prefix_type, int rowsize, - int groupsize, const void *buf, size_t len, bool ascii) +static int do_print_hex_dump(const char *prefix_str, int prefix_type, int rowsize, + int groupsize, const void *buf, size_t len, bool ascii, + bool dbg) { const u8 *ptr = buf; int i, linelen, remaining = len; @@ -146,15 +147,27 @@ int print_hex_dump(const char *prefix_str, int prefix_type, int rowsize, switch (prefix_type) { case DUMP_PREFIX_ADDRESS: - printf("%s%0*lx: %s\n", prefix_str, - IS_ENABLED(CONFIG_PHYS_64BIT) ? 16 : 8, - (ulong)map_to_sysmem(ptr) + i, linebuf); + if (dbg) { + debug("%s%0*lx: %s\n", prefix_str, + IS_ENABLED(CONFIG_PHYS_64BIT) ? 16 : 8, + (ulong)map_to_sysmem(ptr) + i, linebuf); + } else } + printf("%s%0*lx: %s\n", prefix_str, + IS_ENABLED(CONFIG_PHYS_64BIT) ? 16 : 8, + (ulong)map_to_sysmem(ptr) + i, linebuf); + } break; case DUMP_PREFIX_OFFSET: - printf("%s%.8x: %s\n", prefix_str, i, linebuf); + if (dbg) + debug("%s%.8x: %s\n", prefix_str, i, linebuf); + else + printf("%s%.8x: %s\n", prefix_str, i, linebuf); break; default: - printf("%s%s\n", prefix_str, linebuf); + if (dbg) + debug("%s%s\n", prefix_str, linebuf); + else + printf("%s%s\n", prefix_str, linebuf); break; } if (!IS_ENABLED(CONFIG_SPL_BUILD) && ctrlc()) @@ -164,10 +177,30 @@ int print_hex_dump(const char *prefix_str, int prefix_type, int rowsize, return 0; } +int print_hex_dump(const char *prefix_str, int prefix_type, int rowsize, + int groupsize, const void *buf, size_t len, bool ascii) +{ + return do_print_hex_dump(prefix_str, prefix_type, rowsize, groupsize, + buf, len, ascii, false); +} + +int debug_hex_dump(const char *prefix_str, int prefix_type, int rowsize, + int groupsize, const void *buf, size_t len, bool ascii) +{ + return do_print_hex_dump(prefix_str, prefix_type, rowsize, groupsize, + buf, len, ascii, true); +} + void print_hex_dump_bytes(const char *prefix_str, int prefix_type, const void *buf, size_t len) { - print_hex_dump(prefix_str, prefix_type, 16, 1, buf, len, true); + do_print_hex_dump(prefix_str, prefix_type, 16, 1, buf, len, true, false); +} + +void debug_hex_dump_bytes(const char *prefix_str, int prefix_type, + const void *buf, size_t len) +{ + do_print_hex_dump(prefix_str, prefix_type, 16, 1, buf, len, true, true); } #else /* @@ -180,8 +213,19 @@ int print_hex_dump(const char *prefix_str, int prefix_type, int rowsize, return -ENOSYS; } +int debug_hex_dump(const char *prefix_str, int prefix_type, int rowsize, + int groupsize, const void *buf, size_t len, bool ascii) +{ + return -ENOSYS; +} + void print_hex_dump_bytes(const char *prefix_str, int prefix_type, const void *buf, size_t len) { } + +void debug_hex_dump_bytes(const char *prefix_str, int prefix_type, + const void *buf, size_t len) +{ +} #endif /* CONFIG_HEXDUMP */ From patchwork Tue Nov 9 12:02:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Shevchenko X-Patchwork-Id: 1552947 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4HpRSv3qmTz9sCD for ; Tue, 9 Nov 2021 23:03:11 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 501728391E; Tue, 9 Nov 2021 13:03:06 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=linux.intel.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id DE7C68391E; Tue, 9 Nov 2021 13:03:03 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 131F283632 for ; Tue, 9 Nov 2021 13:02:59 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=linux.intel.com Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=andriy.shevchenko@linux.intel.com X-IronPort-AV: E=McAfee;i="6200,9189,10162"; a="295867954" X-IronPort-AV: E=Sophos;i="5.87,220,1631602800"; d="scan'208";a="295867954" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Nov 2021 04:02:58 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,220,1631602800"; d="scan'208";a="503478779" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga008.jf.intel.com with ESMTP; 09 Nov 2021 04:02:56 -0800 Received: by black.fi.intel.com (Postfix, from userid 1003) id 9D8FDC5; Tue, 9 Nov 2021 14:02:58 +0200 (EET) From: Andy Shevchenko To: Andy Shevchenko , Simon Glass , u-boot@lists.denx.de Cc: Bin Meng Subject: [PATCH v1 2/2] x86: scu: Add a few debug messages to the driver Date: Tue, 9 Nov 2021 15:02:55 +0300 Message-Id: <20211109120255.77679-2-andriy.shevchenko@linux.intel.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211109120255.77679-1-andriy.shevchenko@linux.intel.com> References: <20211109120255.77679-1-andriy.shevchenko@linux.intel.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean For some devices that have slightly different firmware implementation it's good to see what's going on when communicating with the SCU. Add a few debug messages for that purpose. Signed-off-by: Andy Shevchenko Reviewed-by: Simon Glass --- arch/x86/lib/scu.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/x86/lib/scu.c b/arch/x86/lib/scu.c index 90ef239bcd3d..c7274e064647 100644 --- a/arch/x86/lib/scu.c +++ b/arch/x86/lib/scu.c @@ -11,6 +11,7 @@ */ #include #include +#include #include #include #include @@ -48,6 +49,7 @@ struct scu { */ static void scu_ipc_send_command(struct ipc_regs *regs, u32 cmd) { + debug("%s(): 0x%08x\n", __func__, cmd); writel(cmd, ®s->cmd); } @@ -92,12 +94,18 @@ static int scu_ipc_cmd(struct ipc_regs *regs, u32 cmd, u32 sub, for (i = 0; i < inlen; i++) writel(*in++, ®s->wbuf[i]); + debug_hex_dump("SCU in", DUMP_PREFIX_OFFSET, 16, 4, in, inlen * 4, false); + scu_ipc_send_command(regs, (inlen << 16) | (sub << 12) | cmd); err = scu_ipc_check_status(regs); if (!err) { + u32 *buf = out; + for (i = 0; i < outlen; i++) *out++ = readl(®s->rbuf[i]); + + debug_hex_dump("SCU out", DUMP_PREFIX_OFFSET, 16, 4, buf, outlen * 4, false); } return err;