summaryrefslogtreecommitdiff
path: root/src/uxa
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2014-10-08 13:59:55 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2014-10-08 13:59:55 +0100
commitc139e2fb95f2db0b39aadcd58cc63b316a278951 (patch)
treea3ddbf756e480d3d00e93e73d16d2ffeeb19e507 /src/uxa
parent57c48e4973ac0dad09744eaa82315a5f023094e7 (diff)
intel: Store pointer to struct intel_device
Beware the barbarians at the gate, who invade and steal your ScrnInfoPtr and its Entity from underneath you. In some configurations, we lose access to the struct intel_device stored on the Entity after initialisation, causing havoc. Workaround this by storing the intel_device that we open in our driverPrivate. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src/uxa')
-rw-r--r--src/uxa/intel.h15
-rw-r--r--src/uxa/intel_dri3.c4
-rw-r--r--src/uxa/intel_driver.c21
-rw-r--r--src/uxa/intel_hwmc.c8
-rw-r--r--src/uxa/intel_memory.c2
5 files changed, 27 insertions, 23 deletions
diff --git a/src/uxa/intel.h b/src/uxa/intel.h
index 3a1641f3..a3982298 100644
--- a/src/uxa/intel.h
+++ b/src/uxa/intel.h
@@ -54,7 +54,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "xorg-server.h"
#include "xf86_OSproc.h"
#include "compiler.h"
-#include "xf86Pci.h"
#include "xf86Cursor.h"
#include "xf86xv.h"
#include "xf86Crtc.h"
@@ -113,6 +112,7 @@ enum dri_type {
typedef struct intel_screen_private {
ScrnInfoPtr scrn;
+ struct intel_device *dev;
int cpp;
#define RENDER_BATCH I915_EXEC_RENDER
@@ -167,7 +167,6 @@ typedef struct intel_screen_private {
int Chipset;
EntityInfoPtr pEnt;
- struct pci_device *PciInfo;
const struct intel_device_info *info;
unsigned int BR[20];
@@ -326,14 +325,14 @@ typedef struct intel_screen_private {
#define IS_HSW(intel) (INTEL_INFO(intel)->gen == 075)
/* Some chips have specific errata (or limits) that we need to workaround. */
-#define IS_I830(intel) ((intel)->PciInfo->device_id == PCI_CHIP_I830_M)
-#define IS_845G(intel) ((intel)->PciInfo->device_id == PCI_CHIP_845_G)
-#define IS_I865G(intel) ((intel)->PciInfo->device_id == PCI_CHIP_I865_G)
+#define IS_I830(intel) (intel_get_device_id((intel)->dev) == PCI_CHIP_I830_M)
+#define IS_845G(intel) (intel_get_device_id((intel)->dev) == PCI_CHIP_845_G)
+#define IS_I865G(intel) (intel_get_device_id((intel)->dev) == PCI_CHIP_I865_G)
-#define IS_I915G(pI810) ((intel)->PciInfo->device_id == PCI_CHIP_I915_G || (intel)->PciInfo->device_id == PCI_CHIP_E7221_G)
-#define IS_I915GM(pI810) ((intel)->PciInfo->device_id == PCI_CHIP_I915_GM)
+#define IS_I915G(pI810) (intel_get_device_id((intel)->dev) == PCI_CHIP_I915_G || intel_get_device_id((intel)->dev) == PCI_CHIP_E7221_G)
+#define IS_I915GM(pI810) (intel_get_device_id((intel)->dev) == PCI_CHIP_I915_GM)
-#define IS_965_Q(pI810) ((intel)->PciInfo->device_id == PCI_CHIP_I965_Q)
+#define IS_965_Q(pI810) (intel_get_device_id((intel)->dev) == PCI_CHIP_I965_Q)
/* supports Y tiled surfaces (pre-965 Mesa isn't ready yet) */
#define SUPPORTS_YTILING(pI810) (INTEL_INFO(intel)->gen >= 040)
diff --git a/src/uxa/intel_dri3.c b/src/uxa/intel_dri3.c
index fed6b185..2dd2b55f 100644
--- a/src/uxa/intel_dri3.c
+++ b/src/uxa/intel_dri3.c
@@ -40,9 +40,11 @@ intel_dri3_open(ScreenPtr screen,
RRProviderPtr provider,
int *out)
{
+ ScrnInfoPtr scrn = xf86ScreenToScrn(screen);
+ intel_screen_private *intel = intel_get_screen_private(scrn);
int fd;
- fd = intel_get_client_fd(xf86ScreenToScrn(screen));
+ fd = intel_get_client_fd(intel->dev);
if (fd < 0)
return -fd;
diff --git a/src/uxa/intel_driver.c b/src/uxa/intel_driver.c
index f31f7bd6..ebd7498f 100644
--- a/src/uxa/intel_driver.c
+++ b/src/uxa/intel_driver.c
@@ -200,7 +200,7 @@ static void PreInitCleanup(ScrnInfoPtr scrn)
static void intel_check_chipset_option(ScrnInfoPtr scrn)
{
intel_screen_private *intel = intel_get_screen_private(scrn);
- intel_detect_chipset(scrn, intel->pEnt);
+ intel_detect_chipset(scrn, intel->dev);
}
static Bool I830GetEarlyOptions(ScrnInfoPtr scrn)
@@ -268,9 +268,8 @@ static void intel_check_dri_option(ScrnInfoPtr scrn)
static Bool intel_open_drm_master(ScrnInfoPtr scrn)
{
intel_screen_private *intel = intel_get_screen_private(scrn);
-
- intel->drmSubFD = intel_get_device(scrn);
- return intel->drmSubFD != -1;
+ intel->dev = intel_get_device(scrn, &intel->drmSubFD);
+ return intel->dev != NULL;
}
static int intel_init_bufmgr(intel_screen_private *intel)
@@ -381,7 +380,7 @@ static Bool can_accelerate_blt(struct intel_screen_private *intel)
}
if (INTEL_INFO(intel)->gen == 060) {
- struct pci_device *const device = intel->PciInfo;
+ struct pci_device *const device = xf86GetPciInfoForEntity(intel->pEnt->index);
/* Sandybridge rev07 locks up easily, even with the
* BLT ring workaround in place.
@@ -482,8 +481,6 @@ static Bool I830PreInit(ScrnInfoPtr scrn, int flags)
scrn->displayWidth = 640; /* default it */
- intel->PciInfo = xf86GetPciInfoForEntity(intel->pEnt->index);
-
if (!intel_open_drm_master(scrn)) {
xf86DrvMsg(scrn->scrnIndex, X_ERROR,
"Failed to become DRM master.\n");
@@ -860,7 +857,7 @@ I830ScreenInit(SCREEN_INIT_ARGS_DECL)
#ifdef INTEL_XVMC
MessageType from;
#endif
- struct pci_device *const device = intel->PciInfo;
+ struct pci_device *const device = xf86GetPciInfoForEntity(intel->pEnt->index);
int fb_bar = IS_GEN2(intel) ? 0 : 2;
scrn->videoRam = device->regions[fb_bar].size / 1024;
@@ -1065,7 +1062,7 @@ static void I830FreeScreen(FREE_SCREEN_ARGS_DECL)
if (intel && !((uintptr_t)intel & 3)) {
intel_mode_fini(intel);
intel_bufmgr_fini(intel);
- intel_put_device(scrn);
+ intel_put_device(intel->dev);
free(intel);
scrn->driverPrivate = NULL;
@@ -1075,12 +1072,13 @@ static void I830FreeScreen(FREE_SCREEN_ARGS_DECL)
static void I830LeaveVT(VT_FUNC_ARGS_DECL)
{
SCRN_INFO_PTR(arg);
+ intel_screen_private *intel = intel_get_screen_private(scrn);
xf86RotateFreeShadow(scrn);
xf86_hide_cursors(scrn);
- if (intel_put_master(scrn))
+ if (intel_put_master(intel->dev))
xf86DrvMsg(scrn->scrnIndex, X_WARNING,
"drmDropMaster failed: %s\n", strerror(errno));
}
@@ -1091,8 +1089,9 @@ static void I830LeaveVT(VT_FUNC_ARGS_DECL)
static Bool I830EnterVT(VT_FUNC_ARGS_DECL)
{
SCRN_INFO_PTR(arg);
+ intel_screen_private *intel = intel_get_screen_private(scrn);
- if (intel_get_master(scrn)) {
+ if (intel_get_master(intel->dev)) {
xf86DrvMsg(scrn->scrnIndex, X_WARNING,
"drmSetMaster failed: %s\n",
strerror(errno));
diff --git a/src/uxa/intel_hwmc.c b/src/uxa/intel_hwmc.c
index f991aa65..829cb8e0 100644
--- a/src/uxa/intel_hwmc.c
+++ b/src/uxa/intel_hwmc.c
@@ -191,6 +191,7 @@ Bool intel_xvmc_adaptor_init(ScreenPtr pScreen)
{
ScrnInfoPtr scrn = xf86ScreenToScrn(pScreen);
intel_screen_private *intel = intel_get_screen_private(scrn);
+ struct pci_device *pci;
static XF86MCAdaptorRec *pAdapt;
char *name;
char buf[64];
@@ -207,6 +208,10 @@ Bool intel_xvmc_adaptor_init(ScreenPtr pScreen)
return FALSE;
}
+ pci = xf86GetPciInfoForEntity(intel->pEnt->index);
+ if (pci == NULL)
+ return FALSE;
+
pAdapt = calloc(1, sizeof(XF86MCAdaptorRec));
if (!pAdapt) {
ErrorF("Allocation error.\n");
@@ -249,8 +254,7 @@ Bool intel_xvmc_adaptor_init(ScreenPtr pScreen)
}
sprintf(buf, "pci:%04x:%02x:%02x.%d",
- intel->PciInfo->domain,
- intel->PciInfo->bus, intel->PciInfo->dev, intel->PciInfo->func);
+ pci->domain, pci->bus, pci->dev, pci->func);
xf86XvMCRegisterDRInfo(pScreen, INTEL_XVMC_LIBNAME,
buf,
diff --git a/src/uxa/intel_memory.c b/src/uxa/intel_memory.c
index 5796e6d5..0c6cf30c 100644
--- a/src/uxa/intel_memory.c
+++ b/src/uxa/intel_memory.c
@@ -168,7 +168,7 @@ agp_aperture_size(struct pci_device *dev, int gen)
void intel_set_gem_max_sizes(ScrnInfoPtr scrn)
{
intel_screen_private *intel = intel_get_screen_private(scrn);
- size_t agp_size = agp_aperture_size(intel->PciInfo,
+ size_t agp_size = agp_aperture_size(xf86GetPciInfoForEntity(intel->pEnt->index),
INTEL_INFO(intel)->gen);
/* The chances of being able to mmap an object larger than