[PATCH 3/3] xfree86: vgaarb: make arbiter optional at build time
Dave Airlie
airlied at redhat.com
Thu Sep 10 16:17:28 PDT 2009
On Thu, 2009-09-10 at 17:52 +0300, Tiago Vignatti wrote:
> This patch implements the option of a server without support for vga
> arbitration, cutting off totally such code. It introduces --{enable,
> disable}-vgaarb to autoconf (enabled by default).
>
> Note that the server now requires libpciaccess >= 0.10.8.
>
> Signed-off-by: Tiago Vignatti <tiago.vignatti at nokia.com>
> ---
>
> Another way to cook this option would be to let dummy functions and avoid
> VGAARB macro all over the code. It's cleaner but the code remains with some
> (minor) VGA arbiter symbols. Any comments regarding this?
>
Yeah keep the symbols, and have dummy functions, its a lot cleaner
than all those ifdefs which is very ugly.
how much text size is the arbiter anyways? I hate adding all these
--enable/--disable flags unless someone has a tinderbox set up
to build with all the various flags as often as possible, (*hint*).
Dave.
> configure.ac | 10 ++++++++--
> hw/xfree86/common/Makefile.am | 15 ++++++++++-----
> hw/xfree86/common/xf86Bus.c | 5 ++++-
> hw/xfree86/common/xf86DPMS.c | 7 ++++++-
> hw/xfree86/common/xf86Init.c | 16 ++++++++++++++--
> hw/xfree86/common/xf86VGAarbiter.c | 15 ---------------
> hw/xfree86/common/xf86VGAarbiter.h | 10 +++++-----
> hw/xfree86/common/xf86str.h | 6 ++++++
> hw/xfree86/dri/dri.c | 6 +++++-
> hw/xfree86/dri2/dri2.c | 4 ++++
> hw/xfree86/loader/sdksyms.sh | 2 ++
> include/xorg-config.h.in | 6 +++---
> 12 files changed, 67 insertions(+), 35 deletions(-)
>
> diff --git a/configure.ac b/configure.ac
> index 6345fd9..28e5a59 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -591,6 +591,7 @@ AC_ARG_ENABLE(xaa, AS_HELP_STRING([--enable-xaa], [Build XAA (defa
> AC_ARG_ENABLE(vgahw, AS_HELP_STRING([--enable-vgahw], [Build Xorg with vga access (default: enabled)]), [VGAHW=$enableval], [VGAHW=yes])
> AC_ARG_ENABLE(vbe, AS_HELP_STRING([--enable-vbe], [Build Xorg with VBE module (default: enabled)]), [VBE=$enableval], [VBE=yes])
> AC_ARG_ENABLE(int10-module, AS_HELP_STRING([--enable-int10-module], [Build Xorg with int10 module (default: enabled)]), [INT10MODULE=$enableval], [INT10MODULE=yes])
> +AC_ARG_ENABLE(vgaarb, AS_HELP_STRING([--enable-vgaarb], [Build Xorg with VGA arbitration support (default: enabled)]), [VGAARBITER=$enableval], [VGAARBITER=yes])
>
> dnl DDXes.
> AC_ARG_ENABLE(xorg, AS_HELP_STRING([--enable-xorg], [Build Xorg server (default: auto)]), [XORG=$enableval], [XORG=auto])
> @@ -1381,7 +1382,7 @@ if test "x$XORG" = xyes; then
> AC_SUBST([symbol_visibility])
> dnl ===================================================================
>
> - PKG_CHECK_MODULES([PCIACCESS], [pciaccess >= 0.8.0])
> + PKG_CHECK_MODULES([PCIACCESS], [pciaccess >= 0.10.8])
> SAVE_LIBS=$LIBS
> SAVE_CFLAGS=$CFLAGS
> CFLAGS=$PCIACCESS_CFLAGS
> @@ -1389,7 +1390,11 @@ if test "x$XORG" = xyes; then
> AC_CHECK_FUNCS([pci_system_init_dev_mem])
> AC_CHECK_FUNCS([pci_device_enable])
> AC_CHECK_FUNCS([pci_device_is_boot_vga])
> - AC_CHECK_FUNCS([pci_device_vgaarb_init])
> +
> + if test "x$VGAARBITER" == xyes; then
> + AC_DEFINE(VGAARB, 1, [Want VGA arbitration.])
> + fi
> +
> LIBS=$SAVE_LIBS
> CFLAGS=$SAVE_CFLAGS
> XORG_SYS_LIBS="$XORG_SYS_LIBS $PCIACCESS_LIBS $DLOPEN_LIBS $GLX_SYS_LIBS $SELINUX_LIB"
> @@ -1609,6 +1614,7 @@ AM_CONDITIONAL([SOLARIS_ASM_INLINE], [test "x$solaris_asm_inline" = xyes])
> AM_CONDITIONAL([SOLARIS_VT], [test "x$solaris_vt" = xyes])
> AM_CONDITIONAL([DGA], [test "x$DGA" = xyes])
> AM_CONDITIONAL([XF86VIDMODE], [test "x$XF86VIDMODE" = xyes])
> +AM_CONDITIONAL([VGAARBITER], [test "x$VGAARBITER" = xyes])
>
> dnl XWin DDX
>
> diff --git a/hw/xfree86/common/Makefile.am b/hw/xfree86/common/Makefile.am
> index ad27210..ae37b10 100644
> --- a/hw/xfree86/common/Makefile.am
> +++ b/hw/xfree86/common/Makefile.am
> @@ -17,6 +17,12 @@ if DGA
> DGASOURCES = xf86DGA.c
> endif
>
> +if VGAARBITER
> +VGAARBSOURCES = xf86VGAarbiter.c
> +VGAARB_SDK = xf86VGAarbiter.h
> +VGAARB_EXTRADIST = xf86VGAarbiter.h xf86VGAarbiterPriv.h
> +endif
> +
> XISOURCES = xf86Xinput.c xisb.c
> XISDKINCS = xf86Xinput.h xisb.h
> RANDRSOURCES = xf86RandR.c
> @@ -35,7 +41,7 @@ AM_LDFLAGS = -r
> libcommon_la_SOURCES = xf86Configure.c xf86ShowOpts.c xf86Bus.c xf86Config.c \
> xf86Cursor.c $(DGASOURCES) xf86DPMS.c \
> xf86Events.c xf86Globals.c xf86AutoConfig.c \
> - xf86Option.c xf86Init.c xf86VGAarbiter.c \
> + xf86Option.c xf86Init.c $(VGAARBSOURCES) \
> xf86VidMode.c xf86fbman.c xf86cmap.c \
> xf86Helper.c xf86PM.c xf86Xinput.c xisb.c \
> xf86Mode.c xorgHelper.c \
> @@ -52,7 +58,7 @@ sdk_HEADERS = compiler.h fourcc.h xf86.h xf86Module.h xf86Opt.h \
> xf86PciInfo.h xf86Priv.h xf86Privstr.h \
> xf86cmap.h xf86fbman.h xf86str.h xf86Xinput.h xisb.h \
> $(XVSDKINCS) $(XF86VMODE_SDK) xorgVersion.h \
> - xf86sbusBus.h xf86VGAarbiter.h
> + xf86sbusBus.h $(VGAARB_SDK)
>
> DISTCLEANFILES = xf86Build.h
> CLEANFILES = $(BUILT_SOURCES)
> @@ -83,9 +89,8 @@ EXTRA_DIST = \
> xorgVersion.h \
> $(MODEDEFSOURCES) \
> modeline2c.awk \
> - xf86VGAarbiter.h \
> - xf86VGAarbiterPriv.h \
> - $(DISTKBDSOURCES)
> + $(VGAARB_EXTRADIST) \
> + $(DISTKBDSOURCES)
>
> if LNXACPI
> XORG_CFLAGS += -DHAVE_ACPI
> diff --git a/hw/xfree86/common/xf86Bus.c b/hw/xfree86/common/xf86Bus.c
> index 9d243c1..03d284f 100644
> --- a/hw/xfree86/common/xf86Bus.c
> +++ b/hw/xfree86/common/xf86Bus.c
> @@ -47,7 +47,9 @@
>
> #define XF86_OS_PRIVS
> #include "xf86_OSproc.h"
> +#ifdef VGAARB
> #include "xf86VGAarbiter.h"
> +#endif
>
> #include "Pci.h"
>
> @@ -525,8 +527,9 @@ xf86PostScreenInit(void)
> SetSIGIOForState(OPERATING);
> return;
> }
> -
> +#ifdef VGAARB
> xf86VGAarbiterWrapFunctions();
> +#endif
>
> DebugF("PostScreenInit generation: %i\n",serverGeneration);
> xf86EnterServerState(OPERATING);
> diff --git a/hw/xfree86/common/xf86DPMS.c b/hw/xfree86/common/xf86DPMS.c
> index 22174c7..7e4e3a5 100644
> --- a/hw/xfree86/common/xf86DPMS.c
> +++ b/hw/xfree86/common/xf86DPMS.c
> @@ -42,8 +42,9 @@
> #include <X11/extensions/dpmsconst.h>
> #include "dpmsproc.h"
> #endif
> +#ifdef VGAARB
> #include "xf86VGAarbiter.h"
> -
> +#endif
>
> #ifdef DPMSExtension
> static int DPMSKeyIndex;
> @@ -163,9 +164,13 @@ DPMSSet(ClientPtr client, int level)
> pScrn = xf86Screens[i];
> pDPMS = dixLookupPrivate(&screenInfo.screens[i]->devPrivates, DPMSKey);
> if (pDPMS && pScrn->DPMSSet && pDPMS->Enabled && pScrn->vtSema) {
> +#ifdef VGAARB
> xf86VGAarbiterLock(pScrn);
> +#endif
> pScrn->DPMSSet(pScrn, level, 0);
> +#ifdef VGAARB
> xf86VGAarbiterUnlock(pScrn);
> +#endif
> }
> }
> return Success;
> diff --git a/hw/xfree86/common/xf86Init.c b/hw/xfree86/common/xf86Init.c
> index 8f2cdf6..6846a47 100644
> --- a/hw/xfree86/common/xf86Init.c
> +++ b/hw/xfree86/common/xf86Init.c
> @@ -78,7 +78,9 @@
> #include "picturestr.h"
> #endif
>
> +#ifdef VGAARB
> #include "xf86VGAarbiter.h"
> +#endif
> #include "globals.h"
>
> #ifdef DPMSExtension
> @@ -729,9 +731,9 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
> xf86Msg(X_ERROR, "No devices detected.\n");
> return;
> }
> -
> +#ifdef VGAARB
> xf86VGAarbiterInit();
> -
> +#endif
> /*
> * Match up the screens found by the probes against those specified
> * in the config file. Remove the ones that won't be used. Sort
> @@ -812,12 +814,16 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
> */
>
> for (i = 0; i < xf86NumScreens; i++) {
> +#ifdef VGAARB
> xf86VGAarbiterScrnInit(xf86Screens[i]);
> xf86VGAarbiterLock(xf86Screens[i]);
> +#endif
> if (xf86Screens[i]->PreInit &&
> xf86Screens[i]->PreInit(xf86Screens[i], 0))
> xf86Screens[i]->configured = TRUE;
> +#ifdef VGAARB
> xf86VGAarbiterUnlock(xf86Screens[i]);
> +#endif
> }
> for (i = 0; i < xf86NumScreens; i++)
> if (!xf86Screens[i]->configured)
> @@ -1026,7 +1032,9 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
> #endif /* SCO325 */
>
> for (i = 0; i < xf86NumScreens; i++) {
> +#ifdef VGAARB
> xf86VGAarbiterLock(xf86Screens[i]);
> +#endif
> /*
> * Almost everything uses these defaults, and many of those that
> * don't, will wrap them.
> @@ -1041,7 +1049,9 @@ InitOutput(ScreenInfo *pScreenInfo, int argc, char **argv)
> xf86Screens[i]->DriverFunc = NULL;
> xf86Screens[i]->pScreen = NULL;
> scr_index = AddScreen(xf86Screens[i]->ScreenInit, argc, argv);
> +#ifdef VGAARB
> xf86VGAarbiterUnlock(xf86Screens[i]);
> +#endif
> if (scr_index == i) {
> /*
> * Hook in our ScrnInfoRec, and initialise some other pScreen
> @@ -1181,7 +1191,9 @@ ddxGiveUp(void)
> {
> int i;
>
> +#ifdef VGAARB
> xf86VGAarbiterFini();
> +#endif
>
> #ifdef XF86PM
> if (xf86OSPMClose)
> diff --git a/hw/xfree86/common/xf86VGAarbiter.c b/hw/xfree86/common/xf86VGAarbiter.c
> index 9b72331..4bbed99 100644
> --- a/hw/xfree86/common/xf86VGAarbiter.c
> +++ b/hw/xfree86/common/xf86VGAarbiter.c
> @@ -31,8 +31,6 @@
> #include "xorg-config.h"
>
> #include "xf86VGAarbiter.h"
> -
> -#ifdef HAVE_PCI_DEVICE_VGAARB_INIT
> #include "xf86VGAarbiterPriv.h"
> #include "xf86Bus.h"
> #include "xf86Priv.h"
> @@ -1161,16 +1159,3 @@ VGAarbiterCompositeRects(CARD8 op, PicturePtr pDst, xRenderColor *color, int nRe
> PICTURE_EPILOGUE (CompositeRects, VGAarbiterCompositeRects);
> }
> #endif
> -#else
> -/* dummy functions */
> -void xf86VGAarbiterInit(void) {}
> -void xf86VGAarbiterFini(void) {}
> -
> -void xf86VGAarbiterLock(ScrnInfoPtr pScrn) {}
> -void xf86VGAarbiterUnlock(ScrnInfoPtr pScrn) {}
> -Bool xf86VGAarbiterAllowDRI(ScreenPtr pScreen) { return TRUE; }
> -void xf86VGAarbiterScrnInit(ScrnInfoPtr pScrn) {}
> -void xf86VGAarbiterDeviceDecodes(ScrnInfoPtr pScrn) {}
> -Bool xf86VGAarbiterWrapFunctions(void) { return FALSE; }
> -
> -#endif
> diff --git a/hw/xfree86/common/xf86VGAarbiter.h b/hw/xfree86/common/xf86VGAarbiter.h
> index 904b6b0..2dca749 100644
> --- a/hw/xfree86/common/xf86VGAarbiter.h
> +++ b/hw/xfree86/common/xf86VGAarbiter.h
> @@ -31,12 +31,12 @@
> #include "xf86.h"
>
> /* Functions */
> -extern void xf86VGAarbiterInit(void);
> -extern void xf86VGAarbiterFini(void);
> +void xf86VGAarbiterInit(void);
> +void xf86VGAarbiterFini(void);
> void xf86VGAarbiterScrnInit(ScrnInfoPtr pScrn);
> -extern Bool xf86VGAarbiterWrapFunctions(void);
> -extern void xf86VGAarbiterLock(ScrnInfoPtr pScrn);
> -extern void xf86VGAarbiterUnlock(ScrnInfoPtr pScrn);
> +Bool xf86VGAarbiterWrapFunctions(void);
> +void xf86VGAarbiterLock(ScrnInfoPtr pScrn);
> +void xf86VGAarbiterUnlock(ScrnInfoPtr pScrn);
>
> /* allow a driver to remove itself from arbiter - really should be
> * done in the kernel though */
> diff --git a/hw/xfree86/common/xf86str.h b/hw/xfree86/common/xf86str.h
> index b9a2e06..60d91e6 100644
> --- a/hw/xfree86/common/xf86str.h
> +++ b/hw/xfree86/common/xf86str.h
> @@ -517,7 +517,11 @@ typedef struct _confdrirec {
>
> /* These values should be adjusted when new fields are added to ScrnInfoRec */
> #define NUM_RESERVED_INTS 16
> +#ifdef VGAARB
> #define NUM_RESERVED_POINTERS 14
> +#else
> +#define NUM_RESERVED_POINTERS 15
> +#endif
> #define NUM_RESERVED_FUNCS 11
>
> typedef pointer (*funcPointer)(void);
> @@ -796,7 +800,9 @@ typedef struct _ScrnInfoRec {
> int reservedInt[NUM_RESERVED_INTS];
>
> int * entityInstanceList;
> +#ifdef VGAARB
> struct pci_device *vgaDev;
> +#endif
>
> pointer reservedPtr[NUM_RESERVED_POINTERS];
>
> diff --git a/hw/xfree86/dri/dri.c b/hw/xfree86/dri/dri.c
> index d32b284..225722f 100644
> --- a/hw/xfree86/dri/dri.c
> +++ b/hw/xfree86/dri/dri.c
> @@ -69,7 +69,9 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
> #include "mipointer.h"
> #include "xf86_OSproc.h"
> #include "inputstr.h"
> +#ifdef VGAARB
> #include "xf86VGAarbiter.h"
> +#endif
>
> #define PCI_BUS_NO_DOMAIN(bus) ((bus) & 0xffu)
>
> @@ -334,12 +336,14 @@ DRIScreenInit(ScreenPtr pScreen, DRIInfoPtr pDRIInfo, int *pDRMFD)
> return FALSE;
> }
>
> +#ifdef VGAARB
> if (!xf86VGAarbiterAllowDRI(pScreen)) {
> DRIDrvMsg(pScreen->myNum, X_WARNING,
> "Direct rendering is not supported when VGA arb is necessary for the device\n");
> return FALSE;
> }
> -
> +#endif
> +
> /*
> * If Xinerama is on, don't allow DRI to initialise. It won't be usable
> * anyway.
> diff --git a/hw/xfree86/dri2/dri2.c b/hw/xfree86/dri2/dri2.c
> index d15ced1..d5ecc7b 100644
> --- a/hw/xfree86/dri2/dri2.c
> +++ b/hw/xfree86/dri2/dri2.c
> @@ -39,7 +39,9 @@
> #include "scrnintstr.h"
> #include "windowstr.h"
> #include "dri2.h"
> +#ifdef VGAARB
> #include "xf86VGAarbiter.h"
> +#endif
>
> #include "xf86.h"
>
> @@ -415,11 +417,13 @@ DRI2ScreenInit(ScreenPtr pScreen, DRI2InfoPtr info)
> if (info->version < 3)
> return FALSE;
>
> +#ifdef VGAARB
> if (!xf86VGAarbiterAllowDRI(pScreen)) {
> xf86DrvMsg(pScreen->myNum, X_WARNING,
> "[DRI2] Direct rendering is not supported when VGA arb is necessary for the device\n");
> return FALSE;
> }
> +#endif
>
> ds = xalloc(sizeof *ds);
> if (!ds)
> diff --git a/hw/xfree86/loader/sdksyms.sh b/hw/xfree86/loader/sdksyms.sh
> index 1186547..448742a 100755
> --- a/hw/xfree86/loader/sdksyms.sh
> +++ b/hw/xfree86/loader/sdksyms.sh
> @@ -121,7 +121,9 @@ cat > sdksyms.c << EOF
> #include "xf86fbman.h"
> #include "xf86str.h"
> #include "xf86Xinput.h"
> +#ifdef VGAARB
> #include "xf86VGAarbiter.h"
> +#endif
> #include "xisb.h"
> #if XV
> # include "xf86xv.h"
> diff --git a/include/xorg-config.h.in b/include/xorg-config.h.in
> index d159420..c092033 100644
> --- a/include/xorg-config.h.in
> +++ b/include/xorg-config.h.in
> @@ -124,10 +124,10 @@
> /* Have pci_enable_device */
> #undef HAVE_PCI_DEVICE_ENABLE
>
> -/* Define to 1 if you have the `pci_device_vgaarb_init' function. */
> -#undef HAVE_PCI_DEVICE_VGAARB_INIT
> -
> /* Path to text files containing PCI IDs */
> #undef PCI_TXT_IDS_PATH
>
> +/* Legacy VGA arbitration */
> +#undef VGAARB
> +
> #endif /* _XORG_CONFIG_H_ */
More information about the xorg-devel
mailing list