Skip to contentSkip to conversation

GPU device layer patchset (00/07)

RFC New Dave Airlie 6 participants 16 messages Jul 22, 2006 – Jul 31, 2006

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

This patchset contains 7 patches to implement the GPU device layer.

0001-drm-remove-local-copies-of-pci-bus-slot-func.txt 0002-drm-remove-pci-domain-local-copy.txt 0003-gpu-Initial-GPU-layer-addition.txt 0004-gpu-radeon-add-a-radeon-lowlevel-GPU-driver.txt 0005-gpu-radeonfb-add-GPU-support-to-radeonfb.txt 0006-gpu-drm-Add-GPU-layer-support-to-generic-DRM.txt 0007-drm-gpu-radeon-Add-radeon-DRM-support-to-use-GPU-layer.txt

The first two patches are changes to the DRM layer that I will submit separately later but are required for this work.

The GPU layer generic code is in 0003 and 0006, radeon gpu driver 0004, radeonfb in 0005 and radeon drm in 0007.

The code is also available in a git repo branch: 'gpu-branch'
git://git.kernel.org/pub/scm/linux/kernel/git/airlied/gpu-2.6

This is the initial implementation for review.

Dave.

#1 lore raw

PATCH 1/1 drm: remove local copies of pci bus/slot/func (01/07)

The drm keeps a local copy of these for little use.

(cherry picked from ed13f8ab3c841ebe5395dc6e10cb5f9aeb6fd627 commit)

---
 drivers/char/drm/drmP.h      |    3 ---
 drivers/char/drm/drm_ioctl.c |    9 ++++++---
 drivers/char/drm/drm_irq.c   |    4 ++--
 drivers/char/drm/drm_stub.c  |    3 ---
 4 files changed, 8 insertions(+), 11 deletions(-)
drivers/char/drm/drmP.h +0 -3
index d2a5618..5c8f245 100644
@@ -712,9 +712,6 @@ typedef struct drm_device {
 
 	struct pci_dev *pdev;		/**< PCI device structure */
 	int pci_domain;			/**< PCI bus domain number */
-	int pci_bus;			/**< PCI bus number */
-	int pci_slot;			/**< PCI slot number */
-	int pci_func;			/**< PCI function number */
 #ifdef __alpha__
 	struct pci_controller *hose;
 #endif
drivers/char/drm/drm_ioctl.c +6 -3
index 555f323..5c020b8 100644
@@ -128,8 +128,9 @@ int drm_setunique(struct inode *inode, s
 	bus &= 0xff;
 
 	if ((domain != dev->pci_domain) ||
-	    (bus != dev->pci_bus) ||
-	    (slot != dev->pci_slot) || (func != dev->pci_func))
+	    (bus != dev->pdev->bus->number) ||
+	    (slot != PCI_SLOT(dev->pdev->devfn)) ||
+	    (func != PCI_FUNC(dev->pdev->devfn)))
 		return -EINVAL;
 
 	return 0;
@@ -148,7 +149,9 @@ static int drm_set_busid(drm_device_t * 
 		return ENOMEM;
 
 	len = snprintf(dev->unique, dev->unique_len, "pci:%04x:%02x:%02x.%d",
-		 dev->pci_domain, dev->pci_bus, dev->pci_slot, dev->pci_func);
+		       dev->pci_domain, dev->pdev->bus->number,
+		       PCI_SLOT(dev->pdev->devfn),
+		       PCI_FUNC(dev->pdev->devfn));
 
 	if (len > dev->unique_len)
 		DRM_ERROR("Unique buffer overflowed\n");
drivers/char/drm/drm_irq.c +2 -2
index ebdb718..ee4b183 100644
@@ -65,8 +65,8 @@ int drm_irq_by_busid(struct inode *inode
 		return -EFAULT;
 
 	if ((p.busnum >> 8) != dev->pci_domain ||
-	    (p.busnum & 0xff) != dev->pci_bus ||
-	    p.devnum != dev->pci_slot || p.funcnum != dev->pci_func)
+	    (p.busnum & 0xff) != dev->pdev->bus->number ||
+	    p.devnum != PCI_SLOT(dev->pdev->devfn) || p.funcnum != PCI_FUNC(dev->pdev->devfn))
 		return -EINVAL;
 
 	p.irq = dev->irq;
drivers/char/drm/drm_stub.c +0 -3
index 9a842a3..96449d5 100644
@@ -72,9 +72,6 @@ #ifdef __alpha__
 #else
 	dev->pci_domain = 0;
 #endif
-	dev->pci_bus = pdev->bus->number;
-	dev->pci_slot = PCI_SLOT(pdev->devfn);
-	dev->pci_func = PCI_FUNC(pdev->devfn);
 	dev->irq = pdev->irq;
 
 	dev->maplist = drm_calloc(1, sizeof(*dev->maplist), DRM_MEM_MAPS);
Signature · 1 line
1.4.1.ga3e6
#2 lore raw

PATCH 1/1 drm: remove pci domain local copy (02/07)

Just call a function to retrieve the pci domain, this isn't exactly hotpath code.

(cherry picked from 01852d755753bbfcd5434c55d4d7375580f8338f commit)

---
 drivers/char/drm/drmP.h      |   10 +++++++++-
 drivers/char/drm/drm_ioctl.c |    4 ++--
 drivers/char/drm/drm_irq.c   |    2 +-
 3 files changed, 12 insertions(+), 4 deletions(-)
drivers/char/drm/drmP.h +9 -1
index 5c8f245..4dd28e1 100644
@@ -711,7 +711,6 @@ typedef struct drm_device {
 	drm_agp_head_t *agp;	/**< AGP data */
 
 	struct pci_dev *pdev;		/**< PCI device structure */
-	int pci_domain;			/**< PCI bus domain number */
 #ifdef __alpha__
 	struct pci_controller *hose;
 #endif
@@ -733,6 +732,15 @@ static __inline__ int drm_core_check_fea
 	return ((dev->driver->driver_features & feature) ? 1 : 0);
 }
 
+static inline int drm_get_pci_domain(struct drm_device *dev)
+{
+#ifdef __alpha__
+	return dev->hose->bus->number;
+#else
+	return 0;
+#endif
+}
+
 #if __OS_HAS_AGP
 static inline int drm_core_has_AGP(struct drm_device *dev)
 {
drivers/char/drm/drm_ioctl.c +2 -2
index 5c020b8..9d9f988 100644
@@ -127,7 +127,7 @@ int drm_setunique(struct inode *inode, s
 	domain = bus >> 8;
 	bus &= 0xff;
 
-	if ((domain != dev->pci_domain) ||
+	if ((domain != drm_get_pci_domain(dev)) ||
 	    (bus != dev->pdev->bus->number) ||
 	    (slot != PCI_SLOT(dev->pdev->devfn)) ||
 	    (func != PCI_FUNC(dev->pdev->devfn)))
@@ -149,7 +149,7 @@ static int drm_set_busid(drm_device_t * 
 		return ENOMEM;
 
 	len = snprintf(dev->unique, dev->unique_len, "pci:%04x:%02x:%02x.%d",
-		       dev->pci_domain, dev->pdev->bus->number,
+		       drm_get_pci_domain(dev), dev->pdev->bus->number,
 		       PCI_SLOT(dev->pdev->devfn),
 		       PCI_FUNC(dev->pdev->devfn));
 
drivers/char/drm/drm_irq.c +1 -1
index ee4b183..f93d8cd 100644
@@ -64,7 +64,7 @@ int drm_irq_by_busid(struct inode *inode
 	if (copy_from_user(&p, argp, sizeof(p)))
 		return -EFAULT;
 
-	if ((p.busnum >> 8) != dev->pci_domain ||
+	if ((p.busnum >> 8) != drm_get_pci_domain(dev) ||
 	    (p.busnum & 0xff) != dev->pdev->bus->number ||
 	    p.devnum != PCI_SLOT(dev->pdev->devfn) || p.funcnum != PCI_FUNC(dev->pdev->devfn))
 		return -EINVAL;
Signature · 1 line
1.4.1.ga3e6
#3 lore raw

PATCH 1/1 gpu: Initial GPU layer addition. (03/07)

This is the new Linux GPU driver layer generic portion. It registers a bus at system init time, and this bus can be used by lowlevel drivers to create subdevices on the GPU bus. The other GPU drivers can be registered via the lowlevel driver on the other subdevices.

---
 drivers/video/Kconfig     |    4 
 drivers/video/Makefile    |    2 
 drivers/video/gpu_layer.c |  393 +++++++++++++++++++++++++++++++++++++++++++++
 include/linux/gpu_layer.h |  120 ++++++++++++++
 4 files changed, 519 insertions(+), 0 deletions(-)
drivers/video/Kconfig +4 -0
index 6533b0f..8512aa8 100644
@@ -4,6 +4,10 @@ #
 
 menu "Graphics support"
 
+config GPU
+	bool
+	default n
+
 config FIRMWARE_EDID
        bool "Enable firmware EDID"
        default y
drivers/video/Makefile +2 -0
index 95563c9..a882fdd 100644
@@ -4,6 +4,8 @@ # Rewritten to use lists instead of if-s
 
 # Each configuration option enables a list of files.
 
+obj-$(CONFIG_GPU)		  += gpu_layer.o
+
 obj-$(CONFIG_FB)                  += fb.o
 fb-y                              := fbmem.o fbmon.o fbcmap.o fbsysfs.o \
                                      modedb.o fbcvt.o
drivers/video/gpu_layer.c new file +393 -0

393 lines not on this page · raw message

include/linux/gpu_layer.h new file +120 -0

120 lines not on this page · raw message

Signature · 1 line
1.4.1.ga3e6
#4 lore raw

PATCH 1/1 gpu/radeon: add a radeon lowlevel GPU driver (04/07)

This creates a lowlevel radeon driver which detects the card and sets up the GPU layer to use it.

---
 drivers/video/Kconfig      |    5 +
 drivers/video/Makefile     |    2 
 drivers/video/radeon_gpu.c |  343 ++++++++++++++++++++++++++++++++++++++++++++
 include/linux/radeon_gpu.h |   92 ++++++++++++
 4 files changed, 442 insertions(+), 0 deletions(-)
drivers/video/Kconfig +5 -0
index 8512aa8..6602752 100644
@@ -8,6 +8,11 @@ config GPU
 	bool
 	default n
 
+config GPU_RADEON
+	tristate "ATI Radeon gpu driver"
+	select GPU
+	default n
+
 config FIRMWARE_EDID
        bool "Enable firmware EDID"
        default y
drivers/video/Makefile +2 -0
index a882fdd..2650f02 100644
@@ -6,6 +6,8 @@ # Each configuration option enables a li
 
 obj-$(CONFIG_GPU)		  += gpu_layer.o
 
+obj-$(CONFIG_GPU_RADEON)          += radeon_gpu.o
+
 obj-$(CONFIG_FB)                  += fb.o
 fb-y                              := fbmem.o fbmon.o fbcmap.o fbsysfs.o \
                                      modedb.o fbcvt.o
drivers/video/radeon_gpu.c new file +343 -0

343 lines not on this page · raw message

include/linux/radeon_gpu.h new file +92 -0

92 lines not on this page · raw message

Signature · 1 line
1.4.1.ga3e6
#5 lore raw

PATCH 1/1 gpu/radeonfb: add GPU support to radeonfb (05/07)

This patch adds support to the radeonfb driver to use the new GPU layer to driver the radeon.

---
 drivers/video/Kconfig              |    1 
 drivers/video/aty/radeon_accel.c   |   18 +--
 drivers/video/aty/radeon_base.c    |  257 +++++++++++++++++-------------------
 drivers/video/aty/radeon_i2c.c     |   12 +-
 drivers/video/aty/radeon_monitor.c |   12 +-
 drivers/video/aty/radeon_pm.c      |  137 ++++++++++---------
 drivers/video/aty/radeonfb.h       |   84 +-----------
 7 files changed, 224 insertions(+), 297 deletions(-)
drivers/video/Kconfig +1 -0
index 6602752..9872ab5 100644
@@ -1003,6 +1003,7 @@ config FB_MATROX_MULTIHEAD
 config FB_RADEON
 	tristate "ATI Radeon display support"
 	depends on FB && PCI
+	select GPU_RADEON
 	select I2C_ALGOBIT if FB_RADEON_I2C
 	select I2C if FB_RADEON_I2C
 	select FB_MODE_HELPERS
drivers/video/aty/radeon_accel.c +9 -9
index 3ca27cb..b0413d3 100644
@@ -203,9 +203,9 @@ void radeonfb_engine_reset(struct radeon
 	host_path_cntl = INREG(HOST_PATH_CNTL);
 	rbbm_soft_reset = INREG(RBBM_SOFT_RESET);
 
-	if (rinfo->family == CHIP_FAMILY_R300 ||
-	    rinfo->family == CHIP_FAMILY_R350 ||
-	    rinfo->family == CHIP_FAMILY_RV350) {
+	if (rinfo->gpu_info->family == CHIP_FAMILY_R300 ||
+	    rinfo->gpu_info->family == CHIP_FAMILY_R350 ||
+	    rinfo->gpu_info->family == CHIP_FAMILY_RV350) {
 		u32 tmp;
 
 		OUTREG(RBBM_SOFT_RESET, (rbbm_soft_reset |
@@ -241,9 +241,9 @@ void radeonfb_engine_reset(struct radeon
 	INREG(HOST_PATH_CNTL);
 	OUTREG(HOST_PATH_CNTL, host_path_cntl);
 
-	if (rinfo->family != CHIP_FAMILY_R300 ||
-	    rinfo->family != CHIP_FAMILY_R350 ||
-	    rinfo->family != CHIP_FAMILY_RV350)
+	if (rinfo->gpu_info->family != CHIP_FAMILY_R300 ||
+	    rinfo->gpu_info->family != CHIP_FAMILY_R350 ||
+	    rinfo->gpu_info->family != CHIP_FAMILY_RV350)
 		OUTREG(RBBM_SOFT_RESET, rbbm_soft_reset);
 
 	OUTREG(CLOCK_CNTL_INDEX, clock_cntl_index);
@@ -260,9 +260,9 @@ void radeonfb_engine_init (struct radeon
 	radeonfb_engine_reset(rinfo);
 
 	radeon_fifo_wait (1);
-	if ((rinfo->family != CHIP_FAMILY_R300) &&
-	    (rinfo->family != CHIP_FAMILY_R350) &&
-	    (rinfo->family != CHIP_FAMILY_RV350))
+	if ((rinfo->gpu_info->family != CHIP_FAMILY_R300) &&
+	    (rinfo->gpu_info->family != CHIP_FAMILY_R350) &&
+	    (rinfo->gpu_info->family != CHIP_FAMILY_RV350))
 		OUTREG(RB2D_DSTCACHE_MODE, 0);
 
 	radeon_fifo_wait (3);
drivers/video/aty/radeon_base.c +123 -134

643 lines not on this page · raw message

drivers/video/aty/radeon_i2c.c +6 -6
index 9aaca58..c00990e 100644
@@ -76,7 +76,7 @@ static int radeon_setup_i2c_bus(struct r
 	chan->adapter.owner		= THIS_MODULE;
 	chan->adapter.id		= I2C_HW_B_RADEON;
 	chan->adapter.algo_data		= &chan->algo;
-	chan->adapter.dev.parent	= &chan->rinfo->pdev->dev;
+	chan->adapter.dev.parent	= &chan->rinfo->gdev->dev;
 	chan->algo.setsda		= radeon_gpio_setsda;
 	chan->algo.setscl		= radeon_gpio_setscl;
 	chan->algo.getsda		= radeon_gpio_getsda;
@@ -94,9 +94,9 @@ static int radeon_setup_i2c_bus(struct r
 
 	rc = i2c_bit_add_bus(&chan->adapter);
 	if (rc == 0)
-		dev_dbg(&chan->rinfo->pdev->dev, "I2C bus %s registered.\n", name);
+		dev_dbg(&chan->rinfo->gdev->dev, "I2C bus %s registered.\n", name);
 	else
-		dev_warn(&chan->rinfo->pdev->dev, "Failed to register I2C bus %s.\n", name);
+		dev_warn(&chan->rinfo->gdev->dev, "Failed to register I2C bus %s.\n", name);
 	return rc;
 }
 
@@ -157,14 +157,14 @@ static u8 *radeon_do_probe_i2c_edid(stru
 
 	buf = kmalloc(EDID_LENGTH, GFP_KERNEL);
 	if (!buf) {
-		dev_warn(&chan->rinfo->pdev->dev, "Out of memory!\n");
+		dev_warn(&chan->rinfo->gdev->dev, "Out of memory!\n");
 		return NULL;
 	}
 	msgs[1].buf = buf;
 
 	if (i2c_transfer(&chan->adapter, msgs, 2) == 2)
 		return buf;
-	dev_dbg(&chan->rinfo->pdev->dev, "Unable to read EDID block.\n");
+	dev_dbg(&chan->rinfo->gdev->dev, "Unable to read EDID block.\n");
 	kfree(buf);
 	return NULL;
 }
@@ -249,7 +249,7 @@ int radeon_probe_i2c_connector(struct ra
 	}
 	if (edid[0x14] & 0x80) {
 		/* Fix detection using BIOS tables */
-		if (rinfo->is_mobility /*&& conn == ddc_dvi*/ &&
+		if (rinfo->gpu_info->is_mobility /*&& conn == ddc_dvi*/ &&
 		    (INREG(LVDS_GEN_CNTL) & LVDS_ON)) {
 			RTRACE("radeonfb: I2C (port %d) ... found LVDS panel\n", conn);
 			return MT_LCD;
drivers/video/aty/radeon_monitor.c +6 -6
index 98c05bc..7190bad 100644
@@ -123,7 +123,7 @@ static int __devinit radeon_probe_OF_hea
         while (dp == NULL)
 		return MT_NONE;
 
-	if (rinfo->has_CRTC2) {
+	if (rinfo->gpu_info->has_CRTC2) {
 		char *pname;
 		int len, second = 0;
 
@@ -329,8 +329,8 @@ static int __devinit radeon_crt_is_conne
 	ulData            |=  (DAC_FORCE_BLANK_OFF_EN
 			       |DAC_FORCE_DATA_EN
 			       |DAC_FORCE_DATA_SEL_MASK);
-	if ((rinfo->family == CHIP_FAMILY_RV250) ||
-	    (rinfo->family == CHIP_FAMILY_RV280))
+	if ((rinfo->gpu_info->family == CHIP_FAMILY_RV250) ||
+	    (rinfo->gpu_info->family == CHIP_FAMILY_RV280))
 	    ulData |= (0x01b6 << DAC_FORCE_DATA_SHIFT);
 	else
 	    ulData |= (0x01ac << DAC_FORCE_DATA_SHIFT);
@@ -495,7 +495,7 @@ #endif /* DEBUG */
 		/*
 		 * Old single head cards
 		 */
-		if (!rinfo->has_CRTC2) {
+		if (!rinfo->gpu_info->has_CRTC2) {
 #ifdef CONFIG_PPC_OF
 			if (rinfo->mon1_type == MT_NONE)
 				rinfo->mon1_type = radeon_probe_OF_head(rinfo, 0,
@@ -561,7 +561,7 @@ #ifdef CONFIG_FB_RADEON_I2C
 				ddc_crt2_used = 1;
 		}
 #endif /* CONFIG_FB_RADEON_I2C */
-		if (rinfo->mon1_type == MT_NONE && rinfo->is_mobility &&
+		if (rinfo->mon1_type == MT_NONE && rinfo->gpu_info->is_mobility &&
 		    ((rinfo->bios_seg && (INREG(BIOS_4_SCRATCH) & 4))
 		     || (INREG(LVDS_GEN_CNTL) & LVDS_ON))) {
 			rinfo->mon1_type = MT_LCD;
@@ -633,7 +633,7 @@ #endif /* CONFIG_FB_RADEON_I2C */
 	       radeon_get_mon_name(rinfo->mon1_type));
 	if (rinfo->mon1_EDID)
 		printk(KERN_INFO "radeonfb: EDID probed\n");
-	if (!rinfo->has_CRTC2)
+	if (!rinfo->gpu_info->has_CRTC2)
 		return;
 	printk(KERN_INFO "radeonfb: Monitor 2 type %s found\n",
 	       radeon_get_mon_name(rinfo->mon2_type));
drivers/video/aty/radeon_pm.c +70 -67

415 lines not on this page · raw message

drivers/video/aty/radeonfb.h +9 -75

145 lines not on this page · raw message

Signature · 1 line
1.4.1.ga3e6
#6 lore raw

PATCH 1/1 gpu/drm: Add GPU layer support to generic DRM (06/07)

This patch adds the GPU layer support to the drm library. It doesn't touch any drivers just adds the gpu layer to the drm code.

---
 drivers/char/drm/Makefile     |    2 +
 drivers/char/drm/drmP.h       |   16 ++++++++++
 drivers/char/drm/drm_drv.c    |   10 +++++--
 drivers/char/drm/drm_gpu.c    |   63 +++++++++++++++++++++++++++++++++++++++++
 drivers/char/drm/drm_ioctl.c  |    8 +++--
 drivers/char/drm/drm_memory.c |    1 +
 drivers/char/drm/drm_stub.c   |   31 +++++++++-----------
 drivers/char/drm/drm_sysfs.c  |   14 +++++++--
 8 files changed, 116 insertions(+), 29 deletions(-)
drivers/char/drm/Makefile +1 -1
index 9d180c4..150d735 100644
@@ -6,7 +6,7 @@ drm-objs    :=	drm_auth.o drm_bufs.o drm
 		drm_drv.o drm_fops.o drm_ioctl.o drm_irq.o \
 		drm_lock.o drm_memory.o drm_proc.o drm_stub.o drm_vm.o \
 		drm_agpsupport.o drm_scatter.o ati_pcigart.o drm_pci.o \
-		drm_sysfs.o
+		drm_sysfs.o drm_gpu.o
 
 tdfx-objs   := tdfx_drv.o
 r128-objs   := r128_drv.o r128_cce.o r128_state.o r128_irq.o
drivers/char/drm/drmP.h +16 -0
index 4dd28e1..ae590d5 100644
@@ -52,6 +52,7 @@ #include <linux/proc_fs.h>
 #include <linux/init.h>
 #include <linux/file.h>
 #include <linux/pci.h>
+#include <linux/gpu_layer.h>
 #include <linux/jiffies.h>
 #include <linux/smp_lock.h>	/* For (un)lock_kernel */
 #include <linux/mm.h>
@@ -532,6 +533,10 @@ typedef struct ati_pcigart_info {
  * a family of cards. There will one drm_device for each card present
  * in this family
  */
+
+#define DRM_DRV_PCI 1
+#define DRM_DRV_GPU 2
+
 struct drm_device;
 
 struct drm_driver {
@@ -592,6 +597,9 @@ struct drm_driver {
 	drm_ioctl_desc_t *ioctls;
 	int num_ioctls;
 	struct file_operations fops;
+	int drv_type;
+
+	struct gpu_driver gpu_driver;
 	struct pci_driver pci_driver;
 };
 
@@ -710,6 +718,8 @@ typedef struct drm_device {
 
 	drm_agp_head_t *agp;	/**< AGP data */
 
+	/* a pointer to the GPU device */
+	struct gpu_device *gdev;
 	struct pci_dev *pdev;		/**< PCI device structure */
 #ifdef __alpha__
 	struct pci_controller *hose;
@@ -791,9 +801,12 @@ #endif
 /******************************************************************/
 /** \name Internal function definitions */
 /*@{*/
+extern void drm_gpu_cleanup(struct gpu_device *gdev);
+extern int drm_gpu_get_dev(struct gpu_device *gdev, struct drm_driver *driver, void *driver_id, struct pci_dev *pdev);
 
 				/* Driver support (drm_drv.h) */
 extern int drm_init(struct drm_driver *driver);
+extern void drm_cleanup(drm_device_t * dev);
 extern void drm_exit(struct drm_driver *driver);
 extern int drm_ioctl(struct inode *inode, struct file *filp,
 		     unsigned int cmd, unsigned long arg);
@@ -972,9 +985,12 @@ extern int drm_agp_bind_memory(DRM_AGP_M
 extern int drm_agp_unbind_memory(DRM_AGP_MEM * handle);
 
 				/* Stub support (drm_stub.h) */
+extern int drm_fill_in_dev(drm_device_t * dev, unsigned long driver_data,
+			   struct drm_driver *driver);
 extern int drm_get_dev(struct pci_dev *pdev, const struct pci_device_id *ent,
 		       struct drm_driver *driver);
 extern int drm_put_dev(drm_device_t * dev);
+extern int drm_get_head(drm_device_t * dev, drm_head_t * head);
 extern int drm_put_head(drm_head_t * head);
 extern unsigned int drm_debug;
 extern unsigned int drm_cards_limit;
drivers/char/drm/drm_drv.c +7 -3
index 3c0b882..04443d0 100644
@@ -260,6 +260,8 @@ int drm_init(struct drm_driver *driver)
 
 	drm_mem_init();
 
+	driver->drv_type = DRM_DRV_PCI;
+
 	for (i = 0; driver->pci_driver.id_table[i].vendor != 0; i++) {
 		pid = (struct pci_device_id *)&driver->pci_driver.id_table[i];
 
@@ -285,7 +287,7 @@ EXPORT_SYMBOL(drm_init);
  *
  * \sa drm_init
  */
-static void drm_cleanup(drm_device_t * dev)
+void drm_cleanup(drm_device_t * dev)
 {
 	DRM_DEBUG("\n");
 
@@ -344,8 +346,10 @@ void drm_exit(struct drm_driver *driver)
 		dev = head->dev;
 		if (dev) {
 			/* release the pci driver */
-			if (dev->pdev)
-				pci_dev_put(dev->pdev);
+			if (dev->pdev && (dev->driver->drv_type == DRM_DRV_PCI)) {
+				if (dev->pdev)
+					pci_dev_put(dev->pdev);
+			}
 			drm_cleanup(dev);
 		}
 	}
drivers/char/drm/drm_gpu.c new file +63 -0

63 lines not on this page · raw message

drivers/char/drm/drm_ioctl.c +4 -4
index 9d9f988..74fb274 100644
@@ -110,12 +110,12 @@ int drm_setunique(struct inode *inode, s
 	dev->unique[dev->unique_len] = '\0';
 
 	dev->devname =
-	    drm_alloc(strlen(dev->driver->pci_driver.name) +
+	    drm_alloc(strlen(dev->driver->name) +
 		      strlen(dev->unique) + 2, DRM_MEM_DRIVER);
 	if (!dev->devname)
 		return -ENOMEM;
 
-	sprintf(dev->devname, "%s@%s", dev->driver->pci_driver.name,
+	sprintf(dev->devname, "%s@%s", dev->driver->name,
 		dev->unique);
 
 	/* Return error if the busid submitted doesn't match the device's actual
@@ -157,12 +157,12 @@ static int drm_set_busid(drm_device_t * 
 		DRM_ERROR("Unique buffer overflowed\n");
 
 	dev->devname =
-	    drm_alloc(strlen(dev->driver->pci_driver.name) + dev->unique_len +
+	    drm_alloc(strlen(dev->driver->name) + dev->unique_len +
 		      2, DRM_MEM_DRIVER);
 	if (dev->devname == NULL)
 		return ENOMEM;
 
-	sprintf(dev->devname, "%s@%s", dev->driver->pci_driver.name,
+	sprintf(dev->devname, "%s@%s", dev->driver->name,
 		dev->unique);
 
 	return 0;
drivers/char/drm/drm_memory.c +1 -0
index 5681cae..96d962d 100644
@@ -44,6 +44,7 @@ #else
 void drm_mem_init(void)
 {
 }
+EXPORT_SYMBOL(drm_mem_init);
 
 /**
  * Called when "/proc/dri/%dev%/mem" is read.
drivers/char/drm/drm_stub.c +14 -17
index 96449d5..b2e63c8 100644
@@ -53,9 +53,8 @@ drm_head_t **drm_heads;
 struct class *drm_class;
 struct proc_dir_entry *drm_proc_root;
 
-static int drm_fill_in_dev(drm_device_t * dev, struct pci_dev *pdev,
-			   const struct pci_device_id *ent,
-			   struct drm_driver *driver)
+int drm_fill_in_dev(drm_device_t * dev, unsigned long driver_data,
+		    struct drm_driver *driver)
 {
 	int retcode;
 
@@ -64,16 +63,6 @@ static int drm_fill_in_dev(drm_device_t 
 	mutex_init(&dev->struct_mutex);
 	mutex_init(&dev->ctxlist_mutex);
 
-	dev->pdev = pdev;
-
-#ifdef __alpha__
-	dev->hose = pdev->sysdata;
-	dev->pci_domain = dev->hose->bus->number;
-#else
-	dev->pci_domain = 0;
-#endif
-	dev->irq = pdev->irq;
-
 	dev->maplist = drm_calloc(1, sizeof(*dev->maplist), DRM_MEM_MAPS);
 	if (dev->maplist == NULL)
 		return -ENOMEM;
@@ -91,7 +80,7 @@ #endif
 	dev->driver = driver;
 
 	if (dev->driver->load)
-		if ((retcode = dev->driver->load(dev, ent->driver_data)))
+		if ((retcode = dev->driver->load(dev, driver_data)))
 			goto error_out_unreg;
 
 	if (drm_core_has_AGP(dev)) {
@@ -137,7 +126,7 @@ #endif
  * create the proc init entry via proc_init(). This routines assigns
  * minor numbers to secondary heads of multi-headed cards
  */
-static int drm_get_head(drm_device_t * dev, drm_head_t * head)
+int drm_get_head(drm_device_t * dev, drm_head_t * head)
 {
 	drm_head_t **heads = drm_heads;
 	int ret;
@@ -208,14 +197,22 @@ int drm_get_dev(struct pci_dev *pdev, co
 
 	pci_enable_device(pdev);
 
-	if ((ret = drm_fill_in_dev(dev, pdev, ent, driver))) {
+	/* setup up PCI pointers */
+	dev->pdev = pdev;
+
+#ifdef __alpha__
+	dev->hose = pdev->sysdata;
+#endif
+	dev->irq = pdev->irq;
+
+	if ((ret = drm_fill_in_dev(dev, ent->driver_data, driver))) {
 		printk(KERN_ERR "DRM: Fill_in_dev failed.\n");
 		goto err_g1;
 	}
 	if ((ret = drm_get_head(dev, &dev->primary)))
 		goto err_g1;
 	
-	DRM_INFO("Initialized %s %d.%d.%d %s on minor %d\n",
+	DRM_INFO("Initialized PCI %s %d.%d.%d %s on minor %d\n",
 		 driver->name, driver->major, driver->minor, driver->patchlevel,
 		 driver->date, dev->primary.minor);
 
drivers/char/drm/drm_sysfs.c +10 -4
index 51ad98c..eff610c 100644
@@ -98,10 +98,16 @@ struct class_device *drm_sysfs_device_ad
 	struct class_device *class_dev;
 	int i;
 
-	class_dev = class_device_create(cs, NULL,
-					MKDEV(DRM_MAJOR, head->minor),
-					&(head->dev->pdev)->dev,
-					"card%d", head->minor);
+	if (head->dev->driver->drv_type == DRM_DRV_PCI)
+		class_dev = class_device_create(cs, NULL,
+						MKDEV(DRM_MAJOR, head->minor),
+						&(head->dev->pdev)->dev,
+						"card%d", head->minor);
+	else
+		class_dev = class_device_create(cs, NULL,
+						MKDEV(DRM_MAJOR, head->minor),
+						&(head->dev->gdev)->dev,
+						"card%d", head->minor);
 	if (!class_dev)
 		return NULL;
 
Signature · 1 line
1.4.1.ga3e6
#7 lore raw

PATCH 1/1 drm/gpu/radeon: Add radeon DRM support to use GPU layer (07/07)

This ports the radeon DRM to use the GPU layer to bind to the PCI device.

---
 drivers/char/drm/Kconfig        |    1 
 drivers/char/drm/drm_pciids.h   |  178 ++++++++++++++++++++-------------------
 drivers/char/drm/radeon_cp.c    |   40 ++++-----
 drivers/char/drm/radeon_drv.c   |   60 +++++++++++--
 drivers/char/drm/radeon_drv.h   |   22 ++---
 drivers/char/drm/radeon_state.c |   10 +-
 6 files changed, 178 insertions(+), 133 deletions(-)
drivers/char/drm/Kconfig +1 -0
index 5278c38..d73cda7 100644
@@ -34,6 +34,7 @@ config DRM_R128
 config DRM_RADEON
 	tristate "ATI Radeon"
 	depends on DRM && PCI
+	select GPU_RADEON
 	help
 	  Choose this option if you have an ATI Radeon graphics card.  There
 	  are both PCI and AGP versions.  You don't need to choose this to
drivers/char/drm/drm_pciids.h +89 -89

212 lines not on this page · raw message

drivers/char/drm/radeon_cp.c +20 -20
index 5ad43ba..37fbbfe 100644
@@ -1130,7 +1130,7 @@ static void radeon_cp_init_ring_buffer(d
 			     | (dev_priv->fb_location >> 16));
 
 #if __OS_HAS_AGP
-	if (dev_priv->flags & CHIP_IS_AGP) {
+	if (dev_priv->flags & RADEON_IS_AGP) {
 		RADEON_WRITE(RADEON_AGP_BASE, (unsigned int)dev->agp->base);
 		RADEON_WRITE(RADEON_MC_AGP_LOCATION,
 			     (((dev_priv->gart_vm_start - 1 +
@@ -1158,7 +1158,7 @@ #endif
 	dev_priv->ring.tail = cur_read_ptr;
 
 #if __OS_HAS_AGP
-	if (dev_priv->flags & CHIP_IS_AGP) {
+	if (dev_priv->flags & RADEON_IS_AGP) {
 		RADEON_WRITE(RADEON_CP_RB_RPTR_ADDR,
 			     dev_priv->ring_rptr->offset
 			     - dev->agp->base + dev_priv->gart_vm_start);
@@ -1295,7 +1295,7 @@ static void radeon_set_pcigart(drm_radeo
 {
 	u32 tmp;
 
-	if (dev_priv->flags & CHIP_IS_PCIE) {
+	if (dev_priv->flags & RADEON_IS_PCIE) {
 		radeon_set_pciegart(dev_priv, on);
 		return;
 	}
@@ -1333,20 +1333,20 @@ static int radeon_do_init_cp(drm_device_
 	DRM_DEBUG("\n");
 
 	/* if we require new memory map but we don't have it fail */
-	if ((dev_priv->flags & CHIP_NEW_MEMMAP) && !dev_priv->new_memmap)
+	if ((dev_priv->flags & RADEON_NEW_MEMMAP) && !dev_priv->new_memmap)
 	{
 		DRM_ERROR("Cannot initialise DRM on this card\nThis card requires a new X.org DDX\n");
 		radeon_do_cleanup_cp(dev);
 		return DRM_ERR(EINVAL);
 	}
 
-	if (init->is_pci && (dev_priv->flags & CHIP_IS_AGP))
+	if (init->is_pci && (dev_priv->flags & RADEON_IS_AGP))
 	{
 		DRM_DEBUG("Forcing AGP card to PCI mode\n");
-		dev_priv->flags &= ~CHIP_IS_AGP;
+		dev_priv->flags &= ~RADEON_IS_AGP;
 	}
 
-	if ((!(dev_priv->flags & CHIP_IS_AGP)) && !dev->sg) {
+	if ((!(dev_priv->flags & RADEON_IS_AGP)) && !dev->sg) {
 		DRM_ERROR("PCI GART memory not allocated!\n");
 		radeon_do_cleanup_cp(dev);
 		return DRM_ERR(EINVAL);
@@ -1489,7 +1489,7 @@ static int radeon_do_init_cp(drm_device_
 				    init->sarea_priv_offset);
 
 #if __OS_HAS_AGP
-	if (dev_priv->flags & CHIP_IS_AGP) {
+	if (dev_priv->flags & RADEON_IS_AGP) {
 		drm_core_ioremap(dev_priv->cp_ring, dev);
 		drm_core_ioremap(dev_priv->ring_rptr, dev);
 		drm_core_ioremap(dev->agp_buffer_map, dev);
@@ -1548,7 +1548,7 @@ #endif
 		 * align it down.
 		 */
 #if __OS_HAS_AGP
-		if (dev_priv->flags & CHIP_IS_AGP) {
+		if (dev_priv->flags & RADEON_IS_AGP) {
 			base = dev->agp->base;
 			/* Check if valid */
 			if ((base + dev_priv->gart_size) > dev_priv->fb_location &&
@@ -1578,7 +1578,7 @@ #endif
 	}
 
 #if __OS_HAS_AGP
-	if (dev_priv->flags & CHIP_IS_AGP)
+	if (dev_priv->flags & RADEON_IS_AGP)
 		dev_priv->gart_buffers_offset = (dev->agp_buffer_map->offset
 						 - dev->agp->base
 						 + dev_priv->gart_vm_start);
@@ -1604,7 +1604,7 @@ #endif
 	dev_priv->ring.high_mark = RADEON_RING_HIGH_MARK;
 
 #if __OS_HAS_AGP
-	if (dev_priv->flags & CHIP_IS_AGP) {
+	if (dev_priv->flags & RADEON_IS_AGP) {
 		/* Turn off PCI GART */
 		radeon_set_pcigart(dev_priv, 0);
 	} else
@@ -1624,7 +1624,7 @@ #endif
 			    dev_priv->gart_info.mapping.handle;
 
 			dev_priv->gart_info.is_pcie =
-			    !!(dev_priv->flags & CHIP_IS_PCIE);
+			    !!(dev_priv->flags & RADEON_IS_PCIE);
 			dev_priv->gart_info.gart_table_location =
 			    DRM_ATI_GART_FB;
 
@@ -1636,7 +1636,7 @@ #endif
 			    DRM_ATI_GART_MAIN;
 			dev_priv->gart_info.addr = NULL;
 			dev_priv->gart_info.bus_addr = 0;
-			if (dev_priv->flags & CHIP_IS_PCIE) {
+			if (dev_priv->flags & RADEON_IS_PCIE) {
 				DRM_ERROR
 				    ("Cannot use PCI Express without GART in FB memory\n");
 				radeon_do_cleanup_cp(dev);
@@ -1678,7 +1678,7 @@ static int radeon_do_cleanup_cp(drm_devi
 		drm_irq_uninstall(dev);
 
 #if __OS_HAS_AGP
-	if (dev_priv->flags & CHIP_IS_AGP) {
+	if (dev_priv->flags & RADEON_IS_AGP) {
 		if (dev_priv->cp_ring != NULL) {
 			drm_core_ioremapfree(dev_priv->cp_ring, dev);
 			dev_priv->cp_ring = NULL;
@@ -1733,7 +1733,7 @@ static int radeon_do_resume_cp(drm_devic
 	DRM_DEBUG("Starting radeon_do_resume_cp()\n");
 
 #if __OS_HAS_AGP
-	if (dev_priv->flags & CHIP_IS_AGP) {
+	if (dev_priv->flags & RADEON_IS_AGP) {
 		/* Turn off PCI GART */
 		radeon_set_pcigart(dev_priv, 0);
 	} else
@@ -2177,13 +2177,13 @@ int radeon_driver_load(struct drm_device
 	dev->dev_private = (void *)dev_priv;
 	dev_priv->flags = flags;
 
-	switch (flags & CHIP_FAMILY_MASK) {
+	switch (flags & RADEON_FAMILY_MASK) {
 	case CHIP_R100:
 	case CHIP_RV200:
 	case CHIP_R200:
 	case CHIP_R300:
 	case CHIP_R420:
-		dev_priv->flags |= CHIP_HAS_HIERZ;
+		dev_priv->flags |= RADEON_HAS_HIERZ;
 		break;
 	default:
 		/* all other chips have no hierarchical z buffer */
@@ -2191,13 +2191,13 @@ int radeon_driver_load(struct drm_device
 	}
 
 	if (drm_device_is_agp(dev))
-		dev_priv->flags |= CHIP_IS_AGP;
+		dev_priv->flags |= RADEON_IS_AGP;
 
 	if (drm_device_is_pcie(dev))
-		dev_priv->flags |= CHIP_IS_PCIE;
+		dev_priv->flags |= RADEON_IS_PCIE;
 
 	DRM_DEBUG("%s card detected\n",
-		  ((dev_priv->flags & CHIP_IS_AGP) ? "AGP" : (((dev_priv->flags & CHIP_IS_PCIE) ? "PCIE" : "PCI"))));
+		  ((dev_priv->flags & RADEON_IS_AGP) ? "AGP" : (((dev_priv->flags & RADEON_IS_PCIE) ? "PCIE" : "PCI"))));
 	return ret;
 }
 
drivers/char/drm/radeon_drv.c +52 -8

102 lines not on this page · raw message

drivers/char/drm/radeon_drv.h +11 -11
index e5a256f..e9e20b3 100644
@@ -103,7 +103,7 @@ #define DRIVER_PATCHLEVEL	0
 /*
  * Radeon chip families
  */
-enum radeon_family {
+enum radeondrm_family {
 	CHIP_R100,
 	CHIP_RV100,
 	CHIP_RS100,
@@ -132,16 +132,16 @@ enum radeon_cp_microcode_version {
 /*
  * Chip flags
  */
-enum radeon_chip_flags {
-	CHIP_FAMILY_MASK = 0x0000ffffUL,
-	CHIP_FLAGS_MASK = 0xffff0000UL,
-	CHIP_IS_MOBILITY = 0x00010000UL,
-	CHIP_IS_IGP = 0x00020000UL,
-	CHIP_SINGLE_CRTC = 0x00040000UL,
-	CHIP_IS_AGP = 0x00080000UL,
-	CHIP_HAS_HIERZ = 0x00100000UL,
-	CHIP_IS_PCIE = 0x00200000UL,
-	CHIP_NEW_MEMMAP = 0x00400000UL,
+enum radeondrm_chip_flags {
+	RADEON_FAMILY_MASK = 0x0000ffffUL,
+	RADEON_FLAGS_MASK = 0xffff0000UL,
+	RADEON_IS_MOBILITY = 0x00010000UL,
+	RADEON_IS_IGP = 0x00020000UL,
+	RADEON_SINGLE_CRTC = 0x00040000UL,
+	RADEON_IS_AGP = 0x00080000UL,
+	RADEON_HAS_HIERZ = 0x00100000UL,
+	RADEON_IS_PCIE = 0x00200000UL,
+	RADEON_NEW_MEMMAP = 0x00400000UL,
 };
 
 #define GET_RING_HEAD(dev_priv)	(dev_priv->writeback_works ? \
drivers/char/drm/radeon_state.c +5 -5
index 5bb2234..220e060 100644
@@ -862,7 +862,7 @@ static void radeon_cp_dispatch_clear(drm
 		 */
 		dev_priv->sarea_priv->ctx_owner = 0;
 
-		if ((dev_priv->flags & CHIP_HAS_HIERZ)
+		if ((dev_priv->flags & RADEON_HAS_HIERZ)
 		    && (flags & RADEON_USE_HIERZ)) {
 			/* FIXME : reverse engineer that for Rx00 cards */
 			/* FIXME : the mask supposedly contains low-res z values. So can't set
@@ -907,7 +907,7 @@ static void radeon_cp_dispatch_clear(drm
 		for (i = 0; i < nbox; i++) {
 			int tileoffset, nrtilesx, nrtilesy, j;
 			/* it looks like r200 needs rv-style clears, at least if hierz is not enabled? */
-			if ((dev_priv->flags & CHIP_HAS_HIERZ)
+			if ((dev_priv->flags & RADEON_HAS_HIERZ)
 			    && !(dev_priv->microcode_version == UCODE_R200)) {
 				/* FIXME : figure this out for r200 (when hierz is enabled). Or
 				   maybe r200 actually doesn't need to put the low-res z value into
@@ -991,7 +991,7 @@ static void radeon_cp_dispatch_clear(drm
 		}
 
 		/* TODO don't always clear all hi-level z tiles */
-		if ((dev_priv->flags & CHIP_HAS_HIERZ)
+		if ((dev_priv->flags & RADEON_HAS_HIERZ)
 		    && (dev_priv->microcode_version == UCODE_R200)
 		    && (flags & RADEON_USE_HIERZ))
 			/* r100 and cards without hierarchical z-buffer have no high-level z-buffer */
@@ -2982,9 +2982,9 @@ #endif
 		break;
 	
 	case RADEON_PARAM_CARD_TYPE:
-		if (dev_priv->flags & CHIP_IS_PCIE)
+		if (dev_priv->flags & RADEON_IS_PCIE)
 			value = RADEON_CARD_PCIE;
-		else if (dev_priv->flags & CHIP_IS_AGP)
+		else if (dev_priv->flags & RADEON_IS_AGP)
 			value = RADEON_CARD_AGP;
 		else
 			value = RADEON_CARD_PCI;
Signature · 1 line
1.4.1.ga3e6
#8 lore raw

Re: [PATCH] gpu: Initial GPU layer addition. (03/07)

In reply to Dave Airlie

drivers/video/Kconfig # · line 10

Quoted 4 lines · Dave Airlie
drivers/video/Kconfig +4 -0
+config GPU
+	bool
+	default n
+

Does this change existing userspace ABI or just add a new one (via new files in sysfs)? If the latter, can this config option just be enabled by default or killed entirely, making the build dependent on the higher level CONFIG_DRM option?

drivers/video/gpu_layer.c line 24

Quoted 12 lines
drivers/video/gpu_layer.c new file +12 -0
+/* GPUs we manage */
+LIST_HEAD(gpu_bus_list);
+
+/* used when allocating bus numbers */
+#define GPU_MAXBUS		16
+struct gpu_busmap {
+	unsigned long busmap [GPU_MAXBUS / (8*sizeof (unsigned long))];
+};
+static struct gpu_busmap busmap;
+
+/* used when updating list of gpus */
+DEFINE_MUTEX(gpu_bus_list_lock);

Why 16? Isn't there only one logical 'GPU bus' on the system containing all the graphics devices? Or is this a limit on how many devices can be registered? Or is each device considered a GPU bus in itself?

Quoted 7 lines

+ * This registers a GPU bus with the GPU layer,
+ * it fills in a default bus match function, and adds the device to the list + */

drivers/video/gpu_layer.c new file +4 -0
+int gpu_register_bus(struct gpu_bus *bus)
+{
+	int busnum;
+

drivers/video/gpu_layer.c line 174

Quoted 10 lines
drivers/video/gpu_layer.c new file +10 -0
+	mutex_lock(&gpu_bus_list_lock);
+
+	busnum = find_next_zero_bit(busmap.busmap, GPU_MAXBUS, 1);
+	if (busnum < GPU_MAXBUS) {
+		set_bit(busnum, busmap.busmap);
+		bus->busnum = busnum;
+	} else {
+		printk(KERN_ERR "%s: to many buses\n", "gpu");
+		mutex_unlock(&gpu_bus_list_lock);
+		return -E2BIG;

Is this the right return value or should it be -ENOSPC? Also, I think you mean "too" on the previous line (figured I'd metion it before the spelling nazis get to you :).

Overall, seems like a nice layer to help with fb/drm coordination and possibly power management & suspend/resume.

Thanks,
Jesse

#9 lore raw

Re: [PATCH] gpu: Initial GPU layer addition. (03/07)

In reply to Dave Airlie

Nice stuff! A couple of total nits and a check to see if I'm understanding something.

On 22 Jul 2006, Dave Airlie noted:

Quoted 1 line

+ * If the driver type matches thte device, call the bus match function.

Typo.

drivers/video/gpu_layer.c line 172

Quoted 1 line
drivers/video/gpu_layer.c new file +1 -0
+		printk(KERN_ERR "%s: to many buses\n", "gpu");

Another typo.

Quoted 10 lines
drivers/video/gpu_layer.c new file +10 -0
+/**
+ * gpu_alloc_devices
+ *
+ * Allocate and initialise the GPU sub-devices.
+ */
+int gpu_alloc_devices(struct gpu_bus *bus)
+{
+	struct gpu_device *dev;
+	int i;
+

drivers/video/gpu_layer.c line 222

Quoted 10 lines
drivers/video/gpu_layer.c new file +10 -0
+	for (i=0; i<bus->num_subdev; i++) {
+		dev = kzalloc(sizeof(*dev), GFP_KERNEL);
+		if (!dev)
+			return -ENOMEM;
+
+		bus = gpu_bus_get(bus);
+		if (!bus) {
+			kfree(dev);
+			return -ENOMEM;
+		}

If we fall out of either of these paths, what does the bus look like? Does it end up with half its sub-devices on? (I don't *think* we end up leaking dev's allocated earlier....)

Quoted 7 lines
drivers/video/gpu_layer.c new file +7 -0
+/**
+ * gpu_unregister_devices
+ */
+int gpu_unregister_devices(struct gpu_bus *bus)
+{
+	int i;
+

drivers/video/gpu_layer.c line 281

Quoted 10 lines
drivers/video/gpu_layer.c new file +10 -0
+	for (i = 0; i < bus->num_subdev; i++) {
+		struct gpu_device *gpu_dev = bus->devices[i];
+
+		device_del(&gpu_dev->dev);
+
+		kfree(gpu_dev);
+		bus->devices[i] = NULL;
+	}
+	return 0;
+}

... because I think this would still catch them. Am I right?

Signature · 2 lines
`We're sysadmins. We deal with the inconceivable so often I can clearly 
 see the need to define levels of inconceivability.' --- Rik Steenwinkel
#10 lore raw

Re: [PATCH] gpu: Initial GPU layer addition. (03/07)

In reply to Dave Airlie

Dave Airlie <[email protected]> ha scritto:

Quoted 16 lines
drivers/video/gpu_layer.c new file +10 -0
new file mode 100644
index 0000000..36e7037
@@ -0,0 +1,393 @@
+/*
+ * drivers/video/gpu_layer.c
+ *
+ * (C) Copyright Dave Airlie 2006
+ *
+ */
+#include <linux/device.h>
+#include <linux/list.h>
+#include <linux/mutex.h>
+#include <linux/pci.h>

drivers/video/gpu_layer.c line 20

Quoted 10 lines
drivers/video/gpu_layer.c new file +10 -0
+#include <linux/gpu_layer.h>
+
+/* GPUs we manage */
+LIST_HEAD(gpu_bus_list);
+
+/* used when allocating bus numbers */
+#define GPU_MAXBUS             16
+struct gpu_busmap {
+       unsigned long busmap [GPU_MAXBUS / (8*sizeof (unsigned long))];
+};

16 / (8 * 4) is zero (the same with sizeof(long) == 8). When doing bit ops on that zero-sized array you are probably corrupting the BSS.

Luca

Signature · 3 lines
Home: http://kronoz.cjb.net
Recursion n.:
	See Recursion.
#11 lore raw

Re: [PATCH] drm: remove pci domain local copy (02/07)

In reply to Dave Airlie

drivers/char/drm/drmP.h static __inline__ int drm_core_check_fea

Quoted 24 lines · Dave Airlie

Just call a function to retrieve the pci domain, this isn't exactly hotpath code.

(cherry picked from 01852d755753bbfcd5434c55d4d7375580f8338f commit)

---
 drivers/char/drm/drmP.h      |   10 +++++++++-
 drivers/char/drm/drm_ioctl.c |    4 ++--
 drivers/char/drm/drm_irq.c   |    2 +-
 3 files changed, 12 insertions(+), 4 deletions(-)
drivers/char/drm/drmP.h +0 -1
index 5c8f245..4dd28e1 100644
@@ -711,7 +711,6 @@ typedef struct drm_device {
 	drm_agp_head_t *agp;	/**< AGP data */
 
 	struct pci_dev *pdev;		/**< PCI device structure */
-	int pci_domain;			/**< PCI bus domain number */
 #ifdef __alpha__
 	struct pci_controller *hose;
 #endif
@@ -733,6 +732,15 @@ static __inline__ int drm_core_check_fea

I would presume that hose goes away too?

drivers/char/drm/drmP.h static __inline__ int drm_core_check_fea · line 742

Quoted 8 lines
drivers/char/drm/drmP.h +8 -0
+static inline int drm_get_pci_domain(struct drm_device *dev)
+{
+#ifdef __alpha__
+	return dev->hose->bus->number;
+#else
+	return 0;
+#endif
+}

Please use the always-present pci_domain_nr() rather than inventing a DRM-specific function that does the same thing.

Jeff

#12 lore raw

Re: [PATCH] drm: remove pci domain local copy (02/07)

Quoted 2 lines

I would presume that hose goes away too?

Well not yet as I used it below...

Quoted 11 lines

drivers/char/drm/drmP.h static __inline__ int drm_core_check_fea · line 742

Quoted 9 lines
drivers/char/drm/drmP.h +8 -0
+static inline int drm_get_pci_domain(struct drm_device *dev)
+{
+#ifdef __alpha__
+	return dev->hose->bus->number;
+#else
+	return 0;
+#endif
+}

Please use the always-present pci_domain_nr() rather than inventing a DRM-specific function that does the same thing.

Ah well I didn't know that existed, I merely was just moving some code in the DRM into another function in the DRM, it didn't occur that someone might have a generic function and not put it into the DRM code.. I'll look into it thanks,

Dave.

Signature · 3 lines
David Airlie, Software Engineer
http://www.skynet.ie/~airlied / airlied at skynet.ie
Linux kernel - DRI, VAX / pam_smb / ILUG
#13 lore raw
In reply to Dave Airlie
Quoted 1 line · Dave Airlie

This patchset contains 7 patches to implement the GPU device layer.

Where can I find more info on why this might be nice? Or simply more info on what this actually does for me?

Jeff

#14 lore raw
Quoted 5 lines

Where can I find more info on why this might be nice? Or simply more info on what this actually does for me?

It does nothing for you yet, it is just step one for getting the DRM and framebuffer drivers to co-exist in the driver model world, with the next step being allowing a channel of communication between the two layers with a view that later I can ask the DRM to disable fbdev or pass info to it..

Why do we not want fbdev and DRM in one driver? as it would break way too many existing systems..

It also allows DRM to get called at suspend/resume time.

Dave.

Signature · 3 lines
David Airlie, Software Engineer
http://www.skynet.ie/~airlied / airlied at skynet.ie
Linux kernel - DRI, VAX / pam_smb / ILUG
#15 lore raw

Hi!

Quoted 8 lines
Quoted 2 lines

Where can I find more info on why this might be nice? Or simply more info on what this actually does for me?

It does nothing for you yet, it is just step one for getting the DRM and framebuffer drivers to co-exist in the driver model world, with the next step being allowing a channel of communication between the two layers with a view that later I can ask the DRM to disable fbdev or pass info to it..

Quoted 4 lines

Why do we not want fbdev and DRM in one driver? as it would break way too many existing systems..

It also allows DRM to get called at suspend/resume time.

Looks good to me. I guess I should get DRM working...

I actually tried a bit, and got some reasonably-recent Xserver here, but now I get

root@amd:/home/pavel# glxinfo
name of display: :0.0

ERROR! sizeof(I830DRIRec) does not match passed size from device driver
libGL warning: 3D driver returned no fbconfigs.
libGL error: InitDriver failed
libGL error: reverting to (slow) indirect rendering
display: :0 screen: 0
direct rendering: No
server glx vendor string: SGI
server glx version string: 1.2
server glx extensions:

:-(
Pavel

Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html