Handling read/write of I/O port address spaces could be problematic for non-x86 architectures.
Deniz-Eren opened this issue · 0 comments
Read and write functions in src/kernel/include/linux/io.h utilize a static memory region check (of address 0-0xFFFF) to determine when to use I/O port functions in*() and out*(). For addresses beyond this region, functions utilize memory address operations with the appropriate memory barriers.
This however much not elegant, works fine for x86 platform, however for non-x86 platform it could be problematic. For example, if on some architectures the PCI device bar memory regions with address 0-0xFFFF come up as MEM (or memory mapped regions) instead of I/O port regions, then the read and write functions will still use the static 0xFFFF region threshold check to direct the operations to in*() and out*() functions. These functions correspond to x86 in* and out* assembler operations, which perhaps won't work on other architectures, depends on how QNX has implemented the in*() and out*() functions.
Nevertheless, a better implementation would be to track the PCI bar I/O and MEM address blocks and use a more specific I/O memory threshold in read and write functions. This will still give us a simple and fast check, more over still a correct check. When run on x86 platform, this more specific threshold can be more precise and on non-x86 platform the threshold would be 0 and thus all operations will be done as memory operations.
A further benefit of such an implementation would be the behaviour of the read and write functions will be determined by the src/pci.c functions that are responsible for managing the PCI interface for QNX implementation.