Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp745240imi; Fri, 22 Jul 2022 08:32:23 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vws84EXLZx7v3a+/5GIyRt7JKaW8Ql1rfi+I5RdxS5gdvxmpTo6AJNZvhiIN7TsCiOZ0nJ X-Received: by 2002:a17:906:216:b0:711:f623:8bb0 with SMTP id 22-20020a170906021600b00711f6238bb0mr387351ejd.174.1658503942421; Fri, 22 Jul 2022 08:32:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658503942; cv=none; d=google.com; s=arc-20160816; b=QnCZ0LXIrydIiwAQxfE1JQXwkTjClOyubu0s9LK1T463vlLUbtwo1mBWzrO1taj6Xu dGi2VvcXORysCYt3amR9q0xNOUgzrBHIiFqupBS3utb/H8cekWyVc3X26H+a/mQlwsSf bOfwZZRMqPfo0E4yI8xuSqSi/63Pg+isQJLbecovp+YIYdi/CeiVu42VWWwJg89upcKV 2UmMXHaqpo59Zw6LqHd1vjr4PWgbHINv76cv56OUWaGsUv5xxh8wiORHBUHinytGd74/ urgXPQO0vOW6hlv0oHKgDbPgScuz28BQWGyNUXfk92RtLiMbaH0jiYwDGVEoVorUZbfP ywJQ== 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:to:from:cc:in-reply-to:subject:date:dkim-signature; bh=JiTsgIyx7zIuebw3jPBiJz5uZKu7LJAxJF1fKKcrwMc=; b=W/dyMqNzUCSVVhteodP1Hv1ZZwpiqAuv2C8v6GeXCaajUa+lq6HkgHK+hujq0NuYKE Ohq1to0JwNM/YEWRlHDQoIqK+XZ4m6kea7lG85jxvojW3TB76UZ9bhT7yinihh68kinv HdtfrHaufn1kYyAV2xOz5a4PUv5QxSx3gM2KFiwo12f6ZITx3P1j+ZSSKj1Y8V+I6M5b xtwuxnSCsoj3dS2SfsAWPMrqtr6ImC7RxOZKIM6BS2qbTy4R0ZHye1LB4gFO0lZjjkTB auTZtnRjE3TNZNB/uP+EwWp9u5HVFHq2r/5aea/bR3YotdQI9VcRD9+h+H2kj1y/IQ5r 2hpg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@dabbelt-com.20210112.gappssmtp.com header.s=20210112 header.b=rrckFJbU; 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 sa36-20020a1709076d2400b0072b960ad734si3043785ejc.746.2022.07.22.08.31.56; Fri, 22 Jul 2022 08:32:22 -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; dkim=pass header.i=@dabbelt-com.20210112.gappssmtp.com header.s=20210112 header.b=rrckFJbU; 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 S231491AbiGVP1h (ORCPT + 99 others); Fri, 22 Jul 2022 11:27:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231178AbiGVP1e (ORCPT ); Fri, 22 Jul 2022 11:27:34 -0400 Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA0A29EC6B for ; Fri, 22 Jul 2022 08:27:32 -0700 (PDT) Received: by mail-pf1-x42c.google.com with SMTP id y141so4708071pfb.7 for ; Fri, 22 Jul 2022 08:27:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dabbelt-com.20210112.gappssmtp.com; s=20210112; h=date:subject:in-reply-to:cc:from:to:message-id:mime-version :content-transfer-encoding; bh=JiTsgIyx7zIuebw3jPBiJz5uZKu7LJAxJF1fKKcrwMc=; b=rrckFJbUDVsImQF7IueIbd0/U72biyUAgvOzS+WhlcjHCI3ldV94QbLnmmGX/EQSr+ c8TSWho4ZocrCsAjV6gxmPElF1BHN92O4e1VfJB6B8bR82dmtAYAf8QTGOxStbnKVdnF Rr9z7B4FLIxTcqsj3J4Ep53UwR44wRjA2i+TA8UHQ9jC0eqwkKnSRwGNwiYl3JihLKdL 1oyg1K4t6/seSECyO7ysuzncwYAIxoww5m1UBmjQwNf0zHUNZHFNBBwqN39nCLjmjVJG LHZtpEy0JFK7N84KO0Jz7kvgGjh7WVGK2YZaqOzvnCz0FdvPKk9PLma/CLmmlb2xLLpZ 9q9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:subject:in-reply-to:cc:from:to:message-id :mime-version:content-transfer-encoding; bh=JiTsgIyx7zIuebw3jPBiJz5uZKu7LJAxJF1fKKcrwMc=; b=X2rCxoBPz7eY9VueDQACwiutihYlgfEWDMuyl4Cl5qoQ9/73AtXH6SEyPlVdTXe8zW jC9yx/Ij3LSIw81Z0TdaoOZ9DSBWH5x8nFBt4ZxL5nJTfYM63hzu9VJjcZF034yNohvQ dDvFQCbvPcZsv2rQruqVSNXf9hURo/7Uipw0KWQyz6vtefTqQV8VHOHYb2ip/JTEma6k 02R+iLCRJS6o+pYKHLInqAEPFYNxFmZgFZv2JAo25yGPE12whFzOEWE5ooMDVstgEEz2 voBybyUTkwSGsTdV7XzN/eV+Lb6TcKYN8wAJsn7wUxRCExK4KYCf3I+2c1l3e4TAwIHr /J/w== X-Gm-Message-State: AJIora/UjjCZrPkmpax6CKNMgFqd5ho3lJMmX9nZvR7Tx5BQOzMTQ9wz NMqsHIIKj5rLSeR9Nv0LyWg5Ig== X-Received: by 2002:a65:460b:0:b0:41a:6637:6544 with SMTP id v11-20020a65460b000000b0041a66376544mr257298pgq.511.1658503652107; Fri, 22 Jul 2022 08:27:32 -0700 (PDT) Received: from localhost (76-210-143-223.lightspeed.sntcca.sbcglobal.net. [76.210.143.223]) by smtp.gmail.com with ESMTPSA id p4-20020a17090a930400b001e292e30129sm3562385pjo.22.2022.07.22.08.27.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jul 2022 08:27:31 -0700 (PDT) Date: Fri, 22 Jul 2022 08:27:31 -0700 (PDT) X-Google-Original-Date: Fri, 22 Jul 2022 08:27:30 PDT (-0700) Subject: Re: [PATCH v3 2/2] asm-generic: Add new pci.h and use it In-Reply-To: CC: shorne@gmail.com, linux-kernel@vger.kernel.org, Arnd Bergmann , catalin.marinas@arm.com, Will Deacon , guoren@kernel.org, Paul Walmsley , aou@eecs.berkeley.edu, richard@nod.at, anton.ivanov@cambridgegreys.com, johannes@sipsolutions.net, linux-arm-kernel@lists.infradead.org, linux-csky@vger.kernel.org, linux-riscv@lists.infradead.org, linux-um@lists.infradead.org, linux-pci@vger.kernel.org, linux-arch@vger.kernel.org From: Palmer Dabbelt To: Rob Herring , bhelgaas@google.com, macro@orcam.me.uk Message-ID: Mime-Version: 1.0 (MHng) Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 On Thu, 21 Jul 2022 16:06:52 PDT (-0700), Rob Herring wrote: > On Tue, Jul 19, 2022 at 9:59 AM Palmer Dabbelt wrote: >> >> On Sun, 17 Jul 2022 17:41:14 PDT (-0700), shorne@gmail.com wrote: >> > The asm/pci.h used for many newer architectures share similar >> > definitions. Move the common parts to asm-generic/pci.h to allow for >> > sharing code. >> > >> > Two things to note are: >> > >> > - isa_dma_bridge_buggy, traditionally this is defined in asm/dma.h but >> > these architectures avoid creating that file and add the definition >> > to asm/pci.h. >> > - ARCH_GENERIC_PCI_MMAP_RESOURCE, csky does not define this so we >> > undefine it after including asm-generic/pci.h. Why doesn't csky >> > define it? >> > - pci_get_legacy_ide_irq, This function is only used on architectures >> > that support PNP. It is only maintained for arm64, in other >> > architectures it is removed. >> > >> > Suggested-by: Arnd Bergmann >> > Link: https://lore.kernel.org/lkml/CAK8P3a0JmPeczfmMBE__vn=Jbvf=nkbpVaZCycyv40pZNCJJXQ@mail.gmail.com/ >> > Signed-off-by: Stafford Horne >> > --- >> > Second note on isa_dma_bridge_buggy, this is set on x86 but it it also set in >> > pci/quirks.c. We discussed limiting it only to x86 though as its a general >> > quick triggered by pci ids I think it will be more tricky than we thought so I >> > will leave as is. It might be nice to move it out of asm/dma.h and into >> > asm/pci.h though. >> > >> > Since v2: >> > - Nothing >> > Since v1: >> > - Remove definition of pci_get_legacy_ide_irq >> > >> > arch/arm64/include/asm/pci.h | 12 +++--------- >> > arch/csky/include/asm/pci.h | 24 ++++-------------------- >> > arch/riscv/include/asm/pci.h | 25 +++---------------------- >> > arch/um/include/asm/pci.h | 24 ++---------------------- >> > include/asm-generic/pci.h | 36 ++++++++++++++++++++++++++++++++++++ >> > 5 files changed, 48 insertions(+), 73 deletions(-) >> > create mode 100644 include/asm-generic/pci.h >> > >> > diff --git a/arch/arm64/include/asm/pci.h b/arch/arm64/include/asm/pci.h >> > index b33ca260e3c9..1180e83712f5 100644 >> > --- a/arch/arm64/include/asm/pci.h >> > +++ b/arch/arm64/include/asm/pci.h >> > @@ -9,7 +9,6 @@ >> > #include >> > >> > #define PCIBIOS_MIN_IO 0x1000 >> > -#define PCIBIOS_MIN_MEM 0 >> > >> > /* >> > * Set to 1 if the kernel should re-assign all PCI bus numbers >> > @@ -18,9 +17,6 @@ >> > (pci_has_flag(PCI_REASSIGN_ALL_BUS)) >> > >> > #define arch_can_pci_mmap_wc() 1 >> > -#define ARCH_GENERIC_PCI_MMAP_RESOURCE 1 >> > - >> > -extern int isa_dma_bridge_buggy; >> > >> > #ifdef CONFIG_PCI >> > static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel) >> > @@ -28,11 +24,9 @@ static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel) >> > /* no legacy IRQ on arm64 */ >> > return -ENODEV; >> > } >> > - >> > -static inline int pci_proc_domain(struct pci_bus *bus) >> > -{ >> > - return 1; >> > -} >> > #endif /* CONFIG_PCI */ >> > >> > +/* Generic PCI */ >> > +#include >> > + >> > #endif /* __ASM_PCI_H */ >> > diff --git a/arch/csky/include/asm/pci.h b/arch/csky/include/asm/pci.h >> > index ebc765b1f78b..44866c1ad461 100644 >> > --- a/arch/csky/include/asm/pci.h >> > +++ b/arch/csky/include/asm/pci.h >> > @@ -9,26 +9,10 @@ >> > >> > #include >> > >> > -#define PCIBIOS_MIN_IO 0 >> > -#define PCIBIOS_MIN_MEM 0 >> > +/* Generic PCI */ >> > +#include >> > >> > -/* C-SKY shim does not initialize PCI bus */ >> > -#define pcibios_assign_all_busses() 1 >> > - >> > -extern int isa_dma_bridge_buggy; >> > - >> > -#ifdef CONFIG_PCI >> > -static inline int pci_get_legacy_ide_irq(struct pci_dev *dev, int channel) >> > -{ >> > - /* no legacy IRQ on csky */ >> > - return -ENODEV; >> > -} >> > - >> > -static inline int pci_proc_domain(struct pci_bus *bus) >> > -{ >> > - /* always show the domain in /proc */ >> > - return 1; >> > -} >> > -#endif /* CONFIG_PCI */ >> > +/* csky doesn't use generic pci resource mapping */ >> > +#undef ARCH_GENERIC_PCI_MMAP_RESOURCE >> > >> > #endif /* __ASM_CSKY_PCI_H */ >> > diff --git a/arch/riscv/include/asm/pci.h b/arch/riscv/include/asm/pci.h >> > index 7fd52a30e605..12ce8150cfb0 100644 >> > --- a/arch/riscv/include/asm/pci.h >> > +++ b/arch/riscv/include/asm/pci.h >> > @@ -12,29 +12,7 @@ >> > >> > #include >> > >> > -#define PCIBIOS_MIN_IO 0 >> > -#define PCIBIOS_MIN_MEM 0 >> >> My for-next changes these in bb356ddb78b2 ("RISC-V: PCI: Avoid handing >> out address 0 to devices"). Do you mind either splitting out the >> arch/riscv bits or having this in via some sort of shared tag? > > Shouldn't the values not matter here if the IO and mem resources are > described in the DT (and don't use 0)? The values of 4 and 16 look > odd. The linked thread has a fairly long discussion . I agree it's odd to have this in arch code: "don't hand out address 0" isn't really a RISC-V constraint (ie, we don't have architecture-defined limitations on these address spaces) but a constraint that comes from the generic port I/O functions and some other related PCI/resource code where the value 0 is a sentinel. Maybe the right thing to do here is actually to make the default definitions of these macros non-zero, or to add some sort of ARCH_ flavor of them and move that non-zero requirement closer to where it comes from? From the look of it any port that uses the generic port I/O functions and has 0 for these will be broken in the same way. That said, I'm not really a PCI guy so maybe Bjorn or Maciej has a better idea?