Skip to contentSkip to conversation

Linux SCSI hotplug infrastructure

RFC PATCH In review Matt Domsch 2 participants 9 messages Feb 7, 2005 – Feb 8, 2005

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

RFC PATCH 1/1 Linux SCSI hotplug infrastructure

Below is a patch to add some hotplug infrastructure to the Linux SCSI subsystem.

New files:
include/scsi/scsi_hotplug.h
drivers/scsi/scsi_hotplug.c
implements a new exported function:

extern int scsi_topology_hctl_action(struct Scsi_Host *shost, unsigned int channel,

			      unsigned int id, unsigned int lun, enum scsi_topology_action action);

which invokes kobject_hotplug() on a temporary "scsi_topology" device. This device represents a target that exists on a topology (i.e. was just inserted into a hot plug enclosure, or was just created by a RAID controller management application) but is not yet hooked into the kernel.

Modified files:
drivers/scsi/Kconfig
drivers/scsi/Makefile
drivers/scsi/megaraid/megaraid_mbox.c
(will follow in a separate patch)
is the user of this new function.

In addition, two more infrastructure pieces are necessary:
udev-050-scsi_topology.patch - adds the subsystem name "scsi_topology" to the list of devices *not* to wait for the creation of files in sysfs for - scsi_topology devices aren't to be registered in sysfs.

/etc/hotplug/scsi_topology.agent
handles the hotplug call, and invokes /sys/class/scsi_host/hostX/scan and /sys/class/scsi_device/H:C:T:L:/device/delete as appropriate.

The flow is as follows:

# echo "2" > /sys/class/scsi_host/host2/logical_drive_created
(to be done by a management application that knows it just created
logical drive #2 on the controller)

megaraid_mbox.c sysfs method converts logical drive number to HCTL value, calls scsi_topology_hctl_action().

scsi_topology_hctl_action() invokes kobject_hotplug() with a scsi_topology subsystem device.

kobject_hotplug() calls /sbin/hotplug or /sbin/udevsend (more likely the latter), which invokes /etc/hotplug/scsi_topology.agent with the ACTION={add,remove}.

scsi_topology.agent invokes /sys/class/scsi_host/hostX/scan or
/sys/class/scsi_device/H:C:T:L:/device/delete as appropriate.

From this point, we're back into known territory, with the device being made known, or deleted from, the kernel's view.

Thoughts?

Signature · 229 lines
Matt Domsch
Software Architect
Dell Linux Solutions linux.dell.com & www.dell.com/linux
Linux on Dell mailing lists @ http://lists.us.dell.com

=== drivers/scsi/Kconfig 1.95 vs edited ==--- 1.95/drivers/scsi/Kconfig	2005-01-28 11:14:29 -06:00
+++ edited/drivers/scsi/Kconfig	2005-02-05 13:58:45 -06:00
@@ -185,6 +185,16 @@
 	  there should be no noticeable performance impact as long as you have
 	  logging turned off.
 
+config SCSI_HOTPLUG
+	bool "Hot Plug SCSI devices"
+	depends on SCSI && EXPERIMENTAL
+	default y
+	help
+	  If your driver or management applications know about
+	  device hot plugging (insertion/removal of physical disks in
+	  a topology, or creation/deletion of logical disks on a RAID
+	  controller), say Y here.  Otherwise, say N.
+
 menu "SCSI Transport Attributes"
 	depends on SCSI
 
=== drivers/scsi/Makefile 1.72 vs edited ==--- 1.72/drivers/scsi/Makefile	2004-11-20 14:26:17 -06:00
+++ edited/drivers/scsi/Makefile	2005-02-05 13:58:15 -06:00
@@ -147,6 +147,7 @@
 				   scsi_devinfo.o
 scsi_mod-$(CONFIG_SYSCTL)	+= scsi_sysctl.o
 scsi_mod-$(CONFIG_SCSI_PROC_FS)	+= scsi_proc.o
+scsi_mod-$(CONFIG_SCSI_HOTPLUG)	+= scsi_hotplug.o
 
 sd_mod-objs	:= sd.o
 sr_mod-objs	:= sr.o sr_ioctl.o sr_vendor.o
--- /dev/null	Thu Apr 11 09:25:15 2002
+++ include/scsi/scsi_hotplug.h	Sun Feb  6 23:29:51 2005
@@ -0,0 +1,41 @@
+/*
+ *  SCSI Hotplug
+ *
+ *  Copyright (c) 2005 Dell, Inc <[email protected]>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+#ifndef _SCSI_SCSI_HOTPLUG_H
+#define _SCSI_SCSI_HOTPLUG_H
+
+#include <linux/config.h>
+#include <scsi/scsi_host.h>
+#include <scsi/scsi_device.h>
+
+enum scsi_topology_action {
+	SCSI_TOPOLOGY_ADDED    = 1,  /* device added in the topology */
+	SCSI_TOPOLOGY_REMOVED  = 2,  /* device removed from the topology */
+};
+
+#if defined (CONFIG_SCSI_HOTPLUG) || defined(CONFIG_SCSI_HOTPLUG_MODULE)
+extern int scsi_topology_hctl_action(struct Scsi_Host *shost, unsigned int channel,
+			      unsigned int id, unsigned int lun, enum scsi_topology_action action);
+#else
+static inline int scsi_topology_hctl_action(struct Scsi_Host *shost, unsigned int channel,
+				    unsigned int id, unsigned int lun, enum scsi_topology_action action)
+{return -ENOSYS;}
+#endif
+
+#endif /* _SCSI_SCSI_HOTPLUG_H */
--- /dev/null	Thu Apr 11 09:25:15 2002
+++ drivers/scsi/scsi_hotplug.c	Sun Feb  6 23:42:21 2005
@@ -0,0 +1,138 @@
+/*
+ *  SCSI Hotplug
+ *
+ *  Copyright (c) 2005 Dell, Inc <[email protected]>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include <linux/config.h>
+#include <linux/module.h>
+#include <linux/kobject.h>
+#include <scsi/scsi_hotplug.h>
+
+/*
+ * TODO:
+ * - if CONFIG_SCSI_HOTPLUG=y and CONFIG_SCSI=y, then the exported
+ * functions here get dropped by the vmlinux linker, as there are no
+ * vmlinux users of them (only modules).
+ *
+ */
+
+/* This belongs in include/device.h, as drivers/base/core.c defines it too */
+#define to_dev(obj) container_of(obj, struct device, kobj)
+
+static int scsi_topology_device_hotplug(struct kset *kset, struct kobject *kobj, char **envp,
+			       int num_envp, char *buffer, int buffer_size)
+{
+
+	struct device *dev = to_dev(kobj);
+	struct device *parent_dev = dev->parent;
+	struct scsi_device *sdev = to_scsi_device(dev);
+	struct Scsi_Host *shost = dev_to_shost(parent_dev);
+	int length = 0;
+	int i = 0;
+
+	add_hotplug_env_var(envp, num_envp, &i, buffer, buffer_size, &length,
+			    "SCSI_TOPOLOGY_EVENT=1");
+	add_hotplug_env_var(envp, num_envp, &i, buffer, buffer_size, &length,
+			    "SCSI_TOPOLOGY_EVENT_HCTL=1");
+	add_hotplug_env_var(envp, num_envp, &i, buffer, buffer_size, &length,
+			    "SCSI_HOST=%u", shost->host_no);
+	add_hotplug_env_var(envp, num_envp, &i, buffer, buffer_size, &length,
+			    "SCSI_CHANNEL=%u", sdev->channel);
+	add_hotplug_env_var(envp, num_envp, &i, buffer, buffer_size, &length,
+			    "SCSI_ID=%u", sdev->id);
+	add_hotplug_env_var(envp, num_envp, &i, buffer, buffer_size, &length,
+			    "SCSI_LUN=%u", sdev->lun);
+
+	envp[i] = NULL;
+	return 0;
+}
+
+static struct kset_hotplug_ops scsi_topology_device_kset_ops +{
+	.hotplug = scsi_topology_device_hotplug,
+};
+
+static struct kset scsi_topology_device_kset = {
+	.hotplug_ops = &scsi_topology_device_kset_ops,
+	.kobj = {
+		.name = "scsi_topology",
+	},
+};
+
+static void scsi_topology_device_release(struct device *dev)
+{
+	put_device(dev->parent);
+}
+
+static int scsi_topology_device_init(struct scsi_device *sdev,
+				     struct Scsi_Host *shost,
+				     unsigned int channel,
+				     unsigned int id,
+				     unsigned int lun)
+{
+	struct device *dev;
+	memset(sdev, 0, sizeof(*sdev));
+	dev = &sdev->sdev_gendev;
+	snprintf(dev->bus_id, BUS_ID_SIZE, "topology-%u:%u:%u:%u",
+		 shost->host_no, channel, id, lun);
+	dev->parent     = get_device(&shost->shost_gendev);
+	dev->release    = scsi_topology_device_release;
+	sdev->channel = channel;
+	sdev->id = id;
+	sdev->lun = lun;
+	device_initialize(dev);
+	kobject_set_name(&dev->kobj, "%s", dev->bus_id);
+	dev->kobj.parent = &dev->parent->kobj;
+	dev->kobj.kset  = &scsi_topology_device_kset;
+	return 0;
+}
+
+static inline enum kobject_action scsi_topology_action_to_kobject_action(enum scsi_topology_action action)
+{
+	enum kobject_action kaction = KOBJ_CHANGE; /* should there be a KOBJ_NOOP? */
+	switch (action)	{
+	case SCSI_TOPOLOGY_ADDED:
+		kaction = KOBJ_ADD;
+		break;
+	case SCSI_TOPOLOGY_REMOVED:
+		kaction = KOBJ_REMOVE;
+		break;
+	}
+	return kaction;
+}
+
+
+int scsi_topology_hctl_action(struct Scsi_Host *shost, unsigned int channel,
+			      unsigned int id, unsigned int lun, enum scsi_topology_action action)
+{
+	struct scsi_device *sdev;
+	enum kobject_action kaction;
+	int error;
+
+	sdev = kmalloc(sizeof(*sdev), GFP_KERNEL);
+	if (!sdev)
+		return -ENOMEM;
+	error = scsi_topology_device_init(sdev, shost, channel, id, lun);
+	if (error)
+		return error;
+	kaction = scsi_topology_action_to_kobject_action(action);
+	kobject_hotplug(&sdev->sdev_gendev.kobj, kaction);
+	kfree(sdev);
+	return 0;
+}
+EXPORT_SYMBOL_GPL(scsi_topology_hctl_action);


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_ide95&alloc_id396&op=click
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
#1 lore raw
Quoted 4 lines · Matt Domsch

Modified files:
drivers/scsi/megaraid/megaraid_mbox.c
(will follow in a separate patch)
is the user of this new function.

For example. I will rework this to follow the patch submitted last week by LSI to accomplish something similar in their driver.

Signature · 135 lines
Matt Domsch
Software Architect
Dell Linux Solutions linux.dell.com & www.dell.com/linux
Linux on Dell mailing lists @ http://lists.us.dell.com

=== drivers/scsi/megaraid/megaraid_mbox.c 1.12 vs edited ==--- 1.12/drivers/scsi/megaraid/megaraid_mbox.c	2005-01-31 00:33:46 -06:00
+++ edited/drivers/scsi/megaraid/megaraid_mbox.c	2005-02-06 23:35:08 -06:00
@@ -70,6 +70,7 @@
  * For history of changes, see Documentation/ChangeLog.megaraid
  */
 
+#include <scsi/scsi_hotplug.h>
 #include "megaraid_mbox.h"
 
 static int megaraid_init(void);
@@ -455,6 +456,100 @@
 
 
 /*
+ * sysfs class device support
+ * creates three files:
+ * /sys/class/scsi_host
+ * |-- host0
+ * |   |-- logical_drive_created
+ * |   |-- logical_drive_destroyed
+ *
+ * These make the midlayer invoke /sbin/hotplug, which then calls back into sysfs
+ * /sys/class/scsi_host
+ * |-- host0
+ * |   |-- scan
+ *
+ * and
+ *
+ * /sys/devices/pci0000:0x/0000:0x:0x.0/host0
+ * |-- 0:0:0:0
+ * |   |-- delete
+ *
+ * respectively.  This allows userspace applications to work
+ * using their logical drive number, and lets the driver translate
+ * that into host, channel, id, and lun values which the other
+ * mechanisms require.  This is similar to how hot plug CPU works.
+ */
+
+/**
+ * lda_to_hcil()
+ * @adapter
+ * @lda - logical drive address
+ * @host_no
+ * @channel
+ * @id
+ * @lun
+ *
+ * converts a logical drive address into a host, channel id, lun tuple.
+ */
+
+static inline int megaraid_lda_to_hcil(struct Scsi_Host *shost, u32 lda,
+				       u32 *host_no, u32 *channel, u32 *id, u32 *lun)
+{
+	if (lda > MAX_LOGICAL_DRIVES_40LD)
+		return -EINVAL;
+	*host_no = shost->host_no;
+	*channel = shost->max_channel;
+	*id      = (lda < shost->this_id) ? lda : lda + 1;
+	*lun     = 0;
+	return 0;
+}
+
+static int megaraid_host_store(struct class_device *class_dev, const char *buf, size_t count,
+			       enum scsi_topology_action action)
+{
+        struct Scsi_Host *shost = class_to_shost(class_dev);
+	int fields=0, rc=-EINVAL;
+	u32 lda=0, host_no=0, channel=0, id=0, lun=0;
+	fields = sscanf(buf, "%u", &lda);
+	if (fields != 1)
+		return rc;
+	if (lda > MAX_LOGICAL_DRIVES_40LD)
+		return rc;
+	rc = megaraid_lda_to_hcil(shost, lda, &host_no, &channel, &id, &lun);
+	if (rc)
+		return rc;
+
+	rc = scsi_topology_hctl_action(shost, channel, id, lun, action);
+
+	if (rc)
+		return rc;
+	return count;
+}
+
+static ssize_t megaraid_host_store_ld_created(struct class_device *class_dev, const char *buf, size_t count)
+{
+	return megaraid_host_store(class_dev, buf, count, SCSI_TOPOLOGY_ADDED);
+}
+static ssize_t megaraid_host_store_ld_destroyed(struct class_device *class_dev, const char *buf, size_t count)
+{
+	return megaraid_host_store(class_dev, buf, count, SCSI_TOPOLOGY_REMOVED);
+}
+
+
+#define MEGARAID_HOST_WOATTR(_name,_store) \
+CLASS_DEVICE_ATTR(_name, S_IWUSR|S_IWGRP, NULL, _store)
+
+static MEGARAID_HOST_WOATTR(logical_drive_created, megaraid_host_store_ld_created);
+static MEGARAID_HOST_WOATTR(logical_drive_destroyed, megaraid_host_store_ld_destroyed);
+
+/* Host attributes initializer */
+static struct class_device_attribute *megaraid_host_attrs[] = {
+	&class_device_attr_logical_drive_created,
+	&class_device_attr_logical_drive_destroyed,
+	NULL,
+};
+
+/*
  * Scsi host template for megaraid unified driver
  */
 static struct scsi_host_template megaraid_template_g = {
@@ -467,6 +562,7 @@
 	.eh_bus_reset_handler		= megaraid_reset_handler,
 	.eh_host_reset_handler		= megaraid_reset_handler,
 	.use_clustering			= ENABLE_CLUSTERING,
+	.shost_attrs			= megaraid_host_attrs,
 };
 
 


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_ide95&alloc_id396&op=click
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
#2 lore raw
In reply to Matt Domsch
Quoted 4 lines · Matt Domsch

In addition, two more infrastructure pieces are necessary:
udev-050-scsi_topology.patch - adds the subsystem name "scsi_topology" to the list of devices *not* to wait for the creation of files in sysfs for - scsi_topology devices aren't to be registered in sysfs.

Patch follows.

Signature · 26 lines
Matt Domsch
Software Architect
Dell Linux Solutions linux.dell.com & www.dell.com/linux
Linux on Dell mailing lists @ http://lists.us.dell.com

--- udev-050/udev_sysfs.c.~1~	2004-12-17 23:53:07.000000000 -0600
+++ udev-050/udev_sysfs.c	2005-02-07 10:58:45.000000000 -0600
@@ -56,6 +56,7 @@
 	{ .subsystem = "fc_host",	.file = "port_id" },
 	{ .subsystem = "spi_transport",	.file = "width" },
 	{ .subsystem = "spi_host",	.file = "width" },
+	{ .subsystem = "scsi_topology",	.file = NULL },
 	{ NULL, NULL }
 };
 


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_ide95&alloc_id396&op=click
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
#3 lore raw
In reply to Matt Domsch
Quoted 3 lines · Matt Domsch

/etc/hotplug/scsi_topology.agent
handles the hotplug call, and invokes /sys/class/scsi_host/hostX/scan and /sys/class/scsi_device/H:C:T:L:/device/delete as appropriate.

And here's scsi_topology.agent.

--
Matt Domsch
Software Architect
Dell Linux Solutions linux.dell.com & www.dell.com/linux Linux on Dell mailing lists @ http://lists.us.dell.com

#!/bin/bash
#
# SCSI Topology hotplug agent.
# Copyright (C) 2005 Dell, Inc. <[email protected]>
#
# This is invoked when a device, not currently known to the system, is

# added or removed from a SCSI topology.  This includes creation of a
# logical drive on a RAID controller, or manually inserting a disk
# into a SCSI disk enclosure.  This script then invokes the scan
# method of the scsi_host, or the delete method of the scsi_device, to
# inform the kernel of the change made on the topology.
#
# SCSI_TOPOLOGY_EVENT_HCTL is used to know that the data to pass to
# scan is a Host:Controller:Target ID:LUN tuple.  This is to provide
# for future SCSI implmentations that may use a native addressing
# scheme rather than only HCTL.

[ ${SCSI_TOPOLOGY_EVENT} != "1" ] && exit
[ ${SCSI_TOPOLOGY_EVENT_HCTL} != "1" ] && exit

if [ "${ACTION}" = "add" ]; then

    MYPATH=/sys/class/scsi_host/host${SCSI_HOST}/scan
    [ -f ${MYPATH} ] && echo "${SCSI_CHANNEL} ${SCSI_ID} ${SCSI_LUN}" > ${MYPATH}

fi

if [ "${ACTION}" = "remove" ]; then

    MYPATH=/sys/class/scsi_device/${SCSI_HOST}:${SCSI_CHANNEL}:${SCSI_ID}:${SCSI_LUN}/device/delete
    [ -f ${MYPATH} ] && echo "1" > ${MYPATH}

fi

-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users. Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_ide95&alloc_id396&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#4 lore raw
In reply to Matt Domsch
Quoted 44 lines · Matt Domsch

Below is a patch to add some hotplug infrastructure to the Linux SCSI subsystem.

New files:
include/scsi/scsi_hotplug.h
drivers/scsi/scsi_hotplug.c
implements a new exported function:

extern int scsi_topology_hctl_action(struct Scsi_Host *shost, unsigned int channel,

			      unsigned int id, unsigned int lun, enum scsi_topology_action action);

which invokes kobject_hotplug() on a temporary "scsi_topology" device. This device represents a target that exists on a topology (i.e. was just inserted into a hot plug enclosure, or was just created by a RAID controller management application) but is not yet hooked into the kernel.

In addition, two more infrastructure pieces are necessary:
udev-050-scsi_topology.patch - adds the subsystem name "scsi_topology" to the list of devices *not* to wait for the creation of files in sysfs for - scsi_topology devices aren't to be registered in sysfs.

/etc/hotplug/scsi_topology.agent
handles the hotplug call, and invokes /sys/class/scsi_host/hostX/scan and /sys/class/scsi_device/H:C:T:L:/device/delete as appropriate.

The flow is as follows:

# echo "2" > /sys/class/scsi_host/host2/logical_drive_created
(to be done by a management application that knows it just created
logical drive #2 on the controller)

megaraid_mbox.c sysfs method converts logical drive number to HCTL value, calls scsi_topology_hctl_action().

scsi_topology_hctl_action() invokes kobject_hotplug() with a scsi_topology subsystem device.

kobject_hotplug() calls /sbin/hotplug or /sbin/udevsend (more likely the latter), which invokes /etc/hotplug/scsi_topology.agent with the ACTION={add,remove}.

Quoted 7 lines

scsi_topology.agent invokes /sys/class/scsi_host/hostX/scan or
/sys/class/scsi_device/H:C:T:L:/device/delete as appropriate.

From this point, we're back into known territory, with the device being made known, or deleted from, the kernel's view.

Thoughts?

Just curious why the following flow would not work/be preferred:

1. echo "2" > /sys/class/scsi_host/host2/logical_drive_created
2. megaraid_mbox.c sysfs method converts logical drive number to HCTL value, calls scsi_add_device.
3. scsi_add_device works as it does today and generates hotplug events

-Brian

Signature · 14 lines
Brian King
eServer Storage I/O
IBM Linux Technology Center


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_ide95&alloc_id396&op=click
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
#5 lore raw
Quoted 8 lines · Brian King

Just curious why the following flow would not work/be preferred:

1. echo "2" > /sys/class/scsi_host/host2/logical_drive_created
2. megaraid_mbox.c sysfs method converts logical drive number to HCTL value, calls scsi_add_device.
3. scsi_add_device works as it does today and generates hotplug events

-Brian

This direction was what came out of this thread back in December.
http://marc.theaimsgroup.com/?l=linux-kernel&m0314267629902&w=2

Signature · 15 lines
Matt Domsch
Software Architect
Dell Linux Solutions linux.dell.com & www.dell.com/linux
Linux on Dell mailing lists @ http://lists.us.dell.com


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_ide95&alloc_id396&op=click
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
#6 lore raw
In reply to Matt Domsch
Quoted 2 lines · Matt Domsch

Below is a patch to add some hotplug infrastructure to the Linux SCSI subsystem.

I've added and reworked the megaraid_mbox driver to make use of this new infrastructure. I'll send that patch next. The rest is unchanged from yesterday.

I've put this work into a bkbits repo. This is a clone of Linus's linux-2.6, not of James' scsi-misc-2.6.

bk pull http://mdomsch.bkbits.net/linux-2.6-scsi-hotplug

This will update the following files:

 Documentation/scsi/ChangeLog.megaraid  |  130 ++++++++
 drivers/scsi/Kconfig                   |   10 
 drivers/scsi/Makefile                  |    1 
 drivers/scsi/megaraid/Kconfig.megaraid |    1 
 drivers/scsi/megaraid/mega_common.h    |    3 
 drivers/scsi/megaraid/megaraid_ioctl.h |    1 
 drivers/scsi/megaraid/megaraid_mbox.c  |  500 +++++++++++++++++++++++++++++++--
 drivers/scsi/megaraid/megaraid_mbox.h  |   28 +
 drivers/scsi/megaraid/megaraid_mm.c    |   39 ++
 drivers/scsi/megaraid/megaraid_mm.h    |    5 
 drivers/scsi/scsi_hotplug.c            |  138 +++++++++
 include/scsi/scsi_hotplug.h            |   41 ++
 12 files changed, 867 insertions, 30 deletions

through these ChangeSets:

<[email protected]> (05/02/08 1.2132.2.3)
Release Date : Tue Feb 08 12:27:22 EST 2005 - Matt Domsch <[email protected]>
Current Version : 2.20.4.6 (scsi module), 2.20.2.5 (cmm module)
Older Version : 2.20.4.5 (scsi module), 2.20.2.5 (cmm module)

1. Added two new megaraid_shost_attrs
/sys/class/scsi_host

   	|-- host0
   	|   |-- logical_drive_created
   	|   |-- logical_drive_destroyed

and helper functions for them. Written to from userspace by a management application, these invoke SCSI hotplug infrastructure for informing the kernel that a logical drive has been created, or will be destroyed quite soon.
echo "2" > logical_drive_created
after creating logical drive #2 in the management app
echo "4" > logical_drive_destroyed
immediately before destroying logical drive #4 in the management app. Eventually these functions should be called directly from the management app.

2. Made class_device_megaraid_mbox_app_hndl and
dev_attr_megaraid_mbox_ld static.

<[email protected]> (05/02/08 1.2132.2.2)
megaraid_2.20.4.5.patch

<[email protected]> (05/02/07 1.2048.2.1)
Below is a patch to add some hotplug infrastructure to the Linux SCSI subsystem.

New files:
include/scsi/scsi_hotplug.h
drivers/scsi/scsi_hotplug.c
implements a new exported function:

extern int scsi_topology_hctl_action(struct Scsi_Host *shost, unsigned int channel,
unsigned int id, unsigned int lun, enum scsi_topology_action action);

which invokes kobject_hotplug() on a temporary "scsi_topology" device. This device represents a target that exists on a topology (i.e. was just inserted into a hot plug enclosure, or was just created by a RAID controller management application) but is not yet hooked into the kernel.

In addition, two more infrastructure pieces are necessary:
udev-050-scsi_topology.patch - adds the subsystem name "scsi_topology" to the list of devices *not* to wait for the creation of files in sysfs for - scsi_topology devices aren't to be registered in sysfs.

/etc/hotplug/scsi_topology.agent
handles the hotplug call, and invokes /sys/class/scsi_host/hostX/scan and /sys/class/scsi_device/H:C:T:L:/device/delete as appropriate.

The flow is as follows:

   # echo "2" > /sys/class/scsi_host/host2/logical_drive_created
   (to be done by a management application that knows it just created
   logical drive #2 on the controller)

megaraid_mbox.c sysfs method converts logical drive number to HCTL value, calls scsi_topology_hctl_action().

scsi_topology_hctl_action() invokes kobject_hotplug() with a scsi_topology subsystem device.

kobject_hotplug() calls /sbin/hotplug or /sbin/udevsend (more likely the latter), which invokes /etc/hotplug/scsi_topology.agent with the ACTION={add,remove}.

scsi_topology.agent invokes /sys/class/scsi_host/hostX/scan or
/sys/class/scsi_device/H:C:T:L:/device/delete as appropriate.

From this point, we're back into known territory, with the device being made known, or deleted from, the kernel's view.

Signature · 15 lines
Matt Domsch
Software Architect
Dell Linux Solutions linux.dell.com & www.dell.com/linux
Linux on Dell mailing lists @ http://lists.us.dell.com


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_ide95&alloc_id396&op=click
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
#7 lore raw
Quoted 3 lines · Matt Domsch

I've added and reworked the megaraid_mbox driver to make use of this new infrastructure. I'll send that patch next. The rest is unchanged from yesterday.

This is the megaraid_mbox 2.20.4.5 patch as submitted by LSI on-list last week.

Signature · 35 lines
Matt Domsch
Software Architect
Dell Linux Solutions linux.dell.com & www.dell.com/linux
Linux on Dell mailing lists @ http://lists.us.dell.com

You can import this changeset into BK by piping this whole message to
'| bk receive [path to repository]' or apply the patch as usual.

===================================================================


[email protected], 2005-02-08 14:53:12-06:00, [email protected]
  megaraid_2.20.4.5.patch


 Documentation/scsi/ChangeLog.megaraid  |  104 ++++++++
 drivers/scsi/megaraid/Kconfig.megaraid |    1 
 drivers/scsi/megaraid/mega_common.h    |    3 
 drivers/scsi/megaraid/megaraid_ioctl.h |    1 
 drivers/scsi/megaraid/megaraid_mbox.c  |  403 ++++++++++++++++++++++++++++++++-
 drivers/scsi/megaraid/megaraid_mbox.h  |   24 +
 drivers/scsi/megaraid/megaraid_mm.c    |   39 +++
 drivers/scsi/megaraid/megaraid_mm.h    |    5 
 8 files changed, 561 insertions, 19 deletions


diff -Nru a/Documentation/scsi/ChangeLog.megaraid b/Documentation/scsi/ChangeLog.megaraid
--- a/Documentation/scsi/ChangeLog.megaraid	2005-02-08 17:16:50 -06:00
+++ b/Documentation/scsi/ChangeLog.megaraid	2005-02-08 17:16:50 -06:00
@@ -1,3 +1,105 @@
+Release Date	: Thu Feb 03 12:27:22 EST 2005 - Seokmann Ju <[email protected]>
+Current Version	: 2.20.4.5 (scsi module), 2.20.2.5 (cmm module)
+Older Version	: 2.20.4.4 (scsi module), 2.20.2.4 (cmm module)
+
+1.	Modified name of two attributes in scsi_host_template.

+ On Wed, 2005-02-02 at 10:56 -0500, Ju, Seokmann wrote:
+ > + .sdev_attrs = megaraid_device_attrs,
+ > + .shost_attrs = megaraid_class_device_attrs,
+
+ These are, perhaps, slightly confusing names.
+ The terms device and class_device have well defined meanings in the
+ generic device model, neither of which is what you mean here.
+ Why not simply megaraid_sdev_attrs and megaraid_shost_attrs?
+
+ Other than this, it looks fine to me too.
+
+Release Date : Thu Jan 27 00:01:03 EST 2005 - Atul Mukker <[email protected]>
+Current Version : 2.20.4.4 (scsi module), 2.20.2.5 (cmm module)
+Older Version : 2.20.4.3 (scsi module), 2.20.2.4 (cmm module)
+
+1. Bump up the version of scsi module due to its conflict.
+
+Release Date : Thu Jan 21 00:01:03 EST 2005 - Atul Mukker <[email protected]>
+Current Version : 2.20.4.3 (scsi module), 2.20.2.5 (cmm module)
+Older Version : 2.20.4.2 (scsi module), 2.20.2.4 (cmm module)
+
+1. Remove driver ioctl for logical drive to scsi address translation and
+ replace with the sysfs attribute. To remove drives and change
+ capacity, application shall now use the device attribute to get the
+ logical drive number for a scsi device. For adding newly created
+ logical drives, class device attribute would be required to uniquely
+ identify each controller.
+ - Atul Mukker <[email protected]>
+
+ "James, I've been thinking about this a little more, and you may be on
+ to something here. Let each driver add files as such:"
+
+ - Matt Domsch <[email protected]>, 12.15.2004
+ linux-scsi mailing list
+
+
+ "Then, if you simply publish your LD number as an extra parameter of
+ the device, you can look through /sys to find it."
+
+ - James Bottomley <[email protected]>, 01.03.2005
+ linux-scsi mailing list
+
+
+ "I don't see why not ... it's your driver, you can publish whatever
+ extra information you need as scsi_device attributes; that was one of
+ the designs of the extensible attribute system."
+
+ - James Bottomley <[email protected]>, 01.06.2005
+ linux-scsi mailing list
+
+2. Add AMI megaraid support - Brian King <[email protected]>
+ PCI_VENDOR_ID_AMI, PCI_DEVICE_ID_AMI_MEGARAID3,
+ PCI_VENDOR_ID_AMI, PCI_SUBSYS_ID_PERC3_DC,
+
+3. Make some code static - Adrian Bunk <[email protected]>
+ Date: Mon, 15 Nov 2004 03:14:57 +0100
+
+ The patch below makes some needlessly global code static.
+ -wait_queue_head_t wait_q;
+ +static wait_queue_head_t wait_q;
+
+ Signed-off-by: Adrian Bunk <[email protected]>
+
+4. Added NEC ROMB support - NEC MegaRAID PCI Express ROMB controller
+ PCI_VENDOR_ID_LSI_LOGIC, PCI_DEVICE_ID_MEGARAID_NEC_ROMB_2E,
+ PCI_SUBSYS_ID_NEC, PCI_SUBSYS_ID_MEGARAID_NEC_ROMB_2E,
+
+5. Fixed Tape drive issue : For any Direct CDB command to physical device
+ including tape, timeout value set by driver was 10 minutes. With this
+ value, most of command will return within timeout. However, for those
+ command like ERASE or FORMAT, it takes more than an hour depends on
+ capacity of the device and the command could be terminated before it
+ completes.
+ To address this issue, the 'timeout' field in the DCDB command will
+ have NO TIMEOUT (i.e., 4) value as its timeout on DCDB command.
+
+
+
+Release Date : Thu Dec 9 19:10:23 EST 2004
+ - Sreenivas Bagalkote <[email protected]>
+
+Current Version : 2.20.4.2 (scsi module), 2.20.2.4 (cmm module)
+Older Version : 2.20.4.1 (scsi module), 2.20.2.3 (cmm module)
+
+i. Introduced driver ioctl that returns scsi address for a given ld.
+
+ "Why can't the existing sysfs interfaces be used to do this?"
+ - Brian King ([email protected])
+
+ "I've looked into solving this another way, but I cannot see how
+ to get this driver-private mapping of logical drive number-> HCTL
+ without putting code something like this into the driver."
+
+ "...and by providing a mapping a function to userspace, the driver
+ is free to change its mapping algorithm in the future if necessary .."
+ - Matt Domsch ([email protected])
+
Release Date : Thu Dec 9 19:02:14 EST 2004 - Sreenivas Bagalkote <[email protected]>

Current Version : 2.20.4.1 (scsi module), 2.20.2.3 (cmm module)
@@ -13,7 +115,7 @@
i. Handle IOCTL cmd timeouts more properly.

ii. pci_dma_sync_{sg,single}_for_cpu was introduced into megaraid_mbox
- incorrectly (instead of _for_device). Changed to appropriate
+ incorrectly (instead of _for_device). Changed to appropriate
pci_dma_sync_{sg,single}_for_device.

Release Date : Wed Oct 06 11:15:29 EDT 2004 - Sreenivas Bagalkote <[email protected]>

drivers/scsi/megaraid/Kconfig.megaraid +1 -0
diff -Nru a/drivers/scsi/megaraid/Kconfig.megaraid b/drivers/scsi/megaraid/Kconfig.megaraid
@@ -59,6 +59,7 @@
 	INTEL RAID Controller SRCU51L	1000:1960:8086:0520
 	FSC MegaRAID PCI Express ROMB	1000:0408:1734:1065
 	ACER MegaRAID ROMB-2E		1000:0408:1025:004D
+	NEC MegaRAID PCI Express ROMB	1000:0408:1033:8287
 
 	To compile this driver as a module, choose M here: the
 	module will be called megaraid_mbox
drivers/scsi/megaraid/mega_common.h +3 -0
diff -Nru a/drivers/scsi/megaraid/mega_common.h b/drivers/scsi/megaraid/mega_common.h
@@ -221,6 +221,9 @@
 #define MRAID_IS_LOGICAL(adp, scp)	\
 	(SCP2CHANNEL(scp) == (adp)->max_channel) ? 1 : 0
 
+#define MRAID_IS_LOGICAL_SDEV(adp, sdev)	\
+	(sdev->channel == (adp)->max_channel) ? 1 : 0
+
 #define MRAID_GET_DEVICE_MAP(adp, scp, p_chan, target, islogical)	\
 	/*								\
 	 * Is the request coming for the virtual channel		\
drivers/scsi/megaraid/megaraid_ioctl.h +1 -0
diff -Nru a/drivers/scsi/megaraid/megaraid_ioctl.h b/drivers/scsi/megaraid/megaraid_ioctl.h
@@ -291,5 +291,6 @@
 
 int mraid_mm_register_adp(mraid_mmadp_t *);
 int mraid_mm_unregister_adp(uint32_t);
+uint32_t mraid_mm_adapter_app_handle(uint32_t);
 
 #endif /* _MEGARAID_IOCTL_H_ */
drivers/scsi/megaraid/megaraid_mbox.c +391 -12

531 lines not on this page · raw message

drivers/scsi/megaraid/megaraid_mbox.h +22 -2
diff -Nru a/drivers/scsi/megaraid/megaraid_mbox.h b/drivers/scsi/megaraid/megaraid_mbox.h
@@ -21,8 +21,8 @@
 #include "megaraid_ioctl.h"
 
 
-#define MEGARAID_VERSION	"2.20.4.1"
-#define MEGARAID_EXT_VERSION	"(Release Date: Thu Nov  4 17:44:59 EST 2004)"
+#define MEGARAID_VERSION	"2.20.4.5"
+#define MEGARAID_EXT_VERSION	"(Release Date: Thu Feb 03 12:27:22 EST 2005)"
 
 
 /*
@@ -137,6 +137,9 @@
 #define PCI_SUBSYS_ID_PERC3_DC				0x0493
 #define PCI_SUBSYS_ID_PERC3_SC				0x0475
 
+#define PCI_DEVICE_ID_MEGARAID_NEC_ROMB_2E		0x0408
+#define PCI_SUBSYS_ID_MEGARAID_NEC_ROMB_2E		0x8287
+
 #ifndef PCI_SUBSYS_ID_FSC
 #define PCI_SUBSYS_ID_FSC				0x1734
 #endif
@@ -216,6 +219,14 @@
  * @param hw_error		: set if FW not responding
  * @param fast_load		: If set, skip physical device scanning
  * @channel_class		: channel class, RAID or SCSI
+ * @sysfs_sem			: semaphore to serialize access to sysfs res.
+ * @sysfs_uioc			: management packet to issue FW calls from sysfs
+ * @sysfs_mbox64		: mailbox packet to issue FW calls from sysfs
+ * @sysfs_buffer		: data buffer for FW commands issued from sysfs
+ * @sysfs_buffer_dma		: DMA buffer for FW commands issued from sysfs
+ * @sysfs_wait_q		: wait queue for sysfs operations
+ * @random_del_supported	: set if the random deletion is supported
+ * @curr_ldmap			: current LDID map
  *
  * Initialization structure for mailbox controllers: memory based and IO based
  * All the fields in this structure are LLD specific and may be discovered at
@@ -223,6 +234,7 @@
  *
  * NOTE: The fields of this structures are placed to minimize cache misses
  */
+#define MAX_LD_EXTENDED64	64
 typedef struct {
 	mbox64_t			*una_mbox64;
 	dma_addr_t			una_mbox64_dma;
@@ -247,6 +259,14 @@
 	int				hw_error;
 	int				fast_load;
 	uint8_t				channel_class;
+	struct semaphore		sysfs_sem;
+	uioc_t				*sysfs_uioc;
+	mbox64_t			*sysfs_mbox64;
+	caddr_t				sysfs_buffer;
+	dma_addr_t			sysfs_buffer_dma;
+	wait_queue_head_t		sysfs_wait_q;
+	int				random_del_supported;
+	uint16_t			curr_ldmap[MAX_LD_EXTENDED64];
 } mraid_device_t;
 
 // route to raid device from adapter
drivers/scsi/megaraid/megaraid_mm.c +37 -2
diff -Nru a/drivers/scsi/megaraid/megaraid_mm.c b/drivers/scsi/megaraid/megaraid_mm.c
@@ -10,7 +10,7 @@
  *	   2 of the License, or (at your option) any later version.
  *
  * FILE		: megaraid_mm.c
- * Version	: v2.20.2.3 (Dec 09 2004)
+ * Version	: v2.20.2.5 (Jan 21 2005)
  *
  * Common management module
  */
@@ -58,6 +58,7 @@
 
 EXPORT_SYMBOL(mraid_mm_register_adp);
 EXPORT_SYMBOL(mraid_mm_unregister_adp);
+EXPORT_SYMBOL(mraid_mm_adapter_app_handle);
 
 static int majorno;
 static uint32_t drvr_ver	= 0x02200201;
@@ -65,7 +66,7 @@
 static int adapters_count_g;
 static struct list_head adapters_list_g;
 
-wait_queue_head_t wait_q;
+static wait_queue_head_t wait_q;
 
 static struct file_operations lsi_fops = {
 	.open	= mraid_mm_open,
@@ -1006,6 +1007,40 @@
 
 	return rval;
 }
+
+
+/**
+ * mraid_mm_adapter_app_handle - return the application handle for this adapter
+ *
+ * For the given driver data, locate the adadpter in our global list and
+ * return the corresponding handle, which is also used by applications to
+ * uniquely identify an adapter.
+ *
+ * @param unique_id : adapter unique identifier
+ *
+ * @return adapter handle if found in the list
+ * @return 0 if adapter could not be located, should never happen though
+ */
+uint32_t
+mraid_mm_adapter_app_handle(uint32_t unique_id)
+{
+	mraid_mmadp_t	*adapter;
+	mraid_mmadp_t	*tmp;
+	int		index = 0;
+
+	list_for_each_entry_safe(adapter, tmp, &adapters_list_g, list) {
+
+		if (adapter->unique_id == unique_id) {
+
+			return MKADAP(index);
+		}
+
+		index++;
+	}
+
+	return 0;
+}
+
 
 /**
  * mraid_mm_setup_dma_pools - Set up dma buffer pools per adapter
drivers/scsi/megaraid/megaraid_mm.h +3 -2
diff -Nru a/drivers/scsi/megaraid/megaraid_mm.h b/drivers/scsi/megaraid/megaraid_mm.h
@@ -29,9 +29,10 @@
 #include "megaraid_ioctl.h"
 
 
-#define LSI_COMMON_MOD_VERSION	"2.20.2.3"
+#define LSI_COMMON_MOD_VERSION	"2.20.2.5"
 #define LSI_COMMON_MOD_EXT_VERSION	\
-		"(Release Date: Thu Dec  9 19:02:14 EST 2004)"
+		"(Release Date: Fri Jan 21 00:01:03 EST 2005)"
+
 
 #define LSI_DBGLVL			dbglevel
 

===================================================================

This BitKeeper patch contains the following changesets:
1.2132.2.2
## Wrapped with gzip_uu ##

M'XL( &-("4( ]Q<^7/;QI+^&?@K)DZ]6%) "@<O49%B6:0=)KI*DN/:%[]" M@<!01(2##X<E;9C_?;^> 4A0I&A*3G9?K>-()##3T]WS]3'=DWS+/J0\Z2JG M3I;9O3A,W;'Z+?LI3K.NXO$@J+MQB >7<8P'N^,XY+NA)X;M#F]W4S?U=P,_ MRN]K9KU5HZ^U<9Q-@OQ&Q:P+)W/'[#-/TJYBU*W9D^QAPKO*9?_]AY.C2U4] M.&#'8R>ZX5<\8P<':A8GGYW 2]\XV3B(HWJ6.%$:\LPA9J:SH5-3UTW\TS3:
MEMYL38V6WFA/7<,S#*=A<$\W&YU60ZU(]J:4:)%($T0Z>K.A-YO3AMZP=+7' MC+II6&8=_S"]N:N;NWJ'&8UNT^H:9DUO=76=K2+\6Z&<?['O.ZRFJV_97RO, ML>JRD-\XB>-[-IC3ZXUZLSXAK:J_L$;'TEOJQ5R;:NV9?U15=W3UD#E9'H1O M@M27ZNK%;A[R*',R/X[DKLLU3N*;>LD/B6#I#:-MM)I@9*IWS+8)$2RPWAXV MN<$;5F.]UC9?2.P9U&4V&]-&>\\DIG_GOP_?A'EPDSB?>7TKBB.^_1L]_-?4 M2WR"H:18TMG]Q8VCD;](N*%W2 *]T["F)M9H3JV6J7ONL&V,N,<[;?,+(FR^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#J:_(XV [H.1=\]P&D&G@=3$]N59__QB./C< M?=<_K6Y 8X!'0DHVX)2#!R\6Z+CU>DOX@64IKQ</MK**@MM.G >\01^D)<=I MS#+S&8]4Q%A$XI-NFHA,);!5,>5=7J2 L2 57#2>3KFQVJ&M_#KZ=J41,O"4 MR\ERYY!YJ&]W$?IR%TRVE^ZE3(A= 5IQH.-Z7*8:)WJD*FZGZLEY@8-W,KN_ MU50/NE'#"O]!#=4F]0E>Q7)^ (S* "7'E[^A28"B,(Q%UJZRW[:*)#^E0S+B M@J"(HKEAL;[._7 WU:&WY#:*?^C0&PZ'^+=X&<T0IF3Q<[@<3>+4HH.F-;$M MORXIOC?\6J-Y4 8-6D%Y(P(-H+2WRO:1T]8](>N9.K-C>)/Q^][>:QOYU]DC M5.QH?BI6+WQG8=FC.9]%V/0"[VE W7]F!S/?OOCH@[D42O>)LTY_%:S!1)WW M_6ZWWQMV^UFL[B%6#_V 6@7$2,^"\P^+9.U%8CMX18&^^WF,09WE_?3->.R/ .QOXK?^M_Q4O/SX-:

#8 lore raw
In reply to Matt Domsch
Quoted 7 lines · Matt Domsch
Quoted 2 lines · Matt Domsch

Below is a patch to add some hotplug infrastructure to the Linux SCSI subsystem.

I've added and reworked the megaraid_mbox driver to make use of this new infrastructure. I'll send that patch next. The rest is unchanged from yesterday.

And these are the changes megaid_mbox to use the new infrastructure.

Signature · 280 lines
Matt Domsch
Software Architect
Dell Linux Solutions linux.dell.com & www.dell.com/linux
Linux on Dell mailing lists @ http://lists.us.dell.com

You can import this changeset into BK by piping this whole message to
'| bk receive [path to repository]' or apply the patch as usual.

===================================================================


[email protected], 2005-02-08 16:46:03-06:00, [email protected]
  Release Date	: Tue Feb 08 12:27:22 EST 2005 - Matt Domsch <[email protected]>
  Current Version	: 2.20.4.6 (scsi module), 2.20.2.5 (cmm module)
  Older Version	: 2.20.4.5 (scsi module), 2.20.2.5 (cmm module)
  
  1.	Added two new megaraid_shost_attrs
  	/sys/class/scsi_host
  	|-- host0
  	|   |-- logical_drive_created
  	|   |-- logical_drive_destroyed
  	
  	and helper functions for them.  Written to from userspace by
  	a management application, these invoke SCSI hotplug
  	infrastructure for informing the kernel that a logical drive
  	has been created, or will be destroyed quite soon.
  	    echo "2" > logical_drive_created
          after creating logical drive #2 in the management app
  	    echo "4" > logical_drive_destroyed
  	immediately before destroying logical drive #4 in the
  	management app.  Eventually these functions should be called
  	directly from the management app.
  
  2.	Made class_device_megaraid_mbox_app_hndl and
          dev_attr_megaraid_mbox_ld static.
  
  Signed-off-by: Matt Domsch <[email protected]>


 Documentation/scsi/ChangeLog.megaraid |   26 +++++++++
 drivers/scsi/megaraid/megaraid_mbox.c |   97 ++++++++++++++++++++++++++++++----
 drivers/scsi/megaraid/megaraid_mbox.h |    4 -
 3 files changed, 116 insertions, 11 deletions


diff -Nru a/Documentation/scsi/ChangeLog.megaraid b/Documentation/scsi/ChangeLog.megaraid
--- a/Documentation/scsi/ChangeLog.megaraid	2005-02-08 17:16:27 -06:00
+++ b/Documentation/scsi/ChangeLog.megaraid	2005-02-08 17:16:27 -06:00
@@ -1,3 +1,29 @@
+Release Date	: Tue Feb 08 12:27:22 EST 2005 - Matt Domsch <[email protected]>
+Current Version	: 2.20.4.6 (scsi module), 2.20.2.5 (cmm module)
+Older Version	: 2.20.4.5 (scsi module), 2.20.2.5 (cmm module)
+
+1.	Added two new megaraid_shost_attrs
+	/sys/class/scsi_host
+	|-- host0
+	|   |-- logical_drive_created
+	|   |-- logical_drive_destroyed
+	
+	and helper functions for them.  Written to from userspace by
+	a management application, these invoke SCSI hotplug
+	infrastructure for informing the kernel that a logical drive
+	has been created, or will be destroyed quite soon.
+	    echo "2" > logical_drive_created
+        after creating logical drive #2 in the management app
+	    echo "4" > logical_drive_destroyed
+	immediately before destroying logical drive #4 in the
+	management app.  Eventually these functions should be called
+	directly from the management app.
+
+2.	Made class_device_megaraid_mbox_app_hndl and
+        dev_attr_megaraid_mbox_ld static.
+
+
+
 Release Date	: Thu Feb 03 12:27:22 EST 2005 - Seokmann Ju <[email protected]>
 Current Version	: 2.20.4.5 (scsi module), 2.20.2.5 (cmm module)
 Older Version	: 2.20.4.4 (scsi module), 2.20.2.4 (cmm module)
diff -Nru a/drivers/scsi/megaraid/megaraid_mbox.c b/drivers/scsi/megaraid/megaraid_mbox.c
--- a/drivers/scsi/megaraid/megaraid_mbox.c	2005-02-08 17:16:27 -06:00
+++ b/drivers/scsi/megaraid/megaraid_mbox.c	2005-02-08 17:16:27 -06:00
@@ -69,6 +69,7 @@
  * For history of changes, see Documentation/ChangeLog.megaraid
  */
 
+#include <scsi/scsi_hotplug.h>
 #include "megaraid_mbox.h"
 
 static int megaraid_init(void);
@@ -470,29 +471,107 @@
 	}
 };
 
+/*
+ * sysfs class device support
+ * creates two files:
+ * /sys/class/scsi_host
+ * |-- host0
+ * |   |-- logical_drive_created
+ * |   |-- logical_drive_destroyed
+ *
+ * These make the midlayer invoke /sbin/hotplug, which then calls back into sysfs
+ * /sys/class/scsi_host
+ * |-- host0
+ * |   |-- scan
+ *
+ * and
+ *
+ * /sys/devices/pci0000:0x/0000:0x:0x.0/host0
+ * |-- 0:0:0:0
+ * |   |-- delete
+ *
+ * respectively.  This allows userspace applications to work
+ * using their logical drive number, and lets the driver translate
+ * that into host, channel, id, and lun values which the other
+ * mechanisms require.  This is similar to how hot plug CPU works.
+ */
 
+/**
+ * lda_to_hcil()
+ * @adapter
+ * @lda - logical drive address
+ * @host_no
+ * @channel
+ * @id
+ * @lun
+ *
+ * converts a logical drive address into a host, channel id, lun tuple.
+ */
 
-// definitions for the device attributes for exporting logical drive number
-// for a scsi address (Host, Channel, Id, Lun)
-
-CLASS_DEVICE_ATTR(megaraid_mbox_app_hndl, S_IRUSR, megaraid_sysfs_show_app_hndl,
+static inline int megaraid_lda_to_hcil(struct Scsi_Host *shost, u32 lda,
+				       u32 *host_no, u32 *channel, u32 *id, u32 *lun)
+{
+	if (lda > MAX_LOGICAL_DRIVES_40LD)
+		return -EINVAL;
+	*host_no = shost->host_no;
+	*channel = shost->max_channel;
+	*id      = (lda < shost->this_id) ? lda : lda + 1;
+	*lun     = 0;
+	return 0;
+}
+
+static int megaraid_host_store(struct class_device *class_dev, const char *buf, size_t count,
+			       enum scsi_topology_action action)
+{
+        struct Scsi_Host *shost = class_to_shost(class_dev);
+	int fields=0, rc=-EINVAL;
+	u32 lda=0, host_no=0, channel=0, id=0, lun=0;
+	fields = sscanf(buf, "%u", &lda);
+	if (fields != 1)
+		return rc;
+	if (lda > MAX_LOGICAL_DRIVES_40LD)
+		return rc;
+	rc = megaraid_lda_to_hcil(shost, lda, &host_no, &channel, &id, &lun);
+	if (rc)
+		return rc;
+
+	rc = scsi_topology_hctl_action(shost, channel, id, lun, action);
+
+	if (rc)
+		return rc;
+	return count;
+}
+
+static ssize_t megaraid_host_store_ld_created(struct class_device *class_dev, const char *buf, size_t count)
+{
+	return megaraid_host_store(class_dev, buf, count, SCSI_TOPOLOGY_ADDED);
+}
+static ssize_t megaraid_host_store_ld_destroyed(struct class_device *class_dev, const char *buf, size_t count)
+{
+	return megaraid_host_store(class_dev, buf, count, SCSI_TOPOLOGY_REMOVED);
+}
+
+#define MEGARAID_HOST_WOATTR(_name,_store) \
+CLASS_DEVICE_ATTR(_name, S_IWUSR|S_IWGRP, NULL, _store)
+
+static MEGARAID_HOST_WOATTR(logical_drive_created, megaraid_host_store_ld_created);
+static MEGARAID_HOST_WOATTR(logical_drive_destroyed, megaraid_host_store_ld_destroyed);
+static CLASS_DEVICE_ATTR(megaraid_mbox_app_hndl, S_IRUSR, megaraid_sysfs_show_app_hndl,
 		NULL);
 
-// Host template initializer for megaraid mbox sysfs device attributes
 static struct class_device_attribute *megaraid_shost_attrs[] = {
 	&class_device_attr_megaraid_mbox_app_hndl,
+	&class_device_attr_logical_drive_created,
+	&class_device_attr_logical_drive_destroyed,
 	NULL,
 };
 
+static DEVICE_ATTR(megaraid_mbox_ld, S_IRUSR, megaraid_sysfs_show_ldnum, NULL);
 
-DEVICE_ATTR(megaraid_mbox_ld, S_IRUSR, megaraid_sysfs_show_ldnum, NULL);
-
-// Host template initializer for megaraid mbox sysfs device attributes
 static struct device_attribute *megaraid_sdev_attrs[] = {
 	&dev_attr_megaraid_mbox_ld,
 	NULL,
 };
-
 
 /*
  * Scsi host template for megaraid unified driver
diff -Nru a/drivers/scsi/megaraid/megaraid_mbox.h b/drivers/scsi/megaraid/megaraid_mbox.h
--- a/drivers/scsi/megaraid/megaraid_mbox.h	2005-02-08 17:16:27 -06:00
+++ b/drivers/scsi/megaraid/megaraid_mbox.h	2005-02-08 17:16:27 -06:00
@@ -21,8 +21,8 @@
 #include "megaraid_ioctl.h"
 
 
-#define MEGARAID_VERSION	"2.20.4.5"
-#define MEGARAID_EXT_VERSION	"(Release Date: Thu Feb 03 12:27:22 EST 2005)"
+#define MEGARAID_VERSION	"2.20.4.6"
+#define MEGARAID_EXT_VERSION	"(Release Date: Tue Feb 08 12:27:22 EST 2005)"
 
 
 /*

===================================================================


This BitKeeper patch contains the following changesets:
1.2132.2.3
## Wrapped with gzip_uu ##


M'XL( $M("4(  \U9^U/;2!+^V?HK^D@=!:P?>OJ5P,%B7]:U)% VD+U:ME1C
M:8P4]/!I) BWWO_]ND>2'\$$ \G5&<>6QC-?=W_=T]VCO($+P9-NY0-+4[L7
MA\+QE#?P2RS2;L7E05!WXA 'AG&, PTO#GDC=.6TQOBF(1SA-P(_RK[4]'JS
M1K<U+TZG07:MX*HSECH>W/)$="M:W9B/I/=3WJT,^^\O3HZ&BK*_#\<>BZ[Y
MB*>POZ^D<7++ E<<LM0+XJB>)BP2(4\9*3.;3YWIJJKCGZ6U#-5JSK2F:K9F
MCN9J&C,U[JJZV6Z:RI)EAZ5%OQ<V_+&*9B%:&P$-39^9;4-M*CW0ZKIFZ'6]
M;H!J-52]H;9!:W;-9E<U:BI^JK!. OQD0$U5?H;O:\RQXL"0!YP)#CV6\DH7
MSC,._^1C(+WTKM[JZCKT1^= ]D!-*@>Y<O!NG:8'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