[PATCH 1/6] mpt fusion: Add support for ATTO 4LD: Rebranded LSI 53C1030

2007-08-14 Thread Prakash, Sathya
Add support for ATTO UL4D, they are rebranded 53C1030. 
The changes are
1. Adding a new PCI vendor ID in pci table 
2. The spi_port_page_2 is in different format than that of LSI generic 
spi_port_page_2 and hence mapping code is added.

signed-off-by: Sathya Prakash [EMAIL PROTECTED]
---

diff --git a/drivers/message/fusion/Kconfig b/drivers/message/fusion/Kconfig
index f55cc03..3c44a2f 100644
--- a/drivers/message/fusion/Kconfig
+++ b/drivers/message/fusion/Kconfig
@@ -20,6 +20,7 @@ config FUSION_SPI
  LSI53C1020A
  LSI53C1030
  LSI53C1035
+ ATTO UL4D
 
 config FUSION_FC
tristate Fusion MPT ScsiHost drivers for FC
diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
index 414c109..81e9e9c 100644
--- a/drivers/message/fusion/mptbase.c
+++ b/drivers/message/fusion/mptbase.c
@@ -4888,6 +4888,38 @@ mpt_GetScsiPortSettings(MPT_ADAPTER *ioc, int portnum)
/* Nvram data is left with INVALID mark
 */
rc = 1;
+   } else if (ioc-pcidev-vendor == 0x117c) {
+
+   /* This is an ATTO adapter, read Page2 
accordingly
+   */
+   ATTO_SCSIPortPage2_t *pPP2 = 
(ATTO_SCSIPortPage2_t  *) pbuf;
+   ATTODeviceInfo_t *pdevice = NULL;
+   u16 ATTOFlags;
+
+   /* Save the Port Page 2 data
+* (reformat into a 32bit quantity)
+*/
+   for (ii=0; ii  MPT_MAX_SCSI_DEVICES; ii++) {
+ pdevice = pPP2-DeviceSettings[ii];
+ ATTOFlags = le16_to_cpu(pdevice-ATTOFlags);
+ data = 0;
+
+ /* Translate ATTO device flags to LSI format
+  */
+ if (ATTOFlags  ATTOFLAG_DISC)
+   data |= 
(MPI_SCSIPORTPAGE2_DEVICE_DISCONNECT_ENABLE);
+ if (ATTOFlags  ATTOFLAG_ID_ENB)
+   data |= 
(MPI_SCSIPORTPAGE2_DEVICE_ID_SCAN_ENABLE);
+ if (ATTOFlags  ATTOFLAG_LUN_ENB)
+   data |= 
(MPI_SCSIPORTPAGE2_DEVICE_LUN_SCAN_ENABLE);
+ if (ATTOFlags  ATTOFLAG_TAGGED)
+   data |= 
(MPI_SCSIPORTPAGE2_DEVICE_TAG_QUEUE_ENABLE);
+ if (!(ATTOFlags  ATTOFLAG_WIDE_ENB))
+   data |= 
(MPI_SCSIPORTPAGE2_DEVICE_WIDE_DISABLE);
+
+ data = (data  16) | (pdevice-Period  8) 
| 10;
+ ioc-spi_data.nvram[ii] = data;
+   }
} else {
SCSIPortPage2_t *pPP2 = (SCSIPortPage2_t  *) 
pbuf;
MpiDeviceInfo_t *pdevice = NULL;
diff --git a/drivers/message/fusion/mptbase.h b/drivers/message/fusion/mptbase.h
index 15ff226..a8c8080 100644
--- a/drivers/message/fusion/mptbase.h
+++ b/drivers/message/fusion/mptbase.h
@@ -194,6 +194,35 @@
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
 /*
+ *  ATTO UL4D associated structures and defines
+ */
+#define ATTOFLAG_DISC 0x0001
+#define ATTOFLAG_TAGGED   0x0002
+#define ATTOFLAG_WIDE_ENB 0x0008
+#define ATTOFLAG_ID_ENB   0x0010
+#define ATTOFLAG_LUN_ENB  0x0060
+
+typedef struct _ATTO_DEVICE_INFO
+{
+   u8  Offset; /* 00h */
+   u8  Period; /* 01h */
+   u16 ATTOFlags;  /* 02h */
+} ATTO_DEVICE_INFO, MPI_POINTER PTR_ATTO_DEVICE_INFO,
+  ATTODeviceInfo_t, MPI_POINTER pATTODeviceInfo_t;
+
+typedef struct _ATTO_CONFIG_PAGE_SCSI_PORT_2
+{
+   CONFIG_PAGE_HEADER  Header; /* 00h */
+   u16 PortFlags;  /* 04h */
+   u16 Unused1;/* 06h */
+   u32 Unused2;/* 08h */
+   ATTO_DEVICE_INFODeviceSettings[16]; /* 0Ch */
+} fATTO_CONFIG_PAGE_SCSI_PORT_2, MPI_POINTER PTR_ATTO_CONFIG_PAGE_SCSI_PORT_2,
+  ATTO_SCSIPortPage2_t, MPI_POINTER pATTO_SCSIPortPage2_t;
+
+
+/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
+/*
  *  MPT protocol driver defs...
  */
 typedef enum {
diff --git a/drivers/message/fusion/mptspi.c b/drivers/message/fusion/mptspi.c
index 8c98420..be59bbc 100644
--- a/drivers/message/fusion/mptspi.c
+++ b/drivers/message/fusion/mptspi.c
@@ -1190,6 +1190,8 @@ static struct spi_function_template 
mptspi_transport_functions = {
 static struct 

[PATCH 2/6] mpt fusion: Usage of high priority request FIFO to send task management commands

2007-08-14 Thread Prakash, Sathya
Added support for sending the task management requests through High priority 
request FIFO instead of Doorbell writes when firmware support High priority
FIFO.

signed-off-by: Sathya Prakash [EMAIL PROTECTED]
---

diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
index 81e9e9c..290f126 100644
--- a/drivers/message/fusion/mptbase.c
+++ b/drivers/message/fusion/mptbase.c
@@ -842,6 +842,38 @@ mpt_put_msg_frame(int handle, MPT_ADAPTER *ioc, 
MPT_FRAME_HDR *mf)
CHIPREG_WRITE32(ioc-chip-RequestFifo, mf_dma_addr);
 }
 
+/**
+ * mpt_put_msg_frame_hi_pri - Send a protocol specific MPT request frame
+ * to a IOC using hi priority request queue.
+ * @handle: Handle of registered MPT protocol driver
+ * @ioc: Pointer to MPT adapter structure
+ * @mf: Pointer to MPT request frame
+ *
+ * This routine posts a MPT request frame to the request post FIFO of a
+ * specific MPT adapter.
+ **/
+void
+mpt_put_msg_frame_hi_pri(int handle, MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf)
+{
+   u32 mf_dma_addr;
+   int req_offset;
+   u16  req_idx;   /* Request index */
+
+   /* ensure values are reset properly! */
+   mf-u.frame.hwhdr.msgctxu.fld.cb_idx = handle;
+   req_offset = (u8 *)mf - (u8 *)ioc-req_frames;
+   req_idx = req_offset / ioc-req_sz;
+   mf-u.frame.hwhdr.msgctxu.fld.req_idx = cpu_to_le16(req_idx);
+   mf-u.frame.hwhdr.msgctxu.fld.rsvd = 0;
+
+   DBG_DUMP_PUT_MSG_FRAME(ioc, (u32 *)mf);
+
+   mf_dma_addr = (ioc-req_frames_low_dma + req_offset);
+   dsgprintk(ioc, printk(MYIOC_s_DEBUG_FMT mf_dma_addr=%x req_idx=%d\n,
+   ioc-name, mf_dma_addr, req_idx));
+   CHIPREG_WRITE32(ioc-chip-RequestHiPriFifo, mf_dma_addr);
+}
+
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
 /**
  * mpt_free_msg_frame - Place MPT request frame back on FreeQ.
@@ -7315,6 +7347,7 @@ EXPORT_SYMBOL(mpt_device_driver_register);
 EXPORT_SYMBOL(mpt_device_driver_deregister);
 EXPORT_SYMBOL(mpt_get_msg_frame);
 EXPORT_SYMBOL(mpt_put_msg_frame);
+EXPORT_SYMBOL(mpt_put_msg_frame_hi_pri);
 EXPORT_SYMBOL(mpt_free_msg_frame);
 EXPORT_SYMBOL(mpt_add_sge);
 EXPORT_SYMBOL(mpt_send_handshake_request);
diff --git a/drivers/message/fusion/mptbase.h b/drivers/message/fusion/mptbase.h
index a8c8080..012be5e 100644
--- a/drivers/message/fusion/mptbase.h
+++ b/drivers/message/fusion/mptbase.h
@@ -336,7 +336,8 @@ typedef struct _SYSIF_REGS
u32 Reserved2[2];   /* 38-3F  reserved for future use*/
u32 RequestFifo;/* 40 Request Post/Free FIFO */
u32 ReplyFifo;  /* 44 Reply   Post/Free FIFO */
-   u32 Reserved3[2];   /* 48-4F  reserved for future use*/
+   u32 RequestHiPriFifo; /* 48   Hi Priority Request FIFO   */
+   u32 Reserved3;  /* 4C-4F  reserved for future use*/
u32 HostIndex;  /* 50 Host Index register*/
u32 Reserved4[15];  /* 54-8F */
u32 Fubar;  /* 90 For Fubar usage*/
@@ -893,6 +894,7 @@ extern void  mpt_device_driver_deregister(int cb_idx);
 extern MPT_FRAME_HDR   *mpt_get_msg_frame(int handle, MPT_ADAPTER *ioc);
 extern void mpt_free_msg_frame(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf);
 extern void mpt_put_msg_frame(int handle, MPT_ADAPTER *ioc, MPT_FRAME_HDR 
*mf);
+extern void mpt_put_msg_frame_hi_pri(int handle, MPT_ADAPTER *ioc, 
MPT_FRAME_HDR *mf);
 extern void mpt_add_sge(char *pAddr, u32 flagslength, dma_addr_t dma_addr);
 
 extern int  mpt_send_handshake_request(int handle, MPT_ADAPTER *ioc, int 
reqBytes, u32 *req, int sleepFlag);
diff --git a/drivers/message/fusion/mptctl.c b/drivers/message/fusion/mptctl.c
index 89695e7..ca75ee8 100644
--- a/drivers/message/fusion/mptctl.c
+++ b/drivers/message/fusion/mptctl.c
@@ -342,7 +342,7 @@ static int mptctl_bus_reset(MPT_IOCTL *ioctl)
SCSITaskMgmt_t  *pScsiTm;
MPT_SCSI_HOST   *hd;
int  ii;
-   int  retval;
+   int  retval=0;
 
 
ioctl-reset = ~MPTCTL_RESET_OK;
@@ -395,12 +395,19 @@ static int mptctl_bus_reset(MPT_IOCTL *ioctl)
DBG_DUMP_TM_REQUEST_FRAME(ioctl-ioc, (u32 *)mf);
 
ioctl-wait_done=0;
-   if ((retval = mpt_send_handshake_request(mptctl_id, ioctl-ioc,
-sizeof(SCSITaskMgmt_t), (u32*)pScsiTm, CAN_SLEEP)) != 0) {
-   dfailprintk(ioctl-ioc, printk(MYIOC_s_ERR_FMT _send_handshake 
FAILED!
-(hd %p, ioc %p, mf %p) \n, hd-ioc-name, hd,
-   hd-ioc, mf));
-   goto mptctl_bus_reset_done;
+
+   if ((ioctl-ioc-facts.IOCCapabilities  
MPI_IOCFACTS_CAPABILITY_HIGH_PRI_Q) 
+   (ioctl-ioc-facts.MsgVersion = MPI_VERSION_01_05))
+   mpt_put_msg_frame_hi_pri(mptctl_id, ioctl-ioc, mf);
+   else {
+   retval = 

[PATCH 3/6] mpt fusion: Changing call back indices to u8 from int

2007-08-14 Thread Prakash, Sathya
The call back index requires only u8 but in lot of places it is referred as 
int, now everywhere the call back index variables are declared as u8 with 
uniform name cb_idx

signed-off-by: Sathya Prakash [EMAIL PROTECTED]
---

diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
index 290f126..71d967d 100644
--- a/drivers/message/fusion/mptbase.c
+++ b/drivers/message/fusion/mptbase.c
@@ -102,8 +102,6 @@ static int mfcounter = 0;
 /*
  *  Public data...
  */
-int mpt_lan_index = -1;
-int mpt_stm_index = -1;
 
 struct proc_dir_entry *mpt_proc_root_dir;
 
@@ -125,11 +123,14 @@ static MPT_EVHANDLER   
MptEvHandlers[MPT_MAX_PROTOCOL_DRIVERS];
 static MPT_RESETHANDLER 
MptResetHandlers[MPT_MAX_PROTOCOL_DRIVERS];
 static struct mpt_pci_driver   
*MptDeviceDriverHandlers[MPT_MAX_PROTOCOL_DRIVERS];
 
-static int mpt_base_index = -1;
-static int last_drv_idx = -1;
-
 static DECLARE_WAIT_QUEUE_HEAD(mpt_waitq);
 
+/*
+ *  Driver Callback Index's
+ */
+static u8 mpt_base_index = MPT_MAX_PROTOCOL_DRIVERS;
+static u8 last_drv_idx;
+
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
 /*
  *  Forward protos...
@@ -235,6 +236,23 @@ static int mpt_set_debug_level(const char *val, struct 
kernel_param *kp)
return 0;
 }
 
+/**
+ * mpt_get_cb_idx - obtain cb_idx for registered driver
+ * @dclass: class driver enum
+ *
+ * Returns cb_idx, or zero means it wasn't found
+ **/
+static u8
+mpt_get_cb_idx(MPT_DRIVER_CLASS dclass)
+{
+   u8 cb_idx;
+
+   for (cb_idx = MPT_MAX_PROTOCOL_DRIVERS-1; cb_idx; cb_idx--)
+   if (MptDriverClass[cb_idx] == dclass)
+   return cb_idx;
+   return 0;
+}
+
 /*
  *  Process turbo (context) reply...
  */
@@ -243,8 +261,8 @@ mpt_turbo_reply(MPT_ADAPTER *ioc, u32 pa)
 {
MPT_FRAME_HDR *mf = NULL;
MPT_FRAME_HDR *mr = NULL;
-   int req_idx = 0;
-   int cb_idx;
+   u16 req_idx = 0;
+   u8 cb_idx;
 
dmfprintk(ioc, printk(MYIOC_s_DEBUG_FMT Got TURBO reply 
req_idx=%08x\n,
ioc-name, pa));
@@ -256,7 +274,7 @@ mpt_turbo_reply(MPT_ADAPTER *ioc, u32 pa)
mf = MPT_INDEX_2_MFPTR(ioc, req_idx);
break;
case MPI_CONTEXT_REPLY_TYPE_LAN:
-   cb_idx = mpt_lan_index;
+   cb_idx = mpt_get_cb_idx(MPTLAN_DRIVER);
/*
 *  Blind set of mf to NULL here was fatal
 *  after lan_reply says freeme
@@ -277,7 +295,7 @@ mpt_turbo_reply(MPT_ADAPTER *ioc, u32 pa)
mr = (MPT_FRAME_HDR *) CAST_U32_TO_PTR(pa);
break;
case MPI_CONTEXT_REPLY_TYPE_SCSI_TARGET:
-   cb_idx = mpt_stm_index;
+   cb_idx = mpt_get_cb_idx(MPTSTM_DRIVER);
mr = (MPT_FRAME_HDR *) CAST_U32_TO_PTR(pa);
break;
default:
@@ -286,7 +304,7 @@ mpt_turbo_reply(MPT_ADAPTER *ioc, u32 pa)
}
 
/*  Check for (valid) IO callback!  */
-   if (cb_idx  1 || cb_idx = MPT_MAX_PROTOCOL_DRIVERS ||
+   if (!cb_idx || cb_idx = MPT_MAX_PROTOCOL_DRIVERS ||
MptCallbacks[cb_idx] == NULL) {
printk(MYIOC_s_WARN_FMT %s: Invalid cb_idx (%d)!\n,
__FUNCTION__, ioc-name, cb_idx);
@@ -304,8 +322,8 @@ mpt_reply(MPT_ADAPTER *ioc, u32 pa)
 {
MPT_FRAME_HDR   *mf;
MPT_FRAME_HDR   *mr;
-   int  req_idx;
-   int  cb_idx;
+   u16  req_idx;
+   u8   cb_idx;
int  freeme;
 
u32 reply_dma_low;
@@ -350,7 +368,7 @@ mpt_reply(MPT_ADAPTER *ioc, u32 pa)
mpt_iocstatus_info(ioc, (u32)ioc_stat, mf);
 
/*  Check for (valid) IO callback!  */
-   if (cb_idx  1 || cb_idx = MPT_MAX_PROTOCOL_DRIVERS ||
+   if (!cb_idx || cb_idx = MPT_MAX_PROTOCOL_DRIVERS ||
MptCallbacks[cb_idx] == NULL) {
printk(MYIOC_s_WARN_FMT %s: Invalid cb_idx (%d)!\n,
__FUNCTION__, ioc-name, cb_idx);
@@ -563,28 +581,27 @@ mpt_base_reply(MPT_ADAPTER *ioc, MPT_FRAME_HDR *mf, 
MPT_FRAME_HDR *reply)
  * in order to register separate callbacks; one for normal SCSI IO;
  * one for MptScsiTaskMgmt requests; one for Scan/DV requests.
  *
- * Returns a positive integer valued handle in the
- * range (and S.O.D. order) {N,...,7,6,5,...,1} if successful.
- * Any non-positive return value (including zero!) should be considered
- * an error by the caller.
+ * Returns u8 valued handle in the range (and S.O.D. order)
+ * {N,...,7,6,5,...,1} if successful.
+ * A return value of MPT_MAX_PROTOCOL_DRIVERS (including zero!) should be
+ * considered an error by the caller.
  */
-int
+u8
 mpt_register(MPT_CALLBACK cbfunc, MPT_DRIVER_CLASS dclass)
 {
-   int i;
-
-   last_drv_idx = -1;
+   u8 

[PATCH 4/6] mpt fusion: Creation of mptsas.h header file

2007-08-14 Thread Prakash, Sathya
The data structure definitions from mptsas.c are moved to a new header file 
mptsas.h

signed-off-by: Sathya Prakash [EMAIL PROTECTED]
---

diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
index ffbf0e5..5951fe0 100644
--- a/drivers/message/fusion/mptsas.c
+++ b/drivers/message/fusion/mptsas.c
@@ -61,6 +61,7 @@
 
 #include mptbase.h
 #include mptscsih.h
+#include mptsas.h
 
 
 #define my_NAMEFusion MPT SAS Host driver
@@ -96,111 +97,6 @@ static u8   mptsasMgmtCtx = MPT_MAX_PROTOCOL_DRIVERS;
 
 static void mptsas_hotplug_work(struct work_struct *work);
 
-struct mptsas_target_reset_event {
-   struct list_headlist;
-   EVENT_DATA_SAS_DEVICE_STATUS_CHANGE sas_event_data;
-   u8  target_reset_issued;
-};
-
-enum mptsas_hotplug_action {
-   MPTSAS_ADD_DEVICE,
-   MPTSAS_DEL_DEVICE,
-   MPTSAS_ADD_RAID,
-   MPTSAS_DEL_RAID,
-   MPTSAS_ADD_INACTIVE_VOLUME,
-   MPTSAS_IGNORE_EVENT,
-};
-
-struct mptsas_hotplug_event {
-   struct work_struct  work;
-   MPT_ADAPTER *ioc;
-   enum mptsas_hotplug_action event_type;
-   u64 sas_address;
-   u8  channel;
-   u8  id;
-   u32 device_info;
-   u16 handle;
-   u16 parent_handle;
-   u8  phy_id;
-   u8  phys_disk_num_valid;/* hrc (hidden raid 
component) */
-   u8  phys_disk_num;  /* hrc - unique index*/
-   u8  hidden_raid_component;  /* hrc - don't expose*/
-};
-
-struct mptsas_discovery_event {
-   struct work_struct  work;
-   MPT_ADAPTER *ioc;
-};
-
-/*
- * SAS topology structures
- *
- * The MPT Fusion firmware interface spreads information about the
- * SAS topology over many manufacture pages, thus we need some data
- * structure to collect it and process it for the SAS transport class.
- */
-
-struct mptsas_devinfo {
-   u16 handle; /* unique id to address this device */
-   u16 handle_parent;  /* unique id to address parent device */
-   u16 handle_enclosure; /* enclosure identifier of the enclosure */
-   u16 slot;   /* physical slot in enclosure */
-   u8  phy_id; /* phy number of parent device */
-   u8  port_id;/* sas physical port this device
-  is assoc'd with */
-   u8  id; /* logical target id of this device */
-   u32 phys_disk_num;  /* phys disk id, for csmi-ioctls */
-   u8  channel;/* logical bus number of this device */
-   u64 sas_address;/* WWN of this device,
-  SATA is assigned by HBA,expander */
-   u32 device_info;/* bitfield detailed info about this device */
-};
-
-/*
- * Specific details on ports, wide/narrow
- */
-struct mptsas_portinfo_details{
-   u16 num_phys;   /* number of phys belong to this port */
-   u64 phy_bitmask;/* TODO, extend support for 255 phys */
-   struct sas_rphy *rphy;  /* transport layer rphy object */
-   struct sas_port *port;  /* transport layer port object */
-   struct scsi_target *starget;
-   struct mptsas_portinfo *port_info;
-};
-
-struct mptsas_phyinfo {
-   u16 handle; /* unique id to address this */
-   u8  phy_id; /* phy index */
-   u8  port_id;/* firmware port identifier */
-   u8  negotiated_link_rate;   /* nego'd link rate for this phy */
-   u8  hw_link_rate;   /* hardware max/min phys link rate */
-   u8  programmed_link_rate;   /* programmed max/min phy link rate */
-   u8  sas_port_add_phy;   /* flag to request sas_port_add_phy*/
-   struct mptsas_devinfo identify; /* point to phy device info */
-   struct mptsas_devinfo attached; /* point to attached device info */
-   struct sas_phy *phy;/* transport layer phy object */
-   struct mptsas_portinfo *portinfo;
-   struct mptsas_portinfo_details * port_details;
-};
-
-struct mptsas_portinfo {
-   struct list_head list;
-   u16 num_phys;   /* number of phys */
-   struct mptsas_phyinfo *phy_info;
-};
-
-struct mptsas_enclosure {
-   u64 enclosure_logical_id;   /* The WWN for the enclosure */
-   u16 enclosure_handle;   /* unique id to address this */
-   u16 flags;  /* details enclosure management */
-   u16 num_slot;   /* num slots */
-   u16 start_slot; /* first slot */
-   u8  start_id;   /* starting logical target id */
-   u8  start_channel;  /* starting logical channel id */
-   u8  sep_id; /* 

[PATCH 5/6] mpt fusion: Link speed change display support

2007-08-14 Thread Prakash, Sathya
When there is state change in FC links, a message is displayed with old and new 
link speed.

signed-off-by: Sathya Prakash [EMAIL PROTECTED]
---

diff --git a/drivers/message/fusion/mptbase.h b/drivers/message/fusion/mptbase.h
index 04ef0a3..1197eba 100644
--- a/drivers/message/fusion/mptbase.h
+++ b/drivers/message/fusion/mptbase.h
@@ -698,6 +698,8 @@ typedef struct _MPT_ADAPTER
 
struct work_struct   fc_setup_reset_work;
struct list_head fc_rports;
+   struct work_struct   fc_lsc_work;
+   u8   fc_link_speed[2];
spinlock_t   fc_rescan_work_lock;
struct work_struct   fc_rescan_work;
char fc_rescan_work_q_name[KOBJ_NAME_LEN];
diff --git a/drivers/message/fusion/mptfc.c b/drivers/message/fusion/mptfc.c
index 2b3e27a..aadb071 100644
--- a/drivers/message/fusion/mptfc.c
+++ b/drivers/message/fusion/mptfc.c
@@ -675,6 +675,50 @@ mptfc_qcmd(struct scsi_cmnd *SCpnt, void (*done)(struct 
scsi_cmnd *))
 }
 
 /*
+ * mptfc_display_port_link_speed - displaying link speed
+ * @ioc: Pointer to MPT_ADAPTER structure
+ * @portnum: IOC Port number
+ * @pp0dest: port page0 data payload
+ *
+ */
+static void
+mptfc_display_port_link_speed(MPT_ADAPTER *ioc, int portnum, FCPortPage0_t 
*pp0dest)
+{
+   u8  old_speed, new_speed, state;
+   char*old, *new;
+
+   if (portnum = 2)
+   return;
+
+   old_speed = ioc-fc_link_speed[portnum];
+   new_speed = pp0dest-CurrentSpeed;
+   state = pp0dest-PortState;
+
+   if (state != MPI_FCPORTPAGE0_PORTSTATE_OFFLINE 
+   new_speed != MPI_FCPORTPAGE0_CURRENT_SPEED_UKNOWN) {
+
+   old = old_speed == MPI_FCPORTPAGE0_CURRENT_SPEED_1GBIT ? 1 
Gbps :
+  old_speed == MPI_FCPORTPAGE0_CURRENT_SPEED_2GBIT ? 2 
Gbps :
+   old_speed == MPI_FCPORTPAGE0_CURRENT_SPEED_4GBIT ? 4 
Gbps :
+Unknown;
+   new = new_speed == MPI_FCPORTPAGE0_CURRENT_SPEED_1GBIT ? 1 
Gbps :
+  new_speed == MPI_FCPORTPAGE0_CURRENT_SPEED_2GBIT ? 2 
Gbps :
+   new_speed == MPI_FCPORTPAGE0_CURRENT_SPEED_4GBIT ? 4 
Gbps :
+Unknown;
+   if (old_speed == 0)
+   printk(MYIOC_s_NOTE_FMT
+   FC Link Established, Speed = %s\n,
+   ioc-name, new);
+   else if (old_speed != new_speed)
+   printk(MYIOC_s_WARN_FMT
+   FC Link Speed Change, Old Speed = %s, New 
Speed = %s\n,
+   ioc-name, old, new);
+
+   ioc-fc_link_speed[portnum] = new_speed;
+   }
+}
+
+/*
  * mptfc_GetFcPortPage0 - Fetch FCPort config Page0.
  * @ioc: Pointer to MPT_ADAPTER structure
  * @portnum: IOC Port number
@@ -773,6 +817,7 @@ mptfc_GetFcPortPage0(MPT_ADAPTER *ioc, int portnum)
 complete.\n,
ioc-name);
}
+   mptfc_display_port_link_speed(ioc, portnum, pp0dest);
}
 
pci_free_consistent(ioc-pcidev, data_sz, (u8 *) ppage0_alloc, 
page0_dma);
@@ -1023,6 +1068,18 @@ mptfc_init_host_attr(MPT_ADAPTER *ioc,int portnum)
 }
 
 static void
+mptfc_link_status_change(struct work_struct *work)
+{
+   MPT_ADAPTER *ioc =
+   container_of(work, MPT_ADAPTER, fc_rescan_work);
+   int ii;
+
+   for (ii=0; ii  ioc-facts.NumberOfPorts; ii++)
+   (void) mptfc_GetFcPortPage0(ioc, ii);
+
+}
+
+static void
 mptfc_setup_reset(struct work_struct *work)
 {
MPT_ADAPTER *ioc =
@@ -1163,6 +1220,7 @@ mptfc_probe(struct pci_dev *pdev, const struct 
pci_device_id *id)
spin_lock_init(ioc-fc_rescan_work_lock);
INIT_WORK(ioc-fc_rescan_work, mptfc_rescan_devices);
INIT_WORK(ioc-fc_setup_reset_work, mptfc_setup_reset);
+   INIT_WORK(ioc-fc_lsc_work, mptfc_link_status_change);
 
spin_lock_irqsave(ioc-FreeQlock, flags);
 
@@ -1337,6 +1395,14 @@ mptfc_event_process(MPT_ADAPTER *ioc, 
EventNotificationReply_t *pEvReply)
}
spin_unlock_irqrestore(ioc-fc_rescan_work_lock, flags);
break;
+   case MPI_EVENT_LINK_STATUS_CHANGE:
+   spin_lock_irqsave(ioc-fc_rescan_work_lock, flags);
+   if (ioc-fc_rescan_work_q) {
+   queue_work(ioc-fc_rescan_work_q,
+  ioc-fc_lsc_work);
+   }
+   spin_unlock_irqrestore(ioc-fc_rescan_work_lock, flags);
+   break;
default:
rc = mptscsih_event_process(ioc,pEvReply);
break;
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to 

READ CAPACITY failed on ia64

2007-08-14 Thread Robert Nagy
Hi

Here is an ia64 box with a QLogic QLA12160 PCI to SCSI Host Adapter
and two SCSI disks.

One of them is a SEAGATE ST318453LC (18352 MB) the other one is a
SEAGATE ST3146807LC (147GB). The ST3146807LC disk works fine in
other boxes. I just put it into this one from a HP server where
it was working with the *same* controller.

In this box I get the following error message:

sd 0:0:2:0: [sdb] READ CAPACITY failed
sd 0:0:2:0: [sdb] Result: hostbyte=0x00 driverbyte=0x08
sd 0:0:2:0: [sdb] Sense Key : 0x3 [current]
sd 0:0:2:0: [sdb] ASC=0x31 ASCQ=0x0
sd 0:0:2:0: [sdb] Write Protect is off
sd 0:0:2:0: [sdb] Mode Sense: ab 00 10 08
sd 0:0:2:0: [sdb] Write cache: enabled, read cache: enabled, supports DPO and FU
A
sd 0:0:2:0: [sdb] Attached SCSI disk

I am currently running 2.6.22 but I've also tried with serveral other
(and older) kernels and it still can't get the capacity of the disk.

The other disk ST318453LC is just working fine and it is serving
as the system disk.
The only thing I can do is to run scsiformat(8) which finishes
correctly. I've also tried to fill the disk with zeroes using dd(1)
but that did not help anything either.

The full dmesg of the box can be found at http://humppa.hu/dmesg.scsi

EFI information:
Seg: 1 Bus: 0 Dev: 3 Func: 0 - Qlogic 12160 SCSI Controller detected: Firmware 
Rev 6
  (Pun 1,Lun 0): SEAGATE ST318453LC   0002
  (Pun 2,Lun 0): SEAGATE ST3146807LC  0003

Do you guys have any idea? 

Thanks
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [patch 0/4] Updated AN patches, now without gendisk

2007-08-14 Thread Kay Sievers
On Mon, 2007-08-13 at 09:26 -0700, Kristen Carlson Accardi wrote:
 On Sat, 11 Aug 2007 16:00:53 +0200
 Kay Sievers [EMAIL PROTECTED] wrote:
 
  On 8/8/07, Kristen Carlson Accardi [EMAIL PROTECTED] wrote:
   Here is an updated set of patches that implement Asynchronous Notification
   support for ATAPI devices.  In this version I no longer export the AN
   capability through genhd, and the uevent is sent by the scsi_device
   instead of gendisk.  I added a generic SCSI device event mechanism so
   that it can be expanded in the future with other types of events.  Please
   let me know what you think.
  
  Does that mean:
  http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=8ce7ad7b2d11fae2c3d285a6a0caea9322c0b8fc
  
  will go away?
 
 Yes - this method was rejected by James, so I had to change away from
 using the genhd to transmit events.

Ok. :)
 
  Then we will need to come up with an idea to propagate that to the
  blockdev, it gets a bit nasty for userspace to find out which
  blockdevice it should update. It's certainly possible, but just not as
  easy as it is now, because userspace just doesn't really care in most
  cases what kind of bus device a block device is coming from.
 
 Is it possible to use the linkage that is in the scsi_device directory
 of the disk that is sending the event to find the relevant block devices?
 For example, /sys/class/scsi_device/0:0:0:0/device/block:sda
 on my system tells me which block devices belong to this device.

Yeah, we will find a way to do that.

We want to unify the event handling, if we add AN support proper. That
means that polled device should send similar events as AN capable, and
userspace runs the same code in both cases. The polling for non-AN
devices would be just a periodic open() and the result would not be used
for anything. We would rely on the events triggered by the polling.

Can you try the attached patch, what does it do in your setup, and how
it behaves with AN and without?

Btw, what is the behavior of the eject button on a locked drive with AN.
Today we poll for changes to get notification about the pressed button,
which otherwise would be ignored on a locked drive.

Thanks,
Kay


From: Kay Sievers [EMAIL PROTECTED]
Subject: scsi: send media state change modification events

This will send for a card reader slot (remove/add media):
  UEVENT[1187091572.155884] change   
/devices/pci:00/:00:1d.7/usb5/5-2/5-2:1.0/host7/target7:0:0/7:0:0:0 
(scsi)
  UEVENT[1187091572.162314] remove   /block/sdb/sdb1 (block)
  UEVENT[1187091572.172464] add  /block/sdb/sdb1 (block)
  UEVENT[1187091572.175408] change   
/devices/pci:00/:00:1d.7/usb5/5-2/5-2:1.0/host7/target7:0:0/7:0:0:0 
(scsi)

and for a DVD drive (add/eject media):
  UEVENT[1187091590.189159] change   
/devices/pci:00/:00:1f.1/host4/target4:0:0/4:0:0:0 (scsi)
  UEVENT[1187091590.957124] add  /module/isofs (module)
  UEVENT[1187091604.468207] change   
/devices/pci:00/:00:1f.1/host4/target4:0:0/4:0:0:0 (scsi)

Userspace gets events, even for unpartitioned media. This unifies
the event handling for asynchronoous events (AN) and events caused by
perodical polling the device from userspace.

Signed-off-by: Kay Sievers [EMAIL PROTECTED]
---
 drivers/scsi/sd.c |   24 +++-
 drivers/scsi/sr.c |   13 ++---
 drivers/scsi/sr.h |1 +
 include/scsi/sd.h |1 +
 4 files changed, 27 insertions(+), 12 deletions(-)

diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 2c6116f..5271bfa 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -722,8 +722,11 @@ static int sd_media_changed(struct gendisk *disk)
 * can deal with it then.  It is only because of unrecoverable errors
 * that we would ever take a device offline in the first place.
 */
-   if (!scsi_device_online(sdp))
-   goto not_present;
+   if (!scsi_device_online(sdp)) {
+   set_media_not_present(sdkp);
+   retval = 1;
+   goto out;
+   }
 
/*
 * Using TEST_UNIT_READY enables differentiation between drive with
@@ -735,6 +738,7 @@ static int sd_media_changed(struct gendisk *disk)
 * sd_revalidate() is called.
 */
retval = -ENODEV;
+
if (scsi_block_when_processing_errors(sdp))
retval = scsi_test_unit_ready(sdp, SD_TIMEOUT, SD_MAX_RETRIES);
 
@@ -744,8 +748,11 @@ static int sd_media_changed(struct gendisk *disk)
 * and we will figure it out later once the drive is
 * available again.
 */
-   if (retval)
-goto not_present;
+   if (retval) {
+   set_media_not_present(sdkp);
+   retval = 1;
+   goto out;
+   }
 
/*
 * For removable scsi disk we have to recognise the presence
@@ -756,12 +763,11 @@ static int sd_media_changed(struct gendisk *disk)
 
retval = sdp-changed;
sdp-changed = 0;
-

Re: READ CAPACITY failed on ia64

2007-08-14 Thread Matthew Wilcox
On Tue, Aug 14, 2007 at 01:50:05PM +0200, Robert Nagy wrote:
 In this box I get the following error message:

If you turn on CONFIG_SCSI_CONSTANTS, you'll get the error message
decoded for you, but ...

 sd 0:0:2:0: [sdb] READ CAPACITY failed
 sd 0:0:2:0: [sdb] Result: hostbyte=0x00 driverbyte=0x08
 sd 0:0:2:0: [sdb] Sense Key : 0x3 [current]

Medium Error, /* 3: Data error detected on the medium */

 sd 0:0:2:0: [sdb] ASC=0x31 ASCQ=0x0

{0x3100, Medium format corrupted},

 I am currently running 2.6.22 but I've also tried with serveral other
 (and older) kernels and it still can't get the capacity of the disk.

Looks like the disc is broken.  Given that a scsiformat doesn't fix it,
it's probably irretrievable.

-- 
Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours.  We can't possibly take such
a retrograde step.
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Linux 2.6.23-rc3

2007-08-14 Thread James Smart


A little more
The -EEXIST matches http://marc.info/?l=linux-scsim=117699334422336w=2
I had a bug fix at http://marc.info/?l=linux-scsim=117856436302690w=2

Mathew's fix below superceeded my patch and supposedly also corrects it.

-- james s

PS: Emulex's testing has been with my fix. We haven't tested Mathew's yet.

Matthew Wilcox wrote:

On Tue, Aug 14, 2007 at 11:10:22AM +0200, Tore Anderson wrote:

  I gave it a spin, and got quite a few troubles that appears related to
 the lpfc driver.  I don't know if these problems happened due to the
 recent update as the latest kernel I ran before was 2.6.20 (where I
 never saw problems like these).  First I see that something failed when
 the volumes on the SAN (on a Sun StorageTek 6140 / Engenio 3994) is
 registered, causing two errors errors such as:


You didn't seem to include your .config, but I assume you're using async
scanning.  Could you try including this patch:

http://marc.info/?l=linux-scsim=118289275414202w=2


-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Linux 2.6.23-rc3

2007-08-14 Thread Tore Anderson
* James Smart

 I've seen these before (and they haven't been specific to the LLDD).

  You're probably right.  I saw trouble happening when lpfc was in
 action and thought it might have something to do with it, but then
 again I'm not very intimate with the inner workings of the kernel.

 If you believe these are related to the -rc3 lpfc mods, I recommend 
 retesting on an -rc2 or 2.6.22 to see how similar they are.

  I have no opinion if this is something that appeared in -rc3 or not as
 I upgraded to it directly from 2.6.20 (which never gave me similar
 problems).  I'm compiling a new kernel with Matthew Wilcox' patch now,
 and will try a few more reboots to see how that helped.  I'll post
 about my findings tomorrow.

Regards
-- 
Tore Anderson
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Problems with USB disk [solved]

2007-08-14 Thread Chuck Ebbert
On 08/13/2007 10:50 AM, Niels wrote:
 On Sunday 12 August 2007 11:54, Niels wrote:
 
 On Friday 10 August 2007 14:43, Niels wrote:

 On Wednesday 08 August 2007 12:57, Ismail Dönmez wrote:

 On Wednesday 08 August 2007 13:48:29 you wrote:
 On Tuesday 07 August 2007 23:18, Greg KH wrote:
 On Tue, Aug 07, 2007 at 10:26:15PM +0200, Niels wrote:
 Hi,

 I'm having problems with a new 500 GB USB disk. It works, but
 sometimes I get these in dmesg:


 usb 1-3: reset high speed USB device using ehci_hcd and address 2
 usb 5-1: USB disconnect, address 2
 drivers/usb/class/usblp.c: usblp0: removed
 sd 0:0:0:0: Device not ready: 6: Sense Key : 0x2 [current]

 : ASC=0x4 ASCQ=0x2

 end_request: I/O error, dev sda, sector 254148215
 sd 0:0:0:0: Device not ready: 6: Sense Key : 0x2 [current]

 : ASC=0x4 ASCQ=0x2

 end_request: I/O error, dev sda, sector 252434023
 EXT3-fs error (device sda1): ext3_find_entry: reading directory
 #15761836 offset 0


 There's also a printer connected. This is on a pci/usb2 card. When
 the above happens, I get I/O errors. When I mount the drive next,
 there are errors and often missing files. Quite annoying!

 Kernel is 2.6.21

 What's going on?
 You have a low voltage issue, or a bad cable.  The device is
 electronically disconnecting itself.  Try using a externally-powered
 hub, or a new cable.
 I am seeing a similar problem with 2.6.22 and 2.6.23-* kernels with my
 60G iPod Video, works fine with 2.6.18 kernel though.


 So far I'm seeing this:

 - On 2.6.21 I mount the drive. After a while it spins down, and when I
 then unmount it, an error pops up in dmesg.

 - On 2.6.18 I can't provoke the same error. The drive doesn't appear to
 spin down. I don't know if the data corruption from 2.6.21 occurs with
 regular use.

 There are a number of other factor I need to eliminate on my system, but
 that's it so far. CONFIG_USB_SUSPEND is not set on either kernel.

 OK, on a vanilla 2.6.18.8 I also have this problem, with both the pci/usb2
 card, and the usb1 on the board. I listen to music from the drive, and
 after some time (10-20 minutes or so), it freaks out:

 =
 sd 1:0:0:0: Device not ready: 6: Current: sense key=0x2
 ASC=0x4 ASCQ=0x2
 end_request: I/O error, dev sda, sector 126693711
 sd 1:0:0:0: Device not ready: 6: Current: sense key=0x2
 ASC=0x4 ASCQ=0x2
 end_request: I/O error, dev sda, sector 126693711
 sd 1:0:0:0: Device not ready: 6: Current: sense key=0x2
 ASC=0x4 ASCQ=0x2
 end_request: I/O error, dev sda, sector 126693711
 =

 
 Using a new PSU and a powered hub made no difference. But I found a solution
 here:
 
 http://alienghic.livejournal.com/382903.html
 
 Basically, the problem is, as suspected, that the drive spins down / goes to
 suspend. This can be disabled with sdparm --clear STANDBY -6 /dev/sda.
 
 It seems to me to be an error that the kernel reports this as something like
 a hardware failure. Or at least very misleading.
 

Oh, nice. The usb-storage (SCSI) disk spins itself down and we can't handle 
that.
Should we be disabling auto-spindown when we connect the device, or be able to
handle this by sending the start command when needed?

-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH 1/6] mpt fusion: Add support for ATTO 4LD: Rebranded LSI 53C1030

2007-08-14 Thread Moore, Eric
On Tuesday, August 14, 2007 4:34 AM,  Prakash, Sathya wrote:
 Add support for ATTO UL4D, they are rebranded 53C1030. 
 The changes are
 1. Adding a new PCI vendor ID in pci table 
 2. The spi_port_page_2 is in different format than that of 
 LSI generic 
 spi_port_page_2 and hence mapping code is added.
 
 signed-off-by: Sathya Prakash [EMAIL PROTECTED]


ACK
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH 2/6] mpt fusion: Usage of high priority request FIFO to send task management commands

2007-08-14 Thread Moore, Eric
On Tuesday, August 14, 2007 4:39 AM, Prakash, Sathya wrote: 
 Added support for sending the task management requests 
 through High priority 
 request FIFO instead of Doorbell writes when firmware support 
 High priority
 FIFO.
 
 signed-off-by: Sathya Prakash [EMAIL PROTECTED]
 ---

ACK
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH 3/6] mpt fusion: Changing call back indices to u8 from int

2007-08-14 Thread Moore, Eric
On  Tuesday, August 14, 2007 4:43 AM, Prakash, Sathya wrote:
 
 The call back index requires only u8 but in lot of places it 
 is referred as int, now everywhere the call back index 
 variables are declared as u8 with uniform name cb_idx
 
 signed-off-by: Sathya Prakash [EMAIL PROTECTED]
 ---
 

Pls note we killed both mpt_lan_index and mpt_stm_index, external
symbols, which the janitors have long wanted to remove.  The new
function mpt_get_cb_idx will obtain the proper cb_idx handle. 

ACK

-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH 4/6] mpt fusion: Creation of mptsas.h header file

2007-08-14 Thread Moore, Eric
On Tuesday, August 14, 2007 4:46 AM,  Prakash, Sathya wrote:

 The data structure definitions from mptsas.c are moved to a 
 new header file mptsas.h
 
 signed-off-by: Sathya Prakash [EMAIL PROTECTED]
 ---

ACK
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH 5/6] mpt fusion: Link speed change display support

2007-08-14 Thread Moore, Eric
On Tuesday, August 14, 2007 4:50 AM,Prakash, Sathya wrote:  

 When there is state change in FC links, a message is 
 displayed with old and new link speed.
 
 signed-off-by: Sathya Prakash [EMAIL PROTECTED]
 ---

ACK
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH 6/6] mpt fusion: Changing company name from LSI Logic to LSI

2007-08-14 Thread Moore, Eric
On Tuesday, August 14, 2007 4:53 AM, Prakash, Sathya wrote:
 
 Recently LSI Logic Corp is renamed as LSI Corp, so where ever 
 there is a reference of LSI Logic, they are changed to LSI in 
 mpt fusion driver code.
 
 signed-off-by: Sathya Prakash [EMAIL PROTECTED]
 ---

ACK
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] add container release logic - update fc transport to utilize it

2007-08-14 Thread James Smart
Consistent with the code in the rest of the transports, when the driver
module attached or detached to a transport, the transport ignored the
statuses from transport_container_register() and 
transport_container_unregister().
This was particularly bad on the unregister path, because the transport would
free the transport-internal structure that held all the attribute 
containers. Thus, if a driver was told to unload, and the unload path
completed faster than the tear down of the scsi object tree (as a sysfs 
attribute
was in use at the time, or whatever), you could get into ugly reuse of a freed
internal structure. 

Given that this is a module-global thing, there's no real relationship to
the create/release (or refcounting) of the device objects that eventually
bind to the structure.

I modified the container logic to potentially call back the container owner
whenever all objects on the container were freed. This allowed the release to
happen in the background to the LLDD removal.

Assuming this is how we want to handle this scenario, the other SCSI transports
need to be updated accordingly.

-- james s

This patch was cut against 2.6.23-rc3

Signed-off-by: James Smart [EMAIL PROTECTED]

diff -upNr a/drivers/base/attribute_container.c 
b/drivers/base/attribute_container.c
--- a/drivers/base/attribute_container.c2007-08-16 02:59:50.0 
-0400
+++ b/drivers/base/attribute_container.c2007-08-16 07:27:23.0 
-0400
@@ -97,6 +97,8 @@ attribute_container_unregister(struct at
int retval = -EBUSY;
mutex_lock(attribute_container_mutex);
spin_lock(cont-containers.k_lock);
+   if (cont-release)
+   cont-flags |= ATTRIBUTE_CONTAINER_RELEASE_PENDING;
if (!list_empty(cont-containers.k_list))
goto out;
retval = 0;
@@ -104,6 +106,8 @@ attribute_container_unregister(struct at
  out:
spin_unlock(cont-containers.k_lock);
mutex_unlock(attribute_container_mutex);
+   if ((retval == 0)  (cont-release))
+   cont-release(cont-release_arg, cont);
return retval;

 }
@@ -212,6 +216,7 @@ attribute_container_remove_device(struct
 {
struct attribute_container *cont;
 
+rmv_restart:
mutex_lock(attribute_container_mutex);
list_for_each_entry(cont, attribute_container_list, node) {
struct internal_container *ic;
@@ -234,6 +239,13 @@ attribute_container_remove_device(struct
class_device_unregister(ic-classdev);
}
}
+
+   if ((cont-flags  ATTRIBUTE_CONTAINER_RELEASE_PENDING)
+list_empty(cont-containers.k_list)) {
+   mutex_unlock(attribute_container_mutex);
+   cont-release(cont-release_arg, cont);
+   goto rmv_restart;
+   }
}
mutex_unlock(attribute_container_mutex);
 }
diff -upNr a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
--- a/drivers/scsi/scsi_transport_fc.c  2007-08-16 03:00:03.0 -0400
+++ b/drivers/scsi/scsi_transport_fc.c  2007-08-16 07:29:03.0 -0400
@@ -314,6 +314,11 @@ static void fc_scsi_scan_rport(struct wo
 struct fc_internal {
struct scsi_transport_template t;
struct fc_function_template *f;
+#define FCI_STARGET_CONTAINER  0x01
+#define FCI_SHOST_CONTAINER0x02
+#define FCI_RPORT_CONTAINER0x04
+#define FCI_VPORT_CONTAINER0x08
+   u32 active_containers;
 
/*
 * For attributes : each object has :
@@ -1956,10 +1961,31 @@ static int fc_user_scan(struct Scsi_Host
return 0;
 }
 
+void
+fc_transport_container_release(void *arg, struct attribute_container *cont)
+{
+   struct fc_internal *i = arg;
+
+   if (cont == i-t.target_attrs.ac)
+   i-active_containers = ~FCI_STARGET_CONTAINER;
+
+   if (cont == i-t.host_attrs.ac)
+   i-active_containers = ~FCI_SHOST_CONTAINER;
+
+   if (cont == i-rport_attr_cont.ac)
+   i-active_containers = ~FCI_RPORT_CONTAINER;
+
+   if (cont == i-vport_attr_cont.ac)
+   i-active_containers = ~FCI_VPORT_CONTAINER;
+
+   if (i-active_containers == 0)
+   kfree(i);
+}
+
 struct scsi_transport_template *
 fc_attach_transport(struct fc_function_template *ft)
 {
-   int count;
+   int count, err;
struct fc_internal *i = kzalloc(sizeof(struct fc_internal),
GFP_KERNEL);
 
@@ -1969,26 +1995,58 @@ fc_attach_transport(struct fc_function_t
i-t.target_attrs.ac.attrs = i-starget_attrs[0];
i-t.target_attrs.ac.class = fc_transport_class.class;
i-t.target_attrs.ac.match = fc_target_match;
+   i-t.target_attrs.ac.release = fc_transport_container_release;
+   i-t.target_attrs.ac.release_arg = i;
i-t.target_size = sizeof(struct 

Re: [PATCH 1/6] mpt fusion: Add support for ATTO 4LD: Rebranded LSI 53C1030

2007-08-14 Thread Matthew Wilcox
On Tue, Aug 14, 2007 at 04:03:31PM +0530, Prakash, Sathya wrote:
 +++ b/drivers/message/fusion/mptspi.c
 @@ -1190,6 +1190,8 @@ static struct spi_function_template 
 mptspi_transport_functions = {
  static struct pci_device_id mptspi_pci_table[] = {
   { PCI_VENDOR_ID_LSI_LOGIC, MPI_MANUFACTPAGE_DEVID_53C1030,
   PCI_ANY_ID, PCI_ANY_ID },
 + { 0x117c /* ATTO */, MPI_MANUFACTPAGE_DEVID_53C1030,
 + PCI_ANY_ID, PCI_ANY_ID },
   { PCI_VENDOR_ID_LSI_LOGIC, MPI_MANUFACTPAGE_DEVID_53C1035,
   PCI_ANY_ID, PCI_ANY_ID },
   {0} /* Terminating entry */

I'd rather see this patch add PCI_VENDOR_ID_ATTO to
include/linux/pci_ids.h

-- 
Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours.  We can't possibly take such
a retrograde step.
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 4/6] mpt fusion: Creation of mptsas.h header file

2007-08-14 Thread Matthew Wilcox
On Tue, Aug 14, 2007 at 04:15:38PM +0530, Prakash, Sathya wrote:
 The data structure definitions from mptsas.c are moved to a new header file 
 mptsas.h

Why?  Are they used outside mptsas.c in some future patch?

-- 
Bill, look, we understand that you're interested in selling us this
operating system, but compare it to ours.  We can't possibly take such
a retrograde step.
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] add container release logic - update fc transport to utilize it

2007-08-14 Thread James Bottomley
On Thu, 2007-08-16 at 08:16 -0400, James Smart wrote:
 Consistent with the code in the rest of the transports, when the driver
 module attached or detached to a transport, the transport ignored the
 statuses from transport_container_register() and 
 transport_container_unregister().
 This was particularly bad on the unregister path, because the transport would
 free the transport-internal structure that held all the attribute 
 containers. Thus, if a driver was told to unload, and the unload path
 completed faster than the tear down of the scsi object tree (as a sysfs 
 attribute
 was in use at the time, or whatever), you could get into ugly reuse of a freed
 internal structure. 
 
 Given that this is a module-global thing, there's no real relationship to
 the create/release (or refcounting) of the device objects that eventually
 bind to the structure.
 
 I modified the container logic to potentially call back the container owner
 whenever all objects on the container were freed. This allowed the release to
 happen in the background to the LLDD removal.
 
 Assuming this is how we want to handle this scenario, the other SCSI 
 transports
 need to be updated accordingly.

I'm afraid if you look at your solution, you'll see it still doesn't
quite work:  If the next thing the user does after unloading lpfc is to
unload the transport class, the module is blown away with potentially a
live release callback to now freed code.

Isn't a better way to handle it simply to give
transport_container_unregister() the semantics everyone is expecting
(i.e. to wait for everything to be tidied up and gone)?  That way none
of the transport classes needs updating, and we don't have to handle the
rather nasty release and unload races.

James


-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] add container release logic - update fc transport to utilize it

2007-08-14 Thread James Smart

James Bottomley wrote:

I'm afraid if you look at your solution, you'll see it still doesn't
quite work:  If the next thing the user does after unloading lpfc is to
unload the transport class, the module is blown away with potentially a
live release callback to now freed code.


You're right...  Although, most don't as the transports are dependencies
for the LLDD's, and it's only the LLDDs they care about. But, point taken.


Isn't a better way to handle it simply to give
transport_container_unregister() the semantics everyone is expecting
(i.e. to wait for everything to be tidied up and gone)?  That way none
of the transport classes needs updating, and we don't have to handle the
rather nasty release and unload races.


I was hoping you'd give some guidance. This area is black voodoo... :)

Sure - so are you suggesting that transport_container_unregister()
continually loop until successful ?  If not, what other kind of semantic
can we give it that we don't have to muck with the transport classes ?

-- james s


-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/1] cciss: fix error reporting for SG_IO

2007-08-14 Thread Mike Miller (OS Dev)
Patch 1/1
Steve has been trying to send this out but it doesn't seem to be getting
anywhere. Please review this patch for accuracy. There's a couple of things
not clear to us.

Thanks,
mikem


We found a problem with the way cciss was filling out rq-errors.
Previously, it just put a 1 or a 0 in there and used the negation
of this as the uptodate parameter to one of the functions in the
block layer, being a block device.

For the SG_IO support, this is not sufficient, and we noticed
that for example, sg_turs from sg3_utils does not correctly
detect problems due to cciss filling out rq-errors incorrectly.

So, below is my attempt at fixing this, but I'm not completely
sure I did it all right.  It is better than before, in that
now sg_turs seems to detect when things go wrong (e.g.:
when a disk is inaccessible due to cables being yanked, it
notices.)

There is some stuff in scsi.h:

 /*
  *  Use these to separate status msg and our bytes
  *
  *  These are set by:
  *
  *  status byte = set from target device
  *  msg_byte= return status from host adapter itself.
  *  host_byte   = set by low-level driver to indicate status.
  *  driver_byte = set by mid-level.
  */
 #define status_byte(result) (((result)  1)  0x7f)
 #define msg_byte(result)(((result)  8)  0xff)
 #define host_byte(result)   (((result)  16)  0xff)
 #define driver_byte(result) (((result)  24)  0xff)

I'm unsure about the msg_byte (sg_turs appears not to 
look at it.)  I used a device specific code (cciss 
notion of CommandStatus) here.  Not sure if that's correct, 
but not sure what else I would use.  Any clarification on 
that would be helpful.  And of course, let me know if you 
notice anything else I might have screwed up.

-- steve

Signed-off-by: Stephen M. Cameron [EMAIL PROTECTED]

---

 drivers/block/cciss.c |   81 ++
 1 files changed, 63 insertions(+), 18 deletions(-)

diff -puN drivers/block/cciss.c~sg_io_fix_error_reporting drivers/block/cciss.c
--- linux-2.6.23-rc2/drivers/block/cciss.c~sg_io_fix_error_reporting
2007-08-13 09:44:58.0 -0500
+++ linux-2.6.23-rc2-scameron/drivers/block/cciss.c 2007-08-13 
09:44:58.0 -0500
@@ -2366,30 +2366,57 @@ static inline void resend_cciss_cmd(ctlr
start_io(h);
 }
 
+/* inverse of macros in scsi.h */
+
+#define shift_status_byte(x) ((x)  0xff)
+#define shift_msg_byte(x) (((x)  0xff)  8)
+#define shift_host_byte(x) (((x)  0xff)  16)
+#define shift_driver_byte(x) (((x)  0xff)  24)
+
+#define make_status_bytes(s, m, h, d) \
+   shift_status_byte((s)) |\
+   shift_msg_byte((m)) |\
+   shift_host_byte((h)) |\
+shift_driver_byte((d))
+
 static inline int evaluate_target_status(CommandList_struct *cmd)
 {
unsigned char sense_key;
-   int error_count = 1;
+   unsigned char status_byte, msg_byte, host_byte, driver_byte;
+   int error_value;
+
+   /* If we get in here, it means we got target status, that is, scsi 
status */
+   status_byte = cmd-err_info-ScsiStatus;
+   driver_byte = DRIVER_OK;
+   msg_byte = cmd-err_info-CommandStatus; /* correct?  seems too device 
specific */
+
+   if (blk_pc_request(cmd-rq))
+   host_byte = DID_PASSTHROUGH;
+   else
+   host_byte = DID_OK;
+
+   error_value = make_status_bytes(status_byte, msg_byte,
+   host_byte, driver_byte);
 
-   if (cmd-err_info-ScsiStatus != 0x02) { /* not check condition? */
+   if (cmd-err_info-ScsiStatus != SAM_STAT_CHECK_CONDITION) {
if (!blk_pc_request(cmd-rq))
printk(KERN_WARNING cciss: cmd %p 
   has SCSI Status 0x%x\n,
   cmd, cmd-err_info-ScsiStatus);
-   return error_count;
+   return error_value;
}
 
/* check the sense key */
sense_key = 0xf  cmd-err_info-SenseInfo[2];
/* no status or recovered error */
-   if ((sense_key == 0x0) || (sense_key == 0x1))
-   error_count = 0;
+   if (((sense_key == 0x0) || (sense_key == 0x1))  
!blk_pc_request(cmd-rq))
+   error_value = 0;
 
if (!blk_pc_request(cmd-rq)) { /* Not SG_IO or similar? */
-   if (error_count != 0)
+   if (error_value != 0)
printk(KERN_WARNING cciss: cmd %p has CHECK CONDITION
sense key = 0x%x\n, cmd, sense_key);
-   return error_count;
+   return error_value;
}
 
/* SG_IO or similar, copy sense data back */
@@ -2401,7 +2428,7 @@ static inline int evaluate_target_status
} else
cmd-rq-sense_len = 0;
 
-   return error_count;
+   return error_value;
 }
 
 /* checks the status of the job and calls complete buffers to mark all
@@ -2417,7 +2444,7 @@ static 

[PATCH ] Addition to pci_ids.h for ATTO Technology, Inc.

2007-08-14 Thread Eric Moore
A new PCI_VENDOR_ID for pci_ids.h.

signed-off-by: Eric Moore [EMAIL PROTECTED]

diff -uarpN b/include/linux/pci_ids.h a/include/linux/pci_ids.h
--- b/include/linux/pci_ids.h   2007-08-08 16:50:40.0 -0600
+++ a/include/linux/pci_ids.h   2007-08-14 16:03:40.0 -0600
@@ -1461,6 +1461,8 @@
 #define PCI_DEVICE_ID_TOSHIBA_TC86C001_MISC0x0108
 #define PCI_DEVICE_ID_TOSHIBA_SPIDER_NET 0x01b3
 
+#define PCI_VENDOR_ID_ATTO 0x117c
+
 #define PCI_VENDOR_ID_RICOH0x1180
 #define PCI_DEVICE_ID_RICOH_RL5C4650x0465
 #define PCI_DEVICE_ID_RICOH_RL5C4660x0466
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH 4/6] mpt fusion: Creation of mptsas.h header file

2007-08-14 Thread Moore, Eric
On Tuesday, August 14, 2007 12:50 PM, Matthew Wilcox wrote:  
 On Tue, Aug 14, 2007 at 04:15:38PM +0530, Prakash, Sathya wrote:
  The data structure definitions from mptsas.c are moved to a 
 new header file mptsas.h
 
 Why?  Are they used outside mptsas.c in some future patch?
 

Having rougly 10 data structures, and nearly 100 lines of code, Id
prefer it to have it in a seperate header so our sources files is not so
cluttered with a bunch of structs and defines..   In our internal
sources, we do need this broken out into a seperate header due to its
inclusion in our IOCTLS sources.  
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/6] mpt fusion: Add support for ATTO 4LD: Rebranded LSI 53C1030

2007-08-14 Thread Christoph Hellwig
On Tue, Aug 14, 2007 at 04:03:31PM +0530, Prakash, Sathya wrote:
 2. The spi_port_page_2 is in different format than that of LSI generic 
 spi_port_page_2 and hence mapping code is added.

Not that we can change it anymore, but what idiot decided to do such
a change?  An chance LSI could stop licencees from doing such bloody
braindamaged things to the firmware in the future?

add a reminder for anyone to never but ATTO hardware as the company
is utterly useles..
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [PATCH 1/6] mpt fusion: Add support for ATTO 4LD: Rebranded LSI 53C1030

2007-08-14 Thread Moore, Eric
On Tuesday, August 14, 2007 4:44 PM,  Christoph Hellwig wrote:
 
 Not that we can change it anymore, but what idiot decided to do such
 a change?  An chance LSI could stop licencees from doing such bloody
 braindamaged things to the firmware in the future?
 
 add a reminder for anyone to never but ATTO hardware as the company
 is utterly useles..


I really not sure the significance of that change to spi_device config
pages.  My guess that atto flags have something significant to some
other OS, like windows.  I couldn't find anyone from ATTO that would
answer my doubts.   There are some customers that want PCI EXPRESS U320
card, and LSI never decided to make anything beyond xscale. There is
this express  card from ATTO, as well as one from HP, both having the
LSI 1030 chip.  LSI managment approved this request for this patch, so
we pushed forward with supplying this changeset.

I have reposted the patch per Wilcox's request having the ATTO ids, but
I just don't see it posted to the forum.  I may have to repost.

Eric  
-
To unsubscribe from this list: send the line unsubscribe linux-scsi in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/6] mpt fusion: Add support for ATTO 4LD: Rebranded LSI 53C1030

2007-08-14 Thread Eric Moore
Per request from Matthew Wilcox - using PCI_VENDOR_ATTO.

Add support for ATTO UL4D, they are rebranded 53C1030.
The changes are
1. Adding a new PCI vendor ID in pci table
2. The spi_port_page_2 is in different format than that of LSI generic
spi_port_page_2 and hence mapping code is added.

signed-off-by: Sathya Prakash [EMAIL PROTECTED]
signed-off-by: Eric Moore [EMAIL PROTECTED]

diff -uarpN b/drivers/message/fusion/Kconfig a/drivers/message/fusion/Kconfig
--- b/drivers/message/fusion/Kconfig2007-08-14 15:50:10.0 -0600
+++ a/drivers/message/fusion/Kconfig2007-08-14 15:53:31.0 -0600
@@ -20,6 +20,7 @@ config FUSION_SPI
  LSI53C1020A
  LSI53C1030
  LSI53C1035
+ ATTO UL4D
 
 config FUSION_FC
tristate Fusion MPT ScsiHost drivers for FC
diff -uarpN b/drivers/message/fusion/mptbase.c 
a/drivers/message/fusion/mptbase.c
--- b/drivers/message/fusion/mptbase.c  2007-08-14 15:50:10.0 -0600
+++ a/drivers/message/fusion/mptbase.c  2007-08-14 16:05:02.0 -0600
@@ -4888,6 +4888,38 @@ mpt_GetScsiPortSettings(MPT_ADAPTER *ioc
/* Nvram data is left with INVALID mark
 */
rc = 1;
+   } else if (ioc-pcidev-vendor == PCI_VENDOR_ID_ATTO) {
+
+   /* This is an ATTO adapter, read Page2 
accordingly
+   */
+   ATTO_SCSIPortPage2_t *pPP2 = 
(ATTO_SCSIPortPage2_t  *) pbuf;
+   ATTODeviceInfo_t *pdevice = NULL;
+   u16 ATTOFlags;
+
+   /* Save the Port Page 2 data
+* (reformat into a 32bit quantity)
+*/
+   for (ii=0; ii  MPT_MAX_SCSI_DEVICES; ii++) {
+ pdevice = pPP2-DeviceSettings[ii];
+ ATTOFlags = le16_to_cpu(pdevice-ATTOFlags);
+ data = 0;
+
+ /* Translate ATTO device flags to LSI format
+  */
+ if (ATTOFlags  ATTOFLAG_DISC)
+   data |= 
(MPI_SCSIPORTPAGE2_DEVICE_DISCONNECT_ENABLE);
+ if (ATTOFlags  ATTOFLAG_ID_ENB)
+   data |= 
(MPI_SCSIPORTPAGE2_DEVICE_ID_SCAN_ENABLE);
+ if (ATTOFlags  ATTOFLAG_LUN_ENB)
+   data |= 
(MPI_SCSIPORTPAGE2_DEVICE_LUN_SCAN_ENABLE);
+ if (ATTOFlags  ATTOFLAG_TAGGED)
+   data |= 
(MPI_SCSIPORTPAGE2_DEVICE_TAG_QUEUE_ENABLE);
+ if (!(ATTOFlags  ATTOFLAG_WIDE_ENB))
+   data |= 
(MPI_SCSIPORTPAGE2_DEVICE_WIDE_DISABLE);
+
+ data = (data  16) | (pdevice-Period  8) 
| 10;
+ ioc-spi_data.nvram[ii] = data;
+   }
} else {
SCSIPortPage2_t *pPP2 = (SCSIPortPage2_t  *) 
pbuf;
MpiDeviceInfo_t *pdevice = NULL;
diff -uarpN b/drivers/message/fusion/mptbase.h 
a/drivers/message/fusion/mptbase.h
--- b/drivers/message/fusion/mptbase.h  2007-08-14 15:50:10.0 -0600
+++ a/drivers/message/fusion/mptbase.h  2007-08-14 15:53:31.0 -0600
@@ -194,6 +194,35 @@
 
 /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
 /*
+ *  ATTO UL4D associated structures and defines
+ */
+#define ATTOFLAG_DISC 0x0001
+#define ATTOFLAG_TAGGED   0x0002
+#define ATTOFLAG_WIDE_ENB 0x0008
+#define ATTOFLAG_ID_ENB   0x0010
+#define ATTOFLAG_LUN_ENB  0x0060
+
+typedef struct _ATTO_DEVICE_INFO
+{
+   u8  Offset; /* 00h */
+   u8  Period; /* 01h */
+   u16 ATTOFlags;  /* 02h */
+} ATTO_DEVICE_INFO, MPI_POINTER PTR_ATTO_DEVICE_INFO,
+  ATTODeviceInfo_t, MPI_POINTER pATTODeviceInfo_t;
+
+typedef struct _ATTO_CONFIG_PAGE_SCSI_PORT_2
+{
+   CONFIG_PAGE_HEADER  Header; /* 00h */
+   u16 PortFlags;  /* 04h */
+   u16 Unused1;/* 06h */
+   u32 Unused2;/* 08h */
+   ATTO_DEVICE_INFODeviceSettings[16]; /* 0Ch */
+} fATTO_CONFIG_PAGE_SCSI_PORT_2, MPI_POINTER PTR_ATTO_CONFIG_PAGE_SCSI_PORT_2,
+  ATTO_SCSIPortPage2_t, MPI_POINTER pATTO_SCSIPortPage2_t;
+
+
+/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=*/
+/*
  *  MPT protocol driver defs...
  */
 typedef enum {
diff -uarpN b/drivers/message/fusion/mptspi.c