svn commit: r254820 - head/sys/dev/drm2

Jean-Sebastien Pedron dumbbell at FreeBSD.org
Sun Aug 25 00:13:54 UTC 2013


Author: dumbbell
Date: Sun Aug 25 00:13:53 2013
New Revision: 254820
URL: http://svnweb.freebsd.org/changeset/base/254820

Log:
  drm: Use driver-provided "use_msi" callback to determine if MSI is blacklisted
  
  For now, keep the static array for i915. But eventually, it should be
  moved to a callback in the driver itself.

Modified:
  head/sys/dev/drm2/drmP.h
  head/sys/dev/drm2/drm_drv.c

Modified: head/sys/dev/drm2/drmP.h
==============================================================================
--- head/sys/dev/drm2/drmP.h	Sat Aug 24 23:54:06 2013	(r254819)
+++ head/sys/dev/drm2/drmP.h	Sun Aug 25 00:13:53 2013	(r254820)
@@ -698,6 +698,7 @@ struct drm_gem_object {
 
 struct drm_driver_info {
 	int	(*load)(struct drm_device *, unsigned long flags);
+	int	(*use_msi)(struct drm_device *, unsigned long flags);
 	int	(*firstopen)(struct drm_device *);
 	int	(*open)(struct drm_device *, struct drm_file *);
 	void	(*preclose)(struct drm_device *, struct drm_file *file_priv);
@@ -829,8 +830,10 @@ struct drm_device {
 	struct drm_driver_info *driver;
 	drm_pci_id_list_t *id_entry;	/* PCI ID, name, and chipset private */
 
-	u_int16_t pci_device;		/* PCI device id */
-	u_int16_t pci_vendor;		/* PCI vendor id */
+	uint16_t pci_device;		/* PCI device id */
+	uint16_t pci_vendor;		/* PCI vendor id */
+	uint16_t pci_subdevice;		/* PCI subsystem device id */
+	uint16_t pci_subvendor;		/* PCI subsystem vendor id */
 
 	char		  *unique;	/* Unique identifier: e.g., busid  */
 	int		  unique_len;	/* Length of unique field	   */

Modified: head/sys/dev/drm2/drm_drv.c
==============================================================================
--- head/sys/dev/drm2/drm_drv.c	Sat Aug 24 23:54:06 2013	(r254819)
+++ head/sys/dev/drm2/drm_drv.c	Sun Aug 25 00:13:53 2013	(r254820)
@@ -209,13 +209,22 @@ static struct drm_msi_blacklist_entry dr
 	{0, 0}
 };
 
-static int drm_msi_is_blacklisted(int vendor, int device)
+static int drm_msi_is_blacklisted(struct drm_device *dev, unsigned long flags)
 {
 	int i = 0;
 
+	if (dev->driver->use_msi != NULL) {
+		int use_msi;
+
+		use_msi = dev->driver->use_msi(dev, flags);
+
+		return (!use_msi);
+	}
+
+	/* TODO: Maybe move this to a callback in i915? */
 	for (i = 0; drm_msi_blacklist[i].vendor != 0; i++) {
-		if ((drm_msi_blacklist[i].vendor == vendor) &&
-		    (drm_msi_blacklist[i].device == device)) {
+		if ((drm_msi_blacklist[i].vendor == dev->pci_vendor) &&
+		    (drm_msi_blacklist[i].device == dev->pci_device)) {
 			return 1;
 		}
 	}
@@ -264,10 +273,16 @@ int drm_attach(device_t kdev, drm_pci_id
 
 	dev->pci_vendor = pci_get_vendor(dev->device);
 	dev->pci_device = pci_get_device(dev->device);
+	dev->pci_subvendor = pci_get_subvendor(dev->device);
+	dev->pci_subdevice = pci_get_subdevice(dev->device);
+
+	id_entry = drm_find_description(dev->pci_vendor,
+	    dev->pci_device, idlist);
+	dev->id_entry = id_entry;
 
 	if (drm_core_check_feature(dev, DRIVER_HAVE_IRQ)) {
 		if (drm_msi &&
-		    !drm_msi_is_blacklisted(dev->pci_vendor, dev->pci_device)) {
+		    !drm_msi_is_blacklisted(dev, dev->id_entry->driver_private)) {
 			msicount = pci_msi_count(dev->device);
 			DRM_DEBUG("MSI count = %d\n", msicount);
 			if (msicount > 1)
@@ -297,10 +312,6 @@ int drm_attach(device_t kdev, drm_pci_id
 	mtx_init(&dev->event_lock, "drmev", NULL, MTX_DEF);
 	sx_init(&dev->dev_struct_lock, "drmslk");
 
-	id_entry = drm_find_description(dev->pci_vendor,
-	    dev->pci_device, idlist);
-	dev->id_entry = id_entry;
-
 	error = drm_load(dev);
 	if (error == 0)
 		error = drm_create_cdevs(kdev);


More information about the svn-src-all mailing list