#
✕ nick:arnd
#asahi · 2021-02-10 10:58
arndkettenis: from the man page for bus_space(9), I think this would correspond to Linux's regmap, which lets you abstract all kinds of buses that have some form of indexed registers (mmio, pio, i2c, spi, ...)
#asahi · 2021-02-10 10:27
arndright, it might be good to warn if a 64-bit boundary is crossed, but I don't think it's worth trying to handle that correctly
#asahi · 2021-02-10 10:21
arndlimiting the intermediate addresses to 64 bit was an intentional simplification at the time, as nothing relied on it, but that probably means it's not a great idea to start relying on it now
#asahi · 2021-02-10 10:19
arndah, it does __of_address_to_resource(), which has different paths for IORESOURCE_MEM and IORESOURCE_IO, and assumes it can translate memory addresses without caring about the upper bits, and treating I/O ports special
#asahi · 2021-02-10 10:18
arndit seems those use of_pci_address_to_resource(), which reads the resources in the PCI bus node and assumes it does not need to translate those further
#asahi · 2021-02-10 10:15
arndI'd have to check what powerpc and sparc do for their of-based PCI probe, but I think they still use the PCI BARs for reading the addresses rather than the DT information
#asahi · 2021-02-10 10:12
arndright
#asahi · 2021-02-10 10:10
arndyes, from reading it a little more, I would conclude that it works as intended: ->translate() gets called with the 64-bit address portion of the child address and a copy of the parent's base address from the ranges, and it is documented to assume that it is in fact translatable
#asahi · 2021-02-10 10:00
arndyes, it could be separate, I'm just not sure yet what changes are actually needed. I think what we need is for ->translate() to take both 'na' and 'pna' arguments like ->map() does, but I'd have to reread it several times more and look at the git history to see how we got to what it is now
#asahi · 2021-02-10 09:55
arndthat is possible: as I said, we don't actually rely on the translation across PCI host bridges but rather set up the PCI-to-host windows when creating the pci_host_bridge devices in other code
#asahi · 2021-02-10 09:50
arndregarding IORESOURCE_IO, I don't think that is supported at all in the M1, at least the ADT doesn't seem to list it
#asahi · 2021-02-10 09:49
arndor do you mean we couldn't use of_bus_default_translate() for the new bus?
#asahi · 2021-02-10 09:48
arndI don't see what you mean. The memset() in of_bus_default_translate() only clears the low 64 bits of the address, as it gets called with a modified addr and na value
#asahi · 2021-02-10 09:43
arnd<0x43000000 0x5 0x0 MAP_NONPOSTED 0x5 0x0 0x0 0x80000000>
#asahi · 2021-02-10 09:43
arnd<0x43000000 0x5 0x0 (MAP_NONPOSTED | 0x5) 0x0 0x0 0x80000000>
#asahi · 2021-02-10 09:42
arndso an mmio range looks like
#asahi · 2021-02-10 09:41
arndthe pci ranges doing 3->3 conversion should just work fine, all this means is that you can specify in the parent address whether a particular downstream range corresponds to an upstream posted or non-posted area
#asahi · 2021-02-10 09:32
arndsorry, I misread what you said
#asahi · 2021-02-10 09:32
arndYes, I think that would work for this generation, but there is a small chance that a future SoC would require doing something similar to my suggestion, and then we implement two methods
#asahi · 2021-02-10 09:27
arndmost of this originally came from PCMCIA and ISAPnP I think
#asahi · 2021-02-10 09:26
arndit's also possible that some of the ioresource flags are entirely unused
#asahi · 2021-02-10 09:26
arndright, it might be better to have IORESOURCE_MEM with an extra flag
#asahi · 2021-02-10 09:25
arndthe types don't have to be distinct bits (see IORESOURCE_REG)
#asahi · 2021-02-10 09:24
arndif it's a custom type, it could be 0x00000500
#asahi · 2021-02-10 09:23
arndyes, I noticed
#asahi · 2021-02-10 09:23
arndyes, you can specify your own DT properties for things that PCI cannot detect, and you can add a probe-only property (don't remember the spelling) in the host bridge to tell the kernel it should not reassign the resources
#asahi · 2021-02-10 09:20
arndtraditionally, open firmware had assigned the resources to devices and listed them as "ranges" and "reg" properties in the device nodes of the pci child nodes, but we don't do that in fdt because Linux is capable of scanning the pci bus itself
#asahi · 2021-02-10 09:19
arndmarcan: on PCI, the flags get parsed by the PCI host driver when setting up the pci_host_bridge resources, which get used for assigning resources to child devices
#asahi · 2021-02-10 09:16
arndusing the ranges property at least makes it possible to have more complex mappings in the future
#asahi · 2021-02-10 09:15
arndso adding a fourth case (aside from pci, isa and default) in there is slightly ugly, but it's the best I could come up with so far
#asahi · 2021-02-10 09:14
arndthe address gets truncated to the size of resource_size_t
#asahi · 2021-02-10 09:14
arndright, we do limit phys_addr_t/resource_size_t to 64 bits, but 'struct resource' does encode the PCI addresses including the flags
#asahi · 2021-02-10 09:11
arndwith the /soc node adding a third cell to encode flags like pci and isa
#asahi · 2021-02-10 09:10
arndthe root bus could be #address-cells=<3>, but I was thinking <2> here
#asahi · 2021-02-10 09:08
arndyes, unless you have another bus underneath that turns them back into #address=cells=<1> or #address-cells=<2>
#asahi · 2021-02-10 09:06
arndmarcan: you can totally have #address-cells=<3> in a regular bus, I don't think that causes issues with the kernel, though it might not work as intended in other consumers of the dt
#asahi · 2021-02-10 08:59
arndhttps://lore.kernel.org/linux-arm-kernel/CAK8P3a2Ad+xmmMWgznOHPpxgCXKWFYfpHBqt_49_UuxrwFSq+A@mail.gmail.com/
#asahi · 2021-02-10 08:59
arndI was thinking similar to how pci and isa nodes work, which use ranges properties to create multiple address ranges, with a flag in the top word (or top bits of the 64-bit address) distinguishing between types of registers
#asahi · 2021-02-10 08:57
arndmarcan: the way I suggested would be only for the children
#asahi · 2021-02-09 10:27
arndand of course, on a PC, you only really have on platform to worry about
#asahi · 2021-02-09 10:26
arndwhich is arguably worse than what we had before DT
#asahi · 2021-02-09 10:26
arndthe way it works on PCs is that you end up device drivers that have a table looking up the machine name to find what the settings should be
#asahi · 2021-02-09 10:25
arndbkero: you can't support arbitrary board with ACPI because there are no driver bindings
#asahi · 2021-02-09 10:25
arndnever_released: you can totally ship a dtb in firmware and we will make sure it stays as stable as ACPI. We do suffer from incompatible changes in DT, but I would definitely reject a patch that breaks a shipping system that used to work
#asahi · 2021-02-09 10:21
arndDEC Shark with StrongARM110 shipped with Open Firmware in the 1990s, but is equally irrelevant as Windows RT
#asahi · 2021-02-09 10:20
arndpowerpc had been converted to dt-only a few years earlier, and when Linaro formed we assumed we could easily do the same thing on Arm. It turned out that going from three SoC vendors to 70 SoC vendors and from a simple networking SoC to a Cortex-A9 class mobile phone SoC made it somehwat harder
#asahi · 2021-02-09 10:18
arndmid-2011, after a few years of debate
#asahi · 2021-02-09 10:17
arndmarcan: we started using dt in linux-3.0
#asahi · 2021-02-09 10:17
arndmarcan: if apple were to change the base isa from arm to riscv, my guess would be that it wouldn't perform all that differently. better in some areas (mainly code density), worse in some areas, and not competitive for anything that doesn't have a ratified extension yet
#asahi · 2021-02-09 10:14
arndfro the most part, I'd say risc-v is just lacking the software ecosystem that arm has, but that is a matter of time

plus ›