xserver: Branch 'master' - 2 commits

Aaron Plattner aplattner at kemper.freedesktop.org
Tue Oct 7 13:12:48 PDT 2008


 hw/xfree86/common/xf86.h    |    4 ++
 hw/xfree86/common/xf86Bus.c |   75 ++++++++++++++++++++++++++++++++++++++++++++
 hw/xfree86/common/xf86Bus.h |    8 ++++
 hw/xfree86/common/xf86str.h |   12 +++++++
 hw/xfree86/loader/xf86sym.c |    3 +
 5 files changed, 102 insertions(+)

New commits:
commit b574365fca954a999ebaeb7203d1e0ea6d99b3ea
Author: Aaron Plattner <aplattner at nvidia.com>
Date:   Tue Oct 7 13:09:11 2008 -0700

    Revert "Unexport (and unimplement) xf86SetAccessFuncs" for now.
    
    The nvidia driver currently uses these hooks to work around problems where RAC
    will disable access to the hardware at unexpected times.  This change restores
    these hooks until we can come up with a better API for working around RAC.
    
    This reverts commit c1df4fbede8058c15ce3a5759a7758fecafbb9e7.

diff --git a/hw/xfree86/common/xf86.h b/hw/xfree86/common/xf86.h
index 03ea50e..fbbfc73 100644
--- a/hw/xfree86/common/xf86.h
+++ b/hw/xfree86/common/xf86.h
@@ -130,6 +130,8 @@ void xf86DeallocateResourcesForEntity(int entityIndex, unsigned long type);
 resPtr xf86RegisterResources(int entityIndex, resList list,
 			     unsigned long Access);
 Bool xf86CheckPciMemBase(struct pci_device * pPci, memType base);
+void xf86SetAccessFuncs(EntityInfoPtr pEnt, xf86SetAccessFuncPtr funcs,
+			xf86SetAccessFuncPtr oldFuncs);
 Bool xf86IsEntityPrimary(int entityIndex);
 resPtr xf86ReallocatePciResources(int entityIndex, resPtr pRes);
 resPtr xf86SetOperatingState(resList list, int entityIndex, int mask);
diff --git a/hw/xfree86/common/xf86Bus.c b/hw/xfree86/common/xf86Bus.c
index 3030a04..758560d 100644
--- a/hw/xfree86/common/xf86Bus.c
+++ b/hw/xfree86/common/xf86Bus.c
@@ -819,6 +819,24 @@ xf86SetCurrentAccess(Bool Enable, ScrnInfoPtr pScrn)
     }
 }
 
+_X_EXPORT void
+xf86SetAccessFuncs(EntityInfoPtr pEnt, xf86SetAccessFuncPtr funcs,
+		   xf86SetAccessFuncPtr oldFuncs)
+{
+    AccessFuncPtr rac;
+
+    if (!xf86Entities[pEnt->index]->rac)
+	xf86Entities[pEnt->index]->rac = xnfcalloc(1,sizeof(AccessFuncRec));
+
+    rac = xf86Entities[pEnt->index]->rac;
+
+    rac->mem_new = funcs->mem;
+    rac->io_new = funcs->io;
+    rac->io_mem_new = funcs->io_mem;
+    
+    rac->old = oldFuncs;
+}
+
 /*
  * Conflict checking
  */
diff --git a/hw/xfree86/loader/xf86sym.c b/hw/xfree86/loader/xf86sym.c
index 40b9ba4..494d2db 100644
--- a/hw/xfree86/loader/xf86sym.c
+++ b/hw/xfree86/loader/xf86sym.c
@@ -318,6 +318,7 @@ _X_HIDDEN void *xfree86LookupTab[] = {
     SYMFUNC(xf86GetPciInfoForEntity)
     SYMFUNC(xf86RegisterResources)
     SYMFUNC(xf86CheckPciMemBase)
+    SYMFUNC(xf86SetAccessFuncs)
     SYMFUNC(xf86IsEntityPrimary)
     SYMFUNC(xf86SetOperatingState)
     SYMFUNC(xf86FindScreenForEntity)
commit fe85ec34ec2b58188633dac4464a1e9e9977652b
Author: Aaron Plattner <aplattner at nvidia.com>
Date:   Tue Oct 7 13:08:38 2008 -0700

    Revert "Remove unused server state change callbackery" for now.
    
    The nvidia driver currently uses these callbacks to work around problems where
    RAC will disable access to the hardware at unexpected times.  This change
    restores these hooks until we can come up with a better API for working around
    RAC.
    
    This reverts commit d7c0ba2e9eae7044ef4c31d9c3cbb9a71ee0f9f9.
    
    Conflicts:
    
    	hw/xfree86/loader/xf86sym.c

diff --git a/hw/xfree86/common/xf86.h b/hw/xfree86/common/xf86.h
index 9e3826c..03ea50e 100644
--- a/hw/xfree86/common/xf86.h
+++ b/hw/xfree86/common/xf86.h
@@ -137,6 +137,8 @@ void xf86EnterServerState(xf86State state);
 ScrnInfoPtr xf86FindScreenForEntity(int entityIndex);
 Bool xf86NoSharedResources(int screenIndex, resType res);
 resPtr xf86FindIntersectOfLists(resPtr l1, resPtr l2);
+void xf86RegisterStateChangeNotificationCallback(xf86StateChangeNotificationCallbackFunc func, pointer arg);
+Bool xf86DeregisterStateChangeNotificationCallback(xf86StateChangeNotificationCallbackFunc func);
 
 int xf86GetLastScrnFlag(int entityIndex);
 void xf86SetLastScrnFlag(int entityIndex, int scrnIndex);
diff --git a/hw/xfree86/common/xf86Bus.c b/hw/xfree86/common/xf86Bus.c
index 039b295..3030a04 100644
--- a/hw/xfree86/common/xf86Bus.c
+++ b/hw/xfree86/common/xf86Bus.c
@@ -95,6 +95,10 @@ _X_EXPORT resRange res8514Shared[] = {_8514_SHARED, _END};
 static Bool needRAC = FALSE;
 static Bool doFramebufferMode = FALSE;
 
+/* state change notification callback list */
+static StateChangeNotificationPtr StateChangeNotificationList;
+static void notifyStateChange(xf86NotifyState state);
+
 #undef MIN
 #define MIN(x,y) ((x<y)?x:y)
 
@@ -591,6 +595,7 @@ xf86AccessEnter(void)
     PciStateEnter();
     disableAccess();
     EntityEnter();
+    notifyStateChange(NOTIFY_ENTER);
     xf86EnterServerState(SETUP);
     xf86ResAccessEnter = TRUE;
 }
@@ -609,6 +614,7 @@ xf86AccessLeave(void)
 {
     if (!xf86ResAccessEnter)
 	return;
+    notifyStateChange(NOTIFY_LEAVE);
     disableAccess();
     DisablePciBusAccess();
     EntityLeave();
@@ -1751,9 +1757,15 @@ xf86EnterServerState(xf86State state)
      */
     if (!needRAC) {
 	xf86EnableAccess(xf86Screens[0]);
+	notifyStateChange(NOTIFY_ENABLE);
 	return;
     }
     
+    if (state == SETUP)
+	notifyStateChange(NOTIFY_SETUP_TRANSITION);
+    else
+	notifyStateChange(NOTIFY_OPERATING_TRANSITION);
+    
     clearAccess();
     for (i=0; i<xf86NumScreens;i++) {
 
@@ -1796,6 +1808,10 @@ xf86EnterServerState(xf86State state)
 	    break;
 	}
     }
+    if (state == SETUP)
+	notifyStateChange(NOTIFY_SETUP);
+    else
+	notifyStateChange(NOTIFY_OPERATING);
 }
 
 /*
@@ -2045,6 +2061,7 @@ xf86PostProbe(void)
 	} else  {
 	    xf86Msg(X_INFO,"Running in FRAMEBUFFER Mode\n");
 	    xf86AccessRestoreState();
+	    notifyStateChange(NOTIFY_ENABLE);
 	    doFramebufferMode = TRUE;
 
 	    return;
@@ -2703,6 +2720,46 @@ xf86NoSharedResources(int screenIndex,resType res)
     return TRUE;
 }
 
+_X_EXPORT void
+xf86RegisterStateChangeNotificationCallback(xf86StateChangeNotificationCallbackFunc func, pointer arg)
+{
+    StateChangeNotificationPtr ptr =
+	(StateChangeNotificationPtr)xnfalloc(sizeof(StateChangeNotificationRec));
+
+    ptr->func = func;
+    ptr->arg = arg;
+    ptr->next = StateChangeNotificationList;
+    StateChangeNotificationList = ptr;
+}
+
+_X_EXPORT Bool
+xf86DeregisterStateChangeNotificationCallback(xf86StateChangeNotificationCallbackFunc func)
+{
+    StateChangeNotificationPtr *ptr = &StateChangeNotificationList;
+    StateChangeNotificationPtr tmp;
+    
+    while (*ptr) {
+	if ((*ptr)->func == func) {
+	    tmp = (*ptr);
+	    (*ptr) = (*ptr)->next;
+	    xfree(tmp);
+	    return TRUE;
+	}
+	ptr = &((*ptr)->next);
+    }
+    return FALSE;
+}
+
+static void
+notifyStateChange(xf86NotifyState state)
+{
+    StateChangeNotificationPtr ptr = StateChangeNotificationList;
+    while (ptr) {
+	ptr->func(state,ptr->arg);
+	ptr = ptr->next;
+    }
+}
+
 /* Multihead accel sharing accessor functions and entity Private handling */
 
 _X_EXPORT int
diff --git a/hw/xfree86/common/xf86Bus.h b/hw/xfree86/common/xf86Bus.h
index d28190a..c5f5dcc 100644
--- a/hw/xfree86/common/xf86Bus.h
+++ b/hw/xfree86/common/xf86Bus.h
@@ -119,6 +119,14 @@ typedef struct x_BusAccRec {
     } busdep;
 } BusAccRec, *BusAccPtr;
 
+/* state change notification callback */
+typedef struct _stateChange {
+    xf86StateChangeNotificationCallbackFunc func;
+    pointer arg;
+    struct _stateChange *next;
+} StateChangeNotificationRec, *StateChangeNotificationPtr;
+
+
 extern EntityPtr *xf86Entities;
 extern int xf86NumEntities;
 extern xf86AccessRec AccessNULL;
diff --git a/hw/xfree86/common/xf86str.h b/hw/xfree86/common/xf86str.h
index b57b7bd..8c21123 100644
--- a/hw/xfree86/common/xf86str.h
+++ b/hw/xfree86/common/xf86str.h
@@ -778,6 +778,18 @@ typedef enum {
     OPERATING
 } xf86State;
 
+typedef enum {
+    NOTIFY_SETUP_TRANSITION,
+    NOTIFY_SETUP,
+    NOTIFY_OPERATING,
+    NOTIFY_OPERATING_TRANSITION,
+    NOTIFY_ENABLE,
+    NOTIFY_ENTER,
+    NOTIFY_LEAVE
+} xf86NotifyState;
+
+typedef void (*xf86StateChangeNotificationCallbackFunc)(xf86NotifyState state,pointer);
+
 /* DGA */
 
 typedef struct {
diff --git a/hw/xfree86/loader/xf86sym.c b/hw/xfree86/loader/xf86sym.c
index 4fc83f2..40b9ba4 100644
--- a/hw/xfree86/loader/xf86sym.c
+++ b/hw/xfree86/loader/xf86sym.c
@@ -321,6 +321,8 @@ _X_HIDDEN void *xfree86LookupTab[] = {
     SYMFUNC(xf86IsEntityPrimary)
     SYMFUNC(xf86SetOperatingState)
     SYMFUNC(xf86FindScreenForEntity)
+    SYMFUNC(xf86RegisterStateChangeNotificationCallback)
+    SYMFUNC(xf86DeregisterStateChangeNotificationCallback)
     /* Shared Accel Accessor Functions */
     SYMFUNC(xf86GetLastScrnFlag)
     SYMFUNC(xf86SetLastScrnFlag)


More information about the xorg-commit mailing list