xserver: Branch 'pci-rework' - 4 commits
Ian Romanick
idr at kemper.freedesktop.org
Wed Jan 17 22:44:29 EET 2007
hw/xfree86/common/xf86pciBus.c | 5 -
hw/xfree86/common/xf86pciBus.h | 3
hw/xfree86/loader/xf86sym.c | 1
hw/xfree86/os-support/bus/Pci.c | 7 -
hw/xfree86/os-support/bus/Pci.h | 2
hw/xfree86/os-support/bus/linuxPci.c | 120 ++++++++++++------------------
hw/xfree86/os-support/bus/xf86Pci.h | 2
hw/xfree86/os-support/linux/int10/linux.c | 5 -
8 files changed, 55 insertions(+), 90 deletions(-)
New commits:
diff-tree 28976bebec8b6475d0703f8356edd116e25d40b2 (from f36a447d20c0a89b78c5899eeb303cab568ebac6)
Author: Ian Romanick <idr at us.ibm.com>
Date: Wed Jan 17 12:15:09 2007 -0800
Eliminate unused fields in pciAccRec.
diff --git a/hw/xfree86/common/xf86pciBus.c b/hw/xfree86/common/xf86pciBus.c
index 24af975..05e1e7e 100644
--- a/hw/xfree86/common/xf86pciBus.c
+++ b/hw/xfree86/common/xf86pciBus.c
@@ -569,9 +569,6 @@ initPciState(void)
pcaccp = xnfalloc( sizeof( pciAccRec ) );
pvp->user_data = (intptr_t) pcaccp;
- pcaccp->busnum = PCI_MAKE_BUS(pvp->domain, pvp->bus);
- pcaccp->devnum = pvp->dev;
- pcaccp->funcnum = pvp->func;
pcaccp->arg.dev = pvp;
pcaccp->ioAccess.AccessDisable = pciIoAccessDisable;
pcaccp->ioAccess.AccessEnable = pciIoAccessEnable;
diff --git a/hw/xfree86/common/xf86pciBus.h b/hw/xfree86/common/xf86pciBus.h
index 860beb2..7d08502 100644
--- a/hw/xfree86/common/xf86pciBus.h
+++ b/hw/xfree86/common/xf86pciBus.h
@@ -47,9 +47,6 @@ typedef struct {
} pciArg;
typedef struct {
- int busnum;
- int devnum;
- int funcnum;
pciArg arg;
xf86AccessRec ioAccess;
xf86AccessRec io_memAccess;
diff-tree f36a447d20c0a89b78c5899eeb303cab568ebac6 (from 780b55ec6f97864b50f00170b201e93eba188f1b)
Author: Ian Romanick <idr at us.ibm.com>
Date: Tue Jan 16 14:49:19 2007 -0800
Eliminate use of Tag field.
The Tag field was removed from the int10 structures in commit
ca9c41e09ddb72d150d86f5d372eb07eeca7c1a2. This file was over looked.
diff --git a/hw/xfree86/os-support/linux/int10/linux.c b/hw/xfree86/os-support/linux/int10/linux.c
index 1940d91..9993a29 100644
--- a/hw/xfree86/os-support/linux/int10/linux.c
+++ b/hw/xfree86/os-support/linux/int10/linux.c
@@ -90,7 +90,6 @@ xf86ExtendedInitInt10(int entityIndex, i
legacyVGARec vga;
xf86int10BiosLocation bios;
Bool videoBiosMapped = FALSE;
- pciVideoPtr pvp;
if (int10Generation != serverGeneration) {
counter = 0;
@@ -152,8 +151,8 @@ xf86ExtendedInitInt10(int entityIndex, i
pInt = (xf86Int10InfoPtr)xnfcalloc(1, sizeof(xf86Int10InfoRec));
pInt->scrnIndex = screen;
pInt->entityIndex = entityIndex;
- pvp = xf86GetPciInfoForEntity(entityIndex);
- if (pvp) pInt->Tag = pciTag(pvp->bus, pvp->device, pvp->func);
+ pInt->dev = xf86GetPciInfoForEntity(entityIndex);
+
if (!xf86Int10ExecSetup(pInt))
goto error0;
pInt->mem = &linuxMem;
diff-tree 780b55ec6f97864b50f00170b201e93eba188f1b (from 31bd8d150749c548eb70404395b4a52d46412f43)
Author: Ian Romanick <idr at us.ibm.com>
Date: Mon Jan 15 15:30:16 2007 -0800
Fix accidental commit (bug) in linuxOpenLegacy.
diff --git a/hw/xfree86/os-support/bus/linuxPci.c b/hw/xfree86/os-support/bus/linuxPci.c
index 6c53375..5ac49a5 100644
--- a/hw/xfree86/os-support/bus/linuxPci.c
+++ b/hw/xfree86/os-support/bus/linuxPci.c
@@ -432,8 +432,8 @@ linuxMapPci(int ScreenNum, int Flags, st
static int
linuxOpenLegacy(struct pci_device *dev, char *name)
{
- static const char PREFIX[] = "/sys/class/pci_bus/%04x:%02x/legacy_%s";
- char path[sizeof(PREFIX) + 3];
+ static const char PREFIX[] = "/sys/class/pci_bus/%04x:%02x/%s";
+ char path[sizeof(PREFIX) + 10];
pciBusInfo_t *pBusInfo;
int fd = -1;
diff-tree 31bd8d150749c548eb70404395b4a52d46412f43 (from 079a6a55a516778871a8b2f8e9c8dd9162105a76)
Author: Ian Romanick <idr at us.ibm.com>
Date: Mon Jan 15 15:19:30 2007 -0800
Fix domain insanity.
Eliminate xf86GetPciDomain. The domain from libpciaccess is the
domain. Period. This means that 0 is a valid domain. Make sure that
INCLUDE_XF86_NO_DOMAIN is *not* set. Always run in "domain mode,"
even if the only domain possible is 0.
diff --git a/hw/xfree86/common/xf86pciBus.c b/hw/xfree86/common/xf86pciBus.c
index 89543e1..24af975 100644
--- a/hw/xfree86/common/xf86pciBus.c
+++ b/hw/xfree86/common/xf86pciBus.c
@@ -1072,5 +1072,5 @@ pciConvertRange2Host(int entityIndex, re
/* Set domain number */
pRange->type &= ~(ResDomain | ResBus);
- pRange->type |= xf86GetPciDomain(tag) << 24;
+ pRange->type |= pvp->domain << 24;
}
diff --git a/hw/xfree86/loader/xf86sym.c b/hw/xfree86/loader/xf86sym.c
index dd0df69..75181f2 100644
--- a/hw/xfree86/loader/xf86sym.c
+++ b/hw/xfree86/loader/xf86sym.c
@@ -248,7 +248,6 @@ _X_HIDDEN void *xfree86LookupTab[] = {
SYMFUNC(xf86MapVidMem)
SYMFUNC(xf86UnMapVidMem)
SYMFUNC(xf86MapReadSideEffects)
- SYMFUNC(xf86GetPciDomain)
SYMFUNC(xf86MapDomainMemory)
SYMFUNC(xf86ReadLegacyVideoBIOS)
SYMFUNC(xf86UDelay)
diff --git a/hw/xfree86/os-support/bus/Pci.c b/hw/xfree86/os-support/bus/Pci.c
index 1c5404b..8929ef2 100644
--- a/hw/xfree86/os-support/bus/Pci.c
+++ b/hw/xfree86/os-support/bus/Pci.c
@@ -20,7 +20,6 @@
* function
* pciBusAddrToHostAddr() - Convert a PCI address to a host address
* xf86scanpci() - Return info about all PCI devices
- * xf86GetPciDomain() - Return domain number from a PCITAG
* xf86MapDomainMemory() - Like xf86MapPciMem() but can handle
* domain/host address translation
* xf86MapLegacyIO() - Maps PCI I/O spaces
@@ -297,12 +296,6 @@ xf86scanpci(void)
#ifdef INCLUDE_XF86_NO_DOMAIN
-_X_EXPORT int
-xf86GetPciDomain(PCITAG Tag)
-{
- return 0;
-}
-
_X_EXPORT pointer
xf86MapDomainMemory(int ScreenNum, int Flags, struct pci_device *dev,
ADDRESS Base, unsigned long Size)
diff --git a/hw/xfree86/os-support/bus/Pci.h b/hw/xfree86/os-support/bus/Pci.h
index 165439d..bc322ac 100644
--- a/hw/xfree86/os-support/bus/Pci.h
+++ b/hw/xfree86/os-support/bus/Pci.h
@@ -283,6 +283,8 @@
#error No PCI support available for this architecture/OS combination
#endif
+#undef INCLUDE_XF86_NO_DOMAIN
+
extern void ARCH_PCI_INIT(void);
#if defined(ARCH_PCI_OS_INIT)
extern void ARCH_PCI_OS_INIT(void);
diff --git a/hw/xfree86/os-support/bus/linuxPci.c b/hw/xfree86/os-support/bus/linuxPci.c
index 9851651..6c53375 100644
--- a/hw/xfree86/os-support/bus/linuxPci.c
+++ b/hw/xfree86/os-support/bus/linuxPci.c
@@ -99,22 +99,26 @@ static const struct pci_id_match match_h
0x0000ffff00, 0
};
-
-static Bool domain_support = FALSE;
+#ifndef INCLUDE_XF86_NO_DOMAIN
+#define MAX_DOMAINS 257
+static pointer DomainMmappedIO[MAX_DOMAINS];
+#endif
void
linuxPciInit(void)
{
struct stat st;
+
+#ifndef INCLUDE_XF86_NO_DOMAIN
+ (void) memset(DomainMmappedIO, 0, sizeof(DomainMmappedIO));
+#endif
+
if ((xf86Info.pciFlags == PCIForceNone) ||
(-1 == stat("/proc/bus/pci", &st))) {
/* when using this as default for all linux architectures,
we'll need a fallback for 2.0 kernels here */
return;
}
-#ifndef INCLUDE_XF86_NO_DOMAIN
- domain_support = linuxDomainSupport();
-#endif
pciNumBuses = 1;
pciBusInfo[0] = &linuxPci0;
}
@@ -337,10 +341,12 @@ linuxGetSizesStruct(const struct pci_dev
int i;
/* Look up vendor/device */
- for (i = 0; i < NUM_SIZES; i++) {
- if ((dev->vendor_id == pciControllerSizes[i].vendor)
- && (dev->device_id == pciControllerSizes[i].device)) {
- return & pciControllerSizes[i];
+ if (dev != NULL) {
+ for (i = 0; i < NUM_SIZES; i++) {
+ if ((dev->vendor_id == pciControllerSizes[i].vendor)
+ && (dev->device_id == pciControllerSizes[i].device)) {
+ return & pciControllerSizes[i];
+ }
}
}
@@ -355,29 +361,6 @@ linuxGetIOSize(const struct pci_device *
return sizes->io_size;
}
-_X_EXPORT int
-xf86GetPciDomain(PCITAG Tag)
-{
- const struct pci_device *dev;
- int fd, result;
-
- dev = xf86GetPciHostConfigFromTag(Tag);
-
- if (!dev)
- return 1; /* Domain 0 is reserved */
-
- if ((result = PCI_DOM_FROM_TAG(Tag)) != 0)
- return result;
-
- if ((fd = linuxPciOpenFile(dev, FALSE)) < 0)
- return 0;
-
- if ((result = ioctl(fd, PCIIOC_CONTROLLER, 0)) < 0)
- return 0;
-
- return result + 1; /* Domain 0 is reserved */
-}
-
static pointer
linuxMapPci(int ScreenNum, int Flags, struct pci_device *dev,
ADDRESS Base, unsigned long Size, int mmap_ioctl)
@@ -446,41 +429,30 @@ linuxMapPci(int ScreenNum, int Flags, st
return NULL;
}
-#define MAX_DOMAINS 257
-static pointer DomainMmappedIO[MAX_DOMAINS];
-
static int
linuxOpenLegacy(struct pci_device *dev, char *name)
{
-#define PREFIX "/sys/class/pci_bus/%04x:%02x/%s"
- char *path;
- int domain, bus;
+ static const char PREFIX[] = "/sys/class/pci_bus/%04x:%02x/legacy_%s";
+ char path[sizeof(PREFIX) + 3];
pciBusInfo_t *pBusInfo;
- int fd;
-
- path = xalloc(strlen(PREFIX) + strlen(name));
- if (!path)
- return -1;
+ int fd = -1;
while (dev != NULL) {
- sprintf(path, PREFIX, dev->domain, dev->bus, name);
+ snprintf(path, sizeof(path) - 1, PREFIX, dev->domain, dev->bus, name);
fd = open(path, O_RDWR);
if (fd >= 0) {
- xfree(path);
return fd;
}
pBusInfo = pciBusInfo[PCI_MAKE_BUS(dev->domain, dev->bus)];
- if (!pBusInfo || (bridge == pBusInfo->bridge) ||
+ if (!pBusInfo || (dev == pBusInfo->bridge) ||
!pBusInfo->bridge) {
- xfree(path);
return -1;
}
dev = pBusInfo->bridge;
}
- xfree(path);
return fd;
}
@@ -537,24 +509,22 @@ xf86MapLegacyIO(struct pci_device *dev)
{
const PCITAG tag = PCI_MAKE_TAG(PCI_MAKE_BUS(dev->domain, dev->bus),
dev->dev, dev->func);
- const int domain = xf86GetPciDomain(tag);
- const struct pci_device *bridge = xf86GetPciHostConfigFromTag(tag);
+ const int domain = dev->domain;
+ struct pci_device *bridge = xf86GetPciHostConfigFromTag(tag);
int fd;
- if ((domain <= 0) || (domain >= MAX_DOMAINS))
+ if (domain >= MAX_DOMAINS)
FatalError("xf86MapLegacyIO(): domain out of range\n");
if (DomainMmappedIO[domain])
return (IOADDRESS)DomainMmappedIO[domain];
/* Permanently map all of I/O space */
- if ((fd = linuxOpenLegacy(bridge, "legacy_io")) < 0) {
- DomainMmappedIO[domain] = linuxMapPci(-1, VIDMEM_MMIO, bridge,
- 0, linuxGetIOSize(bridge),
- PCIIOC_MMAP_IS_IO);
- /* ia64 can't mmap legacy IO port space */
- if (!DomainMmappedIO[domain])
- return 0;
+ fd = linuxOpenLegacy(bridge, "legacy_io");
+ if (fd < 0) {
+ DomainMmappedIO[domain] = linuxMapPci(-1, VIDMEM_MMIO, bridge,
+ 0, linuxGetIOSize(bridge),
+ PCIIOC_MMAP_IS_IO);
}
else { /* legacy_io file exists, encode fd */
DomainMmappedIO[domain] = (pointer)(fd << 24);
@@ -574,8 +544,8 @@ xf86MapLegacyIO(struct pci_device *dev)
_X_EXPORT int
xf86ReadLegacyVideoBIOS(struct pci_device *dev, unsigned char *Buf)
{
- const ADDRESS Base = V_BIOS;
- const int Len = V_BIOS_SIZE * 2;
+ const ADDRESS Base = 0xC0000;
+ const int Len = 0x10000 * 2;
const int pagemask = getpagesize() - 1;
const ADDRESS offset = Base & ~pagemask;
const unsigned long size = ((Base + Len + pagemask) & ~pagemask) - offset;
@@ -596,12 +566,12 @@ xf86ReadLegacyVideoBIOS(struct pci_devic
/* Using memcpy() here can hang the system */
src = ptr + (Base - offset);
- for (len = 0; len < V_BIOS_SIZE; len++) {
+ for (len = 0; len < (Len / 2); len++) {
Buf[len] = src[len];
}
- if ((buf[0] == 0x55) && (buf[1] == 0xAA) && (buf[2] > 0x80)) {
- for ( /* empty */ ; len < (2 * V_BIOS_SIZE); len++) {
+ if ((Buf[0] == 0x55) && (Buf[1] == 0xAA) && (Buf[2] > 0x80)) {
+ for ( /* empty */ ; len < Len; len++) {
Buf[len] = src[len];
}
}
@@ -615,15 +585,13 @@ resPtr
xf86BusAccWindowsFromOS(void)
{
struct pci_device *dev;
- sturct pci_device_iterator *iter;
+ struct pci_device_iterator *iter;
resPtr pRes = NULL;
resRange range;
iter = pci_id_match_iterator_create(& match_host_bridge);
while ((dev = pci_device_next(iter)) != NULL) {
- const PCITAG tag = PCI_MAKE_TAG(PCI_MAKE_BUS(dev->domain, dev->bus),
- dev->dev, dev->func);
- const int domain = xf86GetPciDomain(tag);
+ const int domain = dev->domain;
const struct pciSizes * const sizes = linuxGetSizesStruct(dev);
RANGE(range, 0, (ADDRESS)(sizes->mem_size - 1),
@@ -634,8 +602,14 @@ xf86BusAccWindowsFromOS(void)
RANGE_TYPE(ResExcIoBlock, domain));
pRes = xf86AddResToList(pRes, &range, -1);
+ /* FIXME: The old code reserved domain 0 for a special purpose. The
+ * FIXME: new code just uses whatever domains the kernel tells it,
+ * FIXME: but there is no way to get a domain < 0. What should
+ * FIXME: happen here?
+ *
if (domain <= 0)
break;
+ */
}
pci_iterator_destroy(iter);
@@ -654,14 +628,12 @@ resPtr
xf86AccResFromOS(resPtr pRes)
{
struct pci_device *dev;
- sturct pci_device_iterator *iter;
+ struct pci_device_iterator *iter;
resRange range;
iter = pci_id_match_iterator_create(& match_host_bridge);
while ((dev = pci_device_next(iter)) != NULL) {
- const PCITAG tag = PCI_MAKE_TAG(PCI_MAKE_BUS(dev->domain, dev->bus),
- dev->dev, dev->func);
- const int domain = xf86GetPciDomain(tag);
+ const int domain = dev->domain;
const struct pciSizes * const sizes = linuxGetSizesStruct(dev);
/*
@@ -692,8 +664,14 @@ xf86AccResFromOS(resPtr pRes)
RANGE_TYPE(ResExcIoBlock, domain));
pRes = xf86AddResToList(pRes, &range, -1);
+ /* FIXME: The old code reserved domain 0 for a special purpose. The
+ * FIXME: new code just uses whatever domains the kernel tells it,
+ * FIXME: but there is no way to get a domain < 0. What should
+ * FIXME: happen here?
+ *
if (domain <= 0)
break;
+ */
}
pci_iterator_destroy(iter);
diff --git a/hw/xfree86/os-support/bus/xf86Pci.h b/hw/xfree86/os-support/bus/xf86Pci.h
index bdbff9a..eef3d2e 100644
--- a/hw/xfree86/os-support/bus/xf86Pci.h
+++ b/hw/xfree86/os-support/bus/xf86Pci.h
@@ -106,6 +106,7 @@
#include <X11/Xarch.h>
#include <X11/Xfuncproto.h>
#include "misc.h"
+#include <pciaccess.h>
/*
* PCI cfg space definitions (e.g. stuff right out of the PCI spec)
@@ -257,7 +258,6 @@ Bool xf86scanpci(void);
extern int pciNumBuses;
/* Domain access functions. Some of these probably shouldn't be public */
-int xf86GetPciDomain(PCITAG tag);
pointer xf86MapDomainMemory(int ScreenNum, int Flags, struct pci_device *dev,
ADDRESS Base, unsigned long Size);
IOADDRESS xf86MapLegacyIO(struct pci_device *dev);
More information about the xorg-commit
mailing list