From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matt Domsch Subject: Re: [RFC][PATCH 2.6.11-rc2] Linux SCSI hotplug infrastructure Date: Tue, 8 Feb 2005 17:23:22 -0600 Message-ID: <20050208232322.GC30086@lists.us.dell.com> References: <20050207182753.GA16526@lists.us.dell.com> <20050208231923.GA30086@lists.us.dell.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Received: from linux.us.dell.com ([143.166.224.162]:19074 "EHLO lists.us.dell.com") by vger.kernel.org with ESMTP id S261685AbVBHXXW (ORCPT ); Tue, 8 Feb 2005 18:23:22 -0500 Received: from lists.us.dell.com (localhost.localdomain [127.0.0.1]) by lists.us.dell.com (8.12.11/8.12.11) with ESMTP id j18NNM2f031782 for ; Tue, 8 Feb 2005 17:23:22 -0600 Received: (from mdomsch@localhost) by lists.us.dell.com (8.12.11/8.12.11/Submit) id j18NNMiM031780 for linux-scsi@vger.kernel.org; Tue, 8 Feb 2005 17:23:22 -0600 Content-Disposition: inline In-Reply-To: <20050208231923.GA30086@lists.us.dell.com> Sender: linux-scsi-owner@vger.kernel.org List-Id: linux-scsi@vger.kernel.org To: linux-scsi@vger.kernel.org On Tue, Feb 08, 2005 at 05:19:23PM -0600, Matt Domsch wrote: > On Mon, Feb 07, 2005 at 12:27:53PM -0600, Matt Domsch wrote: > > 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. -- 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. =================================================================== ChangeSet@1.2132.2.3, 2005-02-08 16:46:03-06:00, Matt_Domsch@dell.com Release Date : Tue Feb 08 12:27:22 EST 2005 - Matt Domsch 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 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 +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 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 #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 M1KW/)$="M:W9B/I/=3WJT,^^\O3HZ&BK*_#\<>BZ[Y MB*>POZ^D<7++ E<)BP2(4\9*3.;3YWIJJKCGZ6U#-5JSK2F:K9F MCN9J&C,U[JJZV6Z:RI)EAZ5%OQY#Q8(K63;+(2=$\ 9,X@=3C M81W@4^*G*8_0SS!)T.\9;B]*/; M^(;#Z'@T@'+KX#(_FB0,51#S 2X:PI1$@C:#U M'A,PYJA787$5$.'.#P(Y:Y\L4F* MM,AQ4FM%"7BCH\92U54"5N68#^6LN, /0^[Z*#>X1\V1@+GV:R2:A41:N"H4 M'=6_Q>N,!0B4,[]P)\97%KC$#((%N6#73[B3XF3IU8=FU/.@U>N8.EU<2.&( MJM_Z#K?G@1N.XR\V3K:]R T 0VF)/)PK0_JKV:B'2)%/IQ P\J\C[M;BR:0V MON]NLIU_!=.R=$TY6V15I?;,EZ*H3%4.X#/_/#X,L^ Z8;>\OA/%$=_]G0;_ MF$G.DWP+-DH;&BO&U!U*:Z;:UEJ8S]JF,3,T4^W,QBK73#8V3&X8G9:JK\V@ MFPO(T[9N6F9G9JAZFQ1G:1:$AX'P[&3D.;GUR&ZJZ3_,'T_4]VUW&\ MI-_8K-MX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