On Wed, Oct 28, 2015 at 02:46:37PM -0400, Sinan Kaya wrote:
[...]
> >-int raw_pci_write(unsigned int domain, unsigned int bus,
> >- unsigned int devfn, int reg, int len, u32 val)
> >+struct pci_ops pci_root_ops = {
> >+ .map_bus = pci_mcfg_dev_base,
> >+ .read = pci_generic_config_read,
> >+ .write = pci_generic_config_write,
>
>
> Can you change these with pci_generic_config_read32 and
> pci_generic_config_write32? We have some targets that can only do 32
> bits PCI config space access.
No.
http://www.spinics.net/lists/linux-pci/msg44869.html
Can you be a bit more specific please ?
Sigh. Looks like we have to start adding platform specific quirks even
before we merged the generic ACPI PCIe host controller implementation.
Lorenzo
> >+};
> >+
> >+#ifdef CONFIG_PCI_MMCONFIG
> >+static int pci_add_mmconfig_region(struct acpi_pci_root_info *ci)
> > {
> >- return -ENXIO;
> >+ struct pci_mmcfg_region *cfg;
> >+ struct acpi_pci_root *root;
> >+ int seg, start, end, err;
> >+
> >+ root = ci->root;
> >+ seg = root->segment;
> >+ start = root->secondary.start;
> >+ end = root->secondary.end;
> >+
> >+ cfg = pci_mmconfig_lookup(seg, start);
> >+ if (cfg)
> >+ return 0;
> >+
> >+ cfg = pci_mmconfig_alloc(seg, start, end, root->mcfg_addr);
> >+ if (!cfg)
> >+ return -ENOMEM;
> >+
> >+ err = pci_mmconfig_inject(cfg);
> >+ return err;
> > }
> >
> >-#ifdef CONFIG_ACPI
> >+static void pci_remove_mmconfig_region(struct acpi_pci_root_info *ci)
> >+{
> >+ struct acpi_pci_root *root = ci->root;
> >+ struct pci_mmcfg_region *cfg;
> >+
> >+ cfg = pci_mmconfig_lookup(root->segment, root->secondary.start);
> >+ if (cfg)
> >+ return;
> >+
> >+ if (cfg->hot_added)
> >+ pci_mmconfig_delete(root->segment, root->secondary.start,
> >+ root->secondary.end);
> >+}
> >+#else
> >+static int pci_add_mmconfig_region(struct acpi_pci_root_info *ci)
> >+{
> >+ return 0;
> >+}
> >+
> >+static void pci_remove_mmconfig_region(struct acpi_pci_root_info *ci) { }
> >+#endif
> >+
> >+static int pci_acpi_root_init_info(struct acpi_pci_root_info *ci)
> >+{
> >+ return pci_add_mmconfig_region(ci);
> >+}
> >+
> >+static void pci_acpi_root_release_info(struct acpi_pci_root_info *ci)
> >+{
> >+ pci_remove_mmconfig_region(ci);
> >+ kfree(ci);
> >+}
> >+
> >+static int pci_acpi_root_prepare_resources(struct acpi_pci_root_info *ci)
> >+{
> >+ struct resource_entry *entry, *tmp;
> >+ int ret;
> >+
> >+ ret = acpi_pci_probe_root_resources(ci);
> >+ if (ret < 0)
> >+ return ret;
> >+
> >+ resource_list_for_each_entry_safe(entry, tmp, &ci->resources) {
> >+ struct resource *res = entry->res;
> >+
> >+ /*
> >+ * Special handling for ARM IO range
> >+ * TODO: need to move pci_register_io_range() function out
> >+ * of drivers/of/address.c for both used by DT and ACPI
> >+ */
> >+ if (res->flags & IORESOURCE_IO) {
> >+ unsigned long port;
> >+ int err;
> >+ resource_size_t length = res->end - res->start;
> >+
> >+ err = pci_register_io_range(res->start, length);
> >+ if (err) {
> >+ resource_list_destroy_entry(entry);
> >+ continue;
> >+ }
> >+
> >+ port = pci_address_to_pio(res->start);
> >+ if (port == (unsigned long)-1) {
> >+ resource_list_destroy_entry(entry);
> >+ continue;
> >+ }
> >+
> >+ res->start = port;
> >+ res->end = res->start + length - 1;
> >+
> >+ if (pci_remap_iospace(res, res->start) < 0)
> >+ resource_list_destroy_entry(entry);
> >+ }
> >+ }
> >+
> >+ return 0;
> >+}
> >+
> >+static struct acpi_pci_root_ops acpi_pci_root_ops = {
> >+ .pci_ops = &pci_root_ops,
> >+ .init_info = pci_acpi_root_init_info,
> >+ .release_info = pci_acpi_root_release_info,
> >+ .prepare_resources = pci_acpi_root_prepare_resources,
> >+};
> >+
> > /* Root bridge scanning */
> > struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
> > {
> >- /* TODO: Should be revisited when implementing PCI on ACPI */
> >- return NULL;
> >+ int node = acpi_get_node(root->device->handle);
> >+ int domain = root->segment;
> >+ int busnum = root->secondary.start;
> >+ struct acpi_pci_root_info *info;
> >+ struct pci_bus *bus;
> >+
> >+ if (domain && !pci_domains_supported) {
> >+ pr_warn("PCI %04x:%02x: multiple domains not supported.\n",
> >+ domain, busnum);
> >+ return NULL;
> >+ }
> >+
> >+ info = kzalloc_node(sizeof(*info), GFP_KERNEL, node);
> >+ if (!info) {
> >+ dev_err(&root->device->dev,
> >+ "pci_bus %04x:%02x: ignored (out of memory)\n",
> >+ domain, busnum);
> >+ return NULL;
> >+ }
> >+
> >+ bus = acpi_pci_root_create(root, &acpi_pci_root_ops, info, root);
> >+
> >+ /* After the PCI-E bus has been walked and all devices discovered,
> >+ * configure any settings of the fabric that might be necessary.
> >+ */
> >+ if (bus) {
> >+ struct pci_bus *child;
> >+
> >+ list_for_each_entry(child, &bus->children, node)
> >+ pcie_bus_configure_settings(child);
> >+ }
> >+
> >+ return bus;
> > }
> > #endif
> >
>
> --
> Sinan Kaya
> Qualcomm Technologies, Inc. on behalf of Qualcomm Innovation Center, Inc.
> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a
> Linux Foundation Collaborative Project
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
On 03.11.2015 15:15, Lorenzo Pieralisi wrote:
> On Wed, Oct 28, 2015 at 02:46:37PM -0400, Sinan Kaya wrote:
>
> [...]
>
>>> -int raw_pci_write(unsigned int domain, unsigned int bus,
>>> - unsigned int devfn, int reg, int len, u32 val)
>>> +struct pci_ops pci_root_ops = {
>>> + .map_bus = pci_mcfg_dev_base,
>>> + .read = pci_generic_config_read,
>>> + .write = pci_generic_config_write,
>>
>>
>> Can you change these with pci_generic_config_read32 and
>> pci_generic_config_write32? We have some targets that can only do 32
>> bits PCI config space access.
>
> No.
>
> http://www.spinics.net/lists/linux-pci/msg44869.html
>
> Can you be a bit more specific please ?
>
> Sigh. Looks like we have to start adding platform specific quirks even
> before we merged the generic ACPI PCIe host controller implementation.
>
The sad reality... But my next version will be still generic. Once that
one appear to be in good shape then we can add quirks.
Regards,
Tomasz
On 11/3/2015 9:39 AM, Tomasz Nowicki wrote:
>>>> +struct pci_ops pci_root_ops = {
>>>> + .map_bus = pci_mcfg_dev_base,
>>>> + .read = pci_generic_config_read,
>>>> + .write = pci_generic_config_write,
>>>
>>>
>>> Can you change these with pci_generic_config_read32 and
>>> pci_generic_config_write32? We have some targets that can only do 32
>>> bits PCI config space access.
>>
>> No.
>>
>> http://www.spinics.net/lists/linux-pci/msg44869.html
>>
>> Can you be a bit more specific please ?
>>
>> Sigh. Looks like we have to start adding platform specific quirks even
>> before we merged the generic ACPI PCIe host controller implementation.
>>
>
> The sad reality... But my next version will be still generic. Once that
> one appear to be in good shape then we can add quirks.
Thanks.
I don't see anywhere in the SBSA spec addendum that the PCI
configuration space section that unaligned accesses *MUST* be supported.
If this is required, please have this info added to the spec. I can work
with the designers for the next chip.
Unaligned access on the current hardware returns incomplete values or
can cause bus faults. The behavior is undefined.
--
Sinan Kaya
Qualcomm Technologies, Inc. on behalf of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a
Linux Foundation Collaborative Project
On 11/03/2015 10:15 PM, Lorenzo Pieralisi wrote:
> On Wed, Oct 28, 2015 at 02:46:37PM -0400, Sinan Kaya wrote:
>
> [...]
>
>>> -int raw_pci_write(unsigned int domain, unsigned int bus,
>>> - unsigned int devfn, int reg, int len, u32 val)
>>> +struct pci_ops pci_root_ops = {
>>> + .map_bus = pci_mcfg_dev_base,
>>> + .read = pci_generic_config_read,
>>> + .write = pci_generic_config_write,
>>
>>
>> Can you change these with pci_generic_config_read32 and
>> pci_generic_config_write32? We have some targets that can only do 32
>> bits PCI config space access.
>
> No.
>
> http://www.spinics.net/lists/linux-pci/msg44869.html
>
> Can you be a bit more specific please ?
>
> Sigh. Looks like we have to start adding platform specific quirks even
> before we merged the generic ACPI PCIe host controller implementation.
Cc Gab, Zhou, and Dondong who upstream the hip05 (designware) PCIe host
support.
I think so, some platform may not support ECAM for root complex,
which needs special handling of access config space, we may need
to consider those cases.
Thanks
Hanjun
On Tuesday 03 November 2015 10:10:21 Sinan Kaya wrote:
>
> I don't see anywhere in the SBSA spec addendum that the PCI
> configuration space section that unaligned accesses *MUST* be supported.
>
> If this is required, please have this info added to the spec. I can work
> with the designers for the next chip.
>
> Unaligned access on the current hardware returns incomplete values or
> can cause bus faults. The behavior is undefined.
Unaligned accesses are not allowed, but any PCI compliant device must
support aligned 1, 2 or 4 byte accesses on its configuration space,
though the byte-enable mechanism. In an ECAM host bridge, those are
mapped to load/store accesses from the CPU with the respective width
and natural alignment.
Arnd
On 11/3/2015 10:59 AM, Arnd Bergmann wrote:
> On Tuesday 03 November 2015 10:10:21 Sinan Kaya wrote:
>>
>> I don't see anywhere in the SBSA spec addendum that the PCI
>> configuration space section that unaligned accesses *MUST* be supported.
>>
>> If this is required, please have this info added to the spec. I can work
>> with the designers for the next chip.
>>
>> Unaligned access on the current hardware returns incomplete values or
>> can cause bus faults. The behavior is undefined.
>
> Unaligned accesses are not allowed, but any PCI compliant device must
> support aligned 1, 2 or 4 byte accesses on its configuration space,
> though the byte-enable mechanism. In an ECAM host bridge, those are
> mapped to load/store accesses from the CPU with the respective width
> and natural alignment.
>
> Arnd
>
As far as I see, the endpoints do not have any problems with unaligned
accesses. It is the host bridge itself (stuff that doesn't get on the
PCIe bus and uses traditional AXI kind bus internally) has problems with
alignment.
If Linux is expecting all HW vendors to implement alignment support,
this needs to be put in the SBSA spec as a hard requirement.
--
Sinan Kaya
Qualcomm Technologies, Inc. on behalf of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a
Linux Foundation Collaborative Project
On Tuesday 03 November 2015 11:33:18 Sinan Kaya wrote:
>
> On 11/3/2015 10:59 AM, Arnd Bergmann wrote:
> > On Tuesday 03 November 2015 10:10:21 Sinan Kaya wrote:
> >>
> >> I don't see anywhere in the SBSA spec addendum that the PCI
> >> configuration space section that unaligned accesses *MUST* be supported.
> >>
> >> If this is required, please have this info added to the spec. I can work
> >> with the designers for the next chip.
> >>
> >> Unaligned access on the current hardware returns incomplete values or
> >> can cause bus faults. The behavior is undefined.
> >
> > Unaligned accesses are not allowed, but any PCI compliant device must
> > support aligned 1, 2 or 4 byte accesses on its configuration space,
> > though the byte-enable mechanism. In an ECAM host bridge, those are
> > mapped to load/store accesses from the CPU with the respective width
> > and natural alignment.
>
> As far as I see, the endpoints do not have any problems with unaligned
> accesses. It is the host bridge itself (stuff that doesn't get on the
> PCIe bus and uses traditional AXI kind bus internally) has problems with
> alignment.
>
> If Linux is expecting all HW vendors to implement alignment support,
> this needs to be put in the SBSA spec as a hard requirement.
As I said, it's not unaligned accesses at all, just 1-byte and aligned
2-byte accesses, and it's not Linux mandating this but the PCI
spec. Please read Russell's email again, it is not possible for PCI
to work according to the specification unless the host bridge allows
sub-32-bit accesses.
You can probably work around this by using the legacy I/O port method
rather than ECAM, if the PCI host bridge itself is functional and just
the host bus it is connected to is buggy.
Arnd
On 11/03/2015 07:19 AM, Hanjun Guo wrote:
> On 11/03/2015 10:15 PM, Lorenzo Pieralisi wrote:
>> On Wed, Oct 28, 2015 at 02:46:37PM -0400, Sinan Kaya wrote:
>>
>> [...]
>>
>>>> -int raw_pci_write(unsigned int domain, unsigned int bus,
>>>> - unsigned int devfn, int reg, int len, u32 val)
>>>> +struct pci_ops pci_root_ops = {
>>>> + .map_bus = pci_mcfg_dev_base,
>>>> + .read = pci_generic_config_read,
>>>> + .write = pci_generic_config_write,
>>>
>>>
>>> Can you change these with pci_generic_config_read32 and
>>> pci_generic_config_write32? We have some targets that can only do 32
>>> bits PCI config space access.
>>
>> No.
>>
>> http://www.spinics.net/lists/linux-pci/msg44869.html
>>
>> Can you be a bit more specific please ?
>>
>> Sigh. Looks like we have to start adding platform specific quirks even
>> before we merged the generic ACPI PCIe host controller implementation.
>
> Cc Gab, Zhou, and Dondong who upstream the hip05 (designware) PCIe host
> support.
>
> I think so, some platform may not support ECAM for root complex,
> which needs special handling of access config space, we may need
> to consider those cases.
>
Yes, it is indeed true. For example, some Cavium ThunderX processors
fall into this category.
Some options I thought of are:
o Use DECLARE_ACPI_MCFG_FIXUP() in the kernel to supply the needed
config space accessors.
o Define additional root_device_ids that imply the needed config space
accessors.
> Thanks
> Hanjun
On 11/3/2015 11:55 AM, Arnd Bergmann wrote:
> On Tuesday 03 November 2015 11:33:18 Sinan Kaya wrote:
>>
>> On 11/3/2015 10:59 AM, Arnd Bergmann wrote:
>>> On Tuesday 03 November 2015 10:10:21 Sinan Kaya wrote:
>>>>
>>>> I don't see anywhere in the SBSA spec addendum that the PCI
>>>> configuration space section that unaligned accesses *MUST* be supported.
>>>>
>>>> If this is required, please have this info added to the spec. I can work
>>>> with the designers for the next chip.
>>>>
>>>> Unaligned access on the current hardware returns incomplete values or
>>>> can cause bus faults. The behavior is undefined.
>>>
>>> Unaligned accesses are not allowed, but any PCI compliant device must
>>> support aligned 1, 2 or 4 byte accesses on its configuration space,
>>> though the byte-enable mechanism. In an ECAM host bridge, those are
>>> mapped to load/store accesses from the CPU with the respective width
>>> and natural alignment.
>>
>> As far as I see, the endpoints do not have any problems with unaligned
>> accesses. It is the host bridge itself (stuff that doesn't get on the
>> PCIe bus and uses traditional AXI kind bus internally) has problems with
>> alignment.
>>
>> If Linux is expecting all HW vendors to implement alignment support,
>> this needs to be put in the SBSA spec as a hard requirement.
>
> As I said, it's not unaligned accesses at all, just 1-byte and aligned
> 2-byte accesses, and it's not Linux mandating this but the PCI
> spec. Please read Russell's email again, it is not possible for PCI
> to work according to the specification unless the host bridge allows
> sub-32-bit accesses.
I'll check back with the hardware designers. Seeing readb/readw/readl
made me nervous that we are trying unaligned access from any boundaries.
In any case, the hardware document says 32 bit configuration space
access to the host bridge only. I'll get more clarification.
>
> You can probably work around this by using the legacy I/O port method
> rather than ECAM, if the PCI host bridge itself is functional and just
> the host bus it is connected to is buggy.
From the sounds of it, we'll need a quirk for config space. We support
legacy I/O only to make the endpoints happy. Some endpoints do not get
initialized if they don't have a BAR address assigned to all the BAR
resources.
I just saw David Daney's email. I like his idea. I think this chip will
fit into the same category.
>
> Arnd
> --
> To unsubscribe from this list: send the line "unsubscribe linux-pci" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
--
Sinan Kaya
Qualcomm Technologies, Inc. on behalf of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a
Linux Foundation Collaborative Project
Hi David
> -----Original Message-----
> From: David Daney [mailto:[email protected]]
> Sent: 03 November 2015 17:39
> To: Hanjun Guo
> Cc: Lorenzo Pieralisi; Sinan Kaya; Tomasz Nowicki; [email protected];
> [email protected]; [email protected]; [email protected]; [email protected];
> [email protected]; [email protected];
> [email protected]; [email protected]; [email protected];
> Wangyijing; [email protected]; [email protected]; linux-
> [email protected]; [email protected]; linux-
> [email protected]; [email protected]; Gabriele Paoloni; Wangzhou
> (B); liudongdong (C)
> Subject: Re: [PATCH V1 11/11] arm64, pci, acpi: Support for ACPI based PCI
> hostbridge init
>
> On 11/03/2015 07:19 AM, Hanjun Guo wrote:
> > On 11/03/2015 10:15 PM, Lorenzo Pieralisi wrote:
> >> On Wed, Oct 28, 2015 at 02:46:37PM -0400, Sinan Kaya wrote:
> >>
> >> [...]
> >>
> >>>> -int raw_pci_write(unsigned int domain, unsigned int bus,
> >>>> - unsigned int devfn, int reg, int len, u32 val)
> >>>> +struct pci_ops pci_root_ops = {
> >>>> + .map_bus = pci_mcfg_dev_base,
> >>>> + .read = pci_generic_config_read,
> >>>> + .write = pci_generic_config_write,
> >>>
> >>>
> >>> Can you change these with pci_generic_config_read32 and
> >>> pci_generic_config_write32? We have some targets that can only do 32
> >>> bits PCI config space access.
> >>
> >> No.
> >>
> >> http://www.spinics.net/lists/linux-pci/msg44869.html
> >>
> >> Can you be a bit more specific please ?
> >>
> >> Sigh. Looks like we have to start adding platform specific quirks even
> >> before we merged the generic ACPI PCIe host controller implementation.
> >
> > Cc Gab, Zhou, and Dondong who upstream the hip05 (designware) PCIe host
> > support.
> >
> > I think so, some platform may not support ECAM for root complex,
> > which needs special handling of access config space, we may need
> > to consider those cases.
> >
>
> Yes, it is indeed true. For example, some Cavium ThunderX processors
> fall into this category.
>
> Some options I thought of are:
>
> o Use DECLARE_ACPI_MCFG_FIXUP() in the kernel to supply the needed
> config space accessors.
>
> o Define additional root_device_ids that imply the needed config space
> accessors.
Yes I like this
it would fit designware too
Gab
>
>
> > Thanks
> > Hanjun
On 11/3/2015 12:43 PM, Sinan Kaya wrote:
> In any case, the hardware document says 32 bit configuration space
> access to the host bridge only. I'll get more clarification.
>
I got confirmation this morning that this chip supports 32 bit access to
the root complex configuration space. 8/16/32 bits accesses to the
endpoints are supported.
>>
>> You can probably work around this by using the legacy I/O port method
>> rather than ECAM, if the PCI host bridge itself is functional and just
>> the host bus it is connected to is buggy.
>
> From the sounds of it, we'll need a quirk for config space. We support
> legacy I/O only to make the endpoints happy. Some endpoints do not get
> initialized if they don't have a BAR address assigned to all the BAR
> resources.
We'll need an MCFG fix up.
--
Sinan Kaya
Qualcomm Technologies, Inc. on behalf of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a
Linux Foundation Collaborative Project