Hi, [taking Mark Kettenis into CC to hear his side of the PCI access granularity debate]
On 29.06.2010 13:14, Martin Mares wrote: >> Fix pciutils non-32bit PCI write on OpenBSD. >> OpenBSD supports only 32bit accesses to PCI config space. Emulate >> smaller writes with a read/modify/write cycle. >> > > Unfortunately, this is wrong ... PCI config space writes can have > arbitrary side-effects (even reads can, sigh), even if you write the > same value. Replacing 8-/16-bit writes by 32-bit read-modify-write > cycles simply does not work. > > If the OS does not support narrow writes, the best libpci can do is to > refuse the operation and let the application, which probably knows better > how the particular piece of hardware behaves, handle it somehow. > nbsd_write() in latest pciutils/lib/nbsd-libpci.c git performs the same read-modify-write operation for NetBSD (which apparently seems to share that limitation), whereas FreeBSD can perform 8/16/32-bit reads just fine according to their documentation. > IOW, either OpenBSD should be fixed, or the work-around should be placed > in flashrom, which knows the device in question. > Pasting from another thread: On 25.06.2010 18:58, Matthieu Herrb wrote: > On Fri, Jun 25, 2010 at 06:24:56PM +0200, Carl-Daniel Hailfinger wrote: > >> On 25.06.2010 17:07, Matthieu Herrb wrote: >> >>> Our /dev/pci only supports 32 bit wide read/write, aligned on 4 bytes >>> boundaries. >>> >>> If you need to write to PCI config space, you'll need a separate >>> kernel interface, with a high-level interface, so that you don't allow >>> random changes in the PCI config space from userland. >>> >>> >> Wouldn't allowing 16 bit and 8 bit reads/writes at native alignments in >> /dev/pci work for that? I could modify flashrom to use read/modify/write >> cycles to emulate 8/16 bit reads/writes with 32 bit reads/writes, but >> that may have undesirable side effects on some chipsets. >> > > As far as I know this is an urban legend. Ask kettenis@ for details. > So far we resisted to do that. libpciaccess handles it for > OpenBSD (/usr/xenocara/lib/libpciaccess/src/openbsd_pci.c). > FreeBSD added 8/16-bit read/write support to /lib/pci in 1997: r26159 | se | 1997-05-26 17:08:43 +0200 (Mo, 26 May 1997) Completely replace the PCI bus driver code to make it better reflect reality. [...] Regards, Carl-Daniel -- http://www.hailfinger.org/