From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8D763C4361B for ; Mon, 7 Dec 2020 03:27:16 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DA40A22CA0 for ; Mon, 7 Dec 2020 03:27:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DA40A22CA0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4Cq7z53tpqzDqWd for ; Mon, 7 Dec 2020 14:27:13 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::242; helo=mail-oi1-x242.google.com; envelope-from=f.fainelli@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=pzZKsSd8; dkim-atps=neutral Received: from mail-oi1-x242.google.com (mail-oi1-x242.google.com [IPv6:2607:f8b0:4864:20::242]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4Cq7ww2CvKzDqKN for ; Mon, 7 Dec 2020 14:25:14 +1100 (AEDT) Received: by mail-oi1-x242.google.com with SMTP id t205so13901546oib.12 for ; Sun, 06 Dec 2020 19:25:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=C2Ix5oeKbqJKBSFQum17pYUeNiQgWG4qBDaCP6pF+9E=; b=pzZKsSd8MbNoUDnMdPCVc5u6LHTCjTVi1zdUIqAWpWGrKhn2SS+tAQeQc1vQfqA/M1 uo8emwG4ei0ap7lYcKus+vFJPiNL9SkPX5E4aXMBBvKSXAMv+GrpZrRpXHAngVWkMhZd klK8iivt8DWyHnAvHGkqeKM1A5/ecGxXpIvop6wwC85CtjCZLEoGJz1YariaxwQOd4Zm uqNOHPLKB8eFtTXr1BHAUBlQr03aC+bJPtTF9wkNuDxCLJUuwzK8mgvxbRXeo+ieU7Zu dGmAKaT/2GABKN60dHgCOR2thZ66V1CUcFOY5jb1kZDWWyVqgLj/rGwqLg55Mz3hUZyh iFgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=C2Ix5oeKbqJKBSFQum17pYUeNiQgWG4qBDaCP6pF+9E=; b=pn55N+JoAdTbCZLw0d0QS2XJ0cAL6TX7onTFYvCuFkuC5PtSPrJwA8GHF8WBP0IDkL oePlJ6YdMMqQ8EApUs0u2dmL3cKeB9jZlXg8e0JNlPqeRLPpmrCZEqJW2LTmheaoR8S3 kUc4G5cZQtf/tYzGi7ktZsQZeG5Ffw1InnVaS/fWwQC2hlq0gSkawWXC+D08eF+bHBE/ CWBzEOYJCOpA2vgzQgUQOmqBwZzQ/VrOXWuyM/VKhpoCgxz8G+E/m7Ijb/YI3/ktTWKQ 2FL/kuMf+OIF2dMS9pvemtPiTXJH2mypVmTXBwUzeV0M8txCFCSk+RoW8Hv6SMdXfE4b ha7w== X-Gm-Message-State: AOAM532ueqnzLGRZL0ozhVtcZWvstS5tO7Um50ZSmU7nqlRj3pHucehz 108BVWkHNcSX6SIVIAMSnMU= X-Google-Smtp-Source: ABdhPJzczOydwnK1CTI9pP9bxm9+oAl7Jgo4Mw8k7GQ6HD6zylEV81DWrC05uDG06SC4srcr560HGA== X-Received: by 2002:aca:3d0b:: with SMTP id k11mr11306704oia.122.1607311511211; Sun, 06 Dec 2020 19:25:11 -0800 (PST) Received: from ?IPv6:2600:1700:dfe0:49f0:98c0:b1b6:3436:9662? ([2600:1700:dfe0:49f0:98c0:b1b6:3436:9662]) by smtp.gmail.com with ESMTPSA id k5sm2350693oot.30.2020.12.06.19.25.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 06 Dec 2020 19:25:10 -0800 (PST) Subject: Re: [PATCH v6 1/5] PCI: Unify ECAM constants in native PCI Express drivers To: =?UTF-8?Q?Krzysztof_Wilczy=c5=84ski?= , Bjorn Helgaas , Jim Quinlan References: <20201129230743.3006978-1-kw@linux.com> <20201129230743.3006978-2-kw@linux.com> From: Florian Fainelli Message-ID: <094b314f-7f61-d0fd-fd63-c9c4da9e84a8@gmail.com> Date: Sun, 6 Dec 2020 19:25:06 -0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Firefox/78.0 Thunderbird/78.5.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Heiko Stuebner , Shawn Lin , Paul Mackerras , Thomas Petazzoni , Jonathan Chocron , Toan Le , Will Deacon , Rob Herring , Lorenzo Pieralisi , Michal Simek , linux-rockchip@lists.infradead.org, bcm-kernel-feedback-list@broadcom.com, Jonathan Derrick , linux-pci@vger.kernel.org, Ray Jui , linux-rpi-kernel@lists.infradead.org, Jonathan Cameron , linux-arm-kernel@lists.infradead.org, Scott Branden , Zhou Wang , Robert Richter , linuxppc-dev@lists.ozlabs.org, Nicolas Saenz Julienne Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" +JimQ, On 12/6/2020 12:16 PM, Krzysztof WilczyƄski wrote: > Hello Nicolas, Florian and Florian, > > [...] >> -/* Configuration space read/write support */ >> -static inline int brcm_pcie_cfg_index(int busnr, int devfn, int reg) >> -{ >> - return ((PCI_SLOT(devfn) & 0x1f) << PCIE_EXT_SLOT_SHIFT) >> - | ((PCI_FUNC(devfn) & 0x07) << PCIE_EXT_FUNC_SHIFT) >> - | (busnr << PCIE_EXT_BUSNUM_SHIFT) >> - | (reg & ~3); >> -} >> - >> static void __iomem *brcm_pcie_map_conf(struct pci_bus *bus, unsigned int devfn, >> int where) >> { >> @@ -716,7 +704,7 @@ static void __iomem *brcm_pcie_map_conf(struct pci_bus *bus, unsigned int devfn, >> return PCI_SLOT(devfn) ? NULL : base + where; >> >> /* For devices, write to the config space index register */ >> - idx = brcm_pcie_cfg_index(bus->number, devfn, 0); >> + idx = PCIE_ECAM_OFFSET(bus->number, devfn, 0); >> writel(idx, pcie->base + PCIE_EXT_CFG_INDEX); >> return base + PCIE_EXT_CFG_DATA + where; >> } > [...] > > Passing the hard-coded 0 as the "reg" argument here never actually did > anything, thus the 32 bit alignment was never correctly enforced. > > My question would be: should this be 32 bit aligned? It seems like the > intention was to perhaps make the alignment? I am sadly not intimately > familiar with his hardware, so I am not sure if there is something to > fix here or not. > > Also, I wonder whether it would be safe to pass the offset (the "where" > variable) rather than hard-coded 0? > > Thank you for help in advance! > > Bjorn also asked the same question: > https://lore.kernel.org/linux-pci/20201120203428.GA272511@bjorn-Precision-5520/ > > Krzysztof > -- Florian