Skip to contentSkip to conversation

PCI IO and IO_COND

DISCUSSION Andrew Murray 1 participant 1 message Apr 4, 2013 PCI

lore
Share & tools
lore
#0 lore raw

Hello,

I have a question regarding the IO_COND macro in lib/iomap.c...

If you have a system which uses GENERIC_IOMAP and you use default values for PIO_OFFSET, PIO_MASK and PIO_RESERVED - it doesn't seem possible to use the ioreadX functions to access the first address of the IO port, i.e. addr=PIO_OFFSET (assuming that you would want to).

/*
* Ugly macros are a way of life.
*/

#define IO_COND(addr, is_pio, is_mmio) do {			\
	unsigned long port = (unsigned long __force)addr;	\
	if (port >= PIO_RESERVED) {				\
		is_mmio;					\
	} else if (port > PIO_OFFSET) {				\
		port &= PIO_MASK;				\
		is_pio;						\
	} else							\
		bad_io_access(port, #is_pio );			\
} while (0)

Should the first else be '} else if (port >= PIO_OFFSET)' or am I missing something here?

I can see that on ARM where IO is used for PCI, the pcibios_min_io variable probably prevents accesses to addr=PIO_OFFSET as it introduces an additional offset.

Thanks,

Andrew Murray