Message ID | 20230329071405.1568021-1-geert+renesas@glider.be |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp221509vqo; Wed, 29 Mar 2023 00:19:06 -0700 (PDT) X-Google-Smtp-Source: AKy350apgE1BXNHZsYCxU+ov4/K29JFug4yZQf/DvN+Iqx60CkZiP20V6yw9Ra6RnGDwYJixeBTG X-Received: by 2002:a17:90a:3:b0:23d:3931:7b49 with SMTP id 3-20020a17090a000300b0023d39317b49mr18501652pja.35.1680074346341; Wed, 29 Mar 2023 00:19:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680074346; cv=none; d=google.com; s=arc-20160816; b=pBf0yJ4MDdqaDOmT/2aX1RnZKewYT6ZqXFd2lPHw3C9FModYCA0Re2adwWmRMYvx1h In0ygg12su2GsmBreAjBf0c4GirdskKEU6J+uN1U4qdZy8JQPVre2wZQ30qOzzyL0MLm mpKm9TB9MDN7vx2ZJWOFQorfj5bZnWSOdi95Sw195AcWILRhmqrxNuVaZtYoQkQQkoCa ZpQfq2NBeVSfXxnfS0NgaFl7lfGfZFHP2Hz+ctlokM1O0xsYqwkAbpUKbseTBhYzRVq+ WpLf2lnkqujE/s7ePX6PN24g7/mz6hlv08PB0rvlaOAYDX1XCeAwjOaml1in/f5G54fK RQ0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=WWpmqjGXJsJDCKEu7LOVmlkX7Y/Ujsc/5vSSbOMRfaY=; b=txdhca2Rtf3fclfN6zLcoS8a/TiDm8PzRtNt+6/Y6z9UYK2g3Rig4gdfUZyxzBFKr3 pWD6j7NLnL5Ea7XSA6u+8MDLi5pGj7ZYj0VR1b9Aq/AbIyNsrTGvR66lC3Ml/sZDZun8 yVt/XkkbAV+QdjvvNc4+zwPBsvnYUeZO8aK0SiR4kyxZg5aXjuxtDvpQPgEAvkGRz5RN 4bNxTArCq79yTp6zwaGNRwqGjWME4Zh18ZW1tjukvTk0okxMGbuKTc0cSJjDOF9s1X9m 0+DutUukZ2lmtdupM0cKQXO1WdkrLEVehsZZ814v2ceJ6lkt0Mijr/z0kzc+sO3U92um 4VoQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id kb11-20020a17090ae7cb00b0023cfd08e30esi956840pjb.148.2023.03.29.00.18.53; Wed, 29 Mar 2023 00:19:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229900AbjC2HOS (ORCPT <rfc822;rua109.linux@gmail.com> + 99 others); Wed, 29 Mar 2023 03:14:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229836AbjC2HOQ (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 29 Mar 2023 03:14:16 -0400 Received: from xavier.telenet-ops.be (xavier.telenet-ops.be [IPv6:2a02:1800:120:4::f00:14]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43116CE for <linux-kernel@vger.kernel.org>; Wed, 29 Mar 2023 00:14:15 -0700 (PDT) Received: from ramsan.of.borg ([84.195.187.55]) by xavier.telenet-ops.be with bizsmtp id e7EC290021C8whw017ECJl; Wed, 29 Mar 2023 09:14:13 +0200 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtp (Exim 4.95) (envelope-from <geert@linux-m68k.org>) id 1phPzr-00FCqK-UX; Wed, 29 Mar 2023 09:14:12 +0200 Received: from geert by rox.of.borg with local (Exim 4.95) (envelope-from <geert@linux-m68k.org>) id 1phQ0Z-006ZvT-V8; Wed, 29 Mar 2023 09:14:11 +0200 From: Geert Uytterhoeven <geert+renesas@glider.be> To: Desnes Nunes <desnesn@redhat.com>, Christoph Hellwig <hch@lst.de>, Marek Szyprowski <m.szyprowski@samsung.com>, Robin Murphy <robin.murphy@arm.com> Cc: iommu@lists.linux.dev, linux-kernel@vger.kernel.org, Geert Uytterhoeven <geert+renesas@glider.be>, kernel test robot <lkp@intel.com>, noreply@ellerman.id.au Subject: [PATCH -next] dma-debug: Use %pa to format phys_addr_t Date: Wed, 29 Mar 2023 09:14:05 +0200 Message-Id: <20230329071405.1568021-1-geert+renesas@glider.be> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.4 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761685637441584755?= X-GMAIL-MSGID: =?utf-8?q?1761685637441584755?= |
Series |
[-next] dma-debug: Use %pa to format phys_addr_t
|
|
Commit Message
Geert Uytterhoeven
March 29, 2023, 7:14 a.m. UTC
On 32-bit without LPAE:
kernel/dma/debug.c: In function ‘debug_dma_dump_mappings’:
kernel/dma/debug.c:537:7: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 9 has type ‘phys_addr_t’ {aka ‘unsigned int’} [-Wformat=]
kernel/dma/debug.c: In function ‘dump_show’:
kernel/dma/debug.c:568:59: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 11 has type ‘phys_addr_t’ {aka ‘unsigned int’} [-Wformat=]
Fixes: bd89d69a529fbef3 ("dma-debug: add cacheline to user/kernel space dump messages")
Reported-by: kernel test robot <lkp@intel.com>
Link: https://lore.kernel.org/r/202303160548.ReyuTsGD-lkp@intel.com
Reported-by: noreply@ellerman.id.au
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
kernel/dma/debug.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
Comments
On Wed, Mar 29, 2023 at 09:14:05AM +0200, Geert Uytterhoeven wrote: > On 32-bit without LPAE: > > kernel/dma/debug.c: In function ‘debug_dma_dump_mappings’: > kernel/dma/debug.c:537:7: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 9 has type ‘phys_addr_t’ {aka ‘unsigned int’} [-Wformat=] > kernel/dma/debug.c: In function ‘dump_show’: > kernel/dma/debug.c:568:59: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 11 has type ‘phys_addr_t’ {aka ‘unsigned int’} [-Wformat=] > > Fixes: bd89d69a529fbef3 ("dma-debug: add cacheline to user/kernel space dump messages") > Reported-by: kernel test robot <lkp@intel.com> > Link: https://lore.kernel.org/r/202303160548.ReyuTsGD-lkp@intel.com > Reported-by: noreply@ellerman.id.au > Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> > --- > kernel/dma/debug.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/kernel/dma/debug.c b/kernel/dma/debug.c > index 676142072d997b6a..f190651bcaddc9e9 100644 > --- a/kernel/dma/debug.c > +++ b/kernel/dma/debug.c > @@ -534,11 +534,11 @@ void debug_dma_dump_mappings(struct device *dev) > if (!dev || dev == entry->dev) { > cln = to_cacheline_number(entry); > dev_info(entry->dev, > - "%s idx %d P=%llx N=%lx D=%llx L=%llx cln=%llx %s %s\n", > + "%s idx %d P=%llx N=%lx D=%llx L=%llx cln=%pa %s %s\n", > type2name[entry->type], idx, > phys_addr(entry), entry->pfn, > entry->dev_addr, entry->size, > - cln, dir2name[entry->direction], > + &cln, dir2name[entry->direction], Won't this just print out the address of cln declared at the beginning of debug_dma_dump_mappings() each time, instead of the value returned from to_cacheline_entry() ? > maperr2str[entry->map_err_type]); > } > } > @@ -565,13 +565,13 @@ static int dump_show(struct seq_file *seq, void *v) > list_for_each_entry(entry, &bucket->list, list) { > cln = to_cacheline_number(entry); > seq_printf(seq, > - "%s %s %s idx %d P=%llx N=%lx D=%llx L=%llx cln=%llx %s %s\n", > + "%s %s %s idx %d P=%llx N=%lx D=%llx L=%llx cln=%pa %s %s\n", > dev_driver_string(entry->dev), > dev_name(entry->dev), > type2name[entry->type], idx, > phys_addr(entry), entry->pfn, > entry->dev_addr, entry->size, > - cln, dir2name[entry->direction], > + &cln, dir2name[entry->direction], same for dump_show() > maperr2str[entry->map_err_type]); > } > spin_unlock_irqrestore(&bucket->lock, flags); > -- > 2.34.1 >
Hi Jerry, On Wed, Mar 29, 2023 at 5:03 PM Jerry Snitselaar <jsnitsel@redhat.com> wrote: > On Wed, Mar 29, 2023 at 09:14:05AM +0200, Geert Uytterhoeven wrote: > > On 32-bit without LPAE: > > > > kernel/dma/debug.c: In function ‘debug_dma_dump_mappings’: > > kernel/dma/debug.c:537:7: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 9 has type ‘phys_addr_t’ {aka ‘unsigned int’} [-Wformat=] > > kernel/dma/debug.c: In function ‘dump_show’: > > kernel/dma/debug.c:568:59: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 11 has type ‘phys_addr_t’ {aka ‘unsigned int’} [-Wformat=] > > > > Fixes: bd89d69a529fbef3 ("dma-debug: add cacheline to user/kernel space dump messages") > > Reported-by: kernel test robot <lkp@intel.com> > > Link: https://lore.kernel.org/r/202303160548.ReyuTsGD-lkp@intel.com > > Reported-by: noreply@ellerman.id.au > > Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> = > > --- a/kernel/dma/debug.c > > +++ b/kernel/dma/debug.c > > @@ -534,11 +534,11 @@ void debug_dma_dump_mappings(struct device *dev) > > if (!dev || dev == entry->dev) { > > cln = to_cacheline_number(entry); > > dev_info(entry->dev, > > - "%s idx %d P=%llx N=%lx D=%llx L=%llx cln=%llx %s %s\n", > > + "%s idx %d P=%llx N=%lx D=%llx L=%llx cln=%pa %s %s\n", > > type2name[entry->type], idx, > > phys_addr(entry), entry->pfn, > > entry->dev_addr, entry->size, > > - cln, dir2name[entry->direction], > > + &cln, dir2name[entry->direction], > > Won't this just print out the address of cln declared at the beginning of debug_dma_dump_mappings() each time, instead of the value > returned from to_cacheline_entry() ? The physical address is passed by reference, cfr. https://elixir.bootlin.com/linux/latest/source/Documentation/core-api/printk-formats.rst#L231 Gr{oetje,eeting}s, Geert
On Wed, Mar 29, 2023 at 05:34:23PM +0200, Geert Uytterhoeven wrote: > Hi Jerry, > > On Wed, Mar 29, 2023 at 5:03 PM Jerry Snitselaar <jsnitsel@redhat.com> wrote: > > On Wed, Mar 29, 2023 at 09:14:05AM +0200, Geert Uytterhoeven wrote: > > > On 32-bit without LPAE: > > > > > > kernel/dma/debug.c: In function ‘debug_dma_dump_mappings’: > > > kernel/dma/debug.c:537:7: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 9 has type ‘phys_addr_t’ {aka ‘unsigned int’} [-Wformat=] > > > kernel/dma/debug.c: In function ‘dump_show’: > > > kernel/dma/debug.c:568:59: warning: format ‘%llx’ expects argument of type ‘long long unsigned int’, but argument 11 has type ‘phys_addr_t’ {aka ‘unsigned int’} [-Wformat=] > > > > > > Fixes: bd89d69a529fbef3 ("dma-debug: add cacheline to user/kernel space dump messages") > > > Reported-by: kernel test robot <lkp@intel.com> > > > Link: https://lore.kernel.org/r/202303160548.ReyuTsGD-lkp@intel.com > > > Reported-by: noreply@ellerman.id.au > > > Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> > = > > > --- a/kernel/dma/debug.c > > > +++ b/kernel/dma/debug.c > > > @@ -534,11 +534,11 @@ void debug_dma_dump_mappings(struct device *dev) > > > if (!dev || dev == entry->dev) { > > > cln = to_cacheline_number(entry); > > > dev_info(entry->dev, > > > - "%s idx %d P=%llx N=%lx D=%llx L=%llx cln=%llx %s %s\n", > > > + "%s idx %d P=%llx N=%lx D=%llx L=%llx cln=%pa %s %s\n", > > > type2name[entry->type], idx, > > > phys_addr(entry), entry->pfn, > > > entry->dev_addr, entry->size, > > > - cln, dir2name[entry->direction], > > > + &cln, dir2name[entry->direction], > > > > Won't this just print out the address of cln declared at the beginning of debug_dma_dump_mappings() each time, instead of the value > > returned from to_cacheline_entry() ? > > The physical address is passed by reference, cfr. > https://elixir.bootlin.com/linux/latest/source/Documentation/core-api/printk-formats.rst#L231 > > Gr{oetje,eeting}s, > > Geert Got it. Thanks Geert snits > > -- > Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org > > In personal conversations with technical people, I call myself a hacker. But > when I'm talking to journalists I just say "programmer" or something like that. > -- Linus Torvalds
I've applied this as it is the first fix I got into my mailbox for it. Arnd sent one a little later, which uses %pap instead of %pa, which confused me a bit. The documentation seems to allow both without any recommendation which one to use, which confuses me even further.
On Thu, Mar 30, 2023, at 01:50, Christoph Hellwig wrote: > I've applied this as it is the first fix I got into my mailbox for it. > > Arnd sent one a little later, which uses %pap instead of %pa, which > confused me a bit. The documentation seems to allow both without > any recommendation which one to use, which confuses me even further. Indeed, I wasn't aware of this either, apparently aaf07621b8bb ("vsprintf: add %pad extension for dma_addr_t use") introduced the %pap form at the same time as %pad but made it the same as the already existing %pa. I also see that the %pa form is a lot more common than %pap, so it's probably better to go with %pa for new users anyway. Arnd
Hi Christoph, On Thu, Mar 30, 2023 at 1:50 AM Christoph Hellwig <hch@infradead.org> wrote: > I've applied this as it is the first fix I got into my mailbox for it. Thank you! > Arnd sent one a little later, which uses %pap instead of %pa, which > confused me a bit. The documentation seems to allow both without > any recommendation which one to use, which confuses me even further. The "%pa" class supports two variants: "%pad" (for dma_addr_t) and "%pap" (for phys_addr_t). "%pa" is a shortcut for the latter, cfr. https://elixir.bootlin.com/linux/latest/source/lib/vsprintf.c#L1792 The default exists because "%pa" was fist, cfr. commit aaf07621b8bbfdc0 ("vsprintf: add %pad extension for dma_addr_t use"), and I don't think we can easily remove it. The default is shorter (saves one byte, even compared to %llx"), so why not use it? Gr{oetje,eeting}s, Geert
diff --git a/kernel/dma/debug.c b/kernel/dma/debug.c index 676142072d997b6a..f190651bcaddc9e9 100644 --- a/kernel/dma/debug.c +++ b/kernel/dma/debug.c @@ -534,11 +534,11 @@ void debug_dma_dump_mappings(struct device *dev) if (!dev || dev == entry->dev) { cln = to_cacheline_number(entry); dev_info(entry->dev, - "%s idx %d P=%llx N=%lx D=%llx L=%llx cln=%llx %s %s\n", + "%s idx %d P=%llx N=%lx D=%llx L=%llx cln=%pa %s %s\n", type2name[entry->type], idx, phys_addr(entry), entry->pfn, entry->dev_addr, entry->size, - cln, dir2name[entry->direction], + &cln, dir2name[entry->direction], maperr2str[entry->map_err_type]); } } @@ -565,13 +565,13 @@ static int dump_show(struct seq_file *seq, void *v) list_for_each_entry(entry, &bucket->list, list) { cln = to_cacheline_number(entry); seq_printf(seq, - "%s %s %s idx %d P=%llx N=%lx D=%llx L=%llx cln=%llx %s %s\n", + "%s %s %s idx %d P=%llx N=%lx D=%llx L=%llx cln=%pa %s %s\n", dev_driver_string(entry->dev), dev_name(entry->dev), type2name[entry->type], idx, phys_addr(entry), entry->pfn, entry->dev_addr, entry->size, - cln, dir2name[entry->direction], + &cln, dir2name[entry->direction], maperr2str[entry->map_err_type]); } spin_unlock_irqrestore(&bucket->lock, flags);