From: lorenzo.pieralisi@arm.com (Lorenzo Pieralisi)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC PATCH v3 2/2] ARM64/PCI: Start using quirks handling for ACPI based PCI host controller
Date: Tue, 21 Jun 2016 10:26:27 +0100 [thread overview]
Message-ID: <20160621092627.GA31277@red-moon> (raw)
In-Reply-To: <CADaLNDme9VCrM0Mk-3eOhai-TSQtzwHfo_CGqO9eLZFkzi1JGQ@mail.gmail.com>
On Mon, Jun 20, 2016 at 12:12:24PM -0700, Duc Dang wrote:
> On Mon, Jun 20, 2016 at 10:17 AM, Christopher Covington
> <cov@codeaurora.org> wrote:
> > Hi Duc,
> >
> > On 06/20/2016 05:42 AM, Lorenzo Pieralisi wrote:
> >> On Fri, Jun 17, 2016 at 02:37:02PM -0700, Duc Dang wrote:
> >>> On Thu, Jun 16, 2016 at 10:48 AM, Lorenzo Pieralisi
> >>> <lorenzo.pieralisi@arm.com> wrote:
> >>>> On Wed, Jun 15, 2016 at 11:34:11AM -0400, Christopher Covington wrote:
> >>>>> From: Tomasz Nowicki <tn@semihalf.com>
> >>>>>
> >>>>> pci_generic_ecam_ops is used by default. Since there are platforms
> >>>>> which have non-compliant ECAM space we need to overwrite these
> >>>>> accessors prior to PCI buses enumeration. In order to do that
> >>>>> we call pci_mcfg_get_ops to retrieve pci_ecam_ops structure so that
> >>>>> we can use proper PCI config space accessors and bus_shift.
> >>>>>
> >>>>> pci_generic_ecam_ops is still used for platforms free from quirks.
> >>>>>
> >>>>> Signed-off-by: Tomasz Nowicki <tn@semihalf.com>
> >>>>> ---
> >>>>> arch/arm64/kernel/pci.c | 7 ++++---
> >>>>> 1 file changed, 4 insertions(+), 3 deletions(-)
> >>>>>
> >>>>> diff --git a/arch/arm64/kernel/pci.c b/arch/arm64/kernel/pci.c
> >>>>> index 94cd43c..a891bda 100644
> >>>>> --- a/arch/arm64/kernel/pci.c
> >>>>> +++ b/arch/arm64/kernel/pci.c
> >>>>> @@ -139,6 +139,7 @@ pci_acpi_setup_ecam_mapping(struct acpi_pci_root *root)
> >>>>> struct pci_config_window *cfg;
> >>>>> struct resource cfgres;
> >>>>> unsigned int bsz;
> >>>>> + struct pci_ecam_ops *ops;
> >>>>>
> >>>>> /* Use address from _CBA if present, otherwise lookup MCFG */
> >>>>> if (!root->mcfg_addr)
> >>>>> @@ -150,12 +151,12 @@ pci_acpi_setup_ecam_mapping(struct acpi_pci_root *root)
> >>>>> return NULL;
> >>>>> }
> >>>>>
> >>>>> - bsz = 1 << pci_generic_ecam_ops.bus_shift;
> >>>>> + ops = pci_mcfg_get_ops(root);
> >>>>> + bsz = 1 << ops->bus_shift;
> >>>>> cfgres.start = root->mcfg_addr + bus_res->start * bsz;
> >>>>> cfgres.end = cfgres.start + resource_size(bus_res) * bsz - 1;
> >>>>> cfgres.flags = IORESOURCE_MEM;
> >>>>> - cfg = pci_ecam_create(&root->device->dev, &cfgres, bus_res,
> >>>>> - &pci_generic_ecam_ops);
> >>>>> + cfg = pci_ecam_create(&root->device->dev, &cfgres, bus_res, ops);
> >>>>
> >>>> Arnd pointed this out already, I think that's the only pending question
> >>>> here.
> >>>>
> >>>> pci_ecam_create() maps ECAM space for config regions retrieved from
> >>>> the MCFG, which are *supposed* to be ECAM compliant.
> >>>>
> >>>> Do we think that's *always* correct/safe regardless of the kind
> >>>> of quirk we are currently fixing up ?
> >>>>
> >>>> Or we do think that configuration space regions should come from
> >>>> a different resource declared in the ACPI namespace if the regions
> >>>> are not MCFG/ECAM compliant (ie config space is not defined through
> >>>> MCFG at all - possibly through a _CRS method for a vendor specific
> >>>> _HID under the PNP0A03 node ?)
> >>>
> >>> Hi Lorenzo,
> >>>
> >>> For X-Gene: the ECAM space is used to access the configuration space
> >>> of PCIe devices, with additional help from controller register to
> >>> specify the bus, device and function number. Below is the RFC patch
> >>> that implements ECAM fixup for X-Gene PCIe controller on top of this
> >>> RFC ECAM quirk v3 for your and others reference.
> >>
> >> Yes, you have an additional resource in the PNP0A03 _CRS to describe
> >> your register that is a deliberate abuse of the ACPI standard in
> >> that the _CRS is meant to describe resources that are passed on
> >> to secondary buses
> >
> > A potential alternative came up in an off-list discussion: Would it be
> > better to hard code the information in the quirk workaround than look it
> > up from a repurposed ACPI resource?
>
> Hi Chris, Lorenzo,
>
> Thanks for looking into this.
>
> Yes, I am open for this approach and I think it may work. I can +
> check the pci_config_window resource start address (cfg->res.start) to
> figure out the controller and then get the fixed controller register
> address or + using the domain number to identify the controller.
First thing to do is to remove config space entry from PNP0A03
_CRS, that's a FW bug.
You could use the {bus-range, domain} to get that register address,
anyway, that's not the main concern here.
Thanks,
Lorenzo
> Regards,
> Duc Dang.
> >
> > Supporting quirk workarounds for early, non-compliant hardware is
> > helpful and perhaps necessary for bootstrapping the ecosystem in a
> > timely manner. But we don't really want to provide an expandable or
> > reusable interface that would make it easy for new hardware to remain
> > non-compliant.
> >
> > Regards,
> > Cov
> >
> > --
> > Qualcomm Innovation Center, Inc.
> > Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
> > a Linux Foundation Collaborative Project
>
WARNING: multiple messages have this Message-ID (diff)
From: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
To: Duc Dang <dhdang@apm.com>
Cc: Christopher Covington <cov@codeaurora.org>,
Tomasz Nowicki <tn@semihalf.com>,
Dongdong Liu <liudongdong3@huawei.com>,
Sinan Kaya <okaya@codeaurora.org>,
Jeff Hugo <jhugo@codeaurora.org>,
Gabriele Paoloni <gabriele.paoloni@huawei.com>,
Jon Masters <jcm@redhat.com>, Mark Salter <msalter@redhat.com>,
Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>,
Jayachandran C <jchandra@broadcom.com>,
David Daney <ddaney@caviumnetworks.com>,
Robert Richter <robert.richter@caviumnetworks.com>,
Hanjun Guo <hanjun.guo@linaro.org>,
linux-arm <linux-arm-kernel@lists.infradead.org>,
Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will.deacon@arm.com>,
Bjorn Helgaas <bhelgaas@google.com>,
Ganapatrao Kulkarni <gkulkarni@caviumnetworks.com>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [RFC PATCH v3 2/2] ARM64/PCI: Start using quirks handling for ACPI based PCI host controller
Date: Tue, 21 Jun 2016 10:26:27 +0100 [thread overview]
Message-ID: <20160621092627.GA31277@red-moon> (raw)
In-Reply-To: <CADaLNDme9VCrM0Mk-3eOhai-TSQtzwHfo_CGqO9eLZFkzi1JGQ@mail.gmail.com>
On Mon, Jun 20, 2016 at 12:12:24PM -0700, Duc Dang wrote:
> On Mon, Jun 20, 2016 at 10:17 AM, Christopher Covington
> <cov@codeaurora.org> wrote:
> > Hi Duc,
> >
> > On 06/20/2016 05:42 AM, Lorenzo Pieralisi wrote:
> >> On Fri, Jun 17, 2016 at 02:37:02PM -0700, Duc Dang wrote:
> >>> On Thu, Jun 16, 2016 at 10:48 AM, Lorenzo Pieralisi
> >>> <lorenzo.pieralisi@arm.com> wrote:
> >>>> On Wed, Jun 15, 2016 at 11:34:11AM -0400, Christopher Covington wrote:
> >>>>> From: Tomasz Nowicki <tn@semihalf.com>
> >>>>>
> >>>>> pci_generic_ecam_ops is used by default. Since there are platforms
> >>>>> which have non-compliant ECAM space we need to overwrite these
> >>>>> accessors prior to PCI buses enumeration. In order to do that
> >>>>> we call pci_mcfg_get_ops to retrieve pci_ecam_ops structure so that
> >>>>> we can use proper PCI config space accessors and bus_shift.
> >>>>>
> >>>>> pci_generic_ecam_ops is still used for platforms free from quirks.
> >>>>>
> >>>>> Signed-off-by: Tomasz Nowicki <tn@semihalf.com>
> >>>>> ---
> >>>>> arch/arm64/kernel/pci.c | 7 ++++---
> >>>>> 1 file changed, 4 insertions(+), 3 deletions(-)
> >>>>>
> >>>>> diff --git a/arch/arm64/kernel/pci.c b/arch/arm64/kernel/pci.c
> >>>>> index 94cd43c..a891bda 100644
> >>>>> --- a/arch/arm64/kernel/pci.c
> >>>>> +++ b/arch/arm64/kernel/pci.c
> >>>>> @@ -139,6 +139,7 @@ pci_acpi_setup_ecam_mapping(struct acpi_pci_root *root)
> >>>>> struct pci_config_window *cfg;
> >>>>> struct resource cfgres;
> >>>>> unsigned int bsz;
> >>>>> + struct pci_ecam_ops *ops;
> >>>>>
> >>>>> /* Use address from _CBA if present, otherwise lookup MCFG */
> >>>>> if (!root->mcfg_addr)
> >>>>> @@ -150,12 +151,12 @@ pci_acpi_setup_ecam_mapping(struct acpi_pci_root *root)
> >>>>> return NULL;
> >>>>> }
> >>>>>
> >>>>> - bsz = 1 << pci_generic_ecam_ops.bus_shift;
> >>>>> + ops = pci_mcfg_get_ops(root);
> >>>>> + bsz = 1 << ops->bus_shift;
> >>>>> cfgres.start = root->mcfg_addr + bus_res->start * bsz;
> >>>>> cfgres.end = cfgres.start + resource_size(bus_res) * bsz - 1;
> >>>>> cfgres.flags = IORESOURCE_MEM;
> >>>>> - cfg = pci_ecam_create(&root->device->dev, &cfgres, bus_res,
> >>>>> - &pci_generic_ecam_ops);
> >>>>> + cfg = pci_ecam_create(&root->device->dev, &cfgres, bus_res, ops);
> >>>>
> >>>> Arnd pointed this out already, I think that's the only pending question
> >>>> here.
> >>>>
> >>>> pci_ecam_create() maps ECAM space for config regions retrieved from
> >>>> the MCFG, which are *supposed* to be ECAM compliant.
> >>>>
> >>>> Do we think that's *always* correct/safe regardless of the kind
> >>>> of quirk we are currently fixing up ?
> >>>>
> >>>> Or we do think that configuration space regions should come from
> >>>> a different resource declared in the ACPI namespace if the regions
> >>>> are not MCFG/ECAM compliant (ie config space is not defined through
> >>>> MCFG at all - possibly through a _CRS method for a vendor specific
> >>>> _HID under the PNP0A03 node ?)
> >>>
> >>> Hi Lorenzo,
> >>>
> >>> For X-Gene: the ECAM space is used to access the configuration space
> >>> of PCIe devices, with additional help from controller register to
> >>> specify the bus, device and function number. Below is the RFC patch
> >>> that implements ECAM fixup for X-Gene PCIe controller on top of this
> >>> RFC ECAM quirk v3 for your and others reference.
> >>
> >> Yes, you have an additional resource in the PNP0A03 _CRS to describe
> >> your register that is a deliberate abuse of the ACPI standard in
> >> that the _CRS is meant to describe resources that are passed on
> >> to secondary buses
> >
> > A potential alternative came up in an off-list discussion: Would it be
> > better to hard code the information in the quirk workaround than look it
> > up from a repurposed ACPI resource?
>
> Hi Chris, Lorenzo,
>
> Thanks for looking into this.
>
> Yes, I am open for this approach and I think it may work. I can +
> check the pci_config_window resource start address (cfg->res.start) to
> figure out the controller and then get the fixed controller register
> address or + using the domain number to identify the controller.
First thing to do is to remove config space entry from PNP0A03
_CRS, that's a FW bug.
You could use the {bus-range, domain} to get that register address,
anyway, that's not the main concern here.
Thanks,
Lorenzo
> Regards,
> Duc Dang.
> >
> > Supporting quirk workarounds for early, non-compliant hardware is
> > helpful and perhaps necessary for bootstrapping the ecosystem in a
> > timely manner. But we don't really want to provide an expandable or
> > reusable interface that would make it easy for new hardware to remain
> > non-compliant.
> >
> > Regards,
> > Cov
> >
> > --
> > Qualcomm Innovation Center, Inc.
> > Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
> > a Linux Foundation Collaborative Project
>
next prev parent reply other threads:[~2016-06-21 9:26 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-17 21:37 [RFC PATCH v3 2/2] ARM64/PCI: Start using quirks handling for ACPI based PCI host controller Duc Dang
2016-06-20 9:42 ` Lorenzo Pieralisi
2016-06-20 9:42 ` Lorenzo Pieralisi
2016-06-20 17:17 ` Christopher Covington
2016-06-20 17:17 ` Christopher Covington
2016-06-20 19:12 ` Duc Dang
2016-06-20 19:12 ` Duc Dang
2016-06-21 8:42 ` Duc Dang
2016-06-21 8:42 ` Duc Dang
2016-06-21 9:26 ` Lorenzo Pieralisi [this message]
2016-06-21 9:26 ` Lorenzo Pieralisi
2016-06-21 9:29 ` Duc Dang
2016-06-21 9:29 ` Duc Dang
-- strict thread matches above, loose matches on Subject: below --
2016-06-15 15:34 [RFC PATCH v3 1/2] ACPI/PCI: Check platform specific ECAM quirks Christopher Covington
2016-06-15 15:34 ` [RFC PATCH v3 2/2] ARM64/PCI: Start using quirks handling for ACPI based PCI host controller Christopher Covington
2016-06-15 15:34 ` Christopher Covington
2016-06-16 17:48 ` Lorenzo Pieralisi
2016-06-16 17:48 ` Lorenzo Pieralisi
2016-06-17 8:01 ` Gabriele Paoloni
2016-06-17 8:01 ` Gabriele Paoloni
2016-06-17 14:13 ` Christopher Covington
2016-06-17 14:13 ` Christopher Covington
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160621092627.GA31277@red-moon \
--to=lorenzo.pieralisi@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.