-
Notifications
You must be signed in to change notification settings - Fork 7.4k
soc: arm: xilinx_zynq7000: add MMU PTEs for all AXI GPIO instances #46463
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
soc: arm: xilinx_zynq7000: add MMU PTEs for all AXI GPIO instances #46463
Conversation
#define AXI_GPIO_MMU_ENTRY(id)\ | ||
MMU_REGION_FLAT_ENTRY("axigpio",\ | ||
DT_REG_ADDR(id),\ | ||
DT_REG_SIZE(id),\ | ||
MT_DEVICE | MATTR_SHARED | MPERM_R | MPERM_W), | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The driver should be refactored to use DEVICE_MMIO_ROM_INIT()
instead.
See #46477 for further discussions related to this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, as @henrikbrixandersen said this should be really fixed at driver level by adding support for the MMIO APIs. The discussion in #46477 is really for ARM64 but the point is the same here.
One point already mentioned in the discussion in #46477 is that the driver for which the [0..n] MMU entries are being added here is for a peripheral which exists both in the Zynq-7000, where the memory has to be mapped via the MMU, and in the UltraScale, which has the MPU. At the time being, all of the UltraScale's peripherals and the On-Chip Memory are covered by a single 128 MB R/W/nocache MPU region if the MPU is active, so there's nothing to do with regards to the UltraScale. If the driver was to be modified to use MMIO rather than having the MMU set up based on code outside of the driver, that would be SoC family-specific. This issue basically affects all supported Xilinx peripherals: the AXI GPIO, the PS GPIO, the UART, the GEM, the CAN controller for which a driver has been submitted for review, and some others still in my pipeline (I2C, SPI, etc.). |
Why? The MMIO API is MMU mapping the addresses only when an MMU is present, see zephyr/include/zephyr/sys/device_mmio.h Lines 36 to 38 in 1578dc6
In case of MPU, the API is simply falling back to access the usual address without mapping anything: zephyr/include/zephyr/sys/device_mmio.h Lines 261 to 269 in 1578dc6
Yeah this sucks. I'm trying to push for all the new drivers to support MMIO API as soon as they are introduced but I cannot push people to fix all the existing drivers, especially when there are a lot of them. So, I can approve this as workaround for an existing driver but if you are going to introduce new drivers these must support the MMIO API out-of-the-box. |
I don't mind converting all the existing Xilinx drivers, that's something that shouldn't take too long, most of them should be fairly simple to switch over, and if memory areas like the SLCR and the MPCore registers can still be mapped via the mmu_regions table in future releases and DMA can still be set up as it currently is being set up in the GEM driver in future releases, there shouldn't be any major conflicts. What I was trying to point out was that if the memory mapping API wasn't compatible with non-MMU systems, some sort of SoC-specific adaptation would have been required for all the Xilinx drivers as the Zynq and the UltraScale support all those peripherals equally. As the physical address is returned by the API in the non-MMU scenario, that assumed issue doesn't exist. So I guess I'll get to it. |
@henrikbrixandersen @carlocaione I've had a go at refactoring the Xilinx AXI GPIO and PS GPIO drivers to use the MMIO API instead, but at the time being, it's just not possible to let GPIO drivers use the MMIO API due to conflicting demands - I opened #48243 to address the issue, as I don't think that having a hand full of particular device drivers or one class of device drivers use a workaround all the other drivers don't need is a good idea. Therefore, could we for now go ahead as suggested herein for now, until a clean solution is found? I'd really like to add support for the Zedboard, where unfortunately, most of the useful GPIOs (slider switches, buttons, LEDs) can only be connected to instances of the AXI GPIO IP core. |
7e9df1a
to
d8d44bc
Compare
@ibirnbaum I'm fine to put aside the MMIO story but please fix the CI to be all green so I can take again another look. |
@carlocaione I'll force-push in order to run the CI again. During the last run, the completely unrelated test case net.socket.tcp failed on the unrelated target mps2_an385. Looks to me like a glitch of the CI itself? |
…ances add the MMU page table entries for all instances of the Xilinx AXI GPIO controller IP core. Other than any Zynq-7000 peripheral supported so far, the existance of 1..n instances of the IP core within the FPGA part of the SoC is optional. Therefore, other than addressing instances of supported peripherals using their DT node label as has always been the case so far, the data for the MMU page table is added using the DT_FOREACH_STATUS_OKAY macro. Signed-off-by: Immo Birnbaum <[email protected]>
d8d44bc
to
595b5b7
Compare
@carlocaione CI passed this time as intended. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am okay with this work-around for now, but we really need to get this working for all kinds of peripherals (in-tree as well as out-of-tree).
If we re-organise the devicetree to closer match that of the Linux kernel (where all memory-mapped peripherals of the Zynq7000 are below an amba
node) we should be able to iterate all these child devices and add corresponding MMU regions.
Add the MMU page table entries for all instances of the Xilinx AXI GPIO controller IP core. Other than any Zynq-7000 peripheral supported so far, the existance of 1..n instances of the IP core within the FPGA part of the SoC is optional. Therefore, other than addressing instances of supported peripherals using their DT nodelabel as has always been the case so far, the data for the MMU page table is added using the DT_FOREACH_STATUS_OKAY macro.
Signed-off-by: Immo Birnbaum [email protected]