pci: fix config space access on FreeBSD
authorRahul Lakkireddy <rahul.lakkireddy@chelsio.com>
Fri, 6 May 2016 07:43:15 +0000 (13:13 +0530)
committerBruce Richardson <bruce.richardson@intel.com>
Wed, 15 Jun 2016 15:13:55 +0000 (17:13 +0200)
PCIOCREAD and PCIOCWRITE ioctls to read/write PCI config space fail
with EPERM due to missing write permission.  Fix by opening /dev/pci/
with O_RDWR instead.

Fixes: 632b2d1deeed ("eal: provide functions to access PCI config")

Signed-off-by: Rahul Lakkireddy <rahul.lakkireddy@chelsio.com>
Signed-off-by: Kumar Sanghvi <kumaras@chelsio.com>
lib/librte_eal/bsdapp/eal/eal_pci.c

index 7fdd6f1..374b68f 100644 (file)
@@ -427,7 +427,7 @@ int rte_eal_pci_read_config(const struct rte_pci_device *dev,
                goto error;
        }
 
-       fd = open("/dev/pci", O_RDONLY);
+       fd = open("/dev/pci", O_RDWR);
        if (fd < 0) {
                RTE_LOG(ERR, EAL, "%s(): error opening /dev/pci\n", __func__);
                goto error;
@@ -471,7 +471,7 @@ int rte_eal_pci_write_config(const struct rte_pci_device *dev,
 
        memcpy(&pi.pi_data, buf, len);
 
-       fd = open("/dev/pci", O_RDONLY);
+       fd = open("/dev/pci", O_RDWR);
        if (fd < 0) {
                RTE_LOG(ERR, EAL, "%s(): error opening /dev/pci\n", __func__);
                goto error;