[PATCH 00/10] Designware PCIe host fixes

Bernhard Beschow posted 10 patches 2 months, 3 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20250820211932.27302-1-shentey@gmail.com
Maintainers: Bernhard Beschow <shentey@gmail.com>, Peter Maydell <peter.maydell@linaro.org>, Andrey Smirnov <andrew.smirnov@gmail.com>
include/hw/pci-host/designware.h |   5 +-
hw/arm/fsl-imx8mp.c              |   1 +
hw/pci-host/designware.c         | 284 ++++++++++++++++---------------
3 files changed, 151 insertions(+), 139 deletions(-)
[PATCH 00/10] Designware PCIe host fixes
Posted by Bernhard Beschow 2 months, 3 weeks ago
This series fixes the Designware PCIe host to work with cards other than
virio-net-pci, e.g. e1000. It was tested on the imx8mp-evk machine.

The series is structured as follows: The first part refactors the device
model to create memory regions for inbound/outbound PCI mappings on demand
rather than upfront since this approach doesn't scale for adding I/O space
support. The second part consists of fixing the memory mapping by adding I/O
space support and fixing default inbound viewport mapping. The third part
concludes the series by implementing device reset and cleaning up the imx8mp SoC
implementation.

Testing done:
* Boot imx8mp-evk machine with Buildroot while having an e1000 card attached.
Observe that it gets an IP address via DHCP and allows for downloading an HTML
file via HTTP.

Bernhard Beschow (10):
  hw/pci-host/designware: Eliminate some helper variables
  hw/pci-host/designware: Create viewport memory regions on demand
  hw/pci-host/designware: Determine PCIDevice of configuration region
    once
  hw/pci-host/designware: Distinguish stronger between viewport memory
    types
  hw/pci-host/designware: Implement I/O space
  hw/pci-host/designware: Fix I/O range
  hw/pci-host/designware: Don't map PCI memory space into PCI inbound
    window
  hw/pci-host/designware: Fix default inbound viewport mapping
  hw/pci-host/designware: Implement device reset
  hw/arm/fsl-imx8mp: Do not map PCI window as unimplemented

 include/hw/pci-host/designware.h |   5 +-
 hw/arm/fsl-imx8mp.c              |   1 +
 hw/pci-host/designware.c         | 284 ++++++++++++++++---------------
 3 files changed, 151 insertions(+), 139 deletions(-)

-- 
2.50.1
Re: [PATCH 00/10] Designware PCIe host fixes
Posted by Guenter Roeck 2 months, 3 weeks ago
On 8/20/25 14:19, Bernhard Beschow wrote:
> This series fixes the Designware PCIe host to work with cards other than
> virio-net-pci, e.g. e1000. It was tested on the imx8mp-evk machine.
> 
> The series is structured as follows: The first part refactors the device
> model to create memory regions for inbound/outbound PCI mappings on demand
> rather than upfront since this approach doesn't scale for adding I/O space
> support. The second part consists of fixing the memory mapping by adding I/O
> space support and fixing default inbound viewport mapping. The third part
> concludes the series by implementing device reset and cleaning up the imx8mp SoC
> implementation.
> 
> Testing done:
> * Boot imx8mp-evk machine with Buildroot while having an e1000 card attached.
> Observe that it gets an IP address via DHCP and allows for downloading an HTML
> file via HTTP.
> 
Crashing for me even if no PCIe card is attached. This is with the series applied
on top of 10.1.0-rc4 or 10.0.3. I have not tried to track down the problem.

Guenter

---
Build reference: v6.17-rc1-287-g685de850cabf
Compiler version: aarch64-linux-gcc (GCC) 13.4.0
Qemu version: 10.0.94 (v10.1.0-rc4-55-g320ed12bd9)

[    7.748393] Internal error: synchronous external abort: 0000000096000010 [#1]  SMP
[    7.748917] Modules linked in:
[    7.749533] CPU: 3 UID: 0 PID: 12 Comm: kworker/u16:0 Tainted: G   M             N  6.17.0-rc2-g685de850cabf #1 PREEMPT
[    7.749689] Tainted: [M]=MACHINE_CHECK, [N]=TEST
[    7.749745] Hardware name: NXP i.MX8MPlus EVK board (DT)
[    7.750118]         ok 1 block_bits=10 cluster_bits=3 blocks_per_group=8192 group_count=4 desc_size=64
[    7.749922] Workqueue: async async_run_entry_fn
[    7.751174] pstate: 200000c5 (nzCv daIF -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[    7.751267] pc : pci_generic_config_read+0x38/0xb8
[    7.751370] lr : pci_generic_config_read+0x24/0xb8
[    7.751474] sp : ffff8000845fb730
[    7.751532] x29: ffff8000845fb730 x28: 00000000000000ff x27: 0000000000000000
[    7.751686] x26: 0000000000000001 x25: ffff80008290c008 x24: ffff8000832cbe80
[    7.751770] x23: 0000000000000000 x22: ffff8000845fb844 x21: ffff000008a73800
[    7.751859] x20: ffff8000845fb7a4 x19: 0000000000000004 x18: 00000000ffffffff
[    7.751942] x17: ffff800080e2f918 x16: ffff800080e2f7ac x15: ffff800080e2e6d8
[    7.752027] x14: 0000000000000000 x13: 0000000000000000 x12: ffff80008427cab8
[    7.752120] x11: 0000000000000326 x10: 0000000000000326 x9 : 00000000000c0326
[    7.752225] x8 : 000000006973b6c5 x7 : ffff800085c00000 x6 : 0000000000000000
[    7.752320] x5 : ffff000007cc5080 x4 : 0000000000000000 x3 : 0000000000000000
[    7.752403] x2 : 0000000000000000 x1 : ffff000004bf5680 x0 : ffff800085900000
[    7.752577] Call trace:
[    7.752694]  pci_generic_config_read+0x38/0xb8 (P)
[    7.752794]  dw_pcie_rd_other_conf+0x38/0xb0
[    7.752851]  pci_bus_read_config_dword+0x80/0xe4
[    7.752903]  pci_bus_generic_read_dev_vendor_id+0x30/0x190
[    7.752964]  pci_scan_device+0xdc/0x184
[    7.753010]  pci_scan_slot+0xe0/0x23c
[    7.753056]  pci_scan_child_bus_extend+0x44/0x2cc
[    7.753110]  pci_scan_bridge_extend+0x514/0x598
[    7.753166]  pci_scan_child_bus_extend+0x104/0x2cc
[    7.753220]  pci_scan_root_bus_bridge+0x64/0xd8
[    7.753273]  pci_host_probe+0x34/0x10c
[    7.753328]  dw_pcie_host_init+0x2f0/0x4b0
[    7.753376]  imx_pcie_probe+0x33c/0x70c
[    7.753439]  platform_probe+0x5c/0x9c
[    7.753485]  really_probe+0xc0/0x390
[    7.753530]  __driver_probe_device+0x7c/0x15c
[    7.753581]  driver_probe_device+0x3c/0x110
[    7.753633]  __device_attach_driver+0xbc/0x158
Re: [PATCH 00/10] Designware PCIe host fixes
Posted by Bernhard Beschow 2 months, 3 weeks ago

Am 21. August 2025 03:36:44 UTC schrieb Guenter Roeck <linux@roeck-us.net>:
>On 8/20/25 14:19, Bernhard Beschow wrote:
>> This series fixes the Designware PCIe host to work with cards other than
>> virio-net-pci, e.g. e1000. It was tested on the imx8mp-evk machine.
>> 
>> The series is structured as follows: The first part refactors the device
>> model to create memory regions for inbound/outbound PCI mappings on demand
>> rather than upfront since this approach doesn't scale for adding I/O space
>> support. The second part consists of fixing the memory mapping by adding I/O
>> space support and fixing default inbound viewport mapping. The third part
>> concludes the series by implementing device reset and cleaning up the imx8mp SoC
>> implementation.
>> 
>> Testing done:
>> * Boot imx8mp-evk machine with Buildroot while having an e1000 card attached.
>> Observe that it gets an IP address via DHCP and allows for downloading an HTML
>> file via HTTP.
>> 
>Crashing for me even if no PCIe card is attached. This is with the series applied
>on top of 10.1.0-rc4 or 10.0.3. I have not tried to track down the problem.
>
>Guenter

Hi Guenther,

Thanks for testing this series! I can reproduce the issue with Buildroot while the functional test passes...

I guess that I was too optimistic in having resolved the issue mentioned in the last patch. Does it work for you if you omit it?

Thanks,
Bernhard

>
>---
>Build reference: v6.17-rc1-287-g685de850cabf
>Compiler version: aarch64-linux-gcc (GCC) 13.4.0
>Qemu version: 10.0.94 (v10.1.0-rc4-55-g320ed12bd9)
>
>[    7.748393] Internal error: synchronous external abort: 0000000096000010 [#1]  SMP
>[    7.748917] Modules linked in:
>[    7.749533] CPU: 3 UID: 0 PID: 12 Comm: kworker/u16:0 Tainted: G   M             N  6.17.0-rc2-g685de850cabf #1 PREEMPT
>[    7.749689] Tainted: [M]=MACHINE_CHECK, [N]=TEST
>[    7.749745] Hardware name: NXP i.MX8MPlus EVK board (DT)
>[    7.750118]         ok 1 block_bits=10 cluster_bits=3 blocks_per_group=8192 group_count=4 desc_size=64
>[    7.749922] Workqueue: async async_run_entry_fn
>[    7.751174] pstate: 200000c5 (nzCv daIF -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
>[    7.751267] pc : pci_generic_config_read+0x38/0xb8
>[    7.751370] lr : pci_generic_config_read+0x24/0xb8
>[    7.751474] sp : ffff8000845fb730
>[    7.751532] x29: ffff8000845fb730 x28: 00000000000000ff x27: 0000000000000000
>[    7.751686] x26: 0000000000000001 x25: ffff80008290c008 x24: ffff8000832cbe80
>[    7.751770] x23: 0000000000000000 x22: ffff8000845fb844 x21: ffff000008a73800
>[    7.751859] x20: ffff8000845fb7a4 x19: 0000000000000004 x18: 00000000ffffffff
>[    7.751942] x17: ffff800080e2f918 x16: ffff800080e2f7ac x15: ffff800080e2e6d8
>[    7.752027] x14: 0000000000000000 x13: 0000000000000000 x12: ffff80008427cab8
>[    7.752120] x11: 0000000000000326 x10: 0000000000000326 x9 : 00000000000c0326
>[    7.752225] x8 : 000000006973b6c5 x7 : ffff800085c00000 x6 : 0000000000000000
>[    7.752320] x5 : ffff000007cc5080 x4 : 0000000000000000 x3 : 0000000000000000
>[    7.752403] x2 : 0000000000000000 x1 : ffff000004bf5680 x0 : ffff800085900000
>[    7.752577] Call trace:
>[    7.752694]  pci_generic_config_read+0x38/0xb8 (P)
>[    7.752794]  dw_pcie_rd_other_conf+0x38/0xb0
>[    7.752851]  pci_bus_read_config_dword+0x80/0xe4
>[    7.752903]  pci_bus_generic_read_dev_vendor_id+0x30/0x190
>[    7.752964]  pci_scan_device+0xdc/0x184
>[    7.753010]  pci_scan_slot+0xe0/0x23c
>[    7.753056]  pci_scan_child_bus_extend+0x44/0x2cc
>[    7.753110]  pci_scan_bridge_extend+0x514/0x598
>[    7.753166]  pci_scan_child_bus_extend+0x104/0x2cc
>[    7.753220]  pci_scan_root_bus_bridge+0x64/0xd8
>[    7.753273]  pci_host_probe+0x34/0x10c
>[    7.753328]  dw_pcie_host_init+0x2f0/0x4b0
>[    7.753376]  imx_pcie_probe+0x33c/0x70c
>[    7.753439]  platform_probe+0x5c/0x9c
>[    7.753485]  really_probe+0xc0/0x390
>[    7.753530]  __driver_probe_device+0x7c/0x15c
>[    7.753581]  driver_probe_device+0x3c/0x110
>[    7.753633]  __device_attach_driver+0xbc/0x158
>
Re: [PATCH 00/10] Designware PCIe host fixes
Posted by Guenter Roeck 2 months, 3 weeks ago
On Thu, Aug 21, 2025 at 10:24:02AM +0000, Bernhard Beschow wrote:
> 
> 
> Am 21. August 2025 03:36:44 UTC schrieb Guenter Roeck <linux@roeck-us.net>:
> >On 8/20/25 14:19, Bernhard Beschow wrote:
> >> This series fixes the Designware PCIe host to work with cards other than
> >> virio-net-pci, e.g. e1000. It was tested on the imx8mp-evk machine.
> >> 
> >> The series is structured as follows: The first part refactors the device
> >> model to create memory regions for inbound/outbound PCI mappings on demand
> >> rather than upfront since this approach doesn't scale for adding I/O space
> >> support. The second part consists of fixing the memory mapping by adding I/O
> >> space support and fixing default inbound viewport mapping. The third part
> >> concludes the series by implementing device reset and cleaning up the imx8mp SoC
> >> implementation.
> >> 
> >> Testing done:
> >> * Boot imx8mp-evk machine with Buildroot while having an e1000 card attached.
> >> Observe that it gets an IP address via DHCP and allows for downloading an HTML
> >> file via HTTP.
> >> 
> >Crashing for me even if no PCIe card is attached. This is with the series applied
> >on top of 10.1.0-rc4 or 10.0.3. I have not tried to track down the problem.
> >
> >Guenter
> 
> Hi Guenther,
> 
> Thanks for testing this series! I can reproduce the issue with Buildroot while the functional test passes...
> 
> I guess that I was too optimistic in having resolved the issue mentioned in the last patch. Does it work for you if you omit it?
> 

It gives me hung task crashes when trying to boot from virtio-pci.
I'll need some time for debugging.

Guenter
Re: [PATCH 00/10] Designware PCIe host fixes
Posted by Guenter Roeck 2 months, 3 weeks ago
On Thu, Aug 21, 2025 at 10:24:02AM +0000, Bernhard Beschow wrote:
> 
> 
> Am 21. August 2025 03:36:44 UTC schrieb Guenter Roeck <linux@roeck-us.net>:
> >On 8/20/25 14:19, Bernhard Beschow wrote:
> >> This series fixes the Designware PCIe host to work with cards other than
> >> virio-net-pci, e.g. e1000. It was tested on the imx8mp-evk machine.
> >> 
> >> The series is structured as follows: The first part refactors the device
> >> model to create memory regions for inbound/outbound PCI mappings on demand
> >> rather than upfront since this approach doesn't scale for adding I/O space
> >> support. The second part consists of fixing the memory mapping by adding I/O
> >> space support and fixing default inbound viewport mapping. The third part
> >> concludes the series by implementing device reset and cleaning up the imx8mp SoC
> >> implementation.
> >> 
> >> Testing done:
> >> * Boot imx8mp-evk machine with Buildroot while having an e1000 card attached.
> >> Observe that it gets an IP address via DHCP and allows for downloading an HTML
> >> file via HTTP.
> >> 
> >Crashing for me even if no PCIe card is attached. This is with the series applied
> >on top of 10.1.0-rc4 or 10.0.3. I have not tried to track down the problem.
> >
> >Guenter
> 
> Hi Guenther,
> 
> Thanks for testing this series! I can reproduce the issue with Buildroot while the functional test passes...
> 
> I guess that I was too optimistic in having resolved the issue mentioned in the last patch. Does it work for you if you omit it?
> 
I'll give it another try tonight.

Guenter

> Thanks,
> Bernhard
> 
> >
> >---
> >Build reference: v6.17-rc1-287-g685de850cabf
> >Compiler version: aarch64-linux-gcc (GCC) 13.4.0
> >Qemu version: 10.0.94 (v10.1.0-rc4-55-g320ed12bd9)
> >
> >[    7.748393] Internal error: synchronous external abort: 0000000096000010 [#1]  SMP
> >[    7.748917] Modules linked in:
> >[    7.749533] CPU: 3 UID: 0 PID: 12 Comm: kworker/u16:0 Tainted: G   M             N  6.17.0-rc2-g685de850cabf #1 PREEMPT
> >[    7.749689] Tainted: [M]=MACHINE_CHECK, [N]=TEST
> >[    7.749745] Hardware name: NXP i.MX8MPlus EVK board (DT)
> >[    7.750118]         ok 1 block_bits=10 cluster_bits=3 blocks_per_group=8192 group_count=4 desc_size=64
> >[    7.749922] Workqueue: async async_run_entry_fn
> >[    7.751174] pstate: 200000c5 (nzCv daIF -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
> >[    7.751267] pc : pci_generic_config_read+0x38/0xb8
> >[    7.751370] lr : pci_generic_config_read+0x24/0xb8
> >[    7.751474] sp : ffff8000845fb730
> >[    7.751532] x29: ffff8000845fb730 x28: 00000000000000ff x27: 0000000000000000
> >[    7.751686] x26: 0000000000000001 x25: ffff80008290c008 x24: ffff8000832cbe80
> >[    7.751770] x23: 0000000000000000 x22: ffff8000845fb844 x21: ffff000008a73800
> >[    7.751859] x20: ffff8000845fb7a4 x19: 0000000000000004 x18: 00000000ffffffff
> >[    7.751942] x17: ffff800080e2f918 x16: ffff800080e2f7ac x15: ffff800080e2e6d8
> >[    7.752027] x14: 0000000000000000 x13: 0000000000000000 x12: ffff80008427cab8
> >[    7.752120] x11: 0000000000000326 x10: 0000000000000326 x9 : 00000000000c0326
> >[    7.752225] x8 : 000000006973b6c5 x7 : ffff800085c00000 x6 : 0000000000000000
> >[    7.752320] x5 : ffff000007cc5080 x4 : 0000000000000000 x3 : 0000000000000000
> >[    7.752403] x2 : 0000000000000000 x1 : ffff000004bf5680 x0 : ffff800085900000
> >[    7.752577] Call trace:
> >[    7.752694]  pci_generic_config_read+0x38/0xb8 (P)
> >[    7.752794]  dw_pcie_rd_other_conf+0x38/0xb0
> >[    7.752851]  pci_bus_read_config_dword+0x80/0xe4
> >[    7.752903]  pci_bus_generic_read_dev_vendor_id+0x30/0x190
> >[    7.752964]  pci_scan_device+0xdc/0x184
> >[    7.753010]  pci_scan_slot+0xe0/0x23c
> >[    7.753056]  pci_scan_child_bus_extend+0x44/0x2cc
> >[    7.753110]  pci_scan_bridge_extend+0x514/0x598
> >[    7.753166]  pci_scan_child_bus_extend+0x104/0x2cc
> >[    7.753220]  pci_scan_root_bus_bridge+0x64/0xd8
> >[    7.753273]  pci_host_probe+0x34/0x10c
> >[    7.753328]  dw_pcie_host_init+0x2f0/0x4b0
> >[    7.753376]  imx_pcie_probe+0x33c/0x70c
> >[    7.753439]  platform_probe+0x5c/0x9c
> >[    7.753485]  really_probe+0xc0/0x390
> >[    7.753530]  __driver_probe_device+0x7c/0x15c
> >[    7.753581]  driver_probe_device+0x3c/0x110
> >[    7.753633]  __device_attach_driver+0xbc/0x158
> >