+ add-a-enable-sysfs-attribute-to-the-pci-devices-to-allow.patch added to -mm tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The patch titled

     pci: add a "enable" sysfs attribute to devices to allow userspace (Xorg) to enable devices without doing foul direct access

has been added to the -mm tree.  Its filename is

     add-a-enable-sysfs-attribute-to-the-pci-devices-to-allow.patch

See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find
out what to do about this


From: Arjan van de Ven <arjan@xxxxxxxxxxxxxxx>

Add an "enable" sysfs attribute to each PCI device.  When read it shows the
"enabled-ness" of the device, but you can write a "0" into it to disable a
device, and a "1" to enable it.

This is needed for X and other cases where userspace wants to enable the
BARs on a device (typical example: to run the video bios on a secundary
head).  Right now X does all this "by hand" via bitbanging, that's just
evil.  This allows X to no longer do that but to just let the kernel do
this.

Signed-off-by: Arjan van de Ven <arjan@xxxxxxxxxxxxxxx>
Cc: Peter Jones <pjones@xxxxxxxxxx>
Cc: Dave Airlie <airlied@xxxxxxxx>
Cc: Greg KH <greg@xxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxx>
---

 drivers/pci/pci-sysfs.c |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+)

diff -puN drivers/pci/pci-sysfs.c~add-a-enable-sysfs-attribute-to-the-pci-devices-to-allow drivers/pci/pci-sysfs.c
--- devel/drivers/pci/pci-sysfs.c~add-a-enable-sysfs-attribute-to-the-pci-devices-to-allow	2006-04-29 23:47:31.000000000 -0700
+++ devel-akpm/drivers/pci/pci-sysfs.c	2006-04-29 23:47:31.000000000 -0700
@@ -43,6 +43,7 @@ pci_config_attr(subsystem_vendor, "0x%04
 pci_config_attr(subsystem_device, "0x%04x\n");
 pci_config_attr(class, "0x%06x\n");
 pci_config_attr(irq, "%u\n");
+pci_config_attr(is_enabled, "%u\n");
 
 static ssize_t local_cpus_show(struct device *dev,
 			struct device_attribute *attr, char *buf)
@@ -90,6 +91,25 @@ static ssize_t modalias_show(struct devi
 		       (u8)(pci_dev->class >> 16), (u8)(pci_dev->class >> 8),
 		       (u8)(pci_dev->class));
 }
+static ssize_t
+is_enabled_store(struct device *dev, struct device_attribute *attr,
+		const char *buf, size_t count)
+{
+	struct pci_dev *pdev = to_pci_dev(dev);
+
+	/* this can crash the machine when done on the "wrong" device */
+	if (!capable(CAP_SYS_ADMIN))
+		return count;
+
+	if (*buf == '0')
+		pci_disable_device(pdev);
+
+	if (*buf == '1')
+		pci_enable_device(pdev);
+
+	return count;
+}
+
 
 struct device_attribute pci_dev_attrs[] = {
 	__ATTR_RO(resource),
@@ -101,6 +121,7 @@ struct device_attribute pci_dev_attrs[] 
 	__ATTR_RO(irq),
 	__ATTR_RO(local_cpus),
 	__ATTR_RO(modalias),
+	__ATTR(enable, 0600, is_enabled_show, is_enabled_store),
 	__ATTR_NULL,
 };
 
_

Patches currently in -mm which might be from arjan@xxxxxxxxxxxxxxx are

input-fix-oops-on-mk712-load.patch
add-a-enable-sysfs-attribute-to-the-pci-devices-to-allow.patch
pi-futex-futex-code-cleanups.patch
pi-futex-introduce-debug_check_no_locks_freed.patch
pi-futex-add-plist-implementation.patch
pi-futex-scheduler-support-for-pi.patch
pi-futex-rt-mutex-core.patch
pi-futex-rt-mutex-docs.patch
pi-futex-rt-mutex-debug.patch
pi-futex-rt-mutex-tester.patch
pi-futex-rt-mutex-futex-api.patch
pi-futex-futex_lock_pi-futex_unlock_pi-support.patch

-
To unsubscribe from this list: send the line "unsubscribe mm-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Kernel Newbies FAQ]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Photo]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux