Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp4685154rwi; Mon, 17 Oct 2022 09:18:32 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4jbEC7lAYa+rkHje+8479sY+mmEHWKTVV3BFMqhRj9VRugeSG7MVJOK/7zbj/XwdLZybnP X-Received: by 2002:a17:903:234f:b0:17f:6711:1f9f with SMTP id c15-20020a170903234f00b0017f67111f9fmr12464011plh.32.1666023512255; Mon, 17 Oct 2022 09:18:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666023512; cv=none; d=google.com; s=arc-20160816; b=k6fZ7TSbe8igFwrWMvGMn5RkV1pYLwN8B7YVM81d2uE/GiGGlqi90BfKrOZNUIiotL F0JaGYRLqByx0fXGmczHhOsA6Pd3wHCTmD311DvHOJrrWl/CQ1Kr+A1hAdY5RPEoUyAL Fz7yn8x0zs/8uP0PetKuRkbbA/UB3BhBCyujZHvfwdHctuEgUF7CAV0n7Iav4iSyaIgI KV23O/1dgu6thgGzL9Ts44y1gxW98WVqkeLI+3emj0LpJRuO7L8obh5xU0OYirl5FX+g pbtW5sLTQa/q9AMYilqn9j0zQNBIxBwGvgjkUhctPmZ0/ma3V/qpmLuY1p1UIiLCMhOM /TIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=c1hr660YTne5HWG47TPibAhxpQ0b+WJkg6fuMvgqI+4=; b=jGu+oY3rORHgDHmp40Pn6Cgn44WeDh5gDEuU/ldqTX5JYj+HXDBth8mDdPBdbJZ9RK cQ1VtXfreSDiYOJZ8d2H7BxgwSaoOgYlv9ENRnHObDyj3CZqemWxpUmnmaETCS7mdGo9 weNBTPDeDevgmkzN6q0CInxWd9EaMce+yhYgx9ZJ7XK3Yfe87qax7j6bWzEFHkmH7GNY 7C5yPzCanA4OhmWb85IqctTXvnNkCRfudDV10BZ5XaPf+GiWGYIGDvuw1NJipxEBigDO c0KTNM8ELDqABG8rMJx5/Dvw4sRvS5H6qrTrxXixisQ/OgjblBTy3C85zA0Chh0/4nW8 p0PQ== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 5-20020a630105000000b0045a048683desi12806914pgb.647.2022.10.17.09.18.19; Mon, 17 Oct 2022 09:18:32 -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 S230122AbiJQPtU (ORCPT + 99 others); Mon, 17 Oct 2022 11:49:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33884 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230134AbiJQPtQ (ORCPT ); Mon, 17 Oct 2022 11:49:16 -0400 Received: from mail-qk1-f176.google.com (mail-qk1-f176.google.com [209.85.222.176]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B765F659CF; Mon, 17 Oct 2022 08:49:15 -0700 (PDT) Received: by mail-qk1-f176.google.com with SMTP id o22so6866306qkl.8; Mon, 17 Oct 2022 08:49:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=c1hr660YTne5HWG47TPibAhxpQ0b+WJkg6fuMvgqI+4=; b=zdUsJqHJJcoFQvqffAq4sBuoSw/VJr03atjS33OHW2fSPB0F/iyZtm7RtxJA8SKPMX tgIHX5miRYKzYFOJ+LsXsTMZKZlGmv50mMAiPwQvdhm5G29NRijTrTeM5E4moBZKT0D5 dH8f08NTQs6r9UM7v0k2S2yjxL6a+U1nQIT64jhLggvvVdoBZptY3pU2kuOWi1W2WxFS Fe7TuB5AeQYF31w8KTKRGKLenS9MwAFeD3jXoOMpJg+tRkUyiHfVwLFnQJAyTmeGDbhM FmsYko8AS+mCsjYQcsaI0RJLTi8Jx+7Bfd2ahSAnrPFwgm0ceBEtaWdwEic9V7+0uxq2 UiXQ== X-Gm-Message-State: ACrzQf0/C3QibntNtSr1fagqmhnh/vxD7c+rAyDEMt+gqssbNpFaQ99l kAmuWPSsOqeUcky5GholY3Y4nqKkyQqtAQ== X-Received: by 2002:a05:620a:b05:b0:6ee:cb0e:3c94 with SMTP id t5-20020a05620a0b0500b006eecb0e3c94mr8002708qkg.379.1666021754734; Mon, 17 Oct 2022 08:49:14 -0700 (PDT) Received: from mail-yb1-f174.google.com (mail-yb1-f174.google.com. [209.85.219.174]) by smtp.gmail.com with ESMTPSA id m21-20020a05620a24d500b006bb82221013sm149076qkn.0.2022.10.17.08.49.13 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 17 Oct 2022 08:49:13 -0700 (PDT) Received: by mail-yb1-f174.google.com with SMTP id 81so13762198ybf.7; Mon, 17 Oct 2022 08:49:13 -0700 (PDT) X-Received: by 2002:a25:687:0:b0:6c2:2b0c:26e with SMTP id 129-20020a250687000000b006c22b0c026emr9748099ybg.202.1666021753122; Mon, 17 Oct 2022 08:49:13 -0700 (PDT) MIME-Version: 1.0 References: <20220902215737.981341-1-sean.anderson@seco.com> <20220902215737.981341-6-sean.anderson@seco.com> <086a6f02-4495-510e-9fc5-64f95e7d55f6@seco.com> In-Reply-To: <086a6f02-4495-510e-9fc5-64f95e7d55f6@seco.com> From: Geert Uytterhoeven Date: Mon, 17 Oct 2022 17:49:01 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH net-next v5 05/14] net: fman: Map the base address once To: Sean Anderson Cc: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org, Camelia Groza , Madalin Bucur , open list , linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no 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: X-Mailing-List: linux-kernel@vger.kernel.org Hi Sean, On Mon, Oct 17, 2022 at 5:34 PM Sean Anderson wrote: > On 10/17/22 11:15 AM, Geert Uytterhoeven wrote: > > On Sat, Sep 3, 2022 at 12:00 AM Sean Anderson wrote: > >> We don't need to remap the base address from the resource twice (once in > >> mac_probe() and again in set_fman_mac_params()). We still need the > >> resource to get the end address, but we can use a single function call > >> to get both at once. > >> > >> While we're at it, use platform_get_mem_or_io and devm_request_resource > >> to map the resource. I think this is the more "correct" way to do things > >> here, since we use the pdev resource, instead of creating a new one. > >> It's still a bit tricky, since we need to ensure that the resource is a > >> child of the fman region when it gets requested. > >> > >> Signed-off-by: Sean Anderson > >> Acked-by: Camelia Groza > > > > Thanks for your patch, which is now commit 262f2b782e255b79 > > ("net: fman: Map the base address once") in v6.1-rc1. > > > >> --- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth_sysfs.c > >> +++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth_sysfs.c > >> @@ -18,7 +18,7 @@ static ssize_t dpaa_eth_show_addr(struct device *dev, > >> > >> if (mac_dev) > >> return sprintf(buf, "%llx", > >> - (unsigned long long)mac_dev->res->start); > >> + (unsigned long long)mac_dev->vaddr); > > > > On 32-bit: > > > > warning: cast from pointer to integer of different size > > [-Wpointer-to-int-cast] > > > > Obviously you should cast to "uintptr_t" or "unsigned long" instead, > > and change the "%llx" to "%p" or "%lx"... > > Isn't there a %px for this purpose? Yes there is. But if it makes sense to use that depends on the still to be answered questions at the bottom... > > However, taking a closer look: > > 1. The old code exposed a physical address to user space, the new > > code exposes the mapped virtual address. > > Is that change intentional? > > No, this is not intentional. So to make this backwards-compatible, I > suppose I need a virt_to_phys? I think virt_to_phys() will work only on real memory, not on MMIO, so you may need to reintroduce the resource again. > > 2. Virtual addresses are useless in user space. > > Moreover, addresses printed by "%p" are obfuscated, as this is > > considered a security issue. Likewise for working around this by > > casting to an integer. > > Yes, you're right that this probably shouldn't be exposed to userspace. > > > What's the real purpose of dpaa_eth_show_addr()? > > I have no idea. This is a question for Madalin. > > > Perhaps it should be removed? > > That would be reasonable IMO. Gr{oetje,eeting}s, Geert -- 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