[kernel/f17] Add and use vga_default_device patches (requested by Matthew Garrett)

Josh Boyer jwboyer at fedoraproject.org
Tue Apr 17 01:27:44 UTC 2012


commit 6ae0c8402e0eef41ae630d75dd2548bc197e0172
Author: Josh Boyer <jwboyer at redhat.com>
Date:   Mon Apr 16 20:34:04 2012 -0400

    Add and use vga_default_device patches (requested by Matthew Garrett)

 kernel.spec                     |    6 +
 vgaarb-vga_default_device.patch |  552 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 558 insertions(+), 0 deletions(-)
---
diff --git a/kernel.spec b/kernel.spec
index 8d8bf84..95b8f85 100644
--- a/kernel.spec
+++ b/kernel.spec
@@ -788,6 +788,8 @@ Patch21530: ALSA-hda-realtek-Add-quirk-for-Mac-Pro-5-1-machines.patch
 Patch21600: apple_bl-Add-register-unregister-functions.patch
 Patch21601: platform-x86-Add-driver-for-Apple-gmux-device.patch
 
+Patch21620: vgaarb-vga_default_device.patch
+
 Patch22000: weird-root-dentry-name-debug.patch
 
 #selinux ptrace child permissions
@@ -1535,6 +1537,9 @@ ApplyPatch selinux-apply-different-permission-to-ptrace-child.patch
 ApplyPatch apple_bl-Add-register-unregister-functions.patch
 ApplyPatch platform-x86-Add-driver-for-Apple-gmux-device.patch
 
+#vgaarb patches.  blame mjg59
+ApplyPatch vgaarb-vga_default_device.patch
+
 # END OF PATCH APPLICATIONS
 
 %endif
@@ -2380,6 +2385,7 @@ fi
 #              '-'
 %changelog
 * Mon Apr 16 2012 Josh Boyer <jwboyer at redhat.com>
+- Add and use vga_default_device patches (requested by Matthew Garrett)
 - Add platform driver for Apple GMUX device (requested by Matthew Garrett)
 
 * Sat Apr 14 2012 Josh Boyer <jwboyer at redhat.com>
diff --git a/vgaarb-vga_default_device.patch b/vgaarb-vga_default_device.patch
new file mode 100644
index 0000000..c67c6c8
--- /dev/null
+++ b/vgaarb-vga_default_device.patch
@@ -0,0 +1,552 @@
+                                                                                                                                                                                                                                                               
+Delivered-To: jwboyer at gmail.com
+Received: by 10.229.187.201 with SMTP id cx9csp141480qcb;
+        Mon, 16 Apr 2012 13:27:50 -0700 (PDT)
+Received: by 10.60.0.201 with SMTP id 9mr17463209oeg.59.1334608065659;
+        Mon, 16 Apr 2012 13:27:45 -0700 (PDT)
+Return-Path: <linux-kernel-owner at vger.kernel.org>
+Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67])
+        by mx.google.com with ESMTP id 4si12245496oei.14.2012.04.16.13.27.44;
+        Mon, 16 Apr 2012 13:27:45 -0700 (PDT)
+Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner at vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67;
+Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner at vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mail=linux-kernel-owner at vger.kernel.org
+Received: (majordomo at vger.kernel.org) by vger.kernel.org via listexpand
+	id S1755065Ab2DPU02 (ORCPT <rfc822;padmanabhlinux at gmail.com>
+	+ 99 others); Mon, 16 Apr 2012 16:26:28 -0400
+Received: from mx1.redhat.com ([209.132.183.28]:1184 "EHLO mx1.redhat.com"
+	rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP
+	id S1754698Ab2DPU01 (ORCPT <rfc822;linux-kernel at vger.kernel.org>);
+	Mon, 16 Apr 2012 16:26:27 -0400
+Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11])
+	by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q3GKQPYb007336
+	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK);
+	Mon, 16 Apr 2012 16:26:25 -0400
+Received: from cavan.codon.org.uk (ovpn-113-122.phx2.redhat.com [10.3.113.122])
+	by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id q3GKQNG5011412
+	(version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO);
+	Mon, 16 Apr 2012 16:26:24 -0400
+Received: from nat-pool-rdu.redhat.com ([66.187.233.202] helo=x220.boston.devel.redhat.com)
+	by cavan.codon.org.uk with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
+	(Exim 4.72)
+	(envelope-from <mjg at redhat.com>)
+	id 1SJsVA-0003T4-U8; Mon, 16 Apr 2012 21:26:21 +0100
+From:	Matthew Garrett <mjg at redhat.com>
+To:	linux-kernel at vger.kernel.org
+Cc:	Matthew Garrett <mjg at redhat.com>, benh at kernel.crashing.org,
+	airlied at redhat.com
+Subject: [PATCH V2 1/4] vgaarb: Add support for setting the default video device
+Date:	Mon, 16 Apr 2012 16:26:02 -0400
+Message-Id: <1334607965-9582-1-git-send-email-mjg at redhat.com>
+X-SA-Do-Not-Run: Yes
+X-SA-Exim-Connect-IP: 66.187.233.202
+X-SA-Exim-Mail-From: mjg at redhat.com
+X-SA-Exim-Scanned: No (on cavan.codon.org.uk); SAEximRunCond expanded to false
+X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11
+Sender:	linux-kernel-owner at vger.kernel.org
+Precedence: bulk
+List-ID: <linux-kernel.vger.kernel.org>
+X-Mailing-List:	linux-kernel at vger.kernel.org
+
+The default VGA device is a somewhat fluid concept on platforms with
+multiple GPUs. Add support for setting it so switching code can update
+things appropriately, and make sure that the sysfs code returns the right
+device if it's changed.
+
+Signed-off-by: Matthew Garrett <mjg at redhat.com>
+Cc: benh at kernel.crashing.org
+Cc: airlied at redhat.com
+---
+Updated to fix builds when __ARCH_HAS_VGA_DEFAULT_DEVICE is false.
+
+ drivers/gpu/vga/vgaarb.c |    7 +++++++
+ drivers/pci/pci-sysfs.c  |    5 +++++
+ include/linux/vgaarb.h   |    2 ++
+ 3 files changed, 14 insertions(+)
+
+diff --git a/drivers/gpu/vga/vgaarb.c b/drivers/gpu/vga/vgaarb.c
+index 111d956..e223b96 100644
+--- a/drivers/gpu/vga/vgaarb.c
++++ b/drivers/gpu/vga/vgaarb.c
+@@ -136,6 +136,11 @@ struct pci_dev *vga_default_device(void)
+ {
+ 	return vga_default;
+ }
++
++void vga_set_default_device(struct pci_dev *pdev)
++{
++	vga_default = pdev;
++}
+ #endif
+ 
+ static inline void vga_irq_set_state(struct vga_device *vgadev, bool state)
+@@ -605,10 +610,12 @@ static bool vga_arbiter_del_pci_device(struct pci_dev *pdev)
+ 		goto bail;
+ 	}
+ 
++#ifndef __ARCH_HAS_VGA_DEFAULT_DEVICE
+ 	if (vga_default == pdev) {
+ 		pci_dev_put(vga_default);
+ 		vga_default = NULL;
+ 	}
++#endif
+ 
+ 	if (vgadev->decodes & (VGA_RSRC_LEGACY_IO | VGA_RSRC_LEGACY_MEM))
+ 		vga_decode_count--;
+diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
+index a3cd8ca..7dd9f2b 100644
+--- a/drivers/pci/pci-sysfs.c
++++ b/drivers/pci/pci-sysfs.c
+@@ -27,6 +27,7 @@
+ #include <linux/security.h>
+ #include <linux/pci-aspm.h>
+ #include <linux/slab.h>
++#include <linux/vgaarb.h>
+ #include "pci.h"
+ 
+ static int sysfs_initialized;	/* = 0 */
+@@ -414,6 +415,10 @@ static ssize_t
+ boot_vga_show(struct device *dev, struct device_attribute *attr, char *buf)
+ {
+ 	struct pci_dev *pdev = to_pci_dev(dev);
++	struct pci_dev *vga_dev = vga_default_device();
++
++	if (vga_dev)
++		return sprintf(buf, "%u\n", (pdev == vga_dev));
+ 
+ 	return sprintf(buf, "%u\n",
+ 		!!(pdev->resource[PCI_ROM_RESOURCE].flags &
+diff --git a/include/linux/vgaarb.h b/include/linux/vgaarb.h
+index 9c3120d..759a25b 100644
+--- a/include/linux/vgaarb.h
++++ b/include/linux/vgaarb.h
+@@ -31,6 +31,7 @@
+ #ifndef LINUX_VGA_H
+ #define LINUX_VGA_H
+ 
++#include <video/vga.h>
+ 
+ /* Legacy VGA regions */
+ #define VGA_RSRC_NONE	       0x00
+@@ -181,6 +182,7 @@ extern void vga_put(struct pci_dev *pdev, unsigned int rsrc);
+ 
+ #ifndef __ARCH_HAS_VGA_DEFAULT_DEVICE
+ extern struct pci_dev *vga_default_device(void);
++extern void vga_set_default_device(struct pci_dev *pdev);
+ #endif
+ 
+ /**
+-- 
+1.7.10
+
+--
+To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
+the body of a message to majordomo at vger.kernel.org
+More majordomo info at  http://vger.kernel.org/majordomo-info.html
+Please read the FAQ at  http://www.tux.org/lkml/
+                                                                                                                                                                                                                                                               
+Delivered-To: jwboyer at gmail.com
+Received: by 10.229.187.201 with SMTP id cx9csp141468qcb;
+        Mon, 16 Apr 2012 13:27:10 -0700 (PDT)
+Received: by 10.182.202.69 with SMTP id kg5mr18039202obc.35.1334608025784;
+        Mon, 16 Apr 2012 13:27:05 -0700 (PDT)
+Return-Path: <linux-kernel-owner at vger.kernel.org>
+Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67])
+        by mx.google.com with ESMTP id p9si5895556obv.34.2012.04.16.13.27.01;
+        Mon, 16 Apr 2012 13:27:05 -0700 (PDT)
+Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner at vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67;
+Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner at vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mail=linux-kernel-owner at vger.kernel.org
+Received: (majordomo at vger.kernel.org) by vger.kernel.org via listexpand
+	id S1755523Ab2DPU0b (ORCPT <rfc822;padmanabhlinux at gmail.com>
+	+ 99 others); Mon, 16 Apr 2012 16:26:31 -0400
+Received: from mx1.redhat.com ([209.132.183.28]:15578 "EHLO mx1.redhat.com"
+	rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP
+	id S1752993Ab2DPU00 (ORCPT <rfc822;linux-kernel at vger.kernel.org>);
+	Mon, 16 Apr 2012 16:26:26 -0400
+Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25])
+	by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q3GKQPu2015452
+	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK)
+	for <linux-kernel at vger.kernel.org>; Mon, 16 Apr 2012 16:26:25 -0400
+Received: from cavan.codon.org.uk (ovpn-113-122.phx2.redhat.com [10.3.113.122])
+	by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q3GKQOk2005441
+	(version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO);
+	Mon, 16 Apr 2012 16:26:25 -0400
+Received: from nat-pool-rdu.redhat.com ([66.187.233.202] helo=x220.boston.devel.redhat.com)
+	by cavan.codon.org.uk with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
+	(Exim 4.72)
+	(envelope-from <mjg at redhat.com>)
+	id 1SJsVC-0003T4-AS; Mon, 16 Apr 2012 21:26:22 +0100
+From:	Matthew Garrett <mjg at redhat.com>
+To:	linux-kernel at vger.kernel.org
+Cc:	Matthew Garrett <mjg at redhat.com>, airlied at redhat.com
+Subject: [PATCH V2 2/4] vga-switcheroo: Use vga_default_device()
+Date:	Mon, 16 Apr 2012 16:26:03 -0400
+Message-Id: <1334607965-9582-2-git-send-email-mjg at redhat.com>
+In-Reply-To: <1334607965-9582-1-git-send-email-mjg at redhat.com>
+References: <1334607965-9582-1-git-send-email-mjg at redhat.com>
+X-SA-Do-Not-Run: Yes
+X-SA-Exim-Connect-IP: 66.187.233.202
+X-SA-Exim-Mail-From: mjg at redhat.com
+X-SA-Exim-Scanned: No (on cavan.codon.org.uk); SAEximRunCond expanded to false
+X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25
+Sender:	linux-kernel-owner at vger.kernel.org
+Precedence: bulk
+List-ID: <linux-kernel.vger.kernel.org>
+X-Mailing-List:	linux-kernel at vger.kernel.org
+
+vga-switcheroo currently changes the default VGA device by fiddling with
+the IORESOURCE_ROM_SHADOW flag on the device. This isn't strictly accurate,
+since there's no guarantee that switching also changes the ROM decoding.
+Switch over to using the vgaarb functions for this.
+
+Signed-off-by: Matthew Garrett <mjg at redhat.com>
+Cc: airlied at redhat.com
+---
+ drivers/gpu/vga/vga_switcheroo.c |    9 +++++----
+ 1 file changed, 5 insertions(+), 4 deletions(-)
+
+diff --git a/drivers/gpu/vga/vga_switcheroo.c b/drivers/gpu/vga/vga_switcheroo.c
+index 9a2c805..44c664e 100644
+--- a/drivers/gpu/vga/vga_switcheroo.c
++++ b/drivers/gpu/vga/vga_switcheroo.c
+@@ -28,6 +28,8 @@
+ #include <linux/pci.h>
+ #include <linux/vga_switcheroo.h>
+ 
++#include <linux/vgaarb.h>
++
+ struct vga_switcheroo_client {
+ 	struct pci_dev *pdev;
+ 	struct fb_info *fb_info;
+@@ -140,7 +142,7 @@ int vga_switcheroo_register_client(struct pci_dev *pdev,
+ 	vgasr_priv.clients[index].reprobe = reprobe;
+ 	vgasr_priv.clients[index].can_switch = can_switch;
+ 	vgasr_priv.clients[index].id = -1;
+-	if (pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW)
++	if (pdev == vga_default_device())
+ 		vgasr_priv.clients[index].active = true;
+ 
+ 	vgasr_priv.registered_clients |= (1 << index);
+@@ -248,9 +250,8 @@ static int vga_switchto_stage1(struct vga_switcheroo_client *new_client)
+ 	if (new_client->pwr_state == VGA_SWITCHEROO_OFF)
+ 		vga_switchon(new_client);
+ 
+-	/* swap shadow resource to denote boot VGA device has changed so X starts on new device */
+-	active->pdev->resource[PCI_ROM_RESOURCE].flags &= ~IORESOURCE_ROM_SHADOW;
+-	new_client->pdev->resource[PCI_ROM_RESOURCE].flags |= IORESOURCE_ROM_SHADOW;
++	vga_set_default_device(new_client->pdev);
++
+ 	return 0;
+ }
+ 
+-- 
+1.7.10
+
+--
+To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
+the body of a message to majordomo at vger.kernel.org
+More majordomo info at  http://vger.kernel.org/majordomo-info.html
+Please read the FAQ at  http://www.tux.org/lkml/
+                                                                                                                                                                                                                                                               
+Delivered-To: jwboyer at gmail.com
+Received: by 10.229.187.201 with SMTP id cx9csp141463qcb;
+        Mon, 16 Apr 2012 13:27:04 -0700 (PDT)
+Received: by 10.60.10.137 with SMTP id i9mr18822682oeb.23.1334608019708;
+        Mon, 16 Apr 2012 13:26:59 -0700 (PDT)
+Return-Path: <linux-kernel-owner at vger.kernel.org>
+Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67])
+        by mx.google.com with ESMTP id h6si5711741obv.22.2012.04.16.13.26.58;
+        Mon, 16 Apr 2012 13:26:59 -0700 (PDT)
+Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner at vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67;
+Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner at vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mail=linux-kernel-owner at vger.kernel.org
+Received: (majordomo at vger.kernel.org) by vger.kernel.org via listexpand
+	id S1755396Ab2DPU0a (ORCPT <rfc822;padmanabhlinux at gmail.com>
+	+ 99 others); Mon, 16 Apr 2012 16:26:30 -0400
+Received: from mx1.redhat.com ([209.132.183.28]:4863 "EHLO mx1.redhat.com"
+	rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP
+	id S1754084Ab2DPU01 (ORCPT <rfc822;linux-kernel at vger.kernel.org>);
+	Mon, 16 Apr 2012 16:26:27 -0400
+Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23])
+	by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q3GKQQrr007340
+	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK);
+	Mon, 16 Apr 2012 16:26:26 -0400
+Received: from cavan.codon.org.uk (ovpn-113-122.phx2.redhat.com [10.3.113.122])
+	by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q3GKQPuK005698
+	(version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO);
+	Mon, 16 Apr 2012 16:26:26 -0400
+Received: from nat-pool-rdu.redhat.com ([66.187.233.202] helo=x220.boston.devel.redhat.com)
+	by cavan.codon.org.uk with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
+	(Exim 4.72)
+	(envelope-from <mjg at redhat.com>)
+	id 1SJsVD-0003T4-F3; Mon, 16 Apr 2012 21:26:23 +0100
+From:	Matthew Garrett <mjg at redhat.com>
+To:	linux-kernel at vger.kernel.org
+Cc:	Matthew Garrett <mjg at redhat.com>, mingo at redhat.com, hpa at zytor.com
+Subject: [PATCH V2 3/4] x86: Use vga_default_device() when determining whether an fb is primary
+Date:	Mon, 16 Apr 2012 16:26:04 -0400
+Message-Id: <1334607965-9582-3-git-send-email-mjg at redhat.com>
+In-Reply-To: <1334607965-9582-1-git-send-email-mjg at redhat.com>
+References: <1334607965-9582-1-git-send-email-mjg at redhat.com>
+X-SA-Do-Not-Run: Yes
+X-SA-Exim-Connect-IP: 66.187.233.202
+X-SA-Exim-Mail-From: mjg at redhat.com
+X-SA-Exim-Scanned: No (on cavan.codon.org.uk); SAEximRunCond expanded to false
+X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23
+Sender:	linux-kernel-owner at vger.kernel.org
+Precedence: bulk
+List-ID: <linux-kernel.vger.kernel.org>
+X-Mailing-List:	linux-kernel at vger.kernel.org
+
+IORESOURCE_ROM_SHADOW is not necessarily an indication that the hardware
+is the primary device. Add support for using the vgaarb functions and
+fall back if nothing's set them.
+
+Signed-off-by: Matthew Garrett <mjg at redhat.com>
+Cc: mingo at redhat.com
+Cc: hpa at zytor.com
+---
+ arch/x86/video/fbdev.c |   20 +++++++++++++++-----
+ 1 file changed, 15 insertions(+), 5 deletions(-)
+
+diff --git a/arch/x86/video/fbdev.c b/arch/x86/video/fbdev.c
+index c5ffb6a..d5644bb 100644
+--- a/arch/x86/video/fbdev.c
++++ b/arch/x86/video/fbdev.c
+@@ -9,24 +9,34 @@
+ #include <linux/fb.h>
+ #include <linux/pci.h>
+ #include <linux/module.h>
++#include <linux/vgaarb.h>
+ 
+ int fb_is_primary_device(struct fb_info *info)
+ {
+ 	struct device *device = info->device;
+ 	struct pci_dev *pci_dev = NULL;
++	struct pci_dev *default_device = vga_default_device();
+ 	struct resource *res = NULL;
+-	int retval = 0;
+ 
+ 	if (device)
+ 		pci_dev = to_pci_dev(device);
+ 
+-	if (pci_dev)
+-		res = &pci_dev->resource[PCI_ROM_RESOURCE];
++	if (!pci_dev)
++		return 0;
++
++	if (default_device) {
++		if (pci_dev == default_device)
++			return 1;
++		else
++			return 0;
++	}
++
++	res = &pci_dev->resource[PCI_ROM_RESOURCE];
+ 
+ 	if (res && res->flags & IORESOURCE_ROM_SHADOW)
+-		retval = 1;
++		return 1;
+ 
+-	return retval;
++	return 0;
+ }
+ EXPORT_SYMBOL(fb_is_primary_device);
+ MODULE_LICENSE("GPL");
+-- 
+1.7.10
+
+--
+To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
+the body of a message to majordomo at vger.kernel.org
+More majordomo info at  http://vger.kernel.org/majordomo-info.html
+Please read the FAQ at  http://www.tux.org/lkml/
+                                                                                                                                                                                                                                                               
+Delivered-To: jwboyer at gmail.com
+Received: by 10.229.187.201 with SMTP id cx9csp141467qcb;
+        Mon, 16 Apr 2012 13:27:10 -0700 (PDT)
+Received: by 10.182.183.73 with SMTP id ek9mr17996942obc.15.1334608026429;
+        Mon, 16 Apr 2012 13:27:06 -0700 (PDT)
+Return-Path: <linux-kernel-owner at vger.kernel.org>
+Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67])
+        by mx.google.com with ESMTP id ry6si1466151obc.95.2012.04.16.13.27.02;
+        Mon, 16 Apr 2012 13:27:06 -0700 (PDT)
+Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner at vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67;
+Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner at vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mail=linux-kernel-owner at vger.kernel.org
+Received: (majordomo at vger.kernel.org) by vger.kernel.org via listexpand
+	id S1755405Ab2DPU0z (ORCPT <rfc822;padmanabhlinux at gmail.com>
+	+ 99 others); Mon, 16 Apr 2012 16:26:55 -0400
+Received: from mx1.redhat.com ([209.132.183.28]:27749 "EHLO mx1.redhat.com"
+	rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP
+	id S1755265Ab2DPU03 (ORCPT <rfc822;linux-kernel at vger.kernel.org>);
+	Mon, 16 Apr 2012 16:26:29 -0400
+Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25])
+	by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q3GKQShl015458
+	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK);
+	Mon, 16 Apr 2012 16:26:28 -0400
+Received: from cavan.codon.org.uk (ovpn-113-122.phx2.redhat.com [10.3.113.122])
+	by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q3GKQQwW005450
+	(version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO);
+	Mon, 16 Apr 2012 16:26:27 -0400
+Received: from nat-pool-rdu.redhat.com ([66.187.233.202] helo=x220.boston.devel.redhat.com)
+	by cavan.codon.org.uk with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
+	(Exim 4.72)
+	(envelope-from <mjg at redhat.com>)
+	id 1SJsVE-0003T4-Uv; Mon, 16 Apr 2012 21:26:25 +0100
+From:	Matthew Garrett <mjg at redhat.com>
+To:	linux-kernel at vger.kernel.org
+Cc:	Matthew Garrett <mjg at redhat.com>, hpa at zytor.com,
+	matt.fleming at intel.com
+Subject: [PATCH V2 4/4] efifb: Implement vga_default_device()
+Date:	Mon, 16 Apr 2012 16:26:05 -0400
+Message-Id: <1334607965-9582-4-git-send-email-mjg at redhat.com>
+In-Reply-To: <1334607965-9582-1-git-send-email-mjg at redhat.com>
+References: <1334607965-9582-1-git-send-email-mjg at redhat.com>
+X-SA-Do-Not-Run: Yes
+X-SA-Exim-Connect-IP: 66.187.233.202
+X-SA-Exim-Mail-From: mjg at redhat.com
+X-SA-Exim-Scanned: No (on cavan.codon.org.uk); SAEximRunCond expanded to false
+X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25
+Sender:	linux-kernel-owner at vger.kernel.org
+Precedence: bulk
+List-ID: <linux-kernel.vger.kernel.org>
+X-Mailing-List:	linux-kernel at vger.kernel.org
+
+EFI doesn't typically make use of the legacy VGA ROM, but it may still be
+configured to pass that through to a given video device. This may lead to
+an inaccurate choice of default video device. Add support to efifb to pick
+out the correct active video device.
+
+Signed-off-by: Matthew Garrett <mjg at redhat.com>
+Cc: hpa at zytor.com
+Cc: matt.fleming at intel.com
+---
+ arch/x86/include/asm/vga.h |    6 ++++
+ drivers/video/efifb.c      |   77 ++++++++++++++++++++++++++++++++------------
+ 2 files changed, 63 insertions(+), 20 deletions(-)
+
+diff --git a/arch/x86/include/asm/vga.h b/arch/x86/include/asm/vga.h
+index c4b9dc2..2723c07 100644
+--- a/arch/x86/include/asm/vga.h
++++ b/arch/x86/include/asm/vga.h
+@@ -17,4 +17,10 @@
+ #define vga_readb(x) (*(x))
+ #define vga_writeb(x, y) (*(y) = (x))
+ 
++#if CONFIG_FB_EFI
++#define __ARCH_HAS_VGA_DEFAULT_DEVICE
++extern struct pci_dev *vga_default_device(void);
++extern void vga_set_default_device(struct pci_dev *pdev);
++#endif
++
+ #endif /* _ASM_X86_VGA_H */
+diff --git a/drivers/video/efifb.c b/drivers/video/efifb.c
+index 784139a..66ed991 100644
+--- a/drivers/video/efifb.c
++++ b/drivers/video/efifb.c
+@@ -18,6 +18,8 @@
+ 
+ static bool request_mem_succeeded = false;
+ 
++static struct pci_dev *default_vga;
++
+ static struct fb_var_screeninfo efifb_defined __devinitdata = {
+ 	.activate		= FB_ACTIVATE_NOW,
+ 	.height			= -1,
+@@ -298,35 +300,70 @@ static struct fb_ops efifb_ops = {
+ 	.fb_imageblit	= cfb_imageblit,
+ };
+ 
++struct pci_dev *vga_default_device(void)
++{
++	return default_vga;
++}
++
++void vga_set_default_device(struct pci_dev *pdev)
++{
++	default_vga = pdev;
++}
++
+ static int __init efifb_setup(char *options)
+ {
+ 	char *this_opt;
+ 	int i;
++	struct pci_dev *dev = NULL;
++
++	if (options && *options) {
++		while ((this_opt = strsep(&options, ",")) != NULL) {
++			if (!*this_opt) continue;
++
++			for (i = 0; i < M_UNKNOWN; i++) {
++				if (!strcmp(this_opt, dmi_list[i].optname) &&
++				    dmi_list[i].base != 0) {
++					screen_info.lfb_base = dmi_list[i].base;
++					screen_info.lfb_linelength = dmi_list[i].stride;
++					screen_info.lfb_width = dmi_list[i].width;
++					screen_info.lfb_height = dmi_list[i].height;
++				}
++			}
++			if (!strncmp(this_opt, "base:", 5))
++				screen_info.lfb_base = simple_strtoul(this_opt+5, NULL, 0);
++			else if (!strncmp(this_opt, "stride:", 7))
++				screen_info.lfb_linelength = simple_strtoul(this_opt+7, NULL, 0) * 4;
++			else if (!strncmp(this_opt, "height:", 7))
++				screen_info.lfb_height = simple_strtoul(this_opt+7, NULL, 0);
++			else if (!strncmp(this_opt, "width:", 6))
++				screen_info.lfb_width = simple_strtoul(this_opt+6, NULL, 0);
++		}
++	}
+ 
+-	if (!options || !*options)
+-		return 0;
++	for_each_pci_dev(dev) {
++		int i;
+ 
+-	while ((this_opt = strsep(&options, ",")) != NULL) {
+-		if (!*this_opt) continue;
++		if ((dev->class >> 8) != PCI_CLASS_DISPLAY_VGA)
++			continue;
+ 
+-		for (i = 0; i < M_UNKNOWN; i++) {
+-			if (!strcmp(this_opt, dmi_list[i].optname) &&
+-					dmi_list[i].base != 0) {
+-				screen_info.lfb_base = dmi_list[i].base;
+-				screen_info.lfb_linelength = dmi_list[i].stride;
+-				screen_info.lfb_width = dmi_list[i].width;
+-				screen_info.lfb_height = dmi_list[i].height;
+-			}
++		for (i=0; i < DEVICE_COUNT_RESOURCE; i++) {
++			resource_size_t start, end;
++
++			if (!(pci_resource_flags(dev, i) & IORESOURCE_MEM))
++				continue;
++
++			start = pci_resource_start(dev, i);
++			end  = pci_resource_end(dev, i);
++
++			if (!start || !end)
++				continue;
++
++			if (screen_info.lfb_base >= start &&
++			    (screen_info.lfb_base + screen_info.lfb_size) < end)
++				default_vga = dev;
+ 		}
+-		if (!strncmp(this_opt, "base:", 5))
+-			screen_info.lfb_base = simple_strtoul(this_opt+5, NULL, 0);
+-		else if (!strncmp(this_opt, "stride:", 7))
+-			screen_info.lfb_linelength = simple_strtoul(this_opt+7, NULL, 0) * 4;
+-		else if (!strncmp(this_opt, "height:", 7))
+-			screen_info.lfb_height = simple_strtoul(this_opt+7, NULL, 0);
+-		else if (!strncmp(this_opt, "width:", 6))
+-			screen_info.lfb_width = simple_strtoul(this_opt+6, NULL, 0);
+ 	}
++
+ 	return 0;
+ }
+ 
+-- 
+1.7.10
+
+--
+To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
+the body of a message to majordomo at vger.kernel.org
+More majordomo info at  http://vger.kernel.org/majordomo-info.html
+Please read the FAQ at  http://www.tux.org/lkml/


More information about the scm-commits mailing list