]> git.karo-electronics.de Git - karo-tx-linux.git/commit
PCI: Rework config space blocking services
authorJan Kiszka <jan.kiszka@siemens.com>
Fri, 4 Nov 2011 08:45:59 +0000 (09:45 +0100)
committerJesse Barnes <jbarnes@virtuousgeek.org>
Tue, 13 Dec 2011 18:41:53 +0000 (10:41 -0800)
commit6b98003ac32c3ea0d4ba5def7737353a058708cb
treede114a48bb2d03e2c1b64d935cab1bee130c5f9b
parent10ac6800925db9f4dedffd04a65948276d8c3590
PCI: Rework config space blocking services

pci_block_user_cfg_access was designed for the use case that a single
context, the IPR driver, temporarily delays user space accesses to the
config space via sysfs. This assumption became invalid by the time
pci_dev_reset was added as locking instance. Today, if you run two loops
in parallel that reset the same device via sysfs, you end up with a
kernel BUG as pci_block_user_cfg_access detect the broken assumption.

This reworks the pci_block_user_cfg_access to a sleeping service
pci_cfg_access_lock and an atomic-compatible variant called
pci_cfg_access_trylock. The former not only blocks user space access as
before but also waits if access was already locked. The latter service
just returns false in this case, allowing the caller to resolve the
conflict instead of raising a BUG.

Adaptions of the ipr driver were originally written by Brian King.

Acked-by: Brian King <brking@linux.vnet.ibm.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
drivers/pci/access.c
drivers/pci/iov.c
drivers/pci/pci.c
drivers/scsi/ipr.c
drivers/scsi/ipr.h
drivers/uio/uio_pci_generic.c
include/linux/pci.h