[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

libpciaccess: Changes to 'upstream-unstable'



 configure.ac             |   10 +
 include/pciaccess.h      |   58 ++++++++
 src/Makefile.am          |    9 +
 src/common_bridge.c      |    4 
 src/common_device_name.c |    2 
 src/common_interface.c   |   29 ++++
 src/common_vgaarb.c      |  324 +++++++++++++++++++++++++++++++++++++++++++++++
 src/common_vgaarb_stub.c |   79 +++++++++++
 src/linux_sysfs.c        |   57 ++++++++
 src/pciaccess_private.h  |    6 
 10 files changed, 575 insertions(+), 3 deletions(-)

New commits:
commit 312cde3c2f3530b031134cfb53a8a54731f02b1b
Author: Dave Airlie <airlied@redhat.com>
Date:   Mon Aug 31 09:14:16 2009 +1000

    pciaccess: bump to 0.10.8

diff --git a/configure.ac b/configure.ac
index 403c120..05d5b67 100644
--- a/configure.ac
+++ b/configure.ac
@@ -24,7 +24,7 @@ dnl Process this file with autoconf to create configure.
 
 AC_PREREQ([2.57])
 
-AC_INIT(libpciaccess, 0.10.7, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg&component=libpciaccess], libpciaccess)
+AC_INIT(libpciaccess, 0.10.8, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg&component=libpciaccess], libpciaccess)
 AM_INIT_AUTOMAKE([dist-bzip2])
 AM_MAINTAINER_MODE
 
diff --git a/src/Makefile.am b/src/Makefile.am
index c06959e..4dd7a5f 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -66,7 +66,7 @@ INCLUDES = -I$(top_srcdir)/include
 
 libpciaccess_la_LIBADD = @PCIACCESS_LIBS@
 
-libpciaccess_la_LDFLAGS = -version-number 0:10:7 -no-undefined
+libpciaccess_la_LDFLAGS = -version-number 0:10:8 -no-undefined
 
 libpciaccessincludedir = $(includedir)
 libpciaccessinclude_HEADERS = \

commit 566a67767e9fea463c24421d99dc12db590a7b5f
Author: Thomas Klausner <wiz@netbsd.org>
Date:   Mon Aug 31 09:13:27 2009 +1000

    pciaccess: fix vga arb stubs

diff --git a/src/common_vgaarb_stub.c b/src/common_vgaarb_stub.c
index 764733b..9394273 100644
--- a/src/common_vgaarb_stub.c
+++ b/src/common_vgaarb_stub.c
@@ -67,7 +67,7 @@ pci_device_vgaarb_trylock(void)
 }
 
 int
-pci_device_vgaarb_unlock(void);
+pci_device_vgaarb_unlock(void)
 {
     return 0;
 }

commit d062dd78baeb28ef2cc59f4fb4a7d82ecd5adf60
Author: Dave Airlie <airlied@redhat.com>
Date:   Fri Aug 28 11:29:00 2009 +1000

    libpciaccess: bump to 0.10.7 for vga arb interface addition

diff --git a/configure.ac b/configure.ac
index 34470eb..403c120 100644
--- a/configure.ac
+++ b/configure.ac
@@ -24,7 +24,7 @@ dnl Process this file with autoconf to create configure.
 
 AC_PREREQ([2.57])
 
-AC_INIT(libpciaccess, 0.10.6, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg&component=libpciaccess], libpciaccess)
+AC_INIT(libpciaccess, 0.10.7, [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg&component=libpciaccess], libpciaccess)
 AM_INIT_AUTOMAKE([dist-bzip2])
 AM_MAINTAINER_MODE
 
diff --git a/src/Makefile.am b/src/Makefile.am
index 0de6894..c06959e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -66,7 +66,7 @@ INCLUDES = -I$(top_srcdir)/include
 
 libpciaccess_la_LIBADD = @PCIACCESS_LIBS@
 
-libpciaccess_la_LDFLAGS = -version-number 0:10:2 -no-undefined
+libpciaccess_la_LDFLAGS = -version-number 0:10:7 -no-undefined
 
 libpciaccessincludedir = $(includedir)
 libpciaccessinclude_HEADERS = \

commit 2f997f90c8d0b54baab85285703550e8df28325e
Author: Dave Airlie <airlied@redhat.com>
Date:   Fri Aug 28 11:24:53 2009 +1000

    vgaarb: update stub interface

diff --git a/src/common_vgaarb_stub.c b/src/common_vgaarb_stub.c
index 5fc5dfe..764733b 100644
--- a/src/common_vgaarb_stub.c
+++ b/src/common_vgaarb_stub.c
@@ -28,46 +28,52 @@
 #include "pciaccess.h"
 
 int
-pci_device_vgaarb_init(struct pci_device *dev)
+pci_device_vgaarb_init(void)
 {
 #ifdef DEBUG
     fprintf(stderr, "%s: You're using VGA arbiter stub functions!\n",
                                                             __FUNCTION__);
 #endif
-    return 0;
+    return -1;
 }
 
 void
-pci_device_vgaarb_fini(struct pci_device *dev)
+pci_device_vgaarb_fini(void)
 {
 }
 
 int
 pci_device_vgaarb_set_target(struct pci_device *dev)
 {
-    return 0;
+    return -1;
 }
 
 int
-pci_device_vgaarb_decodes(struct pci_device *dev)
+pci_device_vgaarb_decodes(int new_vga_rsrc)
 {
-    return 0;
+    return -1;
 }
 
 int
-pci_device_vgaarb_lock(struct pci_device *dev)
+pci_device_vgaarb_lock(void)
 {
-    return 0;
+    return -1;
 }
 
 int
-pci_device_vgaarb_trylock(struct pci_device *dev)
+pci_device_vgaarb_trylock(void)
 {
-    return 0;
+    return -1;
 }
 
 int
-pci_device_vgaarb_unlock(struct pci_device *dev)
+pci_device_vgaarb_unlock(void);
 {
     return 0;
 }
+
+int pci_device_vgaarb_get_info(struct pci_device *dev, int *vga_count,
+			       int *rsrc_decodes)
+{
+    return -1;
+}

commit b229acdfd10fd61f46d8e711910b5c1bdb727857
Author: Dave Airlie <airlied@redhat.com>
Date:   Fri Aug 28 11:21:11 2009 +1000

    Revert "vgaarb: delete stub functions"
    
    This reverts commit b7fd4d06890d801aae93fe1a1af7ab110fd388fd.

diff --git a/src/Makefile.am b/src/Makefile.am
index c7be653..0de6894 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -47,6 +47,8 @@ endif
 
 if LINUX
 VGA_ARBITER = common_vgaarb.c
+else
+VGA_ARBITER = common_vgaarb_stub.c
 endif
 
 libpciaccess_la_SOURCES = common_bridge.c \
diff --git a/src/common_vgaarb_stub.c b/src/common_vgaarb_stub.c
new file mode 100644
index 0000000..5fc5dfe
--- /dev/null
+++ b/src/common_vgaarb_stub.c
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2009 Tiago Vignatti
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+
+#include <stdio.h>
+#include "pciaccess.h"
+
+int
+pci_device_vgaarb_init(struct pci_device *dev)
+{
+#ifdef DEBUG
+    fprintf(stderr, "%s: You're using VGA arbiter stub functions!\n",
+                                                            __FUNCTION__);
+#endif
+    return 0;
+}
+
+void
+pci_device_vgaarb_fini(struct pci_device *dev)
+{
+}
+
+int
+pci_device_vgaarb_set_target(struct pci_device *dev)
+{
+    return 0;
+}
+
+int
+pci_device_vgaarb_decodes(struct pci_device *dev)
+{
+    return 0;
+}
+
+int
+pci_device_vgaarb_lock(struct pci_device *dev)
+{
+    return 0;
+}
+
+int
+pci_device_vgaarb_trylock(struct pci_device *dev)
+{
+    return 0;
+}
+
+int
+pci_device_vgaarb_unlock(struct pci_device *dev)
+{
+    return 0;
+}

commit e70767cb2e574f8544a04903eea3afee33345eea
Author: Tiago Vignatti <tiago.vignatti@nokia.com>
Date:   Wed Aug 26 11:14:03 2009 +0300

    Revert "vgaarb: fix pci_device_vgaarb_get_info() return value."
    
    This reverts commit ef8aca5da46155e9ea0d1227215921ad9ce59150.

diff --git a/src/common_vgaarb.c b/src/common_vgaarb.c
index b7ef021..a40b064 100644
--- a/src/common_vgaarb.c
+++ b/src/common_vgaarb.c
@@ -317,7 +317,7 @@ int pci_device_vgaarb_get_info(struct pci_device *dev, int *vga_count, int *rsrc
 {
     *vga_count = pci_sys->vga_count;
     if (!dev)
-        return -1;
+        return 0;
 
     *rsrc_decodes = dev->vgaarb_rsrc;
         return 0;

commit ef8aca5da46155e9ea0d1227215921ad9ce59150
Author: Tiago Vignatti <tiago.vignatti@nokia.com>
Date:   Sun Aug 16 19:11:15 2009 +0300

    vgaarb: fix pci_device_vgaarb_get_info() return value.
    
    Signed-off-by: Tiago Vignatti <tiago.vignatti@nokia.com>

diff --git a/src/common_vgaarb.c b/src/common_vgaarb.c
index a40b064..b7ef021 100644
--- a/src/common_vgaarb.c
+++ b/src/common_vgaarb.c
@@ -317,7 +317,7 @@ int pci_device_vgaarb_get_info(struct pci_device *dev, int *vga_count, int *rsrc
 {
     *vga_count = pci_sys->vga_count;
     if (!dev)
-        return 0;
+        return -1;
 
     *rsrc_decodes = dev->vgaarb_rsrc;
         return 0;

commit 25be96885671d22ee3f932769d72cf3a31f355ee
Author: Tiago Vignatti <tiago.vignatti@nokia.com>
Date:   Sun Aug 16 19:09:35 2009 +0300

    vgaarb: fix indentation and remove trailing white spaces
    
    Signed-off-by: Tiago Vignatti <tiago.vignatti@nokia.com>

diff --git a/src/common_vgaarb.c b/src/common_vgaarb.c
index 89cc0ce..a40b064 100644
--- a/src/common_vgaarb.c
+++ b/src/common_vgaarb.c
@@ -47,21 +47,21 @@ parse_string_to_decodes_rsrc(char *input, int *vga_count, struct pci_slot_match
 
     tok = strtok_r(input,",",&input_sp);
     if (!tok)
-	goto fail;
+        goto fail;
 
     strncpy(tmp, input, 15);
     tmp[15] = 0;
 
     tok = strtok_r(tmp,":",&count_sp);
     if (!tok)
-	goto fail;
+        goto fail;
     tok = strtok_r(NULL, ":",&count_sp);
     if (!tok)
-	goto fail;
+        goto fail;
 
     *vga_count = strtoul(tok, NULL, 10);
     if (*vga_count == LONG_MAX)
-	goto fail;
+        goto fail;
 
 #ifdef DEBUG
     fprintf(stderr,"vga count is %d\n", *vga_count);
@@ -69,51 +69,51 @@ parse_string_to_decodes_rsrc(char *input, int *vga_count, struct pci_slot_match
 
     tok = strtok_r(NULL, ",",&input_sp);
     if (!tok)
-	goto fail;
+        goto fail;
 
     if (match) {
-	strncpy(tmp, tok, 32);
-	tmp[31] = 0;
-	tok = strtok_r(tmp, ":", &pci_sp);
-    	if (!tok)
- 	    goto fail;
-	tok = strtok_r(NULL, ":", &pci_sp);
-    	if (!tok)
- 	    goto fail;
-	match->domain = strtoul(tok, NULL, 16);
-
-	tok = strtok_r(NULL, ":", &pci_sp);
-    	if (!tok)
- 	    goto fail;
-	match->bus = strtoul(tok, NULL, 16);
-
-	tok = strtok_r(NULL, ".", &pci_sp);
-    	if (!tok)
- 	    goto fail;
-	match->dev = strtoul(tok, NULL, 16);
-
-	tok = strtok_r(NULL, ".", &pci_sp);
-    	if (!tok)
- 	    goto fail;
-	match->func = strtoul(tok, NULL, 16);
+        strncpy(tmp, tok, 32);
+        tmp[31] = 0;
+        tok = strtok_r(tmp, ":", &pci_sp);
+        if (!tok)
+            goto fail;
+        tok = strtok_r(NULL, ":", &pci_sp);
+        if (!tok)
+            goto fail;
+        match->domain = strtoul(tok, NULL, 16);
+
+        tok = strtok_r(NULL, ":", &pci_sp);
+        if (!tok)
+            goto fail;
+        match->bus = strtoul(tok, NULL, 16);
+
+        tok = strtok_r(NULL, ".", &pci_sp);
+        if (!tok)
+            goto fail;
+        match->dev = strtoul(tok, NULL, 16);
+
+        tok = strtok_r(NULL, ".", &pci_sp);
+        if (!tok)
+            goto fail;
+        match->func = strtoul(tok, NULL, 16);
     }
 
     tok = strtok_r(NULL, ",",&input_sp);
     if (!tok)
-	goto fail;
+        goto fail;
     tok = strtok_r(tok, "=", &input_sp);
     if (!tok)
-	goto fail;
+        goto fail;
     tok = strtok_r(NULL, "=", &input_sp);
     if (!tok)
-	goto fail;
+        goto fail;
 
     if (!strncmp(tok, "io+mem", 6))
-    	return VGA_ARB_RSRC_LEGACY_IO | VGA_ARB_RSRC_LEGACY_MEM;
+        return VGA_ARB_RSRC_LEGACY_IO | VGA_ARB_RSRC_LEGACY_MEM;
     if (!strncmp(tok, "io", 2))
-    	return VGA_ARB_RSRC_LEGACY_IO;
+        return VGA_ARB_RSRC_LEGACY_IO;
     if (!strncmp(tok, "mem", 3))
-    	return VGA_ARB_RSRC_LEGACY_MEM;
+        return VGA_ARB_RSRC_LEGACY_MEM;
 fail:
     return VGA_ARB_RSRC_NONE;
 }
@@ -130,14 +130,14 @@ pci_device_vgaarb_init(void)
 
     ret = read(pci_sys->vgaarb_fd, buf, BUFSIZE);
     if (ret <= 0)
-	return -1;
+        return -1;
 
     memset(&match, 0xff, sizeof(match));
     /* need to find the device to go back to and what it was decoding */
     rsrc = parse_string_to_decodes_rsrc(buf, &pci_sys->vga_count, &match);
-    
+
     pci_sys->vga_default_dev = pci_device_find_by_slot(match.domain, match.bus, match.dev, match.func);
-    
+
     if (pci_sys->vga_default_dev)
         pci_sys->vga_default_dev->vgaarb_rsrc = rsrc;
     return 0;
@@ -219,20 +219,20 @@ pci_device_vgaarb_set_target(struct pci_device *dev)
     int ret;
 
     if (!dev)
-	dev = pci_sys->vga_default_dev;
+        dev = pci_sys->vga_default_dev;
     if (!dev)
-	return -1;
+        return -1;
 
     len = snprintf(buf, BUFSIZE, "target PCI:%04x:%02x:%02x.%x",
                    dev->domain, dev->bus, dev->dev, dev->func);
 
     ret = vgaarb_write(pci_sys->vgaarb_fd, buf, len);
     if (ret)
-	return ret;
+        return ret;
 
     ret = read(pci_sys->vgaarb_fd, buf, BUFSIZE);
     if (ret <= 0)
-	return -1;
+        return -1;
 
     dev->vgaarb_rsrc = parse_string_to_decodes_rsrc(buf, &pci_sys->vga_count, NULL);
     pci_sys->vga_target = dev;
@@ -248,9 +248,9 @@ pci_device_vgaarb_decodes(int new_vgaarb_rsrc)
     struct pci_device *dev = pci_sys->vga_target;
 
     if (!dev)
-	return -1;
+        return -1;
     if (dev->vgaarb_rsrc == new_vgaarb_rsrc)
-	return 0;
+        return 0;
 
     len = snprintf(buf, BUFSIZE, "decodes %s", rsrc_to_str(dev->vgaarb_rsrc));
     ret = vgaarb_write(pci_sys->vgaarb_fd, buf, len);
@@ -285,7 +285,7 @@ pci_device_vgaarb_trylock(void)
     struct pci_device *dev = pci_sys->vga_target;
 
     if (!dev)
-	return -1;
+        return -1;
 
     if (dev->vgaarb_rsrc == 0 || pci_sys->vga_count == 1)
         return 0;
@@ -303,7 +303,7 @@ pci_device_vgaarb_unlock(void)
     struct pci_device *dev = pci_sys->vga_target;
 
     if (!dev)
-	return -1;
+        return -1;
 
     if (dev->vgaarb_rsrc == 0 || pci_sys->vga_count == 1)
         return 0;
@@ -317,7 +317,8 @@ int pci_device_vgaarb_get_info(struct pci_device *dev, int *vga_count, int *rsrc
 {
     *vga_count = pci_sys->vga_count;
     if (!dev)
-	return 0;
+        return 0;
+
     *rsrc_decodes = dev->vgaarb_rsrc;
-    return 0;
+        return 0;
 }

commit b7fd4d06890d801aae93fe1a1af7ab110fd388fd
Author: Tiago Vignatti <tiago.vignatti@nokia.com>
Date:   Sun Aug 16 18:59:21 2009 +0300

    vgaarb: delete stub functions
    
    Such stub functions is already with API outdated. Moreover, if some operating
    system doesn't have arbiter's implementation then the app can set some
    autoconf tricks like "ifdef HAVE_PCI_DEVICE_VGAARB_INIT".
    
    Signed-off-by: Tiago Vignatti <tiago.vignatti@nokia.com>

diff --git a/src/Makefile.am b/src/Makefile.am
index 0de6894..c7be653 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -47,8 +47,6 @@ endif
 
 if LINUX
 VGA_ARBITER = common_vgaarb.c
-else
-VGA_ARBITER = common_vgaarb_stub.c
 endif
 
 libpciaccess_la_SOURCES = common_bridge.c \
diff --git a/src/common_vgaarb_stub.c b/src/common_vgaarb_stub.c
deleted file mode 100644
index 5fc5dfe..0000000
--- a/src/common_vgaarb_stub.c
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (c) 2009 Tiago Vignatti
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use,
- * copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following
- * conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
- * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
- * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
- * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- * OTHER DEALINGS IN THE SOFTWARE.
- *
- */
-
-#include <stdio.h>
-#include "pciaccess.h"
-
-int
-pci_device_vgaarb_init(struct pci_device *dev)
-{
-#ifdef DEBUG
-    fprintf(stderr, "%s: You're using VGA arbiter stub functions!\n",
-                                                            __FUNCTION__);
-#endif
-    return 0;
-}
-
-void
-pci_device_vgaarb_fini(struct pci_device *dev)
-{
-}
-
-int
-pci_device_vgaarb_set_target(struct pci_device *dev)
-{
-    return 0;
-}
-
-int
-pci_device_vgaarb_decodes(struct pci_device *dev)
-{
-    return 0;
-}
-
-int
-pci_device_vgaarb_lock(struct pci_device *dev)
-{
-    return 0;
-}
-
-int
-pci_device_vgaarb_trylock(struct pci_device *dev)
-{
-    return 0;
-}
-
-int
-pci_device_vgaarb_unlock(struct pci_device *dev)
-{
-    return 0;
-}

commit 76363486864b325b8f156ece35736ddb64c4e697
Author: Julien Cristau <jcristau@debian.org>
Date:   Sun Aug 9 11:28:38 2009 +0200

    Silence compiler warning about pci_id_file_open definition
    
    src/common_device_name.c:59: warning: function declaration isn't a prototype
    src/common_device_name.c: In function 'pci_id_file_open':
    src/common_device_name.c:59: warning: old-style function definition

diff --git a/src/common_device_name.c b/src/common_device_name.c
index be601ed..896a8a3 100644
--- a/src/common_device_name.c
+++ b/src/common_device_name.c
@@ -55,7 +55,7 @@
 typedef gzFile pci_id_file;
 
 static pci_id_file
-pci_id_file_open()
+pci_id_file_open(void)
 {
     pci_id_file result;
 

commit 4eac0173588ab9ef67fcadb47b531abb114aa0a7
Author: Julien Cristau <jcristau@debian.org>
Date:   Sat Aug 8 18:12:08 2009 +0200

    configure.ac: fix help text for the linux-rom-fallback option
    
    LINUX_ROM defaults to no, fix the help text to reflect that
    
    Signed-off-by: Julien Cristau <jcristau@debian.org>

diff --git a/configure.ac b/configure.ac
index 528e32b..34470eb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -44,7 +44,7 @@ AC_ARG_WITH(pciids-path, AC_HELP_STRING([--with-pciids-path=PCIIDS_PATH],
 AC_DEFINE_DIR(PCIIDS_PATH, pciids_path, [Path to pci.ids])
 
 AC_ARG_ENABLE(linux-rom-fallback, AS_HELP_STRING([--enable-linux-rom-fallback],
-		[Enable support for falling back to /dev/mem for roms (default: enabled)]),
+		[Enable support for falling back to /dev/mem for roms (default: disabled)]),
 		[LINUX_ROM=$enableval],[LINUX_ROM=no])
 
 if test "x$LINUX_ROM" = xyes; then

commit dedd31b3bcdeea12955bf565b8e3f2a9d3c66057
Author: Dave Airlie <airlied@redhat.com>
Date:   Thu Aug 6 09:39:01 2009 +1000

    pciaccess: make linux rom reading fallback optional
    
    On kernels which have ROM files, the boot VGA rom file
    will contain the 0xc0000 file anyways. If another card
    is missing a rom file there is no need for this.
    
    This is fallback is disabled by default, on the premise
    that distro shipping this new a pciaccess will be running
    on kernels with working rom support which is been upstream
    for a long time

diff --git a/configure.ac b/configure.ac
index c55112c..528e32b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -43,6 +43,14 @@ AC_ARG_WITH(pciids-path, AC_HELP_STRING([--with-pciids-path=PCIIDS_PATH],
 	[Path to pci.ids file]), [pciids_path="$withval"])
 AC_DEFINE_DIR(PCIIDS_PATH, pciids_path, [Path to pci.ids])
 
+AC_ARG_ENABLE(linux-rom-fallback, AS_HELP_STRING([--enable-linux-rom-fallback],
+		[Enable support for falling back to /dev/mem for roms (default: enabled)]),
+		[LINUX_ROM=$enableval],[LINUX_ROM=no])
+
+if test "x$LINUX_ROM" = xyes; then
+	AC_DEFINE(LINUX_ROM, 1, [Linux ROM read fallback])
+fi
+
 use_zlib=no
 AC_ARG_WITH(zlib, AC_HELP_STRING([--with-zlib],
 	[Enable zlib support to read gzip compressed pci.ids]),
diff --git a/src/linux_sysfs.c b/src/linux_sysfs.c
index 1ae9e52..7fcd327 100644
--- a/src/linux_sysfs.c
+++ b/src/linux_sysfs.c
@@ -325,10 +325,15 @@ pci_device_linux_sysfs_read_rom( struct pci_device * dev, void * buffer )
     
     fd = open( name, O_RDWR );
     if ( fd == -1 ) {
+#ifdef LINUX_ROM
 	/* If reading the ROM using sysfs fails, fall back to the old
 	 * /dev/mem based interface.
+	 * disable this for newer kernels using configure
 	 */
 	return pci_device_linux_devmem_read_rom(dev, buffer);
+#else
+	return errno;
+#endif
     }
 
 

commit 8aa06cf7ef5e88c53bf6778336ba1a6036b16cc0
Author: Dave Airlie <airlied@redhat.com>
Date:   Thu Aug 6 09:39:01 2009 +1000

    pciaccess: make linux rom reading fallback optional
    
    On kernels which have ROM files, the boot VGA rom file
    will contain the 0xc0000 file anyways. If another card
    is missing a rom file there is no need for this.
    
    This is fallback is disabled by default, on the premise
    that distro shipping this new a pciaccess will be running
    on kernels with working rom support which is been upstream
    for a long time

diff --git a/configure.ac b/configure.ac
index c55112c..528e32b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -43,6 +43,14 @@ AC_ARG_WITH(pciids-path, AC_HELP_STRING([--with-pciids-path=PCIIDS_PATH],
 	[Path to pci.ids file]), [pciids_path="$withval"])
 AC_DEFINE_DIR(PCIIDS_PATH, pciids_path, [Path to pci.ids])
 
+AC_ARG_ENABLE(linux-rom-fallback, AS_HELP_STRING([--enable-linux-rom-fallback],
+		[Enable support for falling back to /dev/mem for roms (default: enabled)]),
+		[LINUX_ROM=$enableval],[LINUX_ROM=no])
+
+if test "x$LINUX_ROM" = xyes; then
+	AC_DEFINE(LINUX_ROM, 1, [Linux ROM read fallback])
+fi
+
 use_zlib=no
 AC_ARG_WITH(zlib, AC_HELP_STRING([--with-zlib],
 	[Enable zlib support to read gzip compressed pci.ids]),
diff --git a/src/linux_sysfs.c b/src/linux_sysfs.c
index 1ae9e52..7fcd327 100644
--- a/src/linux_sysfs.c
+++ b/src/linux_sysfs.c
@@ -325,10 +325,15 @@ pci_device_linux_sysfs_read_rom( struct pci_device * dev, void * buffer )
     
     fd = open( name, O_RDWR );
     if ( fd == -1 ) {
+#ifdef LINUX_ROM
 	/* If reading the ROM using sysfs fails, fall back to the old
 	 * /dev/mem based interface.
+	 * disable this for newer kernels using configure
 	 */
 	return pci_device_linux_devmem_read_rom(dev, buffer);
+#else
+	return errno;
+#endif
     }
 
 

commit 57cf6f1f428ab73fb2a88c39c694e7d14c2c96c6
Author: Dave Airlie <airlied@redhat.com>
Date:   Thu Aug 6 09:39:01 2009 +1000

    pciaccess: make linux rom reading fallback optional
    
    On kernels which have ROM files, the boot VGA rom file
    will contain the 0xc0000 file anyways. If another card
    is missing a rom file there is no need for this.
    
    This is fallback is disabled by default, on the premise
    that distro shipping this new a pciaccess will be running
    on kernels with working rom support which is been upstream
    for a long time

diff --git a/configure.ac b/configure.ac
index c55112c..528e32b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -43,6 +43,14 @@ AC_ARG_WITH(pciids-path, AC_HELP_STRING([--with-pciids-path=PCIIDS_PATH],
 	[Path to pci.ids file]), [pciids_path="$withval"])
 AC_DEFINE_DIR(PCIIDS_PATH, pciids_path, [Path to pci.ids])
 
+AC_ARG_ENABLE(linux-rom-fallback, AS_HELP_STRING([--enable-linux-rom-fallback],
+		[Enable support for falling back to /dev/mem for roms (default: enabled)]),
+		[LINUX_ROM=$enableval],[LINUX_ROM=no])
+
+if test "x$LINUX_ROM" = xyes; then
+	AC_DEFINE(LINUX_ROM, 1, [Linux ROM read fallback])
+fi
+
 use_zlib=no
 AC_ARG_WITH(zlib, AC_HELP_STRING([--with-zlib],
 	[Enable zlib support to read gzip compressed pci.ids]),
diff --git a/src/linux_sysfs.c b/src/linux_sysfs.c
index 65e1cf6..02fbd13 100644
--- a/src/linux_sysfs.c
+++ b/src/linux_sysfs.c
@@ -327,10 +327,15 @@ pci_device_linux_sysfs_read_rom( struct pci_device * dev, void * buffer )
     
     fd = open( name, O_RDWR );
     if ( fd == -1 ) {
+#ifdef LINUX_ROM
 	/* If reading the ROM using sysfs fails, fall back to the old
 	 * /dev/mem based interface.
+	 * disable this for newer kernels using configure
 	 */
 	return pci_device_linux_devmem_read_rom(dev, buffer);
+#else
+	return errno;
+#endif
     }
 
 

commit 7b7999a302c70f1ad9a5c8fc7517e24ab95c3a95
Author: Dave Airlie <airlied@redhat.com>
Date:   Mon Aug 3 12:43:26 2009 +1000

    vgaarb: add vga count + resource accessor

diff --git a/include/pciaccess.h b/include/pciaccess.h
index 71c831e..067954f 100644
--- a/include/pciaccess.h
+++ b/include/pciaccess.h
@@ -502,5 +502,7 @@ int  pci_device_vgaarb_decodes      (int new_vga_rsrc);
 int  pci_device_vgaarb_lock         (void);
 int  pci_device_vgaarb_trylock      (void);
 int  pci_device_vgaarb_unlock       (void);
+/* return the current device count + resource decodes for the device */
+int pci_device_vgaarb_get_info	    (struct pci_device *dev, int *vga_count, int *rsrc_decodes);
 
 #endif /* PCIACCESS_H */
diff --git a/src/common_vgaarb.c b/src/common_vgaarb.c
index 1978ce3..89cc0ce 100644
--- a/src/common_vgaarb.c
+++ b/src/common_vgaarb.c
@@ -312,3 +312,12 @@ pci_device_vgaarb_unlock(void)
 
     return vgaarb_write(pci_sys->vgaarb_fd, buf, len);
 }
+
+int pci_device_vgaarb_get_info(struct pci_device *dev, int *vga_count, int *rsrc_decodes)
+{
+    *vga_count = pci_sys->vga_count;
+    if (!dev)
+	return 0;
+    *rsrc_decodes = dev->vgaarb_rsrc;
+    return 0;
+}

commit 3a6c1be79c05517cfddbce88157bb352237058ab
Author: Dave Airlie <airlied@redhat.com>
Date:   Mon Aug 3 09:39:22 2009 +1000

    vgaarb: more api changes + cleanup
    
    add a comma for ease of parsing,
    use hex on the interface in both directions instead of hex on one
    and decimal on the other

diff --git a/src/common_vgaarb.c b/src/common_vgaarb.c
index 5d46d70..1978ce3 100644
--- a/src/common_vgaarb.c
+++ b/src/common_vgaarb.c
@@ -42,15 +42,20 @@ static int
 parse_string_to_decodes_rsrc(char *input, int *vga_count, struct pci_slot_match *match)
 {
     char *tok;
-    char count[16];
+    char *input_sp, *count_sp, *pci_sp;
+    char tmp[32];
 
-    strncpy(count, input, 10);
-    count[11] = 0;
+    tok = strtok_r(input,",",&input_sp);
+    if (!tok)
+	goto fail;
+
+    strncpy(tmp, input, 15);
+    tmp[15] = 0;
 
-    tok = strtok(count,":");
+    tok = strtok_r(tmp,":",&count_sp);
     if (!tok)
 	goto fail;
-    tok = strtok(NULL, "");
+    tok = strtok_r(NULL, ":",&count_sp);
     if (!tok)
 	goto fail;
 
@@ -62,39 +67,44 @@ parse_string_to_decodes_rsrc(char *input, int *vga_count, struct pci_slot_match
     fprintf(stderr,"vga count is %d\n", *vga_count);
 #endif
 
-    tok = strtok(input, ",");
+    tok = strtok_r(NULL, ",",&input_sp);
     if (!tok)
 	goto fail;
 
     if (match) {
-	tok = strtok(NULL, ":");
+	strncpy(tmp, tok, 32);
+	tmp[31] = 0;
+	tok = strtok_r(tmp, ":", &pci_sp);
+    	if (!tok)
+ 	    goto fail;
+	tok = strtok_r(NULL, ":", &pci_sp);
     	if (!tok)
  	    goto fail;
 	match->domain = strtoul(tok, NULL, 16);
 
-	tok = strtok(NULL, ":");
+	tok = strtok_r(NULL, ":", &pci_sp);
     	if (!tok)
  	    goto fail;
 	match->bus = strtoul(tok, NULL, 16);
 
-	tok = strtok(NULL, ".");
+	tok = strtok_r(NULL, ".", &pci_sp);
     	if (!tok)
  	    goto fail;
 	match->dev = strtoul(tok, NULL, 16);
 
-	tok = strtok(NULL, ".");
+	tok = strtok_r(NULL, ".", &pci_sp);
     	if (!tok)
  	    goto fail;
 	match->func = strtoul(tok, NULL, 16);
     }
 
-    tok = strtok(NULL, ",");
+    tok = strtok_r(NULL, ",",&input_sp);
     if (!tok)
 	goto fail;
-    tok = strtok(tok, "=");
+    tok = strtok_r(tok, "=", &input_sp);
     if (!tok)
 	goto fail;
-    tok = strtok(NULL, "=");
+    tok = strtok_r(NULL, "=", &input_sp);
     if (!tok)
 	goto fail;
 
@@ -213,7 +223,7 @@ pci_device_vgaarb_set_target(struct pci_device *dev)
     if (!dev)
 	return -1;
 
-    len = snprintf(buf, BUFSIZE, "target PCI:%d:%d:%d.%d",
+    len = snprintf(buf, BUFSIZE, "target PCI:%04x:%02x:%02x.%x",
                    dev->domain, dev->bus, dev->dev, dev->func);
 
     ret = vgaarb_write(pci_sys->vgaarb_fd, buf, len);

commit e5127339c6c48ae6f63f9dc841a94fe960d11496
Author: Dave Airlie <airlied@redhat.com>
Date:   Fri Jul 31 16:15:55 2009 +1000

    vgaarb: change API to target taking a device + lock/unlock not taking one
    
    working on the target device - a target device of NULL
    reselects the target that existed when we started.
    
    this is mainly to allow a udev posting tool to return to the
    state of what happened before it ran.

diff --git a/include/pciaccess.h b/include/pciaccess.h
index 9d68a08..71c831e 100644
--- a/include/pciaccess.h
+++ b/include/pciaccess.h
@@ -497,9 +497,10 @@ struct pci_pcmcia_bridge_info {
 int  pci_device_vgaarb_init         (void);


Reply to: