Linux Hotplug development
 help / color / mirror / Atom feed
* Re: [PATCH] Export SMBIOS provided firmware instance and label to sysfs
From: Narendra K @ 2010-07-14 12:13 UTC (permalink / raw)
  To: greg
  Cc: netdev, linux-hotplug, linux-pci, matt_domsch, charles_rose,
	jordan_hargrave, vijay_nijhawan
In-Reply-To: <EDA0A4495861324DA2618B4C45DCB3EE612B93@blrx3m08.blr.amer.dell.com>

> From: Greg KH [mailto:greg@kroah.com] 
> Sent: Saturday, July 10, 2010 11:22 PM
> To: K, Narendra
> Cc: netdev@vger.kernel.org; linux-hotplug@vger.kernel.org;
> linux-pci@vger.kernel.org; Domsch, Matt; Rose, Charles; Hargrave,
> Jordan; Nijhawan, Vijay
> Subject: Re: [PATCH] Export SMBIOS provided firmware instance and label
> to sysfs
> 
> On Sat, Jul 10, 2010 at 12:14:45PM -0500, Narendra K wrote:
> > +static char smbios_attr[4096];
> > +
> > +enum smbios_attr_enum {
> > +	SMBIOS_ATTR_LABEL_SHOW = 1,
> > +	SMBIOS_ATTR_INSTANCE_SHOW,
> donboard->instance);
> > +			else if (attribute = SMBIOS_ATTR_LABEL_SHOW)
> > +				return scnprintf(smbios_attr, PAGE_SIZE,
> > +						"%s\n", dmi->name);
> 
> Wait, depending on the attribute you are looking at, you are placing the
> data in a single buffer?  What happens if userspace opens and reads both
> files at once?
> 

Yes. Also, the scenario of "label" of two pci devices being read by
userapce once will not be handled properly with this approach.

> Please don't use this function for your show attributes, just properly
> copy the correct string into the userspace buffer.  This logic just
> complicates things a lot more, right?

V1 -> V2:

1. The 'smbios_attr' buffer is not being used as mentioned above

2. The function 'smbios_instance_string_exist' is split into two functions,
the other being 'find_smbios_instance_string' which would print the result
into the sysfs provided 'buf' of associated device. The function
'smbios_instance_string_exist' would let us know if the label exists or not.

Please find the patch with above changes here -

From: Narendra K <narendra_k@dell.com>
Subject: [PATCH] Export SMBIOS provided firmware instance and label to sysfs

This patch exports SMBIOS provided firmware instance and label
of onboard pci devices to sysfs

Signed-off-by: Jordan Hargrave <jordan_hargrave@dell.com>
Signed-off-by: Narendra K <narendra_k@dell.com>
---
 drivers/firmware/dmi_scan.c |   26 ++++++++
 drivers/pci/Makefile        |    3 +
 drivers/pci/pci-label.c     |  145 +++++++++++++++++++++++++++++++++++++++++++
 drivers/pci/pci-sysfs.c     |    5 ++
 drivers/pci/pci.h           |    9 +++
 include/linux/dmi.h         |    9 +++
 6 files changed, 197 insertions(+), 0 deletions(-)
 create mode 100644 drivers/pci/pci-label.c

diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
index d464672..6894ce4 100644
--- a/drivers/firmware/dmi_scan.c
+++ b/drivers/firmware/dmi_scan.c
@@ -277,6 +277,29 @@ static void __init dmi_save_ipmi_device(const struct dmi_header *dm)
 	list_add_tail(&dev->list, &dmi_devices);
 }
 
+static void __init dmi_save_dev_onboard(int instance, int segment, int bus,
+					int devfn, const char *name)
+{
+	struct dmi_dev_onboard *onboard_dev;
+
+	onboard_dev = dmi_alloc(sizeof(*onboard_dev) + strlen(name) + 1);
+	if (!onboard_dev) {
+		printk(KERN_ERR "dmi_save_dev_onboard: out of memory.\n");
+		return;
+	}
+	onboard_dev->instance = instance;
+	onboard_dev->segment = segment;
+	onboard_dev->bus = bus;
+	onboard_dev->devfn = devfn;
+
+	strcpy((char *)&onboard_dev[1], name);
+	onboard_dev->dev.type = DMI_DEV_TYPE_DEV_ONBOARD;
+	onboard_dev->dev.name = (char *)&onboard_dev[1];
+	onboard_dev->dev.device_data = onboard_dev;
+
+	list_add(&onboard_dev->dev.list, &dmi_devices);
+}
+
 static void __init dmi_save_extended_devices(const struct dmi_header *dm)
 {
 	const u8 *d = (u8*) dm + 5;
@@ -285,6 +308,8 @@ static void __init dmi_save_extended_devices(const struct dmi_header *dm)
 	if ((*d & 0x80) = 0)
 		return;
 
+	dmi_save_dev_onboard(*(d+1), *(u16 *)(d+2), *(d+4), *(d+5),
+			     dmi_string_nosave(dm, *(d-1)));
 	dmi_save_one_device(*d & 0x7f, dmi_string_nosave(dm, *(d - 1)));
 }
 
@@ -333,6 +358,7 @@ static void __init dmi_decode(const struct dmi_header *dm, void *dummy)
 		break;
 	case 41:	/* Onboard Devices Extended Information */
 		dmi_save_extended_devices(dm);
+		break;
 	}
 }
 
diff --git a/drivers/pci/Makefile b/drivers/pci/Makefile
index 0b51857..dc1aa09 100644
--- a/drivers/pci/Makefile
+++ b/drivers/pci/Makefile
@@ -55,6 +55,9 @@ obj-$(CONFIG_MICROBLAZE) += setup-bus.o
 #
 obj-$(CONFIG_ACPI)    += pci-acpi.o
 
+# SMBIOS provided firmware instance and labels
+obj-$(CONFIG_DMI)    += pci-label.o
+
 # Cardbus & CompactPCI use setup-bus
 obj-$(CONFIG_HOTPLUG) += setup-bus.o
 
diff --git a/drivers/pci/pci-label.c b/drivers/pci/pci-label.c
new file mode 100644
index 0000000..170c5bb
--- /dev/null
+++ b/drivers/pci/pci-label.c
@@ -0,0 +1,145 @@
+/*
+ * Purpose: Export the firmware instance/index and label associated with
+ * a pci device to sysfs
+ * Copyright (C) 2010 Dell Inc.
+ * by Narendra K <Narendra_K@dell.com>,
+ * Jordan Hargrave <Jordan_Hargrave@dell.com>
+ *
+ * SMBIOS defines type 41 for onboard pci devices. This code retrieves
+ * the instance number and string from the type 41 record and exports
+ * it to sysfs.
+ *
+ * Please see http://linux.dell.com/wiki/index.php/Oss/libnetdevname for more
+ * information.
+ */
+
+#include <linux/dmi.h>
+#include <linux/sysfs.h>
+#include <linux/pci.h>
+#include <linux/pci_ids.h>
+#include <linux/module.h>
+#include <linux/device.h>
+#include "pci.h"
+
+enum smbios_attr_enum {
+	SMBIOS_ATTR_NONE = 0,
+	SMBIOS_ATTR_LABEL_SHOW,
+	SMBIOS_ATTR_INSTANCE_SHOW,
+};
+
+static mode_t
+find_smbios_instance_string(struct pci_dev *pdev, char *buf, int attribute)
+{
+	const struct dmi_device *dmi;
+	struct dmi_dev_onboard *donboard;
+	int bus;
+	int devfn;
+
+	bus = pdev->bus->number;
+	devfn = pdev->devfn;
+
+	dmi = NULL;
+	while ((dmi = dmi_find_device(DMI_DEV_TYPE_DEV_ONBOARD,
+				      NULL, dmi)) != NULL) {
+		donboard = dmi->device_data;
+		if (donboard && donboard->bus = bus &&
+					donboard->devfn = devfn) {
+			if (buf) {
+				if (attribute = SMBIOS_ATTR_INSTANCE_SHOW)
+					return scnprintf(buf, PAGE_SIZE,
+							 "%d\n",
+							 donboard->instance);
+				else if (attribute = SMBIOS_ATTR_LABEL_SHOW)
+					return scnprintf(buf, PAGE_SIZE,
+							 "%s\n",
+							 dmi->name);
+			}
+			return strlen(dmi->name);
+		}
+	}
+	return 0;
+}
+
+static mode_t
+smbios_instance_string_exist(struct kobject *kobj, struct attribute *attr,
+			     int n)
+{
+	struct device *dev;
+	struct pci_dev *pdev;
+
+	dev = container_of(kobj, struct device, kobj);
+	pdev = to_pci_dev(dev);
+
+	return find_smbios_instance_string(pdev, NULL, SMBIOS_ATTR_NONE);
+}
+
+static ssize_t
+smbioslabel_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+	struct pci_dev *pdev;
+	pdev = to_pci_dev(dev);
+
+	return find_smbios_instance_string(pdev, buf,
+					   SMBIOS_ATTR_LABEL_SHOW);
+}
+
+static ssize_t
+smbiosinstance_show(struct device *dev,
+		    struct device_attribute *attr, char *buf)
+{
+	struct pci_dev *pdev;
+	pdev = to_pci_dev(dev);
+
+	return find_smbios_instance_string(pdev, buf,
+					   SMBIOS_ATTR_INSTANCE_SHOW);
+}
+
+static struct device_attribute smbios_attr_label = {
+	.attr = {.name = "label", .mode = 0444, .owner = THIS_MODULE},
+	.show = smbioslabel_show,
+};
+
+static struct device_attribute smbios_attr_instance = {
+	.attr = {.name = "index", .mode = 0444, .owner = THIS_MODULE},
+	.show = smbiosinstance_show,
+};
+
+static struct attribute *smbios_attributes[] = {
+	&smbios_attr_label.attr,
+	&smbios_attr_instance.attr,
+	NULL,
+};
+
+static struct attribute_group smbios_attr_group = {
+	.attrs = smbios_attributes,
+	.is_visible = smbios_instance_string_exist,
+};
+
+static int
+pci_create_smbiosname_file(struct pci_dev *pdev)
+{
+	if (!sysfs_create_group(&pdev->dev.kobj, &smbios_attr_group))
+		return 0;
+	return -ENODEV;
+}
+
+static int
+pci_remove_smbiosname_file(struct pci_dev *pdev)
+{
+		sysfs_remove_group(&pdev->dev.kobj, &smbios_attr_group);
+		return 0;
+}
+
+int pci_create_firmware_label_files(struct pci_dev *pdev)
+{
+	if (!pci_create_smbiosname_file(pdev))
+		return 0;
+	return -ENODEV;
+}
+
+int pci_remove_firmware_label_files(struct pci_dev *pdev)
+{
+	if (!pci_remove_smbiosname_file(pdev))
+		return 0;
+	return -ENODEV;
+}
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index afd2fbf..01fd799 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -1132,6 +1132,8 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
 
 	pci_create_slot_links(pdev);
 
+	pci_create_firmware_label_files(pdev);
+
 	return 0;
 
 err_vga_file:
@@ -1201,6 +1203,9 @@ void pci_remove_sysfs_dev_files(struct pci_dev *pdev)
 		sysfs_remove_bin_file(&pdev->dev.kobj, pdev->rom_attr);
 		kfree(pdev->rom_attr);
 	}
+
+	pci_remove_firmware_label_files(pdev);
+
 }
 
 static int __init pci_sysfs_init(void)
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index f8077b3..089f402 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -11,6 +11,15 @@
 extern int pci_uevent(struct device *dev, struct kobj_uevent_env *env);
 extern int pci_create_sysfs_dev_files(struct pci_dev *pdev);
 extern void pci_remove_sysfs_dev_files(struct pci_dev *pdev);
+#ifndef CONFIG_DMI
+static inline int pci_create_firmware_label_files(struct pci_dev *pdev)
+{ return 0; }
+static inline int pci_remove_firmware_label_files(struct pci_dev *pdev)
+{ return 0; }
+#else
+extern int pci_create_firmware_label_files(struct pci_dev *pdev);
+extern int pci_remove_firmware_label_files(struct pci_dev *pdev);
+#endif
 extern void pci_cleanup_rom(struct pci_dev *dev);
 #ifdef HAVE_PCI_MMAP
 extern int pci_mmap_fits(struct pci_dev *pdev, int resno,
diff --git a/include/linux/dmi.h b/include/linux/dmi.h
index a8a3e1a..90e087f 100644
--- a/include/linux/dmi.h
+++ b/include/linux/dmi.h
@@ -20,6 +20,7 @@ enum dmi_device_type {
 	DMI_DEV_TYPE_SAS,
 	DMI_DEV_TYPE_IPMI = -1,
 	DMI_DEV_TYPE_OEM_STRING = -2,
+	DMI_DEV_TYPE_DEV_ONBOARD = -3,
 };
 
 struct dmi_header {
@@ -37,6 +38,14 @@ struct dmi_device {
 
 #ifdef CONFIG_DMI
 
+struct dmi_dev_onboard {
+	struct dmi_device dev;
+	int instance;
+	int segment;
+	int bus;
+	int devfn;
+};
+
 extern int dmi_check_system(const struct dmi_system_id *list);
 const struct dmi_system_id *dmi_first_match(const struct dmi_system_id *list);
 extern const char * dmi_get_system_info(int field);
-- 
1.6.5.2

With regards,
Narendra K



^ permalink raw reply related

* Re: [PATCH] HAL: Ignore internal DM devices with new DM udev rules
From: Milan Broz @ 2010-07-14  9:43 UTC (permalink / raw)
  To: linux-hotplug
In-Reply-To: <1279022894-20089-1-git-send-email-mbroz@redhat.com>

On 07/14/2010 11:12 AM, Robby Workman wrote:
> On Tue, 13 Jul 2010 14:08:14 +0200
> Milan Broz <mbroz@redhat.com> wrote:

> I get two separate dialog windows to enter the passphrase
> (the first appears, I enter the passphrase, and then the 
> second appears), and after entering the passphrase for the 
> second time, I get this:

sigh. If udev rule set this flag, it is not top-level device
and nobody should touch it.

Top level device is then visible, that's the one you want to mount...

if you see the log, event comes there for top-level:

04:04:20.064 [D] osspec.c:249: Found a dm-device (/dev/dm-6), mark it
04:04:20.064 [I] osspec.c:256: SEQNUM"50, ACTION=change, SUBSYSTEM=block, DEVPATH=/sys/devices/virtual/block/dm-6, DEVNAME=/dev/dm-6, IFINDEX=0

so I do not think it is problem with this patch.

But in fact I have no idea how the whole desktop machinery above
that works, I expect that there is some race with another auto mount
system - see dmsetup table if the device is not mapped elsewhere already:-)

Milan

^ permalink raw reply

* Re: [PATCH] HAL: Ignore internal DM devices with new DM udev rules
From: Robby Workman @ 2010-07-14  9:12 UTC (permalink / raw)
  To: linux-hotplug
In-Reply-To: <1279022894-20089-1-git-send-email-mbroz@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1501 bytes --]

On Tue, 13 Jul 2010 14:08:14 +0200
Milan Broz <mbroz@redhat.com> wrote:

> With new device-mapper udev rules are /dev/mapper/* symlinks
> to basic device name /dev/dm-X.
> (Change requested by udev upstream.)
> 
> This change breaks temporary-cryptsetup workaround inside hal.
> 
> With new dm-udev rules (uncluded since device-mapper 1.02.39)
> there is DM_UDEV_DISABLE_OTHER_RULES_FLAG variable
> which controls that scan should be ignored for this device
> (it is set for all internal devices, including temporary cryptsetup,
> internal parts of lvm devices etc.)
> 
> Ignore device if this flag is set.
> 
> See bugs
> https://bugzilla.redhat.com/show_bug.cgi?id=613909
> http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=586286


Perhaps this is a problem with how Xfce's automount implementation
calls everything (although it worked fine prior to our move to
udev-enabled LVM2 and newer cryptsetup (1.1.x)), but I still don't
get an encrypted usb thumbdrive mounted when plugging it in after
applying this patch and rebuilding hal.  

I get two separate dialog windows to enter the passphrase
(the first appears, I enter the passphrase, and then the 
second appears), and after entering the passphrase for the 
second time, I get this:

  Failed to setup the encrypted volume.
  /dev/sdb is already setup?

Just for grins and giggles, I tested an old mmc card, and it
works as expected.

I'm attaching a debug log created by running hald in verbose
mode; any ideas on where to go from here?

-RW

[-- Attachment #2: debug --]
[-- Type: application/octet-stream, Size: 10163 bytes --]

[5822]: 04:04:08.000 [I] addon-storage.c:356: Checking whether device /dev/sdb is locked on HAL
[5822]: 04:04:08.000 [I] addon-storage.c:365: ... device /dev/sdb is not locked on HAL
[5822]: 04:04:08.001 [D] addon-storage.c:548: Media insertion detected on /dev/sdb
04:04:08.001 [D] hald_dbus.c:1659: udi=/org/freedesktop/Hal/devices/storage_serial_SanDisk_Cruzer_Micro_SNDK5D1BF51877607705_0_0, key=storage.removable.media_available
04:04:08.001 [I] hald_dbus.c:3115: entering, local_interface=1
04:04:08.002 [D] hald_dbus.c:3124: udi=/org/freedesktop/Hal/devices/storage_serial_SanDisk_Cruzer_Micro_SNDK5D1BF51877607705_0_0
04:04:08.002 [I] blockdev.c:1780: blockdev_rescan_device: udi=/org/freedesktop/Hal/devices/storage_serial_SanDisk_Cruzer_Micro_SNDK5D1BF51877607705_0_0
Run started hald-probe-storage (20000) (0) 
!  full path is '/usr/libexec/hald-probe-storage', program_dir is '/usr/libexec'
woohoo
[5825]: 04:04:08.009 [D] probe-storage.c:142: Doing probe-storage for /dev/sdb (bus usb) (drive_type disk) (udi=/org/freedesktop/Hal/devices/storage_serial_SanDisk_Cruzer_Micro_SNDK5D1BF51877607705_0_0) (--only-check-for-fs==1)
[5825]: 04:04:08.010 [D] probe-storage.c:440: Checking for file system on /dev/sdb
[5825]: 04:04:08.010 [D] probe-storage.c:446: Doing open ("/dev/sdb", O_RDONLY)
[5825]: 04:04:08.010 [D] probe-storage.c:454: Returned from open(2)
[5825]: 04:04:08.010 [D] probe-storage.c:470: look for existing partitions for sdb
04:04:08.023 [I] hald_dbus.c:1371: storage.removable.media_available -> True
04:04:08.023 [I] hald_dbus.c:1355: storage.removable.media_size -> 1024966656
04:04:08.023 [I] hald_dbus.c:1339: storage.partitioning_scheme -> none
pid 5825: rc=2 signaled=0: /usr/libexec/hald-probe-storage
04:04:08.024 [I] blockdev.c:1736: hald-probe-storage --only-check-for-media returned 2 (exit_type=0)
04:04:08.024 [D] hotplug.c:500: events queued = 0, events in progress = 0
04:04:08.024 [D] hotplug.c:505: Hotplug-queue empty now ... no hotplug events in progress
04:04:18.543 [I] hald_dbus.c:5198: OK for method 'Setup' with signature 's' on interface 'org.freedesktop.Hal.Device.Volume.Crypto' for UDI '/org/freedesktop/Hal/devices/volume_uuid_10660ad9_8d12_4c12_bd3e_c45f4960bd43' and execpath 'hal-luks-setup'
04:04:18.543 [I] hald_dbus.c:4082: no need to enqueue
Run started hal-luks-setup (0) (1) 
!  full path is '/usr/libexec/scripts/hal-luks-setup', program_dir is '/usr/libexec/scripts'
04:04:18.550 [I] access-check.c:72: uid for caller is 0
04:04:18.551 [I] ci-tracker.c:212: Removing CICallerInfo object for :1.200
04:04:18.551 [I] device.c:1894: Removing locks from ':1.200'
04:04:18.554 [I] access-check.c:72: uid for caller is 0
04:04:18.555 [I] ci-tracker.c:212: Removing CICallerInfo object for :1.201
04:04:18.555 [I] device.c:1894: Removing locks from ':1.201'
04:04:18.560 [I] device.c:1894: Removing locks from ':1.202'
04:04:19.530 [I] osspec.c:256: SEQNUM=2241, ACTION=add, SUBSYSTEM=bdi, DEVPATH=/sys/devices/virtual/bdi/253:6, DEVNAME=, IFINDEX=0
04:04:19.530 [D] hotplug.c:476: checking ADD event /sys/devices/virtual/bdi/253:6
04:04:19.530 [D] hotplug.c:397: event /sys/devices/virtual/bdi/253:6: skip ourselves and all later events
04:04:19.530 [I] hotplug.c:145: /sys/devices/virtual/bdi/253:6 is a device (subsystem)
04:04:19.530 [I] device.c:4997: add_dev: subsys=bdi sysfs_path=/sys/devices/virtual/bdi/253:6 dev= parent_dev=0x00000000
04:04:19.530 [D] hotplug.c:500: events queued = 0, events in progress = 0
04:04:19.530 [D] hotplug.c:505: Hotplug-queue empty now ... no hotplug events in progress
04:04:19.530 [I] osspec.c:220: ignoring device requested by DM udev rules
04:04:19.531 [I] osspec.c:220: ignoring device requested by DM udev rules
04:04:19.532 [I] osspec.c:220: ignoring device requested by DM udev rules
04:04:19.561 [I] osspec.c:220: ignoring device requested by DM udev rules
04:04:19.563 [I] osspec.c:256: SEQNUM=2245, ACTION=remove, SUBSYSTEM=bdi, DEVPATH=/sys/devices/virtual/bdi/253:6, DEVNAME=, IFINDEX=0
04:04:19.563 [D] hotplug.c:478: checking REMOVE event /sys/devices/virtual/bdi/253:6
04:04:19.563 [D] hotplug.c:397: event /sys/devices/virtual/bdi/253:6: skip ourselves and all later events
04:04:19.563 [I] device.c:5078: remove_dev: subsys=bdi sysfs_path=/sys/devices/virtual/bdi/253:6
04:04:19.563 [W] device.c:5082: Error removing device
04:04:19.563 [D] hotplug.c:500: events queued = 0, events in progress = 0
04:04:19.563 [D] hotplug.c:505: Hotplug-queue empty now ... no hotplug events in progress
04:04:19.564 [I] osspec.c:256: SEQNUM=2246, ACTION=remove, SUBSYSTEM=block, DEVPATH=/sys/devices/virtual/block/dm-6, DEVNAME=dm-6, IFINDEX=0
04:04:19.564 [D] hotplug.c:478: checking REMOVE event /sys/devices/virtual/block/dm-6
04:04:19.564 [D] hotplug.c:397: event /sys/devices/virtual/block/dm-6: skip ourselves and all later events
04:04:19.564 [I] blockdev.c:1663: block_rem: sysfs_path=/sys/devices/virtual/block/dm-6
04:04:19.564 [W] blockdev.c:1667: Device is not in the HAL database
04:04:19.564 [D] hotplug.c:500: events queued = 0, events in progress = 0
04:04:19.564 [D] hotplug.c:505: Hotplug-queue empty now ... no hotplug events in progress
04:04:19.700 [I] osspec.c:220: ignoring device requested by DM udev rules
04:04:19.701 [I] osspec.c:256: SEQNUM=2249, ACTION=add, SUBSYSTEM=bdi, DEVPATH=/sys/devices/virtual/bdi/253:6, DEVNAME=, IFINDEX=0
04:04:19.701 [D] hotplug.c:476: checking ADD event /sys/devices/virtual/bdi/253:6
04:04:19.701 [D] hotplug.c:397: event /sys/devices/virtual/bdi/253:6: skip ourselves and all later events
04:04:19.701 [I] hotplug.c:145: /sys/devices/virtual/bdi/253:6 is a device (subsystem)
04:04:19.701 [I] device.c:4997: add_dev: subsys=bdi sysfs_path=/sys/devices/virtual/bdi/253:6 dev= parent_dev=0x00000000
04:04:19.701 [D] hotplug.c:500: events queued = 0, events in progress = 0
04:04:19.701 [D] hotplug.c:505: Hotplug-queue empty now ... no hotplug events in progress
04:04:19.735 [I] osspec.c:256: SEQNUM=2247, ACTION=change, SUBSYSTEM=block, DEVPATH=/sys/devices/pci0000:00/0000:00:1d.7/usb2/2-1/2-1:1.0/host9/target9:0:0/9:0:0:0/block/sdb, DEVNAME=/dev/sdb, IFINDEX=0
04:04:19.735 [D] hotplug.c:480: checking event /sys/devices/pci0000:00/0000:00:1d.7/usb2/2-1/2-1:1.0/host9/target9:0:0/9:0:0:0/block/sdb, action: 4
04:04:19.735 [D] hotplug.c:397: event /sys/devices/pci0000:00/0000:00:1d.7/usb2/2-1/2-1:1.0/host9/target9:0:0/9:0:0:0/block/sdb: skip ourselves and all later events
04:04:19.735 [I] blockdev.c:1716: block_change: sysfs_path=/sys/devices/pci0000:00/0000:00:1d.7/usb2/2-1/2-1:1.0/host9/target9:0:0/9:0:0:0/block/sdb
04:04:19.735 [D] hotplug.c:500: events queued = 0, events in progress = 0
04:04:19.735 [D] hotplug.c:505: Hotplug-queue empty now ... no hotplug events in progress
04:04:20.064 [D] osspec.c:249: Found a dm-device (/dev/dm-6), mark it
04:04:20.064 [I] osspec.c:256: SEQNUM=2250, ACTION=change, SUBSYSTEM=block, DEVPATH=/sys/devices/virtual/block/dm-6, DEVNAME=/dev/dm-6, IFINDEX=0
04:04:20.064 [D] hotplug.c:480: checking event /sys/devices/virtual/block/dm-6, action: 4
04:04:20.064 [D] hotplug.c:397: event /sys/devices/virtual/block/dm-6: skip ourselves and all later events
04:04:20.065 [I] blockdev.c:904: block_add: sysfs_path=/sys/devices/virtual/block/dm-6 dev=/dev/dm-6 is_part=0, parent=0x00000000
04:04:20.065 [I] blockdev.c:958: Looking in /sys/devices/virtual/block/dm-6/slaves for Device Mapper
04:04:20.065 [I] blockdev.c:969:  /sys/devices/virtual/block/dm-6/slaves/. -> /sys/devices/virtual/block/dm-6/slaves
04:04:20.065 [I] blockdev.c:1003: Couldn't find slave volume in devices
04:04:20.065 [I] blockdev.c:969:  /sys/devices/virtual/block/dm-6/slaves/.. -> /sys/devices/virtual/block/dm-6
04:04:20.065 [I] blockdev.c:1003: Couldn't find slave volume in devices
04:04:20.065 [I] blockdev.c:969:  /sys/devices/virtual/block/dm-6/slaves/sdb -> /sys/devices/pci0000:00/0000:00:1d.7/usb2/2-1/2-1:1.0/host9/target9:0:0/9:0:0:0/block/sdb
04:04:20.065 [I] blockdev.c:1009: Done looking in /sys/devices/virtual/block/dm-6/slaves
04:04:20.065 [I] blockdev.c:1016: Ignoring hotplug event - no parent
04:04:20.065 [W] blockdev.c:1587: Not adding device object
04:04:20.065 [D] hotplug.c:500: events queued = 0, events in progress = 0
04:04:20.065 [D] hotplug.c:505: Hotplug-queue empty now ... no hotplug events in progress
04:04:20.087 [I] device.c:1894: Removing locks from ':1.203'
pid 5826: rc=0 signaled=0: /usr/libexec/scripts/hal-luks-setup
04:04:20.087 [I] hald_dbus.c:4106: No more methods in queue
04:04:20.087 [D] hotplug.c:500: events queued = 0, events in progress = 0
04:04:20.087 [D] hotplug.c:505: Hotplug-queue empty now ... no hotplug events in progress
04:04:59.627 [I] hald_dbus.c:5198: OK for method 'Setup' with signature 's' on interface 'org.freedesktop.Hal.Device.Volume.Crypto' for UDI '/org/freedesktop/Hal/devices/volume_uuid_10660ad9_8d12_4c12_bd3e_c45f4960bd43' and execpath 'hal-luks-setup'
04:04:59.627 [I] hald_dbus.c:4082: no need to enqueue
Run started hal-luks-setup (0) (1) 
!  full path is '/usr/libexec/scripts/hal-luks-setup', program_dir is '/usr/libexec/scripts'
04:04:59.632 [I] access-check.c:72: uid for caller is 0
04:04:59.633 [I] ci-tracker.c:212: Removing CICallerInfo object for :1.204
04:04:59.633 [I] device.c:1894: Removing locks from ':1.204'
04:04:59.637 [I] access-check.c:72: uid for caller is 0
04:04:59.638 [I] ci-tracker.c:212: Removing CICallerInfo object for :1.205
04:04:59.638 [I] device.c:1894: Removing locks from ':1.205'
04:04:59.642 [I] device.c:1894: Removing locks from ':1.206'
pid 5866: rc=1 signaled=0: /usr/libexec/scripts/hal-luks-setup
04:04:59.646 [I] hald_dbus.c:4106: No more methods in queue
04:04:59.646 [I] hald_dbus.c:4169: failed with 'org.freedesktop.Hal.Device.Volume.Crypto.SetupError' '/dev/sdb is already setup?'
04:04:59.646 [D] hotplug.c:500: events queued = 0, events in progress = 0
04:04:59.646 [D] hotplug.c:505: Hotplug-queue empty now ... no hotplug events in progress
04:05:18.890 [I] ci-tracker.c:212: Removing CICallerInfo object for :1.199
04:05:18.890 [I] device.c:1894: Removing locks from ':1.199'
04:05:18.970 [I] device.c:1894: Removing locks from ':1.207'


^ permalink raw reply

* [PATCH] HAL: Ignore internal DM devices with new DM udev rules
From: Milan Broz @ 2010-07-13 12:08 UTC (permalink / raw)
  To: linux-hotplug

With new device-mapper udev rules are /dev/mapper/* symlinks
to basic device name /dev/dm-X.
(Change requested by udev upstream.)

This change breaks temporary-cryptsetup workaround inside hal.

With new dm-udev rules (uncluded since device-mapper 1.02.39)
there is DM_UDEV_DISABLE_OTHER_RULES_FLAG variable
which controls that scan should be ignored for this device
(it is set for all internal devices, including temporary cryptsetup,
internal parts of lvm devices etc.)

Ignore device if this flag is set.

See bugs
https://bugzilla.redhat.com/show_bug.cgi?ida3909
http://bugs.debian.org/cgi-bin/bugreport.cgi?bugX6286

Signed-off-by: Milan Broz <mbroz@redhat.com>
---
 hald/linux/osspec.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/hald/linux/osspec.c b/hald/linux/osspec.c
index a8233fd..6d616bc 100644
--- a/hald/linux/osspec.c
+++ b/hald/linux/osspec.c
@@ -215,6 +215,11 @@ hald_udev_data (GIOChannel *source, GIOCondition condition, gpointer user_data)
 				g_free (str);
 			}
 			g_free (dstr);
+		} else if (strncmp(key, "DM_UDEV_DISABLE_OTHER_RULES_FLAG=", 33) = 0) {
+			if (strtoul(&key[33], NULL, 10) = 1) {
+				HAL_INFO (("ignoring device requested by DM udev rules"));
+				goto invalid;
+			}
 		}
 	}
 
-- 
1.7.1


^ permalink raw reply related

* Re: [PATCH] path_id: Handle SAS and SATA devices
From: David Zeuthen @ 2010-07-12 14:47 UTC (permalink / raw)
  To: linux-hotplug
In-Reply-To: <20100707145508.A42312A2B9@ochil.suse.de>

On Mon, 2010-07-12 at 11:07 +0200, Kay Sievers wrote:
> On Wed, Jul 7, 2010 at 16:55, Hannes Reinecke <hare@suse.de> wrote:
> >
> > SAS devices should be referenced by the SAS address of the target;
> > on the initiator side we assume an identity mapping between SAS
> > addresses and PCI devnumber.
> > SATA devices have an identity mapping between SATA links and
> > linux scsi_host structures, so we can map the host number onto
> > the SATA link.
> > For this to work the LUN numbering needs to be updated, too,
> > as SATA devices do not have the concept of a LUN, whereas normal
> > SCSI devices have.
> 
> David, any chance to give this a try on your SAS box, and see if this
> works as expected for you too?

Sure, will do later this week - it's currently powered off and in a
moving box!

Thanks,
David



^ permalink raw reply

* Re: [PATCH] path_id: Handle SAS and SATA devices
From: Harald Hoyer @ 2010-07-12  9:16 UTC (permalink / raw)
  To: linux-hotplug
In-Reply-To: <20100707145508.A42312A2B9@ochil.suse.de>


Customers request connection (channel) and drive bay identifier to be part of 
the symlink name.

On 07/07/2010 04:55 PM, Hannes Reinecke wrote:
>
> SAS devices should be referenced by the SAS address of the target;
> on the initiator side we assume an identity mapping between SAS
> addresses and PCI devnumber.
> SATA devices have an identity mapping between SATA links and
> linux scsi_host structures, so we can map the host number onto
> the SATA link.
> For this to work the LUN numbering needs to be updated, too,
> as SATA devices do not have the concept of a LUN, whereas normal
> SCSI devices have.
>
> Signed-off-by: Hannes Reinecke<hare@suse.de>
>
> diff --git a/extras/path_id/path_id.c b/extras/path_id/path_id.c
> index dcee378..1b6c363 100644
> --- a/extras/path_id/path_id.c
> +++ b/extras/path_id/path_id.c
> @@ -97,7 +97,6 @@ static struct udev_device *handle_scsi_fibre_channel(struct udev_device *parent,
>   	struct udev_device *targetdev;
>   	struct udev_device *fcdev = NULL;
>   	const char *port;
> -	unsigned int lun;
>
>   	targetdev = udev_device_get_parent_with_subsystem_devtype(parent, "scsi", "scsi_target");
>   	if (targetdev = NULL)
> @@ -112,8 +111,7 @@ static struct udev_device *handle_scsi_fibre_channel(struct udev_device *parent,
>   		goto out;
>   	}
>
> -	lun = strtoul(udev_device_get_sysnum(parent), NULL, 10);
> -	path_prepend(path, "fc-%s:0x%04x%04x00000000", port, lun&  0xffff, (lun>>  16)&  0xffff);
> +	path_prepend(path, "fc-%s", port);
>   out:
>   	udev_device_unref(fcdev);
>   	return parent;
> @@ -121,7 +119,34 @@ out:
>
>   static struct udev_device *handle_scsi_sas(struct udev_device *parent, char **path)
>   {
> -	return NULL;
> +	struct udev *udev  = udev_device_get_udev(parent);
> +	struct udev_device *end_dev = NULL;
> +	struct udev_device *sas_dev;
> +	const char *end_dev_wwn;
> +
> +	/* Find end device */
> +	end_dev = parent;
> +	while (1) {
> +		end_dev = udev_device_get_parent(end_dev);
> +		if (end_dev = NULL)
> +			return NULL;
> +		if (!strncmp(udev_device_get_sysname(end_dev), "end_device", 10))
> +			break;
> +	}
> +	if (end_dev = NULL)
> +		return NULL;
> +
> +	/* find sas end device */
> +	sas_dev = udev_device_new_from_subsystem_sysname(udev, "sas_device", udev_device_get_sysname(end_dev));
> +	if (sas_dev = NULL)
> +		return NULL;
> +
> +	end_dev_wwn = udev_device_get_sysattr_value(sas_dev, "sas_address");
> +
> +	path_prepend(path, "sas-%s", end_dev_wwn);
> +
> +	udev_device_unref(sas_dev);
> +	return end_dev;
>   }
>
>   static struct udev_device *handle_scsi_iscsi(struct udev_device *parent, char **path)
> @@ -174,7 +199,7 @@ static struct udev_device *handle_scsi_iscsi(struct udev_device *parent, char **
>   		goto out;
>   	}
>
> -	path_prepend(path, "ip-%s:%s-iscsi-%s-lun-%s", addr, port, target, udev_device_get_sysnum(parent));
> +	path_prepend(path, "ip-%s:%s-iscsi-%s", addr, port, target);
>   out:
>   	udev_device_unref(sessiondev);
>   	udev_device_unref(conndev);
> @@ -183,23 +208,34 @@ out:
>
>   static struct udev_device *handle_scsi_default(struct udev_device *parent, char **path)
>   {
> +	struct udev *udev  = udev_device_get_udev(parent);
>   	struct udev_device *hostdev;
> -	int host, bus, target, lun;
> -	const char *name;
> +	int host, bus, target;
> +	const char *name, *hba, *hostpath;
>   	char *base;
>   	char *pos;
> +	char *type = "scsi";
>   	DIR *dir;
>   	struct dirent *dent;
> -	int basenum;
> -
> -	hostdev = udev_device_get_parent_with_subsystem_devtype(parent, "scsi", "scsi_host");
> -	if (hostdev = NULL)
> -		return NULL;
> +	int basenum, hostnum = 0;
>
>   	name = udev_device_get_sysname(parent);
> -	if (sscanf(name, "%d:%d:%d:%d",&host,&bus,&target,&lun) != 4)
> +	if (sscanf(name, "target%d:%d:%d",&host,&bus,&target) != 3)
>   		return NULL;
>
> +	parent = udev_device_get_parent(parent);
> +	/* Check for libata hosts */
> +	hostdev = udev_device_new_from_subsystem_sysname(udev, "scsi_host", udev_device_get_sysname(parent));
> +	if (hostdev = NULL)
> +		return NULL;
> +	hba = udev_device_get_sysattr_value(hostdev, "proc_name");
> +	if (hba&&  (!strncmp(hba, "sata", 4) || !strcmp(hba, "ahci")))
> +		type = "sata";
> +	if (hba&&  (!strncmp(hba, "pata", 4) || !strncmp(hba, "ata", 3)))
> +		type = "ata";
> +	udev_device_unref(hostdev);
> +	/* Reset to original host path */
> +	hostdev = parent;
>   	/* rebase host offset to get the local relative number */
>   	basenum = -1;
>   	base = strdup(udev_device_get_syspath(hostdev));
> @@ -227,6 +263,7 @@ static struct udev_device *handle_scsi_default(struct udev_device *parent, char
>   		if (strncmp(dent->d_name, "host", 4) != 0)
>   			continue;
>   		i = strtoul(&dent->d_name[4],&rest, 10);
> +		hostnum++;
>   		if (rest[0] != '\0')
>   			continue;
>   		if (basenum = -1 || i<  basenum)
> @@ -239,20 +276,54 @@ static struct udev_device *handle_scsi_default(struct udev_device *parent, char
>   	}
>   	host -= basenum;
>
> -	path_prepend(path, "scsi-%u:%u:%u:%u", host, bus, target, lun);
> +	if (!strcmp(type, "scsi"))
> +		path_prepend(path, "scsi-%u:%u:%u", host, bus, target);
> +	else
> +		path_prepend(path, "%s-%u", type, host);
>   out:
>   	free(base);
>   	return hostdev;
>   }
>
> +static int scsi_is_sata(const char *name)
> +{
> +	char syspath[UTIL_PATH_SIZE];
> +	struct stat stbuf;
> +
> +	strcpy(syspath, name);
> +	strcat(syspath, "/unload_heads");
> +
> +	return (stat(syspath,&stbuf)<  0) ? 0 : 1;
> +}
> +
>   static struct udev_device *handle_scsi(struct udev_device *parent, char **path)
>   {
> +	struct udev *udev  = udev_device_get_udev(parent);
>   	const char *devtype;
>   	const char *name;
>   	const char *id;
>
>   	devtype = udev_device_get_devtype(parent);
> -	if (devtype = NULL || strcmp(devtype, "scsi_device") != 0)
> +	if (devtype = NULL)
> +		return parent;
> +
> +	/* lousy scsi sysfs does not have a "subsystem" for the transport */
> +	name = udev_device_get_syspath(parent);
> +
> +	if (strcmp(devtype, "scsi_device") = 0) {
> +		if (!scsi_is_sata(name)) {
> +			unsigned int host, bus, target, lun;
> +
> +			if (sscanf(udev_device_get_sysname(parent),
> +				   "%d:%d:%d:%d",&host,&bus,&target,&lun) != 4)
> +				return NULL;
> +			path_prepend(path, "lun-0x%04x%04x00000000",
> +				     lun&  0xffff, (lun>>  16)&  0xffff);
> +		}
> +		return parent;
> +	}
> +
> +	if (strcmp(devtype, "scsi_host") = 0)
>   		return parent;
>
>   	/* firewire */
> @@ -263,9 +334,6 @@ static struct udev_device *handle_scsi(struct udev_device *parent, char **path)
>   		goto out;
>   	}
>
> -	/* lousy scsi sysfs does not have a "subsystem" for the transport */
> -	name = udev_device_get_syspath(parent);
> -
>   	if (strstr(name, "/rport-") != NULL) {
>   		parent = handle_scsi_fibre_channel(parent, path);
>   		goto out;
> --
> To unsubscribe from this list: send the line "unsubscribe linux-hotplug" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


^ permalink raw reply

* Re: [PATCH] path_id: Handle SAS and SATA devices
From: Kay Sievers @ 2010-07-12  9:07 UTC (permalink / raw)
  To: linux-hotplug
In-Reply-To: <20100707145508.A42312A2B9@ochil.suse.de>

On Wed, Jul 7, 2010 at 16:55, Hannes Reinecke <hare@suse.de> wrote:
>
> SAS devices should be referenced by the SAS address of the target;
> on the initiator side we assume an identity mapping between SAS
> addresses and PCI devnumber.
> SATA devices have an identity mapping between SATA links and
> linux scsi_host structures, so we can map the host number onto
> the SATA link.
> For this to work the LUN numbering needs to be updated, too,
> as SATA devices do not have the concept of a LUN, whereas normal
> SCSI devices have.

David, any chance to give this a try on your SAS box, and see if this
works as expected for you too?

Thanks,
Kay

^ permalink raw reply

* Re: [PATCH udev] rules: add more FireWire IDs: Point Grey IIDC; AV/C
From: Kay Sievers @ 2010-07-12  9:05 UTC (permalink / raw)
  To: linux-hotplug
In-Reply-To: <tkrat.2795e24c9318eace@s5r6.in-berlin.de>

On Sun, Jul 11, 2010 at 12:32, Stefan Richter <stefanr@s5r6.in-berlin.de> wrote:
> 1. IIDC cameras from Point Grey use the vendor OUI as Specifier_ID
> instead of the 1394 TA's OUI but are otherwise fully compliant to the
> IIDC spec. Their device files should be accessible like those of any
> other IIDC cameras.
>
> 2. Originally, the Software_Version of devices that implement FCP
> (IEC 61883-1 Function Control Protocol) was meant to be a bitmap of all
> command sets that an FCP capable unit supports.  Bitmap flags are
> defined for AV/C, CAL, EHS, HAVi, and vendor unique command sets.
> Software_Version was revised to be a simple identifier instead, and
> devices that support several command sets were meant to instantiate one
> unit directory for each command set.  Still, some devices with the flags
> for AV/C and vendor unique command sets combined were released (but
> apparently no devices with any other flag combinations).  These rare but
> existing AV/C + vendor unique devices need to be accessible just like
> plain AV/C devices.

Applied.

Thanks,
Kay

^ permalink raw reply

* [ANNOUNCE] udev 160 release
From: Kay Sievers @ 2010-07-11 22:54 UTC (permalink / raw)
  To: linux-hotplug

Here comes a new udev version. Thanks to all who have contributed to
this release.

The tarball can be found here:
 ftp://ftp.kernel.org/pub/linux/utils/kernel/hotplug/

The development repository can be found here:
 http://www.kernel.org/git/?p=linux/hotplug/udev.git;a=summary

The ChangeLog can be found here:

http://www.kernel.org/git/?p=linux/hotplug/udev.git;a=blob;hb=HEAD;f=ChangeLog

udev 160
====
Bugfixes.


^ permalink raw reply

* [PATCH udev] rules: add more FireWire IDs: Point Grey IIDC; AV/C +
From: Stefan Richter @ 2010-07-11 10:32 UTC (permalink / raw)
  To: linux-hotplug

1. IIDC cameras from Point Grey use the vendor OUI as Specifier_ID
instead of the 1394 TA's OUI but are otherwise fully compliant to the
IIDC spec. Their device files should be accessible like those of any
other IIDC cameras.

2. Originally, the Software_Version of devices that implement FCP
(IEC 61883-1 Function Control Protocol) was meant to be a bitmap of all
command sets that an FCP capable unit supports.  Bitmap flags are
defined for AV/C, CAL, EHS, HAVi, and vendor unique command sets.
Software_Version was revised to be a simple identifier instead, and
devices that support several command sets were meant to instantiate one
unit directory for each command set.  Still, some devices with the flags
for AV/C and vendor unique command sets combined were released (but
apparently no devices with any other flag combinations).  These rare but
existing AV/C + vendor unique devices need to be accessible just like
plain AV/C devices.

Side notes:
 - Many AV/C devices make use of the Vendor Dependent AV/C command, but
this is unrelated to vendor unique FCP command sets.
 - Here are all standardized FireWire protocol identifiers that I know
of, listed as Specifier_ID:Software_Version | specifier | protocol.
0x00005e:0x000001 | IANA    | IPv4 over 1394 (RFC 2734)
0x00005e:0x000002 | IANA    | IPv6 over 1394 (RFC 3146)
0x00609e:0x010483 | INCITS  | SBP-2 (or SCSI command sets over SBP-3)
0x00609e:0x0105bb | INCITS  | AV/C over SBP-3
0x00a02d:0x010001 | 1394 TA | AV/C (over FCP)
0x00a02d:0x010002 | 1394 TA | CAL
0x00a02d:0x010004 | 1394 TA | EHS
0x00a02d:0x010008 | 1394 TA | HAVi
0x00a02d:0x014000 | 1394 TA | Vendor Unique
0x00a02d:0x014001 | 1394 TA | Vendor Unique and AV/C (over FCP)
0x00a02d:0x000100 | 1394 TA | IIDC 1.04
0x00a02d:0x000101 | 1394 TA | IIDC 1.20
0x00a02d:0x000102 | 1394 TA | IIDC 1.30
0x00a02d:0x0A6BE2 | 1394 TA | DPP 1.0
0x00a02d:0x4B661F | 1394 TA | IICP 1.0
For now we are only interested in udev rules for AV/C and IIDC.

Reported-by: Damien Douxchamps <ddsf@douxchamps.net> (Point Grey IIDC ID)
Reported-by: Clemens Ladisch <clemens@ladisch.de> (AV/C + vendor unique ID)
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
---
 rules/rules.d/50-udev-default.rules |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/rules/rules.d/50-udev-default.rules b/rules/rules.d/50-udev-default.rules
index 10cfbd6..3c0f747 100644
--- a/rules/rules.d/50-udev-default.rules
+++ b/rules/rules.d/50-udev-default.rules
@@ -49,7 +49,9 @@ SUBSYSTEM="dvb", GROUP="video"
 
 # FireWire (firewire-core driver: IIDC devices, AV/C devices)
 SUBSYSTEM="firewire", ATTR{units}="*0x00a02d:0x00010*", GROUP="video"
+SUBSYSTEM="firewire", ATTR{units}="*0x00b09d:0x00010*", GROUP="video"
 SUBSYSTEM="firewire", ATTR{units}="*0x00a02d:0x010001*", GROUP="video"
+SUBSYSTEM="firewire", ATTR{units}="*0x00a02d:0x014001*", GROUP="video"
 
 # FireWire (deprecated dv1394 and video1394 drivers)
 KERNEL="dv1394-[0-9]*",	NAME="dv1394/%n", GROUP="video"
-- 
Stefan Richter
-===-=-=- -== -=-=
http://arcgraph.de/sr/






^ permalink raw reply related

* Re: [PATCH] Export SMBIOS provided firmware instance and label to
From: Greg KH @ 2010-07-10 17:52 UTC (permalink / raw)
  To: Narendra K
  Cc: netdev, linux-hotplug, linux-pci, matt_domsch, charles_rose,
	jordan_hargrave, vijay_nijhawan
In-Reply-To: <20100710171445.GA24568@auslistsprd01.us.dell.com>

On Sat, Jul 10, 2010 at 12:14:45PM -0500, Narendra K wrote:
> +static char smbios_attr[4096];
> +
> +enum smbios_attr_enum {
> +	SMBIOS_ATTR_LABEL_SHOW = 1,
> +	SMBIOS_ATTR_INSTANCE_SHOW,
> +};
> +
> +static mode_t
> +smbios_instance_string_exist(struct kobject *kobj, struct attribute *attr,
> +			     int attribute)
> +{
> +	struct device *dev;
> +	struct pci_dev *pdev;
> +	const struct dmi_device *dmi;
> +	struct dmi_dev_onboard *donboard;
> +	int bus;
> +	int devfn;
> +
> +	dev = container_of(kobj, struct device, kobj);
> +	pdev = to_pci_dev(dev);
> +
> +	bus = pdev->bus->number;
> +	devfn = pdev->devfn;
> +
> +	dmi = NULL;
> +	while ((dmi = dmi_find_device(DMI_DEV_TYPE_DEV_ONBOARD,
> +				      NULL, dmi)) != NULL) {
> +		donboard = dmi->device_data;
> +		if (donboard && donboard->bus = bus &&
> +					donboard->devfn = devfn) {
> +			if (attribute = SMBIOS_ATTR_INSTANCE_SHOW)
> +				return scnprintf(smbios_attr, PAGE_SIZE,
> +						"%d\n", donboard->instance);
> +			else if (attribute = SMBIOS_ATTR_LABEL_SHOW)
> +				return scnprintf(smbios_attr, PAGE_SIZE,
> +						"%s\n", dmi->name);

Wait, depending on the attribute you are looking at, you are placing the
data in a single buffer?  What happens if userspace opens and reads both
files at once?

Please don't use this function for your show attributes, just properly
copy the correct string into the userspace buffer.  This logic just
complicates things a lot more, right?

thanks,

greg k-h

^ permalink raw reply

* Re: [PATCH] Export SMBIOS provided firmware instance and label to
From: Greg KH @ 2010-07-10 17:49 UTC (permalink / raw)
  To: Narendra K
  Cc: netdev, linux-hotplug, linux-pci, matt_domsch, charles_rose,
	jordan_hargrave, vijay_nijhawan
In-Reply-To: <20100710171445.GA24568@auslistsprd01.us.dell.com>

On Sat, Jul 10, 2010 at 12:14:45PM -0500, Narendra K wrote:
> +static char smbios_attr[4096];

Interesting size, too bad you don't reference it again:

> +			if (attribute = SMBIOS_ATTR_INSTANCE_SHOW)
> +				return scnprintf(smbios_attr, PAGE_SIZE,
> +						"%d\n", donboard->instance);
> +			else if (attribute = SMBIOS_ATTR_LABEL_SHOW)
> +				return scnprintf(smbios_attr, PAGE_SIZE,
> +						"%s\n", dmi->name);

PAGE_SIZE here?

Which is it (note, some arches PAGE_SIZE is not 4k...)

> +			return strlen(dmi->name);
> +		}
> +	}
> +	return 0;
> +}
> +
> +static ssize_t
> +smbiosname_show(struct device *dev, struct device_attribute *attr, char *buf)
> +{
> +	ssize_t result;
> +	result = smbios_instance_string_exist(&dev->kobj, &attr->attr,
> +					      SMBIOS_ATTR_LABEL_SHOW);
> +	strncpy(buf, smbios_attr, result);
> +	return result;
> +}
> +
> +static ssize_t
> +smbiosinstance_show(struct device *dev,
> +		    struct device_attribute *attr, char *buf)
> +{
> +	ssize_t result;
> +	result = smbios_instance_string_exist(&dev->kobj, &attr->attr,
> +					      SMBIOS_ATTR_INSTANCE_SHOW);
> +	strncpy(buf, smbios_attr, result);
> +	return result;
> +}
> +
> +static struct device_attribute smbios_attr_label = {
> +	.attr = {.name = "label", .mode = 0444, .owner = THIS_MODULE},
> +	.show = smbiosname_show,
> +};
> +
> +static struct device_attribute smbios_attr_instance = {
> +	.attr = {.name = "index", .mode = 0444, .owner = THIS_MODULE},
> +	.show = smbiosinstance_show,
> +};
> +
> +static struct attribute *smbios_attributes[] = {
> +	&smbios_attr_label.attr,
> +	&smbios_attr_instance.attr,
> +	NULL,
> +};
> +
> +static struct attribute_group smbios_attr_group = {
> +	.attrs = smbios_attributes,
> +	.is_visible = smbios_instance_string_exist,
> +};
> +
> +static int
> +pci_create_smbiosname_file(struct pci_dev *pdev)
> +{
> +	if (smbios_attr_group.is_visible &&

You set .is_visable above, how could it not be set?

> +		smbios_attr_group.is_visible(&pdev->dev.kobj, NULL, 0)) {
> +		if (!sysfs_create_group(&pdev->dev.kobj, &smbios_attr_group))
> +			return 0;

No, sysfs_create_group will call .is_visable, right?  You shouldn't need
to call it yourself or check it, at all.

> +static int
> +pci_remove_smbiosname_file(struct pci_dev *pdev)
> +{
> +	if (smbios_attr_group.is_visible &&
> +		smbios_attr_group.is_visible(&pdev->dev.kobj, NULL, 0)) {
> +		sysfs_remove_group(&pdev->dev.kobj, &smbios_attr_group);
> +		return 0;

Same here, you shouldn't have to check .is_visable.

> +	}
> +	return -1;

Why -1?  Please use a real error value.

thanks,

greg k-h

^ permalink raw reply

* [PATCH] Export SMBIOS provided firmware instance and label to sysfs
From: Narendra K @ 2010-07-10 17:14 UTC (permalink / raw)
  To: netdev, linux-hotplug, linux-pci
  Cc: matt_domsch, charles_rose, jordan_hargrave, vijay_nijhawan

Hello,

This post is in continuation of the discussions in the thread
http://marc.info/?l=linux-pci&m\x127852633816819&w=3.

The patch has the following changes -

1.The patch would be compiled only if CONFIG_DMI is set
2.The .test method has been changed to use .is_visible which is part of
already existing infrastructure.

Please find the patch with the above changes here -

From: Narendra K <narendra_k@dell.com>
Subject: [PATCH] Export SMBIOS provided firmware instance and label to sysfs

This patch exports SMBIOS provided firmware instance and label
of onboard pci devices to sysfs

Signed-off-by: Jordan Hargrave <jordan_hargrave@dell.com>
Signed-off-by: Narendra K <narendra_k@dell.com>
---
 drivers/firmware/dmi_scan.c |   26 ++++++++
 drivers/pci/Makefile        |    3 +
 drivers/pci/pci-label.c     |  142 +++++++++++++++++++++++++++++++++++++++++++
 drivers/pci/pci-sysfs.c     |    5 ++
 drivers/pci/pci.h           |    9 +++
 include/linux/dmi.h         |    9 +++
 6 files changed, 194 insertions(+), 0 deletions(-)
 create mode 100644 drivers/pci/pci-label.c

diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
index d464672..6894ce4 100644
--- a/drivers/firmware/dmi_scan.c
+++ b/drivers/firmware/dmi_scan.c
@@ -277,6 +277,29 @@ static void __init dmi_save_ipmi_device(const struct dmi_header *dm)
 	list_add_tail(&dev->list, &dmi_devices);
 }
 
+static void __init dmi_save_dev_onboard(int instance, int segment, int bus,
+					int devfn, const char *name)
+{
+	struct dmi_dev_onboard *onboard_dev;
+
+	onboard_dev = dmi_alloc(sizeof(*onboard_dev) + strlen(name) + 1);
+	if (!onboard_dev) {
+		printk(KERN_ERR "dmi_save_dev_onboard: out of memory.\n");
+		return;
+	}
+	onboard_dev->instance = instance;
+	onboard_dev->segment = segment;
+	onboard_dev->bus = bus;
+	onboard_dev->devfn = devfn;
+
+	strcpy((char *)&onboard_dev[1], name);
+	onboard_dev->dev.type = DMI_DEV_TYPE_DEV_ONBOARD;
+	onboard_dev->dev.name = (char *)&onboard_dev[1];
+	onboard_dev->dev.device_data = onboard_dev;
+
+	list_add(&onboard_dev->dev.list, &dmi_devices);
+}
+
 static void __init dmi_save_extended_devices(const struct dmi_header *dm)
 {
 	const u8 *d = (u8*) dm + 5;
@@ -285,6 +308,8 @@ static void __init dmi_save_extended_devices(const struct dmi_header *dm)
 	if ((*d & 0x80) = 0)
 		return;
 
+	dmi_save_dev_onboard(*(d+1), *(u16 *)(d+2), *(d+4), *(d+5),
+			     dmi_string_nosave(dm, *(d-1)));
 	dmi_save_one_device(*d & 0x7f, dmi_string_nosave(dm, *(d - 1)));
 }
 
@@ -333,6 +358,7 @@ static void __init dmi_decode(const struct dmi_header *dm, void *dummy)
 		break;
 	case 41:	/* Onboard Devices Extended Information */
 		dmi_save_extended_devices(dm);
+		break;
 	}
 }
 
diff --git a/drivers/pci/Makefile b/drivers/pci/Makefile
index 0b51857..dc1aa09 100644
--- a/drivers/pci/Makefile
+++ b/drivers/pci/Makefile
@@ -55,6 +55,9 @@ obj-$(CONFIG_MICROBLAZE) += setup-bus.o
 #
 obj-$(CONFIG_ACPI)    += pci-acpi.o
 
+# SMBIOS provided firmware instance and labels
+obj-$(CONFIG_DMI)    += pci-label.o
+
 # Cardbus & CompactPCI use setup-bus
 obj-$(CONFIG_HOTPLUG) += setup-bus.o
 
diff --git a/drivers/pci/pci-label.c b/drivers/pci/pci-label.c
new file mode 100644
index 0000000..d0eb964
--- /dev/null
+++ b/drivers/pci/pci-label.c
@@ -0,0 +1,142 @@
+/*
+ * Purpose: Export the firmware instance/index and label associated with
+ * a pci device to sysfs
+ * Copyright (C) 2010 Dell Inc.
+ * by Narendra K <Narendra_K@dell.com>,
+ * Jordan Hargrave <Jordan_Hargrave@dell.com>
+ *
+ * SMBIOS defines type 41 for onboard pci devices. This code retrieves
+ * the instance number and string from the type 41 record and exports
+ * it to sysfs.
+ *
+ * Please see http://linux.dell.com/wiki/index.php/Oss/libnetdevname for more
+ * information.
+ */
+
+#include <linux/dmi.h>
+#include <linux/sysfs.h>
+#include <linux/pci.h>
+#include <linux/pci_ids.h>
+#include <linux/module.h>
+#include <linux/device.h>
+#include "pci.h"
+
+static char smbios_attr[4096];
+
+enum smbios_attr_enum {
+	SMBIOS_ATTR_LABEL_SHOW = 1,
+	SMBIOS_ATTR_INSTANCE_SHOW,
+};
+
+static mode_t
+smbios_instance_string_exist(struct kobject *kobj, struct attribute *attr,
+			     int attribute)
+{
+	struct device *dev;
+	struct pci_dev *pdev;
+	const struct dmi_device *dmi;
+	struct dmi_dev_onboard *donboard;
+	int bus;
+	int devfn;
+
+	dev = container_of(kobj, struct device, kobj);
+	pdev = to_pci_dev(dev);
+
+	bus = pdev->bus->number;
+	devfn = pdev->devfn;
+
+	dmi = NULL;
+	while ((dmi = dmi_find_device(DMI_DEV_TYPE_DEV_ONBOARD,
+				      NULL, dmi)) != NULL) {
+		donboard = dmi->device_data;
+		if (donboard && donboard->bus = bus &&
+					donboard->devfn = devfn) {
+			if (attribute = SMBIOS_ATTR_INSTANCE_SHOW)
+				return scnprintf(smbios_attr, PAGE_SIZE,
+						"%d\n", donboard->instance);
+			else if (attribute = SMBIOS_ATTR_LABEL_SHOW)
+				return scnprintf(smbios_attr, PAGE_SIZE,
+						"%s\n", dmi->name);
+			return strlen(dmi->name);
+		}
+	}
+	return 0;
+}
+
+static ssize_t
+smbiosname_show(struct device *dev, struct device_attribute *attr, char *buf)
+{
+	ssize_t result;
+	result = smbios_instance_string_exist(&dev->kobj, &attr->attr,
+					      SMBIOS_ATTR_LABEL_SHOW);
+	strncpy(buf, smbios_attr, result);
+	return result;
+}
+
+static ssize_t
+smbiosinstance_show(struct device *dev,
+		    struct device_attribute *attr, char *buf)
+{
+	ssize_t result;
+	result = smbios_instance_string_exist(&dev->kobj, &attr->attr,
+					      SMBIOS_ATTR_INSTANCE_SHOW);
+	strncpy(buf, smbios_attr, result);
+	return result;
+}
+
+static struct device_attribute smbios_attr_label = {
+	.attr = {.name = "label", .mode = 0444, .owner = THIS_MODULE},
+	.show = smbiosname_show,
+};
+
+static struct device_attribute smbios_attr_instance = {
+	.attr = {.name = "index", .mode = 0444, .owner = THIS_MODULE},
+	.show = smbiosinstance_show,
+};
+
+static struct attribute *smbios_attributes[] = {
+	&smbios_attr_label.attr,
+	&smbios_attr_instance.attr,
+	NULL,
+};
+
+static struct attribute_group smbios_attr_group = {
+	.attrs = smbios_attributes,
+	.is_visible = smbios_instance_string_exist,
+};
+
+static int
+pci_create_smbiosname_file(struct pci_dev *pdev)
+{
+	if (smbios_attr_group.is_visible &&
+		smbios_attr_group.is_visible(&pdev->dev.kobj, NULL, 0)) {
+		if (!sysfs_create_group(&pdev->dev.kobj, &smbios_attr_group))
+			return 0;
+	}
+	return -1;
+}
+
+static int
+pci_remove_smbiosname_file(struct pci_dev *pdev)
+{
+	if (smbios_attr_group.is_visible &&
+		smbios_attr_group.is_visible(&pdev->dev.kobj, NULL, 0)) {
+		sysfs_remove_group(&pdev->dev.kobj, &smbios_attr_group);
+		return 0;
+	}
+	return -1;
+}
+
+int pci_create_firmware_label_files(struct pci_dev *pdev)
+{
+	if (!pci_create_smbiosname_file(pdev))
+		return 0;
+	return -ENODEV;
+}
+
+int pci_remove_firmware_label_files(struct pci_dev *pdev)
+{
+	if (!pci_remove_smbiosname_file(pdev))
+		return 0;
+	return -ENODEV;
+}
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index afd2fbf..01fd799 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -1132,6 +1132,8 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
 
 	pci_create_slot_links(pdev);
 
+	pci_create_firmware_label_files(pdev);
+
 	return 0;
 
 err_vga_file:
@@ -1201,6 +1203,9 @@ void pci_remove_sysfs_dev_files(struct pci_dev *pdev)
 		sysfs_remove_bin_file(&pdev->dev.kobj, pdev->rom_attr);
 		kfree(pdev->rom_attr);
 	}
+
+	pci_remove_firmware_label_files(pdev);
+
 }
 
 static int __init pci_sysfs_init(void)
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
index f8077b3..089f402 100644
--- a/drivers/pci/pci.h
+++ b/drivers/pci/pci.h
@@ -11,6 +11,15 @@
 extern int pci_uevent(struct device *dev, struct kobj_uevent_env *env);
 extern int pci_create_sysfs_dev_files(struct pci_dev *pdev);
 extern void pci_remove_sysfs_dev_files(struct pci_dev *pdev);
+#ifndef CONFIG_DMI
+static inline int pci_create_firmware_label_files(struct pci_dev *pdev)
+{ return 0; }
+static inline int pci_remove_firmware_label_files(struct pci_dev *pdev)
+{ return 0; }
+#else
+extern int pci_create_firmware_label_files(struct pci_dev *pdev);
+extern int pci_remove_firmware_label_files(struct pci_dev *pdev);
+#endif
 extern void pci_cleanup_rom(struct pci_dev *dev);
 #ifdef HAVE_PCI_MMAP
 extern int pci_mmap_fits(struct pci_dev *pdev, int resno,
diff --git a/include/linux/dmi.h b/include/linux/dmi.h
index a8a3e1a..90e087f 100644
--- a/include/linux/dmi.h
+++ b/include/linux/dmi.h
@@ -20,6 +20,7 @@ enum dmi_device_type {
 	DMI_DEV_TYPE_SAS,
 	DMI_DEV_TYPE_IPMI = -1,
 	DMI_DEV_TYPE_OEM_STRING = -2,
+	DMI_DEV_TYPE_DEV_ONBOARD = -3,
 };
 
 struct dmi_header {
@@ -37,6 +38,14 @@ struct dmi_device {
 
 #ifdef CONFIG_DMI
 
+struct dmi_dev_onboard {
+	struct dmi_device dev;
+	int instance;
+	int segment;
+	int bus;
+	int devfn;
+};
+
 extern int dmi_check_system(const struct dmi_system_id *list);
 const struct dmi_system_id *dmi_first_match(const struct dmi_system_id *list);
 extern const char * dmi_get_system_info(int field);
-- 
1.6.5.2

With regards,
Narendra K

^ permalink raw reply related

* RE: How to use blkid for getting USB partition name???
From: chinnathambi @ 2010-07-08 12:18 UTC (permalink / raw)
  To: linux-hotplug
In-Reply-To: <20100506093216.D2E411F105E@zimbra.jasmin-infotech.com>

It's the USB Label/Volume name for the USB partition. See the following log.
We cant get any verbose output for blkid.

root:/> cat /proc/partitions
major minor  #blocks  name

   8        0  244198584 sda
   8        1          1 sda1
   8        5   33551721 sda5
   8        6   33551721 sda6
   8        7   33551721 sda7
   8        8   33551721 sda8
   8        9   33551721 sda9
   8       10   33551721 sda10
   8       11   33551721 sda11
   8       12    9325701 sda12
root:/> blkid -s TYPE /dev/sda5
root:/> blkid -s UUID /dev/sda5
root:/> BLKID_DEBUG=0xFFFF blkid -p -o /dev/sda5
root:/>

Regards,
Chinnathambi M
 

-----Original Message-----
From: 'Karel Zak' [mailto:kzak@redhat.com] 
Sent: Thursday, July 08, 2010 3:39 PM
To: chinnathambi
Cc: 'stephane ancelot'; linux-hotplug@vger.kernel.org; 'santhosh';
sadasivarao.m@jasmin-infotech.com
Subject: Re: How to use blkid for getting USB partition name???

On Thu, Jul 08, 2010 at 10:25:34AM +0530, chinnathambi wrote:
> root:/> blkid -p -o udev /dev/sda5
> root:/> BLKID_DEBUG=0xffff blkid -p -o udev /dev/sda5
> root:/>
> root:/>
> 
> 		I need to extract the USB name. But I cant get it. I don
> know whether I am doing anything wrong in the basic level. So please
clarify
> in this regard.

 What do you mean with "USB name"? The blkid command returns details
 about filesystems.

    Karel


-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com



^ permalink raw reply

* Re: How to use blkid for getting USB partition name???
From: 'Karel Zak' @ 2010-07-08 10:08 UTC (permalink / raw)
  To: linux-hotplug
In-Reply-To: <20100506093216.D2E411F105E@zimbra.jasmin-infotech.com>

On Thu, Jul 08, 2010 at 10:25:34AM +0530, chinnathambi wrote:
> root:/> blkid -p -o udev /dev/sda5
> root:/> BLKID_DEBUG=0xffff blkid -p -o udev /dev/sda5
> root:/>
> root:/>
> 
> 		I need to extract the USB name. But I cant get it. I don
> know whether I am doing anything wrong in the basic level. So please clarify
> in this regard.

 What do you mean with "USB name"? The blkid command returns details
 about filesystems.

    Karel


-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply

* RE: How to use blkid for getting USB partition name???
From: chinnathambi @ 2010-07-08  5:07 UTC (permalink / raw)
  To: linux-hotplug
In-Reply-To: <20100506093216.D2E411F105E@zimbra.jasmin-infotech.com>

Hai,
	Can any one please clarify in this regard?

Regards,
Chinnathambi M
 
-----Original Message-----
From: chinnathambi [mailto:chinnathambi.m@jasmin-infotech.com] 
Sent: Friday, May 14, 2010 8:19 PM
To: 'chinnathambi'; 'Karel Zak'
Cc: 'stephane ancelot'; 'linux-hotplug@vger.kernel.org'
Subject: RE: How to use blkid for getting USB partition name???


Hai,
	Can any one please clarify in this regard?

Regards,
Chinnathambi M
 
-----Original Message-----
From: chinnathambi [mailto:chinnathambi.m@jasmin-infotech.com] 
Sent: Tuesday, May 11, 2010 10:05 AM
To: 'chinnathambi'; 'Karel Zak'
Cc: 'stephane ancelot'; 'linux-hotplug@vger.kernel.org'
Subject: RE: How to use blkid for getting USB partition name???

Hai,
	Can any one please clarify in this regard?

Regards,
Chinnathambi M
 

-----Original Message-----
From: linux-hotplug-owner@vger.kernel.org
[mailto:linux-hotplug-owner@vger.kernel.org] On Behalf Of chinnathambi
Sent: Friday, May 07, 2010 9:55 AM
To: 'Karel Zak'
Cc: 'stephane ancelot'; linux-hotplug@vger.kernel.org
Subject: RE: How to use blkid for getting USB partition name???

Hai Stephane,
		I am not able to get any verbose output. Pls carify..

root:/> cat /proc/partitions
major minor  #blocks  name

  31        0        256 mtdblock0
  31        1        384 mtdblock1
  31        2       7552 mtdblock2
  31        3       7680 mtdblock3
  31        4        512 mtdblock4
   8        0  244198584 sda
   8        1          1 sda1
   8        5   33551721 sda5
   8        6   33551721 sda6
   8        7   33551721 sda7
   8        8   33551721 sda8
   8        9   33551721 sda9
   8       10   33551721 sda10
   8       11   33551721 sda11
   8       12    9325701 sda12
root:/> blkid -p -o udev /dev/sda5
root:/> BLKID_DEBUG=0xffff blkid -p -o udev /dev/sda5
root:/>
root:/>

		I need to extract the USB name. But I cant get it. I don
know whether I am doing anything wrong in the basic level. So please clarify
in this regard.


Regards,
Chinnathambi M
 
-----Original Message-----
From: linux-hotplug-owner@vger.kernel.org
[mailto:linux-hotplug-owner@vger.kernel.org] On Behalf Of Karel Zak
Sent: Thursday, May 06, 2010 7:09 PM
To: chinnathambi
Cc: 'stephane ancelot'; linux-hotplug@vger.kernel.org
Subject: Re: How to use blkid for getting USB partition name???

On Thu, May 06, 2010 at 03:03:23PM +0530, chinnathambi wrote:
> Hai,
> 	I have enable hotplug for detecting USB. I am having muti partition
> in my USB hard disc. I am trying to recover the parttion name by using

 parttion name...  Do you mean filesystem LABEL?

> blkid. But I cant get any response. I want to know whether I have to
enable
> anything in my kernel. Or after executing blkid command where to check for
> the output ?
> 
> Shown below is how I used blkid.
> 
> root:/> hotplug: usb inserted
> hotplug: usb inserted
> hotplug: usb inserted
> hotplug: usb inserted
> hotplug: usb inserted
> 
> root:/> cat /proc/partitions
> major minor  #blocks  name
> 
>   31        0        256 mtdblock0
>   31        1        384 mtdblock1
>   31        2       7552 mtdblock2
>   31        3       7680 mtdblock3
>   31        4        512 mtdblock4
>    8        0  244198584 sda
>    8        1          1 sda1
>    8        5   33551721 sda5
>    8        6   33551721 sda6
>    8        7   33551721 sda7
>    8        8   33551721 sda8
>    8        9   33551721 sda9
>    8       10   33551721 sda10
>    8       11   33551721 sda11
>    8       12    9325701 sda12
> root:/> blkid /dev/sda5
> root:/> blkid -c -o /dev/sda5

   blkid -p -o udev /dev/sda5

 or

   BLKID_DEBUG=0xffff blkid -p -o udev /dev/sda5

 to get more verbose output.

    Karel

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com
--
To unsubscribe from this list: send the line "unsubscribe linux-hotplug" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


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



^ permalink raw reply

* Re: [PATCH 1/2] Export firmware assigned labels of network devices
From: Domsch, Matt @ 2010-07-07 18:35 UTC (permalink / raw)
  To: Greg KH
  Cc: K, Narendra, netdev@vger.kernel.org,
	linux-hotplug@vger.kernel.org, linux-pci@vger.kernel.org,
	Hargrave, Jordan, Rose, Charles, Nijhawan, Vijay
In-Reply-To: <20100707181134.GB4293@kroah.com>

On Wed, Jul 07, 2010 at 01:11:34PM -0500, Greg KH wrote:
> > > Why do you need it?  What is calling that function?  What am I missing
> > > here?
> > 
> > The function 'pci_create_smbiosname_file' below is calling the .test method.
> > For every pdev the function checks if it has a SMBIOS string associated
> > with it or not. If there is no string (and instance) associated, then the
> > attributes 'label' and 'instance' are not created for that pdev.
> > To check for the existance of the string, the .test method is needed and
> > it is not available in 'struct device_attribute'. It provides 
> > .show and .store. We need a .show and .test. So we defined 
> 
> {sigh}
> 
> So, you just reinvented the is_visible function in struct
> attribute_group?  Please use the infrastructure already available to do
> this, it saves on code and debugging and review time.

I'll take the blame for this.  I recommended Narendra use the .test
method, as this is what I did back in 2005 in drivers/firmware/edd.c
which was one of the earliest consumers of the new sysfs code.  James
added the is_visible field to attribute groups in 2008, which I
missed (only 3 drivers make use of it, so it was easy to miss).  Since
that's the "new" preferred way to do it, we can adjust this patch
accordingly.

Thanks,
Matt

-- 
Matt Domsch
Technology Strategist
Dell | Office of the CTO

^ permalink raw reply

* Re: [PATCH 1/2] Export firmware assigned labels of network devices
From: Greg KH @ 2010-07-07 18:11 UTC (permalink / raw)
  To: Narendra K
  Cc: netdev, linux-hotplug, linux-pci, matt_domsch, jordan_hargrave,
	charles_rose, vijay_nijhawan
In-Reply-To: <20100707174826.GA1046@auslistsprd01.us.dell.com>

On Wed, Jul 07, 2010 at 12:48:26PM -0500, Narendra K wrote:
> > -----Original Message-----
> > From: Greg KH [mailto:greg@kroah.com] 
> > Sent: Wednesday, July 07, 2010 4:52 AM
> > To: K, Narendra
> > Cc: netdev@vger.kernel.org; linux-hotplug@vger.kernel.org;
> > linux-pci@vger.kernel.org; Domsch, Matt; Hargrave, Jordan; Rose,
> > Charles; Nijhawan, Vijay
> > Subject: Re: [PATCH 1/2] Export firmware assigned labels of network
> > devices to sysfs
> > 
> > On Tue, Jul 06, 2010 at 01:52:18PM -0500, Narendra K wrote:
> > > 
> > > 'device_create_file' takes 'struct device_attribute *' as a param
> > which 
> > > we have not used here because  'struct device_attribute' does not have
> > .test
> > > member which we needed in this patch.
> > 
> > Why do you need it?  What is calling that function?  What am I missing
> > here?
> 
> The function 'pci_create_smbiosname_file' below is calling the .test method.
> For every pdev the function checks if it has a SMBIOS string associated
> with it or not. If there is no string (and instance) associated, then the
> attributes 'label' and 'instance' are not created for that pdev.
> To check for the existance of the string, the .test method is needed and
> it is not available in 'struct device_attribute'. It provides 
> .show and .store. We need a .show and .test. So we defined 

{sigh}

So, you just reinvented the is_visible function in struct
attribute_group?  Please use the infrastructure already available to do
this, it saves on code and debugging and review time.

thanks,

greg k-h

^ permalink raw reply

* Re: [PATCH 1/2] Export firmware assigned labels of network devices to sysfs
From: Narendra K @ 2010-07-07 17:48 UTC (permalink / raw)
  To: greg
  Cc: netdev, linux-hotplug, linux-pci, matt_domsch, jordan_hargrave,
	charles_rose, vijay_nijhawan
In-Reply-To: <EDA0A4495861324DA2618B4C45DCB3EE612B27@blrx3m08.blr.amer.dell.com>

> -----Original Message-----
> From: Greg KH [mailto:greg@kroah.com] 
> Sent: Wednesday, July 07, 2010 4:52 AM
> To: K, Narendra
> Cc: netdev@vger.kernel.org; linux-hotplug@vger.kernel.org;
> linux-pci@vger.kernel.org; Domsch, Matt; Hargrave, Jordan; Rose,
> Charles; Nijhawan, Vijay
> Subject: Re: [PATCH 1/2] Export firmware assigned labels of network
> devices to sysfs
> 
> On Tue, Jul 06, 2010 at 01:52:18PM -0500, Narendra K wrote:
> > 
> > 'device_create_file' takes 'struct device_attribute *' as a param
> which 
> > we have not used here because  'struct device_attribute' does not have
> .test
> > member which we needed in this patch.
> 
> Why do you need it?  What is calling that function?  What am I missing
> here?

The function 'pci_create_smbiosname_file' below is calling the .test method.
For every pdev the function checks if it has a SMBIOS string associated
with it or not. If there is no string (and instance) associated, then the
attributes 'label' and 'instance' are not created for that pdev.
To check for the existance of the string, the .test method is needed and
it is not available in 'struct device_attribute'. It provides 
.show and .store. We need a .show and .test. So we defined 

+struct smbios_attribute smbios_attr_label = {
+	.attr = {.name = "label", .mode = 0444, .owner = THIS_MODULE},
+	.show = smbiosname_show,
+	.test = smbios_instance_string_exist,
+};

'smbios_instance_string_exist' checks if the pdev has a 'string' and 'instance'.

+static int 
+pci_create_smbiosname_file(struct pci_dev *pdev)
+{
+	if (smbios_attr_label.test && smbios_attr_label.test(&pdev->dev, NULL, NULL)) {
+		if (sysfs_create_file(&pdev->dev.kobj, &smbios_attr_label.attr))
+			return -1;
+		if (sysfs_create_file(&pdev->dev.kobj, &smbios_attr_instance.attr))
+			return -1;
+		return 0;
+	}
+	return -1;	
+}


+int pci_create_firmware_label_files(struct pci_dev *pdev)
+{
+	if (!pci_create_smbiosname_file(pdev))

> 
> Please always run your patches through scripts/checkpatch.pl and fix up
> the issues it finds before sending it out and having everyone else point
> them out to you :)
> 
> Also, a new thread is nice at times for new versions of patches...

Thanks for the feedback. Sorry for missing this.I would address all the issues 
and post the patch in a new thread.

With regards,
Narendra K

^ permalink raw reply

* [PATCH] path_id: Handle SAS and SATA devices
From: Hannes Reinecke @ 2010-07-07 14:55 UTC (permalink / raw)
  To: linux-hotplug


SAS devices should be referenced by the SAS address of the target;
on the initiator side we assume an identity mapping between SAS
addresses and PCI devnumber.
SATA devices have an identity mapping between SATA links and
linux scsi_host structures, so we can map the host number onto
the SATA link.
For this to work the LUN numbering needs to be updated, too,
as SATA devices do not have the concept of a LUN, whereas normal
SCSI devices have.

Signed-off-by: Hannes Reinecke <hare@suse.de>

diff --git a/extras/path_id/path_id.c b/extras/path_id/path_id.c
index dcee378..1b6c363 100644
--- a/extras/path_id/path_id.c
+++ b/extras/path_id/path_id.c
@@ -97,7 +97,6 @@ static struct udev_device *handle_scsi_fibre_channel(struct udev_device *parent,
 	struct udev_device *targetdev;
 	struct udev_device *fcdev = NULL;
 	const char *port;
-	unsigned int lun;
 
 	targetdev = udev_device_get_parent_with_subsystem_devtype(parent, "scsi", "scsi_target");
 	if (targetdev = NULL)
@@ -112,8 +111,7 @@ static struct udev_device *handle_scsi_fibre_channel(struct udev_device *parent,
 		goto out;
 	}
 
-	lun = strtoul(udev_device_get_sysnum(parent), NULL, 10);
-	path_prepend(path, "fc-%s:0x%04x%04x00000000", port, lun & 0xffff, (lun >> 16) & 0xffff);
+	path_prepend(path, "fc-%s", port);
 out:
 	udev_device_unref(fcdev);
 	return parent;
@@ -121,7 +119,34 @@ out:
 
 static struct udev_device *handle_scsi_sas(struct udev_device *parent, char **path)
 {
-	return NULL;
+	struct udev *udev  = udev_device_get_udev(parent);
+	struct udev_device *end_dev = NULL;
+	struct udev_device *sas_dev;
+	const char *end_dev_wwn;
+
+	/* Find end device */
+	end_dev = parent;
+	while (1) {
+		end_dev = udev_device_get_parent(end_dev);
+		if (end_dev = NULL)
+			return NULL;
+		if (!strncmp(udev_device_get_sysname(end_dev), "end_device", 10))
+			break;
+	}
+	if (end_dev = NULL)
+		return NULL;
+
+	/* find sas end device */
+	sas_dev = udev_device_new_from_subsystem_sysname(udev, "sas_device", udev_device_get_sysname(end_dev));
+	if (sas_dev = NULL)
+		return NULL;
+
+	end_dev_wwn = udev_device_get_sysattr_value(sas_dev, "sas_address");
+
+	path_prepend(path, "sas-%s", end_dev_wwn);
+
+	udev_device_unref(sas_dev);
+	return end_dev;
 }
 
 static struct udev_device *handle_scsi_iscsi(struct udev_device *parent, char **path)
@@ -174,7 +199,7 @@ static struct udev_device *handle_scsi_iscsi(struct udev_device *parent, char **
 		goto out;
 	}
 
-	path_prepend(path, "ip-%s:%s-iscsi-%s-lun-%s", addr, port, target, udev_device_get_sysnum(parent));
+	path_prepend(path, "ip-%s:%s-iscsi-%s", addr, port, target);
 out:
 	udev_device_unref(sessiondev);
 	udev_device_unref(conndev);
@@ -183,23 +208,34 @@ out:
 
 static struct udev_device *handle_scsi_default(struct udev_device *parent, char **path)
 {
+	struct udev *udev  = udev_device_get_udev(parent);
 	struct udev_device *hostdev;
-	int host, bus, target, lun;
-	const char *name;
+	int host, bus, target;
+	const char *name, *hba, *hostpath;
 	char *base;
 	char *pos;
+	char *type = "scsi";
 	DIR *dir;
 	struct dirent *dent;
-	int basenum;
-
-	hostdev = udev_device_get_parent_with_subsystem_devtype(parent, "scsi", "scsi_host");
-	if (hostdev = NULL)
-		return NULL;
+	int basenum, hostnum = 0;
 
 	name = udev_device_get_sysname(parent);
-	if (sscanf(name, "%d:%d:%d:%d", &host, &bus, &target, &lun) != 4)
+	if (sscanf(name, "target%d:%d:%d", &host, &bus, &target) != 3)
 		return NULL;
 
+	parent = udev_device_get_parent(parent);
+	/* Check for libata hosts */
+	hostdev = udev_device_new_from_subsystem_sysname(udev, "scsi_host", udev_device_get_sysname(parent));
+	if (hostdev = NULL)
+		return NULL;
+	hba = udev_device_get_sysattr_value(hostdev, "proc_name");
+	if (hba && (!strncmp(hba, "sata", 4) || !strcmp(hba, "ahci")))
+		type = "sata";
+	if (hba && (!strncmp(hba, "pata", 4) || !strncmp(hba, "ata", 3)))
+		type = "ata";
+	udev_device_unref(hostdev);
+	/* Reset to original host path */
+	hostdev = parent;
 	/* rebase host offset to get the local relative number */
 	basenum = -1;
 	base = strdup(udev_device_get_syspath(hostdev));
@@ -227,6 +263,7 @@ static struct udev_device *handle_scsi_default(struct udev_device *parent, char
 		if (strncmp(dent->d_name, "host", 4) != 0)
 			continue;
 		i = strtoul(&dent->d_name[4], &rest, 10);
+		hostnum++;
 		if (rest[0] != '\0')
 			continue;
 		if (basenum = -1 || i < basenum)
@@ -239,20 +276,54 @@ static struct udev_device *handle_scsi_default(struct udev_device *parent, char
 	}
 	host -= basenum;
 
-	path_prepend(path, "scsi-%u:%u:%u:%u", host, bus, target, lun);
+	if (!strcmp(type, "scsi"))
+		path_prepend(path, "scsi-%u:%u:%u", host, bus, target);
+	else
+		path_prepend(path, "%s-%u", type, host);
 out:
 	free(base);
 	return hostdev;
 }
 
+static int scsi_is_sata(const char *name)
+{
+	char syspath[UTIL_PATH_SIZE];
+	struct stat stbuf;
+
+	strcpy(syspath, name);
+	strcat(syspath, "/unload_heads");
+
+	return (stat(syspath, &stbuf) < 0) ? 0 : 1;
+}
+
 static struct udev_device *handle_scsi(struct udev_device *parent, char **path)
 {
+	struct udev *udev  = udev_device_get_udev(parent);
 	const char *devtype;
 	const char *name;
 	const char *id;
 
 	devtype = udev_device_get_devtype(parent);
-	if (devtype = NULL || strcmp(devtype, "scsi_device") != 0)
+	if (devtype = NULL)
+		return parent;
+
+	/* lousy scsi sysfs does not have a "subsystem" for the transport */
+	name = udev_device_get_syspath(parent);
+
+	if (strcmp(devtype, "scsi_device") = 0) {
+		if (!scsi_is_sata(name)) {
+			unsigned int host, bus, target, lun;
+
+			if (sscanf(udev_device_get_sysname(parent),
+				   "%d:%d:%d:%d", &host, &bus, &target, &lun) != 4)
+				return NULL;
+			path_prepend(path, "lun-0x%04x%04x00000000",
+				     lun & 0xffff, (lun >> 16) & 0xffff);
+		}
+		return parent;
+	}
+
+	if (strcmp(devtype, "scsi_host") = 0)
 		return parent;
 
 	/* firewire */
@@ -263,9 +334,6 @@ static struct udev_device *handle_scsi(struct udev_device *parent, char **path)
 		goto out;
 	}
 
-	/* lousy scsi sysfs does not have a "subsystem" for the transport */
-	name = udev_device_get_syspath(parent);
-
 	if (strstr(name, "/rport-") != NULL) {
 		parent = handle_scsi_fibre_channel(parent, path);
 		goto out;

^ permalink raw reply related

* Re: [PATCH] path_id: add handle_scsi_sas
From: Kay Sievers @ 2010-07-07 12:05 UTC (permalink / raw)
  To: linux-hotplug
In-Reply-To: <1277468902-12862-1-git-send-email-harald@redhat.com>

On Wed, Jul 7, 2010 at 12:20, Hannes Reinecke <hare@suse.de> wrote:
> This is wrong. The whole idea of path_id is that the path traversal is done
> in one common loop, from which there are callouts to the individual device
> handlers.

If you get a working update, please also remove the "unknown" stuff
from the returned string.

We must not return anything we are not entirely sure about, and the
strings must never change when something becomes "known" in the future
with some kernel/driver/sysfs update or anything similar.

In all such cases we better return nothing, than some random stuff we
can not keep reasonable stable.

Thanks,
Kay

^ permalink raw reply

* Re: [PATCH] path_id: add handle_scsi_sas
From: Hannes Reinecke @ 2010-07-07 10:20 UTC (permalink / raw)
  To: linux-hotplug
In-Reply-To: <1277468902-12862-1-git-send-email-harald@redhat.com>

harald@redhat.com wrote:
> From: Harald Hoyer <harald@redhat.com>
> 
> based on code by Jim Garlick.
> ---
>  extras/path_id/path_id.c |   64 +++++++++++++++++++++++++++++++++++++++++++++-
>  1 files changed, 63 insertions(+), 1 deletions(-)
> 
> diff --git a/extras/path_id/path_id.c b/extras/path_id/path_id.c
> index dcee378..c3d241b 100644
> --- a/extras/path_id/path_id.c
> +++ b/extras/path_id/path_id.c
> @@ -121,7 +121,69 @@ out:
>  
>  static struct udev_device *handle_scsi_sas(struct udev_device *parent, char **path)
>  {
> -	return NULL;
> +	struct udev *udev  = udev_device_get_udev(parent);
> +	struct udev_device *end_dev;
> +	struct udev_device *sasdev;
> +	struct udev_device *phydev;
> +	struct udev_device *parent_dev;
> +	struct udev_device *child_dev;
> +	char syspath[UTIL_PATH_SIZE], *base;
> +	char phy_path[UTIL_PATH_SIZE];
> +	const char *end_name, *name, *enc, *bay;
> +	const char *port_path;
> +	int scsi_host;
> +	int num_phys = 8;
> +	int i;
> +
> +	parent_dev = parent;
> +	while (1) {
> +		child_dev = parent_dev;
> +		parent_dev = udev_device_get_parent(child_dev);
> +		if (parent_dev = NULL)
> +			return NULL;
> +		name = udev_device_get_sysname(parent_dev);
> +		if (strstr(name, "end_device-")) {
> +			end_dev = parent_dev;
> +			end_name = name;
> +		} else if (sscanf(name, "host%d", &scsi_host)) {
> +			port_path = udev_device_get_syspath(child_dev);
> +			break;
> +		}
> +	}
> +
This is wrong. The whole idea of path_id is that the path traversal is done
in one common loop, from which there are callouts to the individual device
handlers.

So we should be having one sas_end_device_handler and one sas_host handler.

I'll see to come up with an updated version.

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      zSeries & Storage
hare@suse.de			      +49 911 74053 688
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: Markus Rex, HRB 16746 (AG Nürnberg)

^ permalink raw reply

* Re: [ANNOUNCE] udev 159 release
From: Robby Workman @ 2010-07-07  6:27 UTC (permalink / raw)
  To: linux-hotplug
In-Reply-To: <1278479741.12766.1.camel@yio.site>

On Wed, 07 Jul 2010 07:15:41 +0200
Kay Sievers <kay.sievers@vrfy.org> wrote:

> Here comes a new udev version. Thanks to all who have contributed to
> this release.
> 
> The tarball can be found here:
>  ftp://ftp.kernel.org/pub/linux/utils/kernel/hotplug/


Are you sure?  :-)

Forgot to upload it?

-RW

^ permalink raw reply

* [ANNOUNCE] udev 159 release
From: Kay Sievers @ 2010-07-07  5:15 UTC (permalink / raw)
  To: linux-hotplug

Here comes a new udev version. Thanks to all who have contributed to
this release.

The tarball can be found here:
 ftp://ftp.kernel.org/pub/linux/utils/kernel/hotplug/

The development repository can be found here:
 http://www.kernel.org/git/?p=linux/hotplug/udev.git;a=summary

The ChangeLog can be found here:
 http://www.kernel.org/git/?p=linux/hotplug/udev.git;a=blob;hb=HEAD;f=ChangeLog

udev 159
====
Bugfixes.

New and fixed keymaps.

Install systemd service files if applicable.




^ permalink raw reply

* Re: [PATCH 1/2] Export firmware assigned labels of network devices
From: Greg KH @ 2010-07-06 23:22 UTC (permalink / raw)
  To: Narendra K
  Cc: netdev, linux-hotplug, linux-pci, matt_domsch, jordan_hargrave,
	charles_rose, vijay_nijhawan
In-Reply-To: <20100706185218.GA19357@auslistsprd01.us.dell.com>

On Tue, Jul 06, 2010 at 01:52:18PM -0500, Narendra K wrote:
> > -----Original Message-----
> > From: Greg KH [mailto:greg@kroah.com] 
> > Sent: Wednesday, June 30, 2010 9:12 PM
> > To: K, Narendra
> > Cc: Domsch, Matt; netdev@vger.kernel.org; linux-hotplug@vger.kernel.org;
> > linux-pci@vger.kernel.org; Hargrave, Jordan; Rose, Charles; Nijhawan,
> > Vijay
> > Subject: Re: [PATCH 1/2] Export firmware assigned labels of network
> > devices to sysfs
> > 
> > On Tue, Jun 29, 2010 at 11:28:18AM -0500, Narendra K wrote:
> > > --- a/drivers/pci/Makefile
> > > +++ b/drivers/pci/Makefile
> > > @@ -4,7 +4,7 @@
> > >  
> > >  obj-y		+= access.o bus.o probe.o remove.o pci.o \
> > >  			pci-driver.o search.o pci-sysfs.o rom.o
> > setup-res.o \
> > > -			irq.o vpd.o
> > > +			irq.o vpd.o pci-label.o
> > 
> > No, only build this if CONFIG_DMI is set.
> 
> I have corrected this to build pci-label.o if only if CONFIG_DMI is set.
> 
> 
> > > +pci_create_smbiosname_file(struct pci_dev *pdev)
> > > +{
> > > +	if (smbios_attr_label.test && smbios_attr_label.test(&pdev->dev,
> > NULL, NULL)) {
> > > +		if (sysfs_create_file(&pdev->dev.kobj,
> > &smbios_attr_label.attr))
> > > +			return -1;
> > 
> > What's wrong with the 'device_create_file' calls?
> 
> 'device_create_file' takes 'struct device_attribute *' as a param which 
> we have not used here because  'struct device_attribute' does not have .test
> member which we needed in this patch.

Why do you need it?  What is calling that function?  What am I missing
here?

> Please find the patch with the above change here -

Please always run your patches through scripts/checkpatch.pl and fix up
the issues it finds before sending it out and having everyone else point
them out to you :)

Also, a new thread is nice at times for new versions of patches...

thanks,

greg k-h

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox