hpsa February 2014 driver updates
Subsystems (3)
cover hpsa February 2014 driver updates
This is a big patch series. Most of the changes have to do with enabling alternate command submission paths for certain i/os to bypass the Smart Array RAID firmware stack and submit i/o's more directly to physical devices -- solid state disks -- for increased performance.
---
Hannes Reinecke (1):
hpsa: fixup MSI-X registration
Matt Gates (3):
hpsa: use extended report luns command for HP SSD SmartPath
hpsa: mark last scatter gather element as the last
hpsa: add support for 'fastpath' i/o
Mike MIller (1):
hpsa: get physical device handles for io accel mode 2 as well as mode 1
Mike Miller (1):
hpsa: add ioaccel mode 2 structure definitions
Scott Teel (12):
hpsa: fix task management for mode-1 ioaccell path
hpsa: add hp_ssd_smart_path_enabled sysfs attribute
hpsa: complain if physical or logical aborts are not supported
hpsa: get ioaccel mode 2 i/o working
hpsa: teach hpsa_device_reset to do either target or lun reset
hpsa: add task management for ioaccel mode 2
hpsa: complete the ioaccel raidmap code
hpsa: allow user to disable accelerated i/o path
hpsa: rescan devices on ioaccel2 error
hpsa: retry certain ioaccel error cases on the RAID path
hpsa: update source file copyrights
hpsa: add controller base data-at-rest encryption compatibility ioaccel2
Stephen M. Cameron (17):
hpsa: only allow REQ_TYPE_FS to use fast path
hpsa: add ioaccell mode 1 RAID offload support.
hpsa: update raid offload status on device rescan
hpsa: poll controller to detect device change event
hpsa: do not rescan controllers known to be locked up
hpsa: Acknowledge controller events in ioaccell mode 2 as well as mode 1
hpsa: do ioaccel mode 2 resource allocations
hpsa: initialize controller to perform io accelerator mode 2
hpsa: make device update copy the raid map also
hpsa: allow VPD page zero to be queried
hpsa: do not inquire for unsupported ioaccel status vpd page
hpsa: when switching out of accel mode await only accel command completions
hpsa: only do device rescan for certain events
hpsa: improve error messages for driver initiated commands hpsa add sysfs debug switch for raid map debugging messages
pci: add HP/3PAR vendor id to pci_ids.h
hpsa: Add support for a few HP Storage controllers
Documentation/ABI/testing/sysfs-class-scsi_host | 16 drivers/scsi/hpsa.c | 2292 ++++++++++++++++++++++- drivers/scsi/hpsa.h | 121 + drivers/scsi/hpsa_cmd.h | 251 ++- include/linux/pci_ids.h | 1 5 files changed, 2557 insertions(+), 124 deletions(-)
Signature · 1 line
-- steve
PATCH 1/35 hpsa: use extended report luns command for HP SSD SmartPath
From: Matt Gates <[email protected]>
There is an extended report luns command which contains additional information about physical devices. In particular we need to get the physical device handle so we can use an alternate i/o path for fast physical devices like SSDs so we can speed up certain i/o's by bypassing the RAID stack code in the controller firmware.
--- drivers/scsi/hpsa.c | 13 ++++++++----- drivers/scsi/hpsa_cmd.h | 1 + 2 files changed, 9 insertions(+), 5 deletions(-)
drivers/scsi/hpsa.c +8 -5
@@ -1888,11 +1888,12 @@ static int hpsa_gather_lun_info(struct ctlr_info *h, struct ReportLUNdata *physdev, u32 *nphysicals, struct ReportLUNdata *logdev, u32 *nlogicals) { - if (hpsa_scsi_do_report_phys_luns(h, physdev, reportlunsize, 0)) { + if (hpsa_scsi_do_report_phys_luns(h, physdev, reportlunsize, + HPSA_REPORT_PHYS_EXTENDED)) { dev_err(&h->pdev->dev, "report physical LUNs failed.\n");return -1 ; } - *nphysicals =be32_to_cpu (*((__be32 *)physdev->LUNListLength)) /8 ; + *nphysicals =be32_to_cpu (*((__be32 *)physdev->LUNListLength)) /24 ;if (*nphysicals >HPSA_MAX_PHYS_LUN ) { dev_warn(&h->pdev->dev, "maximum physical LUNs (%d) exceeded." " %d LUNs ignored.\n", HPSA_MAX_PHYS_LUN,
@@ -1923,7 +1924,8 @@ static int hpsa_gather_lun_info(struct ctlr_info *h, }u8 *figure_lunaddrbytes (struct ctlr_info *h,int raid_ctlr_position,int i, -int nphysicals,int nlogicals,struct ReportLUNdata *physdev_list, +int nphysicals,int nlogicals, +struct ReportExtendedLUNdata *physdev_list,struct ReportLUNdata *logdev_list) {/* Helper function, figure out where the LUN ID info is coming from
@@ -1959,7 +1961,7 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)* tell which devices we already know about, vs. new * devices, vs. disappearing devices. */ -struct ReportLUNdata *physdev_list =NULL ; +struct ReportExtendedLUNdata *physdev_list =NULL ;struct ReportLUNdata *logdev_list =NULL ;u32 nphysicals =0 ;u32 nlogicals =0 ;
@@ -1982,7 +1984,8 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno) }memset (lunzerobits,0 ,sizeof (lunzerobits)); -if (hpsa_gather_lun_info (h, reportlunsize, physdev_list, &nphysicals, +if (hpsa_gather_lun_info (h, reportlunsize, + (struct ReportLUNdata *) physdev_list, &nphysicals, logdev_list, &nlogicals)) goto out;
drivers/scsi/hpsa_cmd.h +1 -0
@@ -162,6 +162,7 @@ struct InquiryData {#define HPSA_REPORT_LOG 0xc2/* Report Logical LUNs */ #define HPSA_REPORT_PHYS 0xc3/* Report Physical LUNs */ +#define HPSA_REPORT_PHYS_EXTENDED 0x02struct ReportLUNdata {u8 LUNListLength[4 ];u32 reserved;
PATCH 2/35 hpsa: mark last scatter gather element as the last
In reply to Stephen M. CameronFrom: Matt Gates <[email protected]>
This is normally optional, but for SSD Smart Path support (in subsequent patches) it is required.
--- drivers/scsi/hpsa.c | 8 ++++---- drivers/scsi/hpsa_cmd.h | 1 + 2 files changed, 5 insertions(+), 4 deletions(-)
drivers/scsi/hpsa.c +4 -4
@@ -1438,6 +1438,7 @@ static int hpsa_map_one(struct pci_dev *pdev, cp->SG[0 ].Addr.upper = (u32) ((addr64 >>32 ) & (u64 )0x00000000FFFFFFFF ); cp->SG[0 ].Len = buflen; + cp->SG[0 ].Ext =HPSA_SG_LAST ;/* we are not chaining */ cp->Header.SGList = (u8 )1 ;/* no. SGs contig in this cmd */ cp->Header.SGTotal = (u16 )1 ;/* total sgs in this cmd list */ return 0 ;
@@ -2139,7 +2140,7 @@ static int hpsa_scatter_gather(struct ctlr_info *h, curr_sg->Addr.lower = (u32) (addr64 &0x0FFFFFFFFULL ); curr_sg->Addr.upper = (u32) ((addr64 >>32 ) &0x0FFFFFFFFULL ); curr_sg->Len = len; - curr_sg->Ext =0 ;/* we are not chaining */ + curr_sg->Ext = (i <scsi_sg_count (cmd) -1 ) ?0 :HPSA_SG_LAST ; curr_sg++; }
@@ -3041,7 +3042,7 @@ static int hpsa_passthru_ioctl(struct ctlr_info *h, void __user *argp) c->SG[0 ].Addr.lower = temp64.val32.lower; c->SG[0 ].Addr.upper = temp64.val32.upper; c->SG[0 ].Len = iocommand.buf_size; - c->SG[0 ].Ext =0 ;/* we are not chaining*/ + c->SG[0 ].Ext =HPSA_SG_LAST ;/* we are not chaining*/ }hpsa_scsi_do_simple_cmd_core_if_no_lockup (h, c);if (iocommand.buf_size >0 )
@@ -3171,8 +3172,7 @@ static int hpsa_big_passthru_ioctl(struct ctlr_info *h, void __user *argp) c->SG[i].Addr.lower = temp64.val32.lower; c->SG[i].Addr.upper = temp64.val32.upper; c->SG[i].Len = buff_size[i]; -/* we are not chaining */ - c->SG[i].Ext =0 ; + c->SG[i].Ext = i < sg_used -1 ?0 :HPSA_SG_LAST ; } }hpsa_scsi_do_simple_cmd_core_if_no_lockup (h, c);
drivers/scsi/hpsa_cmd.h +1 -0
@@ -25,6 +25,7 @@#define SENSEINFOBYTES 32/* may vary between hbas */ #define SG_ENTRIES_IN_CMD 32/* Max SG entries excluding chain blocks */ #define HPSA_SG_CHAIN 0x80000000 +#define HPSA_SG_LAST 0x40000000#define MAXREPLYQS 256/* Command Status value */
PATCH 3/35 hpsa: add support for 'fastpath' i/o
In reply to Stephen M. CameronFrom: Matt Gates <[email protected]>
For certain i/o's to certain devices (unmasked physical disks) we can bypass the RAID stack firmware and do the i/o to the device directly and it will be faster.
--- drivers/scsi/hpsa.c | 296 ++++++++++++++++++++++++++++++++++++++++++++--- drivers/scsi/hpsa.h | 51 ++++++++ drivers/scsi/hpsa_cmd.h | 60 ++++++++++ 3 files changed, 388 insertions(+), 19 deletions(-)
drivers/scsi/hpsa.c +277 -19
@@ -204,7 +204,7 @@ static void check_ioctl_unit_attention(struct ctlr_info *h, struct CommandList *c);/* performant mode helper functions */ static void calc_bucket_map (int *bucket,int num_buckets, -int nsgs,int *bucket_map); +int nsgs,int min_blocks,int *bucket_map);static void hpsa_put_ctlr_into_performant_mode (struct ctlr_info *h);static inline u32 next_command (struct ctlr_info *h,u8 q); static int hpsa_find_cfg_addrs(struct pci_dev *pdev, void __iomem *vaddr,
@@ -570,6 +570,9 @@ static inline u32 next_command(struct ctlr_info *h, u8 q)struct reply_pool *rq = &h->reply_queue[q];unsigned long flags; +if (h->transMethod & CFGTBL_Trans_io_accel1) +return h->access.command_completed (h, q); +if (unlikely (!(h->transMethod & CFGTBL_Trans_Performant)))return h->access.command_completed (h, q);
@@ -1203,7 +1206,8 @@ static void complete_scsi_command(struct CommandList *cp) h = cp->h;scsi_dma_unmap (cmd);/* undo the DMA mappings */ -if (cp->Header.SGTotal > h->max_cmd_sg_entries) +if ((cp->cmd_type ==CMD_SCSI ) && + (cp->Header.SGTotal > h->max_cmd_sg_entries))hpsa_unmap_sg_chain_block (h, cp); cmd->result = (DID_OK <<16 );/* host byte */
@@ -1227,6 +1231,19 @@ static void complete_scsi_command(struct CommandList *cp)return ; } +/* For I/O accelerator commands, copy over some fields to the normal +* CISS header used below for error handling. +*/ +if (cp->cmd_type ==CMD_IOACCEL1 ) { +struct io_accel1_cmd *c = &h->ioaccel_cmd_pool[cp->cmdindex]; + cp->Header.SGList = cp->Header.SGTotal =scsi_sg_count (cmd); + cp->Request.CDBLen = c->io_flags &IOACCEL1_IOFLAGS_CDBLEN_MASK ; + cp->Header.Tag.lower = c->Tag.lower; + cp->Header.Tag.upper = c->Tag.upper; +memcpy (cp->Header.LUN.LunAddrBytes, c->CISS_LUN,8 ); +memcpy (cp->Request.CDB, c->CDB, cp->Request.CDBLen); + } +/* an error has occurred */ switch (ei->CommandStatus) {
@@ -2070,6 +2087,9 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)case TYPE_DISK :if (i < nphysicals)break ; +memcpy (&this_device->ioaccel_handle, + &lunaddrbytes[20 ], +sizeof (this_device->ioaccel_handle)); ncurrent++;break ;case TYPE_TAPE :
@@ -2164,6 +2184,104 @@ sglist_finished:return 0 ; } +/* +* Queue a command to the I/O accelerator path. +* This method does not currently support S/G chaining. +*/ +static int hpsa_scsi_ioaccel_queue_command (struct ctlr_info *h, +struct CommandList *c) +{ +struct scsi_cmnd *cmd = c->scsi_cmd; +struct hpsa_scsi_dev_t *dev = cmd->device->hostdata; +struct io_accel1_cmd *cp = &h->ioaccel_cmd_pool[c->cmdindex]; +unsigned int len; +unsigned int total_len =0 ; +struct scatterlist *sg; +u64 addr64; +int use_sg, i; +struct SGDescriptor *curr_sg; +u32 control =IOACCEL1_CONTROL_SIMPLEQUEUE ; + +BUG_ON (cmd->cmd_len >IOACCEL1_IOFLAGS_CDBLEN_MAX ); + + c->cmd_type =CMD_IOACCEL1 ; + +/* Adjust the DMA address to point to the accelerated command buffer */ + c->busaddr = (u32 ) h->ioaccel_cmd_pool_dhandle + + (c->cmdindex *sizeof (*cp)); +BUG_ON (c->busaddr &0x0000007F ); + + use_sg =scsi_dma_map (cmd); +if (use_sg <0 ) +return use_sg; + +if (use_sg) { + curr_sg = cp->SG; +scsi_for_each_sg (cmd, sg, use_sg, i) { + addr64 = (u64 )sg_dma_address (sg); + len =sg_dma_len (sg); + total_len += len; + curr_sg->Addr.lower = (u32) (addr64 &0x0FFFFFFFFULL ); + curr_sg->Addr.upper = + (u32) ((addr64 >>32 ) &0x0FFFFFFFFULL ); + curr_sg->Len = len; + +if (i == (scsi_sg_count (cmd) -1 )) + curr_sg->Ext =HPSA_SG_LAST ; +else + curr_sg->Ext =0 ;/* we are not chaining */ + curr_sg++; + } + +switch (cmd->sc_data_direction) { +case DMA_TO_DEVICE : + control |=IOACCEL1_CONTROL_DATA_OUT ; +break ; +case DMA_FROM_DEVICE : + control |=IOACCEL1_CONTROL_DATA_IN ; +break ; +case DMA_NONE : + control |=IOACCEL1_CONTROL_NODATAXFER ; +break ; +default : +dev_err (&h->pdev->dev,"unknown data direction: %d\n" , + cmd->sc_data_direction); +BUG (); +break ; + } + }else { + control |=IOACCEL1_CONTROL_NODATAXFER ; + } + +/* Fill out the command structure to submit */ + cp->dev_handle = dev->ioaccel_handle; + cp->transfer_len = total_len; + cp->io_flags =IOACCEL1_IOFLAGS_IO_REQ | + (cmd->cmd_len &IOACCEL1_IOFLAGS_CDBLEN_MASK ); + cp->control = control; +memcpy (cp->CDB, cmd->cmnd, cmd->cmd_len); +memcpy (cp->CISS_LUN, dev->scsi3addr,8 ); + +/* Tell the controller to post the reply to the queue for this +* processor. This seems to give the best I/O throughput. +*/ + cp->ReplyQueue =smp_processor_id () % h->nreply_queues; + +/* Set the bits in the address sent down to include: +* - performant mode bit (bit 0) +* - pull count (bits 1-3) +* - command type (bits 4-6) +*/ + c->busaddr |=1 | (h->ioaccel1_blockFetchTable[use_sg] <<1 ) | +IOACCEL1_BUSADDR_CMDTYPE ; + +/* execute command (bypassing cmd queue if possible) */ +if (unlikely (h->access.fifo_full (h))) +enqueue_cmd_and_start_io (h, c); +else + h->access.submit_command (h, c); +return 0 ; +}static int hpsa_scsi_queue_command_lck (struct scsi_cmnd *cmd,void (*done)(struct scsi_cmnd *))
@@ -2207,6 +2325,14 @@ static int hpsa_scsi_queue_command_lck(struct scsi_cmnd *cmd, c->cmd_type =CMD_SCSI ; c->scsi_cmd = cmd; + +/* Call alternate submit routine for I/O accelerated commands */ +if ((likely (h->transMethod & CFGTBL_Trans_io_accel1)) && + (dev->ioaccel_handle) && + ((cmd->cmnd[0 ] ==READ_10 ) || (cmd->cmnd[0 ] ==WRITE_10 )) && + (scsi_sg_count (cmd) <=IOACCEL1_MAXSGENTRIES )) +return hpsa_scsi_ioaccel_queue_command (h, c); + c->Header.ReplyQueue =0 ;/* unused in simple mode */ memcpy (&c->Header.LUN.LunAddrBytes[0 ], &scsi3addr[0 ],8 ); c->Header.Tag.lower = (c->cmdindex <<DIRECT_LOOKUP_SHIFT );
@@ -2780,6 +2906,7 @@ static struct CommandList *cmd_special_alloc(struct ctlr_info *h)return NULL ;memset (c,0 ,sizeof (*c)); + c->cmd_type =CMD_SCSI ; c->cmdindex =-1 ; c->err_info = pci_alloc_consistent(h->pdev, sizeof(*c->err_info),
@@ -3565,7 +3692,7 @@ static inline void finish_cmd(struct CommandList *c)spin_unlock_irqrestore (&h->lock, flags);dial_up_lockup_detection_on_fw_flash_complete (c->h, c); -if (likely (c->cmd_type ==CMD_SCSI )) +if (likely (c->cmd_type ==CMD_IOACCEL1 || c->cmd_type ==CMD_SCSI ))complete_scsi_command (c);else if (c->cmd_type ==CMD_IOCTL_PEND )complete (c->waiting);
@@ -4585,6 +4712,10 @@ static void hpsa_free_cmd_pool(struct ctlr_info *h) h->nr_cmds *sizeof (struct ErrorInfo ), h->errinfo_pool, h->errinfo_pool_dhandle); +if (h->ioaccel_cmd_pool) +pci_free_consistent (h->pdev, + h->nr_cmds *sizeof (struct io_accel1_cmd ), + h->ioaccel_cmd_pool, h->ioaccel_cmd_pool_dhandle); } static int hpsa_request_irq(struct ctlr_info *h,
@@ -4684,6 +4815,7 @@ static void hpsa_undo_allocations_after_kdump_soft_reset(struct ctlr_info *h)hpsa_free_irqs_and_disable_msix (h);hpsa_free_sg_chain_blocks (h);hpsa_free_cmd_pool (h); +kfree (h->ioaccel1_blockFetchTable);kfree (h->blockFetchTable);pci_free_consistent (h->pdev, h->reply_pool_size, h->reply_pool, h->reply_pool_dhandle);
@@ -5037,6 +5169,7 @@ static void hpsa_remove_one(struct pci_dev *pdev) h->reply_pool, h->reply_pool_dhandle);kfree (h->cmd_pool_bits);kfree (h->blockFetchTable); +kfree (h->ioaccel1_blockFetchTable);kfree (h->hba_inquiry_data);pci_disable_device (pdev);pci_release_regions (pdev);
@@ -5077,20 +5210,17 @@ static struct pci_driver hpsa_pci_driver = {* bits of the command address. */ static void calc_bucket_map (int bucket[],int num_buckets, -int nsgs,int *bucket_map) +int nsgs,int min_blocks,int *bucket_map) {int i, j, b, size; -/* even a command with 0 SGs requires 4 blocks */ -#define MINIMUM_TRANSFER_BLOCKS 4 -#define NUM_BUCKETS 8/* Note, bucket_map must have nsgs+1 entries. */ for (i =0 ; i <= nsgs; i++) {/* Compute size of a command with i SG entries */ - size = i +MINIMUM_TRANSFER_BLOCKS ; + size = i + min_blocks; b = num_buckets;/* Assume the biggest bucket */ /* Find the bucket that is just big enough */ -for (j =0 ; j <8 ; j++) { +for (j =0 ; j < num_buckets; j++) {if (bucket[j] >= size) { b = j;break ;
@@ -5101,10 +5231,16 @@ static void calc_bucket_map(int bucket[], int num_buckets, } } -static void hpsa_enter_performant_mode (struct ctlr_info *h,u32 use_short_tags) +static void hpsa_enter_performant_mode (struct ctlr_info *h,u32 trans_support) {int i;unsigned long register_value; +unsigned long transMethod = CFGTBL_Trans_Performant | + (trans_support & CFGTBL_Trans_use_short_tags) | + CFGTBL_Trans_enable_directed_msix | + (trans_support & CFGTBL_Trans_io_accel1); + +struct access_method access = SA5_performant_access;/* This is a bit complicated. There are 8 registers on * the controller which we write to to tell it 8 different
@@ -5136,7 +5272,7 @@ static void hpsa_enter_performant_mode(struct ctlr_info *h, u32 use_short_tags) bft[7 ] =SG_ENTRIES_IN_CMD +4 ;calc_bucket_map (bft,ARRAY_SIZE (bft), -SG_ENTRIES_IN_CMD , h->blockFetchTable); +SG_ENTRIES_IN_CMD ,4 , h->blockFetchTable);for (i =0 ; i <8 ; i++)writel (bft[i], &h->transtable->BlockFetch[i]);
@@ -5153,9 +5289,15 @@ static void hpsa_enter_performant_mode(struct ctlr_info *h, u32 use_short_tags) &h->transtable->RepQAddr[i].lower); } -writel (CFGTBL_Trans_Performant | use_short_tags | - CFGTBL_Trans_enable_directed_msix, - &(h->cfgtable->HostWrite.TransportRequest)); +writel (transMethod, &(h->cfgtable->HostWrite.TransportRequest)); +/* +* enable outbound interrupt coalescing in accelerator mode; +*/ +if (trans_support & CFGTBL_Trans_io_accel1) { + access = SA5_ioaccel_mode1_access; +writel (10 , &h->cfgtable->HostWrite.CoalIntDelay); +writel (4 , &h->cfgtable->HostWrite.CoalIntCount); + }writel (CFGTBL_ChangeReq, h->vaddr +SA5_DOORBELL );hpsa_wait_for_mode_change_ack (h); register_value =readl (&(h->cfgtable->TransportActive));
@@ -5165,13 +5307,88 @@ static void hpsa_enter_performant_mode(struct ctlr_info *h, u32 use_short_tags)return ; }/* Change the access methods to the performant access methods */ - h->access = SA5_performant_access; - h->transMethod = CFGTBL_Trans_Performant; + h->access = access; + h->transMethod = transMethod; + +if (!(trans_support & CFGTBL_Trans_io_accel1)) +return ; + +/* Set up I/O accelerator mode */ +for (i =0 ; i < h->nreply_queues; i++) { +writel (i, h->vaddr +IOACCEL_MODE1_REPLY_QUEUE_INDEX ); + h->reply_queue[i].current_entry = +readl (h->vaddr +IOACCEL_MODE1_PRODUCER_INDEX ); + } + bft[7 ] =IOACCEL1_MAXSGENTRIES +8 ; +calc_bucket_map (bft,ARRAY_SIZE (bft),IOACCEL1_MAXSGENTRIES ,8 , + h->ioaccel1_blockFetchTable); + +/* initialize all reply queue entries to unused */ +memset (h->reply_pool, (u8 )IOACCEL_MODE1_REPLY_UNUSED , + h->reply_pool_size); + +/* set all the constant fields in the accelerator command +* frames once at init time to save CPU cycles later. +*/ +for (i =0 ; i < h->nr_cmds; i++) { +struct io_accel1_cmd *cp = &h->ioaccel_cmd_pool[i]; + + cp->function =IOACCEL1_FUNCTION_SCSIIO ; + cp->err_info = (u32) (h->errinfo_pool_dhandle + + (i *sizeof (struct ErrorInfo ))); + cp->err_info_len =sizeof (struct ErrorInfo ); + cp->sgl_offset =IOACCEL1_SGLOFFSET ; + cp->host_context_flags =IOACCEL1_HCFLAGS_CISS_FORMAT ; + cp->timeout_sec =0 ; + cp->ReplyQueue =0 ; + cp->Tag.lower = (i <<DIRECT_LOOKUP_SHIFT ) |DIRECT_LOOKUP_BIT ; + cp->Tag.upper =0 ; + cp->host_addr.lower = (u32) (h->ioaccel_cmd_pool_dhandle + + (i *sizeof (struct io_accel1_cmd ))); + cp->host_addr.upper =0 ; + } +} + +static int hpsa_alloc_ioaccel_cmd_and_bft (struct ctlr_info *h) +{ +/* Command structures must be aligned on a 128-byte boundary +* because the 7 lower bits of the address are used by the +* hardware. +*/ +#define IOACCEL1_COMMANDLIST_ALIGNMENT 128 +BUILD_BUG_ON (sizeof (struct io_accel1_cmd ) % +IOACCEL1_COMMANDLIST_ALIGNMENT ); + h->ioaccel_cmd_pool = +pci_alloc_consistent (h->pdev, + h->nr_cmds *sizeof (*h->ioaccel_cmd_pool), + &(h->ioaccel_cmd_pool_dhandle)); + + h->ioaccel1_blockFetchTable = +kmalloc (((IOACCEL1_MAXSGENTRIES +1 ) * +sizeof (u32)),GFP_KERNEL ); + +if ((h->ioaccel_cmd_pool ==NULL ) || + (h->ioaccel1_blockFetchTable ==NULL )) + goto clean_up; + +memset (h->ioaccel_cmd_pool,0 , + h->nr_cmds *sizeof (*h->ioaccel_cmd_pool)); +return 0 ; + +clean_up: +if (h->ioaccel_cmd_pool) +pci_free_consistent (h->pdev, + h->nr_cmds *sizeof (*h->ioaccel_cmd_pool), + h->ioaccel_cmd_pool, h->ioaccel_cmd_pool_dhandle); +kfree (h->ioaccel1_blockFetchTable); +return 1 ; }static void hpsa_put_ctlr_into_performant_mode (struct ctlr_info *h) {u32 trans_support; +unsigned long transMethod = CFGTBL_Trans_Performant | + CFGTBL_Trans_use_short_tags;int i;if (hpsa_simple_mode)
@@ -5181,6 +5398,15 @@ static void hpsa_put_ctlr_into_performant_mode(struct ctlr_info *h)if (!(trans_support &PERFORMANT_MODE ))return ; +/* Check for I/O accelerator mode support */ +if (trans_support & CFGTBL_Trans_io_accel1) { + transMethod |= CFGTBL_Trans_io_accel1 | + CFGTBL_Trans_enable_directed_msix; +if (hpsa_alloc_ioaccel_cmd_and_bft (h)) + goto clean_up; + } + +/* TODO, check that this next line h->nreply_queues is correct */ h->nreply_queues = h->msix_vector ?MAX_REPLY_QUEUES :1 ;hpsa_get_max_perf_mode_cmds (h);/* Performant mode ring buffer and supporting data structures */
@@ -5203,9 +5429,7 @@ static void hpsa_put_ctlr_into_performant_mode(struct ctlr_info *h) || (h->blockFetchTable == NULL)) goto clean_up; -hpsa_enter_performant_mode (h, - trans_support & CFGTBL_Trans_use_short_tags); - +hpsa_enter_performant_mode (h, trans_support);return ; clean_up:
@@ -5229,5 +5453,39 @@ static void __exit hpsa_cleanup(void)pci_unregister_driver (&hpsa_pci_driver); } +static void __attribute__((unused))verify_offsets (void ) +{ +#define VERIFY_OFFSET (member, offset) \ + BUILD_BUG_ON(offsetof(struct io_accel1_cmd, member) != offset) + +VERIFY_OFFSET (dev_handle,0x00 ); +VERIFY_OFFSET (reserved1,0x02 ); +VERIFY_OFFSET (function,0x03 ); +VERIFY_OFFSET (reserved2,0x04 ); +VERIFY_OFFSET (err_info,0x0C ); +VERIFY_OFFSET (reserved3,0x10 ); +VERIFY_OFFSET (err_info_len,0x12 ); +VERIFY_OFFSET (reserved4,0x13 ); +VERIFY_OFFSET (sgl_offset,0x14 ); +VERIFY_OFFSET (reserved5,0x15 ); +VERIFY_OFFSET (transfer_len,0x1C ); +VERIFY_OFFSET (reserved6,0x20 ); +VERIFY_OFFSET (io_flags,0x24 ); +VERIFY_OFFSET (reserved7,0x26 ); +VERIFY_OFFSET (LUN ,0x34 ); +VERIFY_OFFSET (control,0x3C ); +VERIFY_OFFSET (CDB ,0x40 ); +VERIFY_OFFSET (reserved8,0x50 ); +VERIFY_OFFSET (host_context_flags,0x60 ); +VERIFY_OFFSET (timeout_sec,0x62 ); +VERIFY_OFFSET (ReplyQueue,0x64 ); +VERIFY_OFFSET (reserved9,0x65 ); +VERIFY_OFFSET (Tag,0x68 ); +VERIFY_OFFSET (host_addr,0x70 ); +VERIFY_OFFSET (CISS_LUN ,0x78 ); +VERIFY_OFFSET (SG ,0x78 +8 ); +#undef VERIFY_OFFSET +} +module_init (hpsa_init);module_exit (hpsa_cleanup);
drivers/scsi/hpsa.h +51 -0
81 lines not on this page · raw message
drivers/scsi/hpsa_cmd.h +60 -0
84 lines not on this page · raw message
PATCH 4/35 hpsa: only allow REQ_TYPE_FS to use fast path
In reply to Stephen M. CameronFrom: Stephen M. Cameron <[email protected]>
When commands sent down the "fast path" fail, they must be re-tried down the normal RAID path. We do this by kicking i/o's back to the scsi mid layer with a DID_SOFT_ERROR status, which causes them to be retried. This won't work for SG_IO's and other non REQ_TYPE_FS i/o's which could get kicked all the way back to the application, which may have no idea that the command needs resubmitting and likely no way to resubmit it in such a way the that driver can recognize it as a resubmit and send it down the normal RAID path. So we just always send non REQ_TYPE_FS i/o's down the normal RAID path, never down the "fast path".
--- drivers/scsi/hpsa.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/scsi/hpsa.c +2 -1
@@ -2330,7 +2330,8 @@ static int hpsa_scsi_queue_command_lck(struct scsi_cmnd *cmd,if ((likely (h->transMethod & CFGTBL_Trans_io_accel1)) && (dev->ioaccel_handle) && ((cmd->cmnd[0 ] ==READ_10 ) || (cmd->cmnd[0 ] ==WRITE_10 )) && - (scsi_sg_count (cmd) <=IOACCEL1_MAXSGENTRIES )) + (scsi_sg_count (cmd) <=IOACCEL1_MAXSGENTRIES ) && +likely (cmd->request->cmd_type ==REQ_TYPE_FS ))return hpsa_scsi_ioaccel_queue_command (h, c); c->Header.ReplyQueue =0 ;/* unused in simple mode */
PATCH 5/35 hpsa: fix task management for mode-1 ioaccell path
In reply to Stephen M. CameronFrom: Scott Teel <[email protected]>
For "mode 1" io accelerated commands, the command tag is in a different location than for commands that go down the normal RAID path, so the abort handler needs to take this into account.
--- drivers/scsi/hpsa.c | 27 +++++++++++++++++++++------ 1 files changed, 21 insertions(+), 6 deletions(-)
drivers/scsi/hpsa.c +21 -6
@@ -2602,12 +2602,27 @@ static void swizzle_abort_tag(u8 *tag) tag[7 ] = original_tag[4 ]; } +static void hpsa_get_tag (struct ctlr_info *h, +struct CommandList *c,u32 *taglower,u32 *tagupper) +{ +if (c->cmd_type ==CMD_IOACCEL1 ) { +struct io_accel1_cmd *cm1 = (struct io_accel1_cmd *) + &h->ioaccel_cmd_pool[c->cmdindex]; + *tagupper = cm1->Tag.upper; + *taglower = cm1->Tag.lower; + }else { + *tagupper = c->Header.Tag.upper; + *taglower = c->Header.Tag.lower; + } +} +static int hpsa_send_abort (struct ctlr_info *h,unsigned char *scsi3addr,struct CommandList *abort,int swizzle) {int rc =IO_OK ;struct CommandList *c;struct ErrorInfo *ei; +u32 tagupper, taglower; c =cmd_special_alloc (h);if (c ==NULL ) {/* trouble... */
@@ -2621,8 +2636,9 @@ static int hpsa_send_abort(struct ctlr_info *h, unsigned char *scsi3addr,if (swizzle)swizzle_abort_tag (&c->Request.CDB[4 ]);hpsa_scsi_do_simple_cmd_core (h, c); +hpsa_get_tag (h, abort, &taglower, &tagupper);dev_dbg (&h->pdev->dev,"%s: Tag:0x%08x:%08x: do_simple_cmd_core completed.\n" , - __func__, abort->Header.Tag.upper, abort->Header.Tag.lower); + __func__, tagupper, taglower);/* no unmap needed here because no data xfer. */ ei = c->err_info;
@@ -2634,8 +2650,7 @@ static int hpsa_send_abort(struct ctlr_info *h, unsigned char *scsi3addr,break ;default :dev_dbg (&h->pdev->dev,"%s: Tag:0x%08x:%08x: interpreting error.\n" , - __func__, abort->Header.Tag.upper, - abort->Header.Tag.lower); + __func__, tagupper, taglower);hpsa_scsi_interpret_error (c); rc =-1 ;break ;
@@ -2747,6 +2762,7 @@ static int hpsa_eh_abort_handler(struct scsi_cmnd *sc)struct scsi_cmnd *as;/* ptr to scsi cmd inside aborted command. */ char msg[256 ];/* For debug messaging. */ int ml =0 ; +u32 tagupper, taglower;/* Find the controller of the command to be aborted */ h =sdev_to_hba (sc->device);
@@ -2779,9 +2795,8 @@ static int hpsa_eh_abort_handler(struct scsi_cmnd *sc) msg);return FAILED ; } - - ml +=sprintf (msg+ml,"Tag:0x%08x:%08x " , - abort->Header.Tag.upper, abort->Header.Tag.lower); +hpsa_get_tag (h, abort, &taglower, &tagupper); + ml +=sprintf (msg+ml,"Tag:0x%08x:%08x " , tagupper, taglower); as = (struct scsi_cmnd *) abort->scsi_cmd;if (as !=NULL ) ml += sprintf(msg+ml, "Command:0x%x SN:0x%lx ",
PATCH 6/35 hpsa: add ioaccell mode 1 RAID offload support.
In reply to Stephen M. CameronFrom: Stephen M. Cameron <[email protected]>
This enables sending i/o's destined for RAID logical drives which can be serviced by a single physical disk down a different, faster i/o path directly to physical drives for certain logical volumes on SSDs bypassing the Smart Array RAID stack for a performance improvement.
--- drivers/scsi/hpsa.c | 565 ++++++++++++++++++++++++++++++++++++++++++++--- drivers/scsi/hpsa.h | 26 ++ drivers/scsi/hpsa_cmd.h | 65 +++++ 3 files changed, 607 insertions(+), 49 deletions(-)
drivers/scsi/hpsa.c +524 -41
@@ -49,6 +49,7 @@#include <linux/atomic.h> #include <linux/kthread.h> #include <linux/jiffies.h> +#include <asm/div64.h> #include "hpsa_cmd.h" #include "hpsa.h"
@@ -216,6 +217,7 @@ static int hpsa_lookup_board_id(struct pci_dev *pdev, u32 *board_id);static int hpsa_wait_for_board_state (struct pci_dev *pdev,void __iomem *vaddr,int wait_for_ready);static inline void finish_cmd (struct CommandList *c); +static void hpsa_wait_for_mode_change_ack (struct ctlr_info *h);#define BOARD_NOT_READY 0#define BOARD_READY 1
@@ -1195,6 +1197,7 @@ static void complete_scsi_command(struct CommandList *cp)struct scsi_cmnd *cmd;struct ctlr_info *h;struct ErrorInfo *ei; +struct hpsa_scsi_dev_t *dev;unsigned char sense_key;unsigned char asc;/* additional sense code */
@@ -1204,6 +1207,7 @@ static void complete_scsi_command(struct CommandList *cp) ei = cp->err_info; cmd = (struct scsi_cmnd *) cp->scsi_cmd; h = cp->h; + dev = cmd->device->hostdata;scsi_dma_unmap (cmd);/* undo the DMA mappings */ if ((cp->cmd_type == CMD_SCSI) &&
@@ -1242,6 +1246,19 @@ static void complete_scsi_command(struct CommandList *cp) cp->Header.Tag.upper = c->Tag.upper;memcpy (cp->Header.LUN.LunAddrBytes, c->CISS_LUN,8 );memcpy (cp->Request.CDB, c->CDB, cp->Request.CDBLen); + +/* Any RAID offload error results in retry which will use +* the normal I/O path so the controller can handle whatever's +* wrong. +*/ +if (is_logical_dev_addr_mode (dev->scsi3addr)) { +if (ei->CommandStatus ==CMD_IOACCEL_DISABLED ) + dev->offload_enabled =0 ; + cmd->result =DID_SOFT_ERROR <<16 ; +cmd_free (h, cp); + cmd->scsi_done (cmd); +return ; + } }/* an error has occurred */
@@ -1406,6 +1423,14 @@ static void complete_scsi_command(struct CommandList *cp) cmd->result =DID_ERROR <<16 ;dev_warn (&h->pdev->dev,"Command unabortable\n" );break ; +case CMD_IOACCEL_DISABLED : +/* This only handles the direct pass-through case since RAID +* offload is handled above. Just attempt a retry. +*/ + cmd->result =DID_SOFT_ERROR <<16 ; +dev_warn (&h->pdev->dev, +"cp %p had HP SSD Smart Path error\n" , cp); +break ;default : cmd->result =DID_ERROR <<16 ; dev_warn(&h->pdev->dev, "cp %p returned unknown status %x\n",
@@ -1650,6 +1675,147 @@ static void hpsa_get_raid_level(struct ctlr_info *h,return ; } +#define HPSA_MAP_DEBUG +#ifdef HPSA_MAP_DEBUG +static void hpsa_debug_map_buff (struct ctlr_info *h,int rc, +struct raid_map_data *map_buff) +{ +struct raid_map_disk_data *dd = &map_buff->data[0 ]; +int map, row, col; +u16 map_cnt, row_cnt, disks_per_row; + +if (rc !=0 ) +return ; + +dev_info (&h->pdev->dev,"structure_size = %u\n" , +le32_to_cpu (map_buff->structure_size)); +dev_info (&h->pdev->dev,"volume_blk_size = %u\n" , +le32_to_cpu (map_buff->volume_blk_size)); +dev_info (&h->pdev->dev,"volume_blk_cnt = 0x%llx\n" , +le64_to_cpu (map_buff->volume_blk_cnt)); +dev_info (&h->pdev->dev,"physicalBlockShift = %u\n" , + map_buff->phys_blk_shift); +dev_info (&h->pdev->dev,"parity_rotation_shift = %u\n" , + map_buff->parity_rotation_shift); +dev_info (&h->pdev->dev,"strip_size = %u\n" , +le16_to_cpu (map_buff->strip_size)); +dev_info (&h->pdev->dev,"disk_starting_blk = 0x%llx\n" , +le64_to_cpu (map_buff->disk_starting_blk)); +dev_info (&h->pdev->dev,"disk_blk_cnt = 0x%llx\n" , +le64_to_cpu (map_buff->disk_blk_cnt)); +dev_info (&h->pdev->dev,"data_disks_per_row = %u\n" , +le16_to_cpu (map_buff->data_disks_per_row)); +dev_info (&h->pdev->dev,"metadata_disks_per_row = %u\n" , +le16_to_cpu (map_buff->metadata_disks_per_row)); +dev_info (&h->pdev->dev,"row_cnt = %u\n" , +le16_to_cpu (map_buff->row_cnt)); +dev_info (&h->pdev->dev,"layout_map_count = %u\n" , +le16_to_cpu (map_buff->layout_map_count)); + + map_cnt =le16_to_cpu (map_buff->layout_map_count); +for (map =0 ; map < map_cnt; map++) { +dev_info (&h->pdev->dev,"Map%u:\n" , map); + row_cnt =le16_to_cpu (map_buff->row_cnt); +for (row =0 ; row < row_cnt; row++) { +dev_info (&h->pdev->dev," Row%u:\n" , row); + disks_per_row = +le16_to_cpu (map_buff->data_disks_per_row); +for (col =0 ; col < disks_per_row; col++, dd++) +dev_info (&h->pdev->dev, +" D%02u: h=0x%04x xor=%u,%u\n" , + col, dd->ioaccel_handle, + dd->xor_mult[0 ], dd->xor_mult[1 ]); + disks_per_row = +le16_to_cpu (map_buff->metadata_disks_per_row); +for (col =0 ; col < disks_per_row; col++, dd++) +dev_info (&h->pdev->dev, +" M%02u: h=0x%04x xor=%u,%u\n" , + col, dd->ioaccel_handle, + dd->xor_mult[0 ], dd->xor_mult[1 ]); + } + } +} +#else +static void hpsa_debug_map_buff (__attribute__((unused))struct ctlr_info *h, + __attribute__((unused))int rc, + __attribute__((unused))struct raid_map_data *map_buff) +{ +} +#endif + +static int hpsa_get_raid_map (struct ctlr_info *h, +unsigned char *scsi3addr,struct hpsa_scsi_dev_t *this_device) +{ +int rc =0 ; +struct CommandList *c; +struct ErrorInfo *ei; + + c =cmd_special_alloc (h); +if (c ==NULL ) { +dev_warn (&h->pdev->dev,"cmd_special_alloc returned NULL!\n" ); +return -ENOMEM ; + } +if (fill_cmd (c,HPSA_GET_RAID_MAP , h, &this_device->raid_map, +sizeof (this_device->raid_map),0 , + scsi3addr,TYPE_CMD )) { +dev_warn (&h->pdev->dev,"Out of memory in hpsa_get_raid_map()\n" ); +cmd_special_free (h, c); +return -ENOMEM ; + } +hpsa_scsi_do_simple_cmd_with_retry (h, c,PCI_DMA_FROMDEVICE ); + ei = c->err_info; +if (ei->CommandStatus !=0 && ei->CommandStatus !=CMD_DATA_UNDERRUN ) { +hpsa_scsi_interpret_error (c); +cmd_special_free (h, c); +return -1 ; + } +cmd_special_free (h, c); + +/* @todo in the future, dynamically allocate RAID map memory */ +if (le32_to_cpu (this_device->raid_map.structure_size) > +sizeof (this_device->raid_map)) { +dev_warn (&h->pdev->dev,"RAID map size is too large!\n" ); + rc =-1 ; + } +hpsa_debug_map_buff (h, rc, &this_device->raid_map); +return rc; +} + +static void hpsa_get_ioaccel_status (struct ctlr_info *h, +unsigned char *scsi3addr,struct hpsa_scsi_dev_t *this_device) +{ +int rc; +unsigned char *buf; +u8 ioaccel_status; + + this_device->offload_config =0 ; + this_device->offload_enabled =0 ; + + buf =kzalloc (64 ,GFP_KERNEL ); +if (!buf) +return ; + rc =hpsa_scsi_do_inquiry (h, scsi3addr, +HPSA_VPD_LV_IOACCEL_STATUS , buf,64 ); +if (rc !=0 ) + goto out; + +#define IOACCEL_STATUS_BYTE 4 +#define OFFLOAD_CONFIGURED_BIT 0x01 +#define OFFLOAD_ENABLED_BIT 0x02 + ioaccel_status = buf[IOACCEL_STATUS_BYTE ]; + this_device->offload_config = + !!(ioaccel_status &OFFLOAD_CONFIGURED_BIT ); +if (this_device->offload_config) { + this_device->offload_enabled = + !!(ioaccel_status &OFFLOAD_ENABLED_BIT ); +if (hpsa_get_raid_map (h, scsi3addr, this_device)) + this_device->offload_enabled =0 ; + } +out: +kfree (buf); +return ; +} +/* Get the device id from inquiry page 0x83 */ static int hpsa_get_device_id (struct ctlr_info *h,unsigned char *scsi3addr,unsigned char *device_id,int buflen)
@@ -1698,6 +1864,14 @@ static int hpsa_scsi_do_report_luns(struct ctlr_info *h, int logical, ei->CommandStatus != CMD_DATA_UNDERRUN) { hpsa_scsi_interpret_error(c); rc = -1; + } else { +if (buf->extended_response_flag != extended_response) { +dev_err (&h->pdev->dev, +"report luns requested format %u, got %u\n" , + extended_response, + buf->extended_response_flag); + rc =-1 ; + } } out:cmd_special_free (h, c);
@@ -1763,10 +1937,15 @@ static int hpsa_update_device_info(struct ctlr_info *h, sizeof(this_device->device_id));if (this_device->devtype ==TYPE_DISK && -is_logical_dev_addr_mode (scsi3addr)) +is_logical_dev_addr_mode (scsi3addr)) {hpsa_get_raid_level (h, scsi3addr, &this_device->raid_level); -else +if (h->fw_support &MISC_FW_RAID_OFFLOAD_BASIC ) +hpsa_get_ioaccel_status (h, scsi3addr, this_device); + }else { this_device->raid_level =RAID_UNKNOWN ; + this_device->offload_config =0 ; + this_device->offload_enabled =0 ; + }if (is_OBDR_device) {/* See if this is a One-Button-Disaster-Recovery device
@@ -1903,15 +2082,25 @@ static int add_ext_target_dev(struct ctlr_info *h,*/ static int hpsa_gather_lun_info (struct ctlr_info *h,int reportlunsize, -struct ReportLUNdata *physdev,u32 *nphysicals, +struct ReportLUNdata *physdev,u32 *nphysicals,int *physical_mode,struct ReportLUNdata *logdev,u32 *nlogicals) { +int physical_entry_size =8 ; + + *physical_mode =0 ; + +/* For I/O accelerator mode we need to read physical device handles */ +if (h->transMethod & CFGTBL_Trans_io_accel1) { + *physical_mode =HPSA_REPORT_PHYS_EXTENDED ; + physical_entry_size =24 ; + }if (hpsa_scsi_do_report_phys_luns (h, physdev, reportlunsize, -HPSA_REPORT_PHYS_EXTENDED )) { + *physical_mode)) {dev_err (&h->pdev->dev,"report physical LUNs failed.\n" );return -1 ; } - *nphysicals =be32_to_cpu (*((__be32 *)physdev->LUNListLength)) /24 ; + *nphysicals =be32_to_cpu (*((__be32 *)physdev->LUNListLength)) / + physical_entry_size;if (*nphysicals >HPSA_MAX_PHYS_LUN ) { dev_warn(&h->pdev->dev, "maximum physical LUNs (%d) exceeded." " %d LUNs ignored.\n", HPSA_MAX_PHYS_LUN,
@@ -1983,10 +2172,11 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)struct ReportLUNdata *logdev_list =NULL ;u32 nphysicals =0 ;u32 nlogicals =0 ; +int physical_mode =0 ;u32 ndev_allocated =0 ;struct hpsa_scsi_dev_t **currentsd, *this_device, *tmpdevice;int ncurrent =0 ; -int reportlunsize =sizeof (*physdev_list) +HPSA_MAX_PHYS_LUN *8 ; +int reportlunsize =sizeof (*physdev_list) +HPSA_MAX_PHYS_LUN *24 ;int i, n_ext_target_devs, ndevs_to_allocate;int raid_ctlr_position;DECLARE_BITMAP (lunzerobits,MAX_EXT_TARGETS );
@@ -2004,7 +2194,7 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno)if (hpsa_gather_lun_info (h, reportlunsize, (struct ReportLUNdata *) physdev_list, &nphysicals, - logdev_list, &nlogicals)) + &physical_mode, logdev_list, &nlogicals)) goto out;/* We might see up to the maximum number of logical and physical disks
@@ -2085,12 +2275,16 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h, int hostno) ncurrent++;break ;case TYPE_DISK : -if (i < nphysicals) +if (i >= nphysicals) { + ncurrent++;break ; -memcpy (&this_device->ioaccel_handle, - &lunaddrbytes[20 ], -sizeof (this_device->ioaccel_handle)); - ncurrent++; + } +if (physical_mode ==HPSA_REPORT_PHYS_EXTENDED ) { +memcpy (&this_device->ioaccel_handle, + &lunaddrbytes[20 ], +sizeof (this_device->ioaccel_handle)); + ncurrent++; + }break ;case TYPE_TAPE :case TYPE_MEDIUM_CHANGER :
@@ -2184,15 +2378,62 @@ sglist_finished:return 0 ; } +#define IO_ACCEL_INELIGIBLE (1) +static int fixup_ioaccel_cdb (u8 *cdb,int *cdb_len) +{ +int is_write =0 ; +u32 block; +u32 block_cnt; + +/* Perform some CDB fixups if needed using 10 byte reads/writes only */ +switch (cdb[0 ]) { +case WRITE_6 : +case WRITE_12 : + is_write =1 ; +case READ_6 : +case READ_12 : +if (*cdb_len ==6 ) { + block = (((u32 ) cdb[2 ]) <<8 ) | cdb[3 ]; + block_cnt = cdb[4 ]; + }else { +BUG_ON (*cdb_len !=12 ); + block = (((u32 ) cdb[2 ]) <<24 ) | + (((u32 ) cdb[3 ]) <<16 ) | + (((u32 ) cdb[4 ]) <<8 ) | + cdb[5 ]; + block_cnt = + (((u32 ) cdb[6 ]) <<24 ) | + (((u32 ) cdb[7 ]) <<16 ) | + (((u32 ) cdb[8 ]) <<8 ) | + cdb[9 ]; + } +if (block_cnt >0xffff ) +return IO_ACCEL_INELIGIBLE ; + + cdb[0 ] = is_write ?WRITE_10 :READ_10 ; + cdb[1 ] =0 ; + cdb[2 ] = (u8) (block >>24 ); + cdb[3 ] = (u8) (block >>16 ); + cdb[4 ] = (u8) (block >>8 ); + cdb[5 ] = (u8) (block); + cdb[6 ] =0 ; + cdb[7 ] = (u8) (block_cnt >>8 ); + cdb[8 ] = (u8) (block_cnt); + cdb[9 ] =0 ; + *cdb_len =10 ; +break ; + } +return 0 ; +} +/* * Queue a command to the I/O accelerator path. -* This method does not currently support S/G chaining. */ static int hpsa_scsi_ioaccel_queue_command (struct ctlr_info *h, -struct CommandList *c) +struct CommandList *c,u32 ioaccel_handle,u8 *cdb,int cdb_len, +u8 *scsi3addr) {struct scsi_cmnd *cmd = c->scsi_cmd; -struct hpsa_scsi_dev_t *dev = cmd->device->hostdata;struct io_accel1_cmd *cp = &h->ioaccel_cmd_pool[c->cmdindex];unsigned int len;unsigned int total_len =0 ;
@@ -2202,8 +2443,15 @@ static int hpsa_scsi_ioaccel_queue_command(struct ctlr_info *h,struct SGDescriptor *curr_sg;u32 control =IOACCEL1_CONTROL_SIMPLEQUEUE ; +/* TODO: implement chaining support */ +if (scsi_sg_count (cmd) > h->ioaccel_maxsg) +return IO_ACCEL_INELIGIBLE ; +BUG_ON (cmd->cmd_len >IOACCEL1_IOFLAGS_CDBLEN_MAX ); +if (fixup_ioaccel_cdb (cdb, &cdb_len)) +return IO_ACCEL_INELIGIBLE ; + c->cmd_type =CMD_IOACCEL1 ;/* Adjust the DMA address to point to the accelerated command buffer */
@@ -2254,13 +2502,13 @@ static int hpsa_scsi_ioaccel_queue_command(struct ctlr_info *h, }/* Fill out the command structure to submit */ - cp->dev_handle = dev->ioaccel_handle; + cp->dev_handle = ioaccel_handle &0xFFFF ; cp->transfer_len = total_len; cp->io_flags =IOACCEL1_IOFLAGS_IO_REQ | - (cmd->cmd_len &IOACCEL1_IOFLAGS_CDBLEN_MASK ); + (cdb_len &IOACCEL1_IOFLAGS_CDBLEN_MASK ); cp->control = control; -memcpy (cp->CDB, cmd->cmnd, cmd->cmd_len); -memcpy (cp->CISS_LUN, dev->scsi3addr,8 ); +memcpy (cp->CDB, cdb, cdb_len); +memcpy (cp->CISS_LUN, scsi3addr,8 );/* Tell the controller to post the reply to the queue for this * processor. This seems to give the best I/O throughput.
@@ -2274,15 +2522,214 @@ static int hpsa_scsi_ioaccel_queue_command(struct ctlr_info *h,*/ c->busaddr |=1 | (h->ioaccel1_blockFetchTable[use_sg] <<1 ) |IOACCEL1_BUSADDR_CMDTYPE ; - -/* execute command (bypassing cmd queue if possible) */ -if (unlikely (h->access.fifo_full (h))) -enqueue_cmd_and_start_io (h, c); -else - h->access.submit_command (h, c); +enqueue_cmd_and_start_io (h, c);return 0 ; } +/* +* Queue a command directly to a device behind the controller using the +* I/O accelerator path. +*/ +static int hpsa_scsi_ioaccel_direct_map (struct ctlr_info *h, +struct CommandList *c) +{ +struct scsi_cmnd *cmd = c->scsi_cmd; +struct hpsa_scsi_dev_t *dev = cmd->device->hostdata; + +return hpsa_scsi_ioaccel_queue_command (h, c, dev->ioaccel_handle, + cmd->cmnd, cmd->cmd_len, dev->scsi3addr); +} + +/* +* Attempt to perform offload RAID mapping for a logical volume I/O. +*/ +static int hpsa_scsi_ioaccel_raid_map (struct ctlr_info *h, +struct CommandList *c) +{ +struct scsi_cmnd *cmd = c->scsi_cmd; +struct hpsa_scsi_dev_t *dev = cmd->device->hostdata; +struct raid_map_data *map = &dev->raid_map; +struct raid_map_disk_data *dd = &map->data[0 ]; +int is_write =0 ; +u32 map_index; +u64 first_block, last_block; +u32 block_cnt; +u32 blocks_per_row; +u64 first_row, last_row; +u32 first_row_offset, last_row_offset; +u32 first_column, last_column; +u32 map_row; +u32 disk_handle; +u64 disk_block; +u32 disk_block_cnt; +u8 cdb[16 ]; +u8 cdb_len; +#if BITS_PER_LONG ==32 +u64 tmpdiv; +#endif + +BUG_ON (!(dev->offload_config && dev->offload_enabled)); + +/* check for valid opcode, get LBA and block count */ +switch (cmd->cmnd[0 ]) { +case WRITE_6 : + is_write =1 ; +case READ_6 : + first_block = + (((u64 ) cmd->cmnd[2 ]) <<8 ) | + cmd->cmnd[3 ]; + block_cnt = cmd->cmnd[4 ]; +break ; +case WRITE_10 : + is_write =1 ; +case READ_10 : + first_block = + (((u64 ) cmd->cmnd[2 ]) <<24 ) | + (((u64 ) cmd->cmnd[3 ]) <<16 ) | + (((u64 ) cmd->cmnd[4 ]) <<8 ) | + cmd->cmnd[5 ]; + block_cnt = + (((u32 ) cmd->cmnd[7 ]) <<8 ) | + cmd->cmnd[8 ]; +break ; +case WRITE_12 : + is_write =1 ; +case READ_12 : + first_block = + (((u64 ) cmd->cmnd[2 ]) <<24 ) | + (((u64 ) cmd->cmnd[3 ]) <<16 ) | + (((u64 ) cmd->cmnd[4 ]) <<8 ) | + cmd->cmnd[5 ]; + block_cnt = + (((u32 ) cmd->cmnd[6 ]) <<24 ) | + (((u32 ) cmd->cmnd[7 ]) <<16 ) | + (((u32 ) cmd->cmnd[8 ]) <<8 ) | + cmd->cmnd[9 ]; +break ; +case WRITE_16 : + is_write =1 ; +case READ_16 : + first_block = + (((u64 ) cmd->cmnd[2 ]) <<56 ) | + (((u64 ) cmd->cmnd[3 ]) <<48 ) | + (((u64 ) cmd->cmnd[4 ]) <<40 ) | + (((u64 ) cmd->cmnd[5 ]) <<32 ) | + (((u64 ) cmd->cmnd[6 ]) <<24 ) | + (((u64 ) cmd->cmnd[7 ]) <<16 ) | + (((u64 ) cmd->cmnd[8 ]) <<8 ) | + cmd->cmnd[9 ]; + block_cnt = + (((u32 ) cmd->cmnd[10 ]) <<24 ) | + (((u32 ) cmd->cmnd[11 ]) <<16 ) | + (((u32 ) cmd->cmnd[12 ]) <<8 ) | + cmd->cmnd[13 ]; +break ; +default : +return IO_ACCEL_INELIGIBLE ;/* process via normal I/O path */ + } +BUG_ON (block_cnt ==0 ); + last_block = first_block + block_cnt -1 ; + +/* check for write to non-RAID-0 */ +if (is_write && dev->raid_level !=0 ) +return IO_ACCEL_INELIGIBLE ; + +/* check for invalid block or wraparound */ +if (last_block >= map->volume_blk_cnt || last_block < first_block) +return IO_ACCEL_INELIGIBLE ; + +/* calculate stripe information for the request */ + blocks_per_row = map->data_disks_per_row * map->strip_size; +#if BITS_PER_LONG ==32 + tmpdiv = first_block; + (void )do_div (tmpdiv, blocks_per_row); + first_row = tmpdiv; + tmpdiv = last_block; + (void )do_div (tmpdiv, blocks_per_row); + last_row = tmpdiv; + first_row_offset = (u32) (first_block - (first_row * blocks_per_row)); + last_row_offset = (u32) (last_block - (last_row * blocks_per_row)); + tmpdiv = first_row_offset; + (void )do_div (tmpdiv, map->strip_size); + first_column = tmpdiv; + tmpdiv = last_row_offset; + (void )do_div (tmpdiv, map->strip_size); + last_column = tmpdiv; +#else + first_row = first_block / blocks_per_row; + last_row = last_block / blocks_per_row; + first_row_offset = (u32) (first_block - (first_row * blocks_per_row)); + last_row_offset = (u32) (last_block - (last_row * blocks_per_row)); + first_column = first_row_offset / map->strip_size; + last_column = last_row_offset / map->strip_size; +#endif + +/* if this isn't a single row/column then give to the controller */ +if ((first_row != last_row) || (first_column != last_column)) +return IO_ACCEL_INELIGIBLE ; + +/* proceeding with driver mapping */ + map_row = ((u32)(first_row >> map->parity_rotation_shift)) % + map->row_cnt; + map_index = (map_row * (map->data_disks_per_row + + map->metadata_disks_per_row)) + first_column; +if (dev->raid_level ==2 ) { +/* simple round-robin balancing of RAID 1+0 reads across +* primary and mirror members. this is appropriate for SSD +* but not optimal for HDD. +*/ +if (dev->offload_to_mirror) + map_index += map->data_disks_per_row; + dev->offload_to_mirror = !dev->offload_to_mirror; + } + disk_handle = dd[map_index].ioaccel_handle; + disk_block = map->disk_starting_blk + (first_row * map->strip_size) + + (first_row_offset - (first_column * map->strip_size)); + disk_block_cnt = block_cnt; + +/* handle differing logical/physical block sizes */ +if (map->phys_blk_shift) { + disk_block <<= map->phys_blk_shift; + disk_block_cnt <<= map->phys_blk_shift; + } +BUG_ON (disk_block_cnt >0xffff ); + +/* build the new CDB for the physical disk I/O */ +if (disk_block >0xffffffff ) { + cdb[0 ] = is_write ?WRITE_16 :READ_16 ; + cdb[1 ] =0 ; + cdb[2 ] = (u8) (disk_block >>56 ); + cdb[3 ] = (u8) (disk_block >>48 ); + cdb[4 ] = (u8) (disk_block >>40 ); + cdb[5 ] = (u8) (disk_block >>32 ); + cdb[6 ] = (u8) (disk_block >>24 ); + cdb[7 ] = (u8) (disk_block >>16 ); + cdb[8 ] = (u8) (disk_block >>8 ); + cdb[9 ] = (u8) (disk_block); + cdb[10 ] = (u8) (disk_block_cnt >>24 ); + cdb[11 ] = (u8) (disk_block_cnt >>16 ); + cdb[12 ] = (u8) (disk_block_cnt >>8 ); + cdb[13 ] = (u8) (disk_block_cnt); + cdb[14 ] =0 ; + cdb[15 ] =0 ; + cdb_len =16 ; + }else { + cdb[0 ] = is_write ?WRITE_10 :READ_10 ; + cdb[1 ] =0 ; + cdb[2 ] = (u8) (disk_block >>24 ); + cdb[3 ] = (u8) (disk_block >>16 ); + cdb[4 ] = (u8) (disk_block >>8 ); + cdb[5 ] = (u8) (disk_block); + cdb[6 ] =0 ; + cdb[7 ] = (u8) (disk_block_cnt >>8 ); + cdb[8 ] = (u8) (disk_block_cnt); + cdb[9 ] =0 ; + cdb_len =10 ; + } +return hpsa_scsi_ioaccel_queue_command (h, c, disk_handle, cdb, cdb_len, + dev->scsi3addr); +} +static int hpsa_scsi_queue_command_lck (struct scsi_cmnd *cmd,void (*done)(struct scsi_cmnd *)) {
@@ -2291,6 +2738,7 @@ static int hpsa_scsi_queue_command_lck(struct scsi_cmnd *cmd,unsigned char scsi3addr[8 ];struct CommandList *c;unsigned long flags; +int rc =0 ;/* Get the ptr to our adapter structure out of cmd->host. */ h =sdev_to_hba (cmd->device);
@@ -2326,13 +2774,29 @@ static int hpsa_scsi_queue_command_lck(struct scsi_cmnd *cmd, c->cmd_type =CMD_SCSI ; c->scsi_cmd = cmd; -/* Call alternate submit routine for I/O accelerated commands */ -if ((likely (h->transMethod & CFGTBL_Trans_io_accel1)) && - (dev->ioaccel_handle) && - ((cmd->cmnd[0 ] ==READ_10 ) || (cmd->cmnd[0 ] ==WRITE_10 )) && - (scsi_sg_count (cmd) <=IOACCEL1_MAXSGENTRIES ) && -likely (cmd->request->cmd_type ==REQ_TYPE_FS )) -return hpsa_scsi_ioaccel_queue_command (h, c); +/* Call alternate submit routine for I/O accelerated commands. +* Retries always go down the normal I/O path. +*/ +if (likely (cmd->retries ==0 && + cmd->request->cmd_type ==REQ_TYPE_FS )) { +if (dev->offload_enabled) { + rc =hpsa_scsi_ioaccel_raid_map (h, c); +if (rc ==0 ) +return 0 ;/* Sent on ioaccel path */ +if (rc <0 ) {/* scsi_dma_map failed. */ +cmd_free (h, c); +return SCSI_MLQUEUE_HOST_BUSY ; + } + }else if (dev->ioaccel_handle) { + rc =hpsa_scsi_ioaccel_direct_map (h, c); +if (rc ==0 ) +return 0 ;/* Sent on direct map path */ +if (rc <0 ) {/* scsi_dma_map failed. */ +cmd_free (h, c); +return SCSI_MLQUEUE_HOST_BUSY ; + } + } + } c->Header.ReplyQueue =0 ;/* unused in simple mode */ memcpy (&c->Header.LUN.LunAddrBytes[0 ], &scsi3addr[0 ],8 );
@@ -3515,6 +3979,18 @@ static int fill_cmd(struct CommandList *c, u8 cmd, struct ctlr_info *h, c->Request.Type.Direction =XFER_NONE ; c->Request.Timeout =0 ;break ; +case HPSA_GET_RAID_MAP : + c->Request.CDBLen =12 ; + c->Request.Type.Attribute =ATTR_SIMPLE ; + c->Request.Type.Direction =XFER_READ ; + c->Request.Timeout =0 ; + c->Request.CDB[0 ] =HPSA_CISS_READ ; + c->Request.CDB[1 ] = cmd; + c->Request.CDB[6 ] = (size >>24 ) &0xFF ;/* MSB */ + c->Request.CDB[7 ] = (size >>16 ) &0xFF ; + c->Request.CDB[8 ] = (size >>8 ) &0xFF ; + c->Request.CDB[9 ] = size &0xFF ; +break ;default :dev_warn (&h->pdev->dev,"unknown command 0x%c\n" , cmd);BUG ();
@@ -4482,6 +4958,7 @@ static void hpsa_find_board_params(struct ctlr_info *h)hpsa_get_max_perf_mode_cmds (h); h->nr_cmds = h->max_commands -4 ;/* Allow room for some ioctls */ h->maxsgentries =readl (&(h->cfgtable->MaxScatterGatherElements)); + h->fw_support =readl (&(h->cfgtable->misc_fw_support));/* * Limit in-command s/g elements to 32 save dma'able memory. * Howvever spec says if 0, use 31
@@ -4566,18 +5043,19 @@ static int hpsa_enter_simple_mode(struct ctlr_info *h)return -ENOTSUPP ; h->max_commands =readl (&(h->cfgtable->CmdsOutMax)); +/* Update the field, and then ring the doorbell */ writel (CFGTBL_Trans_Simple, &(h->cfgtable->HostWrite.TransportRequest));writel (CFGTBL_ChangeReq, h->vaddr +SA5_DOORBELL );hpsa_wait_for_mode_change_ack (h);print_cfg_table (&h->pdev->dev, h->cfgtable); -if (!(readl (&(h->cfgtable->TransportActive)) & CFGTBL_Trans_Simple)) { -dev_warn (&h->pdev->dev, -"unable to get board into simple mode\n" ); -return -ENODEV ; - } +if (!(readl (&(h->cfgtable->TransportActive)) & CFGTBL_Trans_Simple)) + goto error; h->transMethod = CFGTBL_Trans_Simple;return 0 ; +error: +dev_warn (&h->pdev->dev,"unable to get board into simple mode\n" ); +return -ENODEV ; }static int hpsa_pci_init (struct ctlr_info *h)
@@ -4958,7 +5436,7 @@ reinit_after_soft_reset:* the 5 lower bits of the address are used by the hardware. and by * the driver. See comments in hpsa.h for more info. */ -#define COMMANDLIST_ALIGNMENT 32 +#define COMMANDLIST_ALIGNMENT 128BUILD_BUG_ON (sizeof (struct CommandList ) %COMMANDLIST_ALIGNMENT ); h =kzalloc (sizeof (*h),GFP_KERNEL );if (!h)
@@ -5335,8 +5813,8 @@ static void hpsa_enter_performant_mode(struct ctlr_info *h, u32 trans_support) h->reply_queue[i].current_entry =readl (h->vaddr +IOACCEL_MODE1_PRODUCER_INDEX ); } - bft[7 ] =IOACCEL1_MAXSGENTRIES +8 ; -calc_bucket_map (bft,ARRAY_SIZE (bft),IOACCEL1_MAXSGENTRIES ,8 , + bft[7 ] = h->ioaccel_maxsg +8 ; +calc_bucket_map (bft,ARRAY_SIZE (bft), h->ioaccel_maxsg,8 , h->ioaccel1_blockFetchTable);/* initialize all reply queue entries to unused */
@@ -5367,6 +5845,11 @@ static void hpsa_enter_performant_mode(struct ctlr_info *h, u32 trans_support)static int hpsa_alloc_ioaccel_cmd_and_bft (struct ctlr_info *h) { + h->ioaccel_maxsg = +readl (&(h->cfgtable->io_accel_max_embedded_sg_count)); +if (h->ioaccel_maxsg >IOACCEL1_MAXSGENTRIES ) + h->ioaccel_maxsg =IOACCEL1_MAXSGENTRIES ; +/* Command structures must be aligned on a 128-byte boundary * because the 7 lower bits of the address are used by the * hardware.
@@ -5380,7 +5863,7 @@ static int hpsa_alloc_ioaccel_cmd_and_bft(struct ctlr_info *h) &(h->ioaccel_cmd_pool_dhandle)); h->ioaccel1_blockFetchTable = -kmalloc (((IOACCEL1_MAXSGENTRIES +1 ) * +kmalloc (((h->ioaccel_maxsg +1 ) *sizeof (u32)),GFP_KERNEL ); if ((h->ioaccel_cmd_pool == NULL) ||
drivers/scsi/hpsa.h +21 -5
@@ -47,6 +47,13 @@ struct hpsa_scsi_dev_t {unsigned char model[16 ];/* bytes 16-31 of inquiry data */ unsigned char raid_level;/* from inquiry page 0xC1 */ u32 ioaccel_handle; +int offload_config;/* I/O accel RAID offload configured */ +int offload_enabled;/* I/O accel RAID offload enabled */ +int offload_to_mirror;/* Send next I/O accelerator RAID +* offload request to mirror drive +*/ +struct raid_map_data raid_map;/* I/O accelerator RAID map */ + };struct reply_pool {
@@ -133,6 +140,10 @@ struct ctlr_info {u32 *blockFetchTable;u32 *ioaccel1_blockFetchTable;unsigned char *hba_inquiry_data; +u32 driver_support; +u32 fw_support; +int ioaccel_support; +int ioaccel_maxsg;u64 last_intr_timestamp;u32 last_heartbeat;u64 last_heartbeat_timestamp;
@@ -406,8 +417,7 @@ static bool SA5_ioaccel_mode1_intr_pending(struct ctlr_info *h)#define IOACCEL_MODE1_CONSUMER_INDEX 0x1BC#define IOACCEL_MODE1_REPLY_UNUSED 0xFFFFFFFFFFFFFFFFULL -static unsigned long SA5_ioaccel_mode1_completed (struct ctlr_info *h, -u8 q) +static unsigned long SA5_ioaccel_mode1_completed (struct ctlr_info *h,u8 q) {u64 register_value;struct reply_pool *rq = &h->reply_queue[q];
@@ -420,12 +430,18 @@ static unsigned long SA5_ioaccel_mode1_completed(struct ctlr_info *h, rq->head[rq->current_entry] =IOACCEL_MODE1_REPLY_UNUSED ;if (++rq->current_entry == rq->size) rq->current_entry =0 ; +/* +* @todo +* +* Don't really need to write the new index after each command, +* but with current driver design this is easiest. +*/ +wmb (); +writel ((q <<24 ) | rq->current_entry, h->vaddr + +IOACCEL_MODE1_CONSUMER_INDEX );spin_lock_irqsave (&h->lock, flags); h->commands_outstanding--;spin_unlock_irqrestore (&h->lock, flags); - }else { -writel ((q <<24 ) | rq->current_entry, - h->vaddr +IOACCEL_MODE1_CONSUMER_INDEX ); }return (unsigned long ) register_value; }
drivers/scsi/hpsa_cmd.h +62 -3
110 lines not on this page · raw message
PATCH 7/35 hpsa: update raid offload status on device rescan
In reply to Stephen M. CameronFrom: Stephen M. Cameron <[email protected]>
When rescanning for logical drives, store information about whather raid offload is enabled for each logical drive, and update the driver's internal record of this.
--- drivers/scsi/hpsa.c | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-)
drivers/scsi/hpsa.c +9 -0
@@ -787,6 +787,11 @@ static void hpsa_scsi_update_entry(struct ctlr_info *h, int hostno,/* Raid level changed. */ h->dev[entry]->raid_level = new_entry->raid_level; + +/* Raid offload parameters changed. */ + h->dev[entry]->offload_config = new_entry->offload_config; + h->dev[entry]->offload_enabled = new_entry->offload_enabled; +dev_info (&h->pdev->dev,"%s device c%db%dt%dl%d updated.\n" ,scsi_device_type (new_entry->devtype), hostno, new_entry->bus, new_entry->target, new_entry->lun);
@@ -907,6 +912,10 @@ static inline int device_updated(struct hpsa_scsi_dev_t *dev1,*/ if (dev1->raid_level != dev2->raid_level)return 1 ; +if (dev1->offload_config != dev2->offload_config) +return 1 ; +if (dev1->offload_enabled != dev2->offload_enabled) +return 1 ;return 0 ; }
PATCH 8/35 hpsa: poll controller to detect device change event
In reply to Stephen M. CameronFrom: Stephen M. Cameron <[email protected]>
For shared SAS configurations, hosts need to poll Smart Arrays periodically in order to be able to detect configuration changes such as logical drives being added or removed from remote hosts. A register on the controller indicates when such events have occurred, and the driver polls the register via a workqueue and kicks off a rescan of devices if such an event is detected. Additionally, changes to logical drive raid offload eligibility are autodetected in this way.
--- drivers/scsi/hpsa.c | 108 +++++++++++++++++++++++++++++++++++++++++++++++ drivers/scsi/hpsa.h | 1 drivers/scsi/hpsa_cmd.h | 3 + 3 files changed, 112 insertions(+), 0 deletions(-)
drivers/scsi/hpsa.c +108 -0
@@ -220,6 +220,8 @@ static inline void finish_cmd(struct CommandList *c);static void hpsa_wait_for_mode_change_ack (struct ctlr_info *h);#define BOARD_NOT_READY 0#define BOARD_READY 1 +static void hpsa_drain_commands (struct ctlr_info *h); +static void hpsa_flush_cache (struct ctlr_info *h);static inline struct ctlr_info *sdev_to_hba (struct scsi_device *sdev) {
@@ -5022,6 +5024,23 @@ static inline void hpsa_p600_dma_prefetch_quirk(struct ctlr_info *h)writel (dma_prefetch, h->vaddr +I2O_DMA1_CFG ); } +static void hpsa_wait_for_clear_event_notify_ack (struct ctlr_info *h) +{ +int i; +u32 doorbell_value; +unsigned long flags; +/* wait until the clear_event_notify bit 6 is cleared by controller. */ +for (i =0 ; i <MAX_CONFIG_WAIT ; i++) { +spin_lock_irqsave (&h->lock, flags); + doorbell_value =readl (h->vaddr +SA5_DOORBELL ); +spin_unlock_irqrestore (&h->lock, flags); +if (!(doorbell_value &DOORBELL_CLEAR_EVENTS )) +break ; +/* delay and try again */ +msleep (20 ); + } +} +static void hpsa_wait_for_mode_change_ack (struct ctlr_info *h) {int i;
@@ -5398,6 +5417,79 @@ static void detect_controller_lockup(struct ctlr_info *h) h->last_heartbeat_timestamp = now; } +static int hpsa_kickoff_rescan (struct ctlr_info *h) +{ +int i; +char *event_type; + +/* Ask the controller to clear the events we're handling. */ +if (h->transMethod & (CFGTBL_Trans_io_accel1) && + (h->events &HPSA_EVENT_NOTIFY_ACCEL_IO_PATH_STATE_CHANGE || + h->events &HPSA_EVENT_NOTIFY_ACCEL_IO_PATH_CONFIG_CHANGE )) { + +if (h->events &HPSA_EVENT_NOTIFY_ACCEL_IO_PATH_STATE_CHANGE ) + event_type ="state change" ; +if (h->events &HPSA_EVENT_NOTIFY_ACCEL_IO_PATH_CONFIG_CHANGE ) + event_type ="configuration change" ; +/* Stop sending new RAID offload reqs via the IO accelerator */ +scsi_block_requests (h->scsi_host); +for (i =0 ; i < h->ndevices; i++) + h->dev[i]->offload_enabled =0 ; +hpsa_drain_commands (h); +/* Set 'accelerator path config change' bit */ +dev_warn (&h->pdev->dev, +"Acknowledging event: 0x%08x (HP SSD Smart Path %s)\n" , + h->events, event_type); +writel (h->events, &(h->cfgtable->clear_event_notify)); +/* Set the "clear event notify field update" bit 6 */ +writel (DOORBELL_CLEAR_EVENTS , h->vaddr +SA5_DOORBELL ); +/* Wait until ctlr clears 'clear event notify field', bit 6 */ +hpsa_wait_for_clear_event_notify_ack (h); +scsi_unblock_requests (h->scsi_host); + }else { +/* Acknowledge controller notification events. */ +writel (h->events, &(h->cfgtable->clear_event_notify)); +writel (DOORBELL_CLEAR_EVENTS , h->vaddr +SA5_DOORBELL ); +hpsa_wait_for_clear_event_notify_ack (h); +#if 0 +writel (CFGTBL_ChangeReq, h->vaddr +SA5_DOORBELL ); +hpsa_wait_for_mode_change_ack (h); +#endif + } + +/* Something in the device list may have changed to trigger +* the event, so do a rescan. +*/ +hpsa_scan_start (h->scsi_host); +/* release reference taken on scsi host in check_controller_events */ +scsi_host_put (h->scsi_host); +return 0 ; +} + +/* Check a register on the controller to see if there are configuration +* changes (added/changed/removed logical drives, etc.) which mean that +* we should rescan the controller for devices. If so, add the controller +* to the list of controllers needing to be rescanned, and gets a +* reference to the associated scsi_host. +*/ +static void hpsa_ctlr_needs_rescan (struct ctlr_info *h) +{ +if (!(h->fw_support &MISC_FW_EVENT_NOTIFY )) +return ; + + h->events =readl (&(h->cfgtable->event_notify)); +if (!h->events) +return ; + +/* +* Take a reference on scsi host for the duration of the scan +* Release in hpsa_kickoff_rescan(). No lock needed for scan_list +* as only a single thread accesses this list. +*/ +scsi_host_get (h->scsi_host); +hpsa_kickoff_rescan (h); +} +static void hpsa_monitor_ctlr_worker (struct work_struct *work) {unsigned long flags;
@@ -5406,6 +5498,7 @@ static void hpsa_monitor_ctlr_worker(struct work_struct *work)detect_controller_lockup (h);if (h->lockup_detected)return ; +hpsa_ctlr_needs_rescan (h);spin_lock_irqsave (&h->lock, flags);if (h->remove_in_progress) {spin_unlock_irqrestore (&h->lock, flags);
@@ -5947,6 +6040,21 @@ clean_up:kfree (h->blockFetchTable); } +static void hpsa_drain_commands (struct ctlr_info *h) +{ +int cmds_out; +unsigned long flags; + +do {/* wait for all outstanding commands to drain out */ +spin_lock_irqsave (&h->lock, flags); + cmds_out = h->commands_outstanding; +spin_unlock_irqrestore (&h->lock, flags); +if (cmds_out <=0 ) +break ; +msleep (100 ); + }while (1 ); +} +/* * This is it. Register the PCI driver information for the cards we control * the OS will call our registered routines when it finds one of our cards.
drivers/scsi/hpsa.h +1 -0
@@ -176,6 +176,7 @@ struct ctlr_info {#define HPSATMF_LOG_QRY_TASK (1 << 23)#define HPSATMF_LOG_QRY_TSET (1 << 24)#define HPSATMF_LOG_QRY_ASYNC (1 << 25) +u32 events; };#define HPSA_ABORT_MSG 0#define HPSA_DEVICE_RESET_MSG 1
drivers/scsi/hpsa_cmd.h +3 -0
@@ -128,6 +128,7 @@#define CFGTBL_AccCmds 0x00000001l#define DOORBELL_CTLR_RESET 0x00000004l#define DOORBELL_CTLR_RESET2 0x00000020l +#define DOORBELL_CLEAR_EVENTS 0x00000040l#define CFGTBL_Trans_Simple 0x00000002l#define CFGTBL_Trans_Performant 0x00000004l
@@ -495,6 +496,8 @@ struct CfgTable {u32 io_accel_max_embedded_sg_count;u32 io_accel_request_size_offset;u32 event_notify; +#define HPSA_EVENT_NOTIFY_ACCEL_IO_PATH_STATE_CHANGE (1 << 30) +#define HPSA_EVENT_NOTIFY_ACCEL_IO_PATH_CONFIG_CHANGE (1 << 31)u32 clear_event_notify; };
PATCH 9/35 hpsa: do not rescan controllers known to be locked up
In reply to Stephen M. CameronFrom: Stephen M. Cameron <[email protected]>
* Do not check event bits on locked up controllers to see if they need to be rescanned.
* Do not initiate any device rescans on controllers which are known to be locked up.
--- drivers/scsi/hpsa.c | 30 ++++++++++++++++++++++++++++++ 1 files changed, 30 insertions(+), 0 deletions(-)
drivers/scsi/hpsa.c +30 -0
@@ -2868,11 +2868,38 @@ static int hpsa_scsi_queue_command_lck(struct scsi_cmnd *cmd,static DEF_SCSI_QCMD (hpsa_scsi_queue_command) +static int do_not_scan_if_controller_locked_up(struct ctlr_info *h) +{ +unsigned long flags; + +/* +* Don't let rescans be initiated on a controller known +* to be locked up. If the controller locks up *during* +* a rescan, that thread is probably hosed, but at least +* we can prevent new rescan threads from piling up on a +* locked up controller. +*/ +spin_lock_irqsave (&h->lock, flags); +if (unlikely (h->lockup_detected)) { +spin_unlock_irqrestore (&h->lock, flags); +spin_lock_irqsave (&h->scan_lock, flags); + h->scan_finished =1 ; +wake_up_all (&h->scan_wait_queue); +spin_unlock_irqrestore (&h->scan_lock, flags); +return 1 ; + } +spin_unlock_irqrestore (&h->lock, flags); +return 0 ; +} +static void hpsa_scan_start (struct Scsi_Host *sh) {struct ctlr_info *h =shost_to_hba (sh);unsigned long flags; +if (do_not_scan_if_controller_locked_up (h)) +return ; +/* wait until any scan already in progress is finished. */ while (1 ) {spin_lock_irqsave (&h->scan_lock, flags);
@@ -2889,6 +2916,9 @@ static void hpsa_scan_start(struct Scsi_Host *sh) h->scan_finished =0 ;/* mark scan as in progress */ spin_unlock_irqrestore (&h->scan_lock, flags); +if (do_not_scan_if_controller_locked_up (h)) +return ; +hpsa_update_scsi_devices (h, h->scsi_host->host_no);spin_lock_irqsave (&h->scan_lock, flags);
PATCH 10/35 hpsa: add hp_ssd_smart_path_enabled sysfs attribute
In reply to Stephen M. CameronFrom: Scott Teel <[email protected]>
--- drivers/scsi/hpsa.c | 25 +++++++++++++++++++++++++ 1 files changed, 25 insertions(+), 0 deletions(-)
drivers/scsi/hpsa.c +25 -0
@@ -508,10 +508,34 @@ static ssize_t unique_id_show(struct device *dev, sn[12], sn[13], sn[14], sn[15]); } +static ssize_t host_show_hp_ssd_smart_path_enabled (struct device *dev, +struct device_attribute *attr,char *buf) +{ +struct ctlr_info *h; +struct scsi_device *sdev; +struct hpsa_scsi_dev_t *hdev; +unsigned long flags; +int offload_enabled; + + sdev =to_scsi_device (dev); + h =sdev_to_hba (sdev); +spin_lock_irqsave (&h->lock, flags); + hdev = sdev->hostdata; +if (!hdev) { +spin_unlock_irqrestore (&h->lock, flags); +return -ENODEV ; + } + offload_enabled = hdev->offload_enabled; +spin_unlock_irqrestore (&h->lock, flags); +return snprintf (buf,20 ,"%d\n" , offload_enabled); +} + static DEVICE_ATTR(raid_level, S_IRUGO, raid_level_show, NULL); static DEVICE_ATTR(lunid, S_IRUGO, lunid_show, NULL); static DEVICE_ATTR(unique_id, S_IRUGO, unique_id_show, NULL); static DEVICE_ATTR(rescan, S_IWUSR, NULL, host_store_rescan); +static DEVICE_ATTR(hp_ssd_smart_path_enabled, S_IRUGO, + host_show_hp_ssd_smart_path_enabled, NULL); static DEVICE_ATTR(firmware_revision, S_IRUGO, host_show_firmware_revision, NULL); static DEVICE_ATTR(commands_outstanding, S_IRUGO,
@@ -525,6 +549,7 @@ static struct device_attribute *hpsa_sdev_attrs[] = { &dev_attr_raid_level, &dev_attr_lunid, &dev_attr_unique_id, + &dev_attr_hp_ssd_smart_path_enabled, NULL, };
James Bottomley
maintainerRe: [PATCH 10/35] hpsa: add hp_ssd_smart_path_enabled sysfs attribute
Quoted 4 lines · Stephen M. Cameron
From: Scott Teel <[email protected]>
Signed-off-by Scott Teel <[email protected]>
Just a note: when you send a patch to me, that should be signed-off-by. It's because you're part of the transmission path under the DCO (which the signoffs track). When you want me to apply a patch someone else sends in, you either resend it to me with your signoff or just ack it (acked by means you approve it but didn't resend it to me).
I've altered all the acks from you in this series to signoffs.
James
PATCH 11/35 hpsa: complain if physical or logical aborts are not supported
In reply to Stephen M. CameronFrom: Scott Teel <[email protected]>
--- drivers/scsi/hpsa.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
drivers/scsi/hpsa.c +4 -0
@@ -5041,6 +5041,10 @@ static void hpsa_find_board_params(struct ctlr_info *h)/* Find out what task management functions are supported and cache */ h->TMFSupportFlags =readl (&(h->cfgtable->TMFSupportFlags)); +if (!(HPSATMF_PHYS_TASK_ABORT & h->TMFSupportFlags)) +dev_warn (&h->pdev->dev,"Physical aborts not supported\n" ); +if (!(HPSATMF_LOG_TASK_ABORT & h->TMFSupportFlags)) +dev_warn (&h->pdev->dev,"Logical aborts not supported\n" ); }static inline bool hpsa_CISS_signature_present (struct ctlr_info *h)
PATCH 12/35 hpsa: add ioaccel mode 2 structure definitions
In reply to Stephen M. CameronFrom: Mike Miller <[email protected]>
--- drivers/scsi/hpsa.c | 22 ++++++++++ drivers/scsi/hpsa.h | 8 ++++ drivers/scsi/hpsa_cmd.h | 99 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 129 insertions(+), 0 deletions(-)
drivers/scsi/hpsa.c +22 -0
@@ -6131,6 +6131,28 @@ static void __exit hpsa_cleanup(void)static void __attribute__((unused))verify_offsets (void ) {#define VERIFY_OFFSET (member, offset) \ + BUILD_BUG_ON(offsetof(struct io_accel2_cmd, member) != offset) + +VERIFY_OFFSET (IU_type,0 ); +VERIFY_OFFSET (direction,1 ); +VERIFY_OFFSET (reply_queue,2 ); +/* VERIFY_OFFSET(reserved1, 3); */ +VERIFY_OFFSET (scsi_nexus,4 ); +VERIFY_OFFSET (Tag,8 ); +VERIFY_OFFSET (cdb,16 ); +VERIFY_OFFSET (cciss_lun,32 ); +VERIFY_OFFSET (data_len,40 ); +VERIFY_OFFSET (cmd_priority_task_attr,44 ); +VERIFY_OFFSET (sg_count,45 ); +/* VERIFY_OFFSET(reserved3 */ +VERIFY_OFFSET (err_ptr,48 ); +VERIFY_OFFSET (err_len,56 ); +/* VERIFY_OFFSET(reserved4 */ +VERIFY_OFFSET (sg,64 ); + +#undef VERIFY_OFFSET + +#define VERIFY_OFFSET (member, offset) \ BUILD_BUG_ON(offsetof(struct io_accel1_cmd, member) != offset)VERIFY_OFFSET (dev_handle,0x00 );
drivers/scsi/hpsa.h +8 -0
@@ -258,6 +258,14 @@ struct ctlr_info {#define HPSA_INTR_ON 1#define HPSA_INTR_OFF 0 + +/* +* Inbound Post Queue offsets for IO Accelerator Mode 2 +*/ +#define IOACCEL2_INBOUND_POSTQ_32 0x48 +#define IOACCEL2_INBOUND_POSTQ_64_LOW 0xd0 +#define IOACCEL2_INBOUND_POSTQ_64_HI 0xd4 +/* Send the command to the hardware */
drivers/scsi/hpsa_cmd.h +99 -0
117 lines not on this page · raw message
PATCH 13/35 hpsa: Acknowledge controller events in ioaccell mode 2 as well as mode 1
In reply to Stephen M. CameronFrom: Stephen M. Cameron <[email protected]>
--- drivers/scsi/hpsa.c | 3 ++- drivers/scsi/hpsa_cmd.h | 1 + 2 files changed, 3 insertions(+), 1 deletions(-)
drivers/scsi/hpsa.c +2 -1
@@ -5482,7 +5482,8 @@ static int hpsa_kickoff_rescan(struct ctlr_info *h)char *event_type;/* Ask the controller to clear the events we're handling. */ -if (h->transMethod & (CFGTBL_Trans_io_accel1) && +if ((h->transMethod & (CFGTBL_Trans_io_accel1 + | CFGTBL_Trans_io_accel2)) && (h->events &HPSA_EVENT_NOTIFY_ACCEL_IO_PATH_STATE_CHANGE || h->events &HPSA_EVENT_NOTIFY_ACCEL_IO_PATH_CONFIG_CHANGE )) {
drivers/scsi/hpsa_cmd.h +1 -0
@@ -133,6 +133,7 @@#define CFGTBL_Trans_Simple 0x00000002l#define CFGTBL_Trans_Performant 0x00000004l#define CFGTBL_Trans_io_accel1 0x00000080l +#define CFGTBL_Trans_io_accel2 0x00000100l#define CFGTBL_Trans_use_short_tags 0x20000000l#define CFGTBL_Trans_enable_directed_msix (1 << 30)
PATCH 14/35 hpsa: do ioaccel mode 2 resource allocations
In reply to Stephen M. CameronFrom: Stephen M. Cameron <[email protected]>
--- drivers/scsi/hpsa.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ drivers/scsi/hpsa.h | 3 +++ 2 files changed, 53 insertions(+), 0 deletions(-)
drivers/scsi/hpsa.c +50 -0
@@ -5288,6 +5288,10 @@ static void hpsa_free_cmd_pool(struct ctlr_info *h)pci_free_consistent (h->pdev, h->nr_cmds *sizeof (struct CommandList ), h->cmd_pool, h->cmd_pool_dhandle); +if (h->ioaccel2_cmd_pool) +pci_free_consistent (h->pdev, + h->nr_cmds *sizeof (*h->ioaccel2_cmd_pool), + h->ioaccel2_cmd_pool, h->ioaccel2_cmd_pool_dhandle);if (h->errinfo_pool) pci_free_consistent(h->pdev, h->nr_cmds * sizeof(struct ErrorInfo),
@@ -5826,6 +5830,7 @@ static void hpsa_remove_one(struct pci_dev *pdev)kfree (h->cmd_pool_bits);kfree (h->blockFetchTable);kfree (h->ioaccel1_blockFetchTable); +kfree (h->ioaccel2_blockFetchTable);kfree (h->hba_inquiry_data);pci_disable_device (pdev);pci_release_regions (pdev);
@@ -6045,6 +6050,44 @@ clean_up:return 1 ; } +static int ioaccel2_alloc_cmds_and_bft (struct ctlr_info *h) +{ +/* Allocate ioaccel2 mode command blocks and block fetch table */ + + h->ioaccel_maxsg = +readl (&(h->cfgtable->io_accel_max_embedded_sg_count)); +if (h->ioaccel_maxsg >IOACCEL2_MAXSGENTRIES ) + h->ioaccel_maxsg =IOACCEL2_MAXSGENTRIES ; + +#define IOACCEL2_COMMANDLIST_ALIGNMENT 128 +BUILD_BUG_ON (sizeof (struct io_accel2_cmd ) % +IOACCEL2_COMMANDLIST_ALIGNMENT ); + h->ioaccel2_cmd_pool = +pci_alloc_consistent (h->pdev, + h->nr_cmds *sizeof (*h->ioaccel2_cmd_pool), + &(h->ioaccel2_cmd_pool_dhandle)); + + h->ioaccel2_blockFetchTable = +kmalloc (((h->ioaccel_maxsg +1 ) * +sizeof (u32)),GFP_KERNEL ); + +if ((h->ioaccel2_cmd_pool ==NULL ) || + (h->ioaccel2_blockFetchTable ==NULL )) + goto clean_up; + +memset (h->ioaccel2_cmd_pool,0 , + h->nr_cmds *sizeof (*h->ioaccel2_cmd_pool)); +return 0 ; + +clean_up: +if (h->ioaccel2_cmd_pool) +pci_free_consistent (h->pdev, + h->nr_cmds *sizeof (*h->ioaccel2_cmd_pool), + h->ioaccel2_cmd_pool, h->ioaccel2_cmd_pool_dhandle); +kfree (h->ioaccel2_blockFetchTable); +return 1 ; +} +static void hpsa_put_ctlr_into_performant_mode (struct ctlr_info *h) {u32 trans_support;
@@ -6065,6 +6108,13 @@ static void hpsa_put_ctlr_into_performant_mode(struct ctlr_info *h) CFGTBL_Trans_enable_directed_msix;if (hpsa_alloc_ioaccel_cmd_and_bft (h)) goto clean_up; + }else { +if (trans_support & CFGTBL_Trans_io_accel2) { + transMethod |= CFGTBL_Trans_io_accel2 | + CFGTBL_Trans_enable_directed_msix; +if (ioaccel2_alloc_cmds_and_bft (h)) + goto clean_up; + } }/* TODO, check that this next line h->nreply_queues is correct */
drivers/scsi/hpsa.h +3 -0
@@ -105,6 +105,8 @@ struct ctlr_info {dma_addr_t cmd_pool_dhandle;struct io_accel1_cmd *ioaccel_cmd_pool;dma_addr_t ioaccel_cmd_pool_dhandle; +struct io_accel2_cmd *ioaccel2_cmd_pool; +dma_addr_t ioaccel2_cmd_pool_dhandle;struct ErrorInfo *errinfo_pool;dma_addr_t errinfo_pool_dhandle;unsigned long *cmd_pool_bits;
@@ -139,6 +141,7 @@ struct ctlr_info {dma_addr_t reply_pool_dhandle;u32 *blockFetchTable;u32 *ioaccel1_blockFetchTable; +u32 *ioaccel2_blockFetchTable;unsigned char *hba_inquiry_data;u32 driver_support;u32 fw_support;
PATCH 15/35 hpsa: get physical device handles for io accel mode 2 as well as mode 1
In reply to Stephen M. CameronFrom: Mike MIller <[email protected]>
--- drivers/scsi/hpsa.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
drivers/scsi/hpsa.c +2 -1
@@ -2126,7 +2126,8 @@ static int hpsa_gather_lun_info(struct ctlr_info *h, *physical_mode =0 ;/* For I/O accelerator mode we need to read physical device handles */ -if (h->transMethod & CFGTBL_Trans_io_accel1) { +if (h->transMethod & CFGTBL_Trans_io_accel1 || + h->transMethod & CFGTBL_Trans_io_accel2) { *physical_mode =HPSA_REPORT_PHYS_EXTENDED ; physical_entry_size =24 ; }
PATCH 16/35 hpsa: initialize controller to perform io accelerator mode 2
In reply to Stephen M. CameronFrom: Stephen M. Cameron <[email protected]>
--- drivers/scsi/hpsa.c | 111 ++++++++++++++++++++++++++++++++--------------- drivers/scsi/hpsa.h | 1 drivers/scsi/hpsa_cmd.h | 2 - 3 files changed, 78 insertions(+), 36 deletions(-)
drivers/scsi/hpsa.c +76 -35
@@ -5134,6 +5134,7 @@ static int hpsa_enter_simple_mode(struct ctlr_info *h)/* Update the field, and then ring the doorbell */ writel (CFGTBL_Trans_Simple, &(h->cfgtable->HostWrite.TransportRequest)); +writel (0 , &h->cfgtable->HostWrite.command_pool_addr_hi);writel (CFGTBL_ChangeReq, h->vaddr +SA5_DOORBELL );hpsa_wait_for_mode_change_ack (h);print_cfg_table (&h->pdev->dev, h->cfgtable);
@@ -5899,9 +5900,9 @@ static void hpsa_enter_performant_mode(struct ctlr_info *h, u32 trans_support)unsigned long register_value;unsigned long transMethod = CFGTBL_Trans_Performant | (trans_support & CFGTBL_Trans_use_short_tags) | - CFGTBL_Trans_enable_directed_msix | - (trans_support & CFGTBL_Trans_io_accel1); - + CFGTBL_Trans_enable_directed_msix | + (trans_support & (CFGTBL_Trans_io_accel1 | + CFGTBL_Trans_io_accel2));struct access_method access = SA5_performant_access;/* This is a bit complicated. There are 8 registers on
@@ -5922,6 +5923,16 @@ static void hpsa_enter_performant_mode(struct ctlr_info *h, u32 trans_support)* sizes for small commands, and fewer sizes for larger commands. */ int bft[8 ] = {5 ,6 ,8 ,10 ,12 ,20 ,28 ,SG_ENTRIES_IN_CMD +4 }; +#define MIN_IOACCEL2_BFT_ENTRY 5 +#define HPSA_IOACCEL2_HEADER_SZ 4 +int bft2[16 ] = {MIN_IOACCEL2_BFT_ENTRY ,6 ,7 ,8 ,9 ,10 ,11 ,12 , +13 ,14 ,15 ,16 ,17 ,18 ,19 , +HPSA_IOACCEL2_HEADER_SZ +IOACCEL2_MAXSGENTRIES }; +BUILD_BUG_ON (ARRAY_SIZE (bft2) !=16 ); +BUILD_BUG_ON (ARRAY_SIZE (bft) !=8 ); +BUILD_BUG_ON (offsetof(struct io_accel2_cmd , sg) > +16 *MIN_IOACCEL2_BFT_ENTRY ); +BUILD_BUG_ON (sizeof (struct ioaccel2_sg_element ) !=16 );BUILD_BUG_ON (28 >SG_ENTRIES_IN_CMD +4 );/* 5 = 1 s/g entry or 4k * 6 = 2 s/g entry or 8k
@@ -5951,6 +5962,7 @@ static void hpsa_enter_performant_mode(struct ctlr_info *h, u32 trans_support) &h->transtable->RepQAddr[i].lower); } +writel (0 , &h->cfgtable->HostWrite.command_pool_addr_hi);writel (transMethod, &(h->cfgtable->HostWrite.TransportRequest));/* * enable outbound interrupt coalescing in accelerator mode;
@@ -5972,43 +5984,72 @@ static void hpsa_enter_performant_mode(struct ctlr_info *h, u32 trans_support) h->access = access; h->transMethod = transMethod; -if (!(trans_support & CFGTBL_Trans_io_accel1)) +if (!((trans_support & CFGTBL_Trans_io_accel1) || + (trans_support & CFGTBL_Trans_io_accel2)))return ; -/* Set up I/O accelerator mode */ -for (i =0 ; i < h->nreply_queues; i++) { -writel (i, h->vaddr +IOACCEL_MODE1_REPLY_QUEUE_INDEX ); - h->reply_queue[i].current_entry = -readl (h->vaddr +IOACCEL_MODE1_PRODUCER_INDEX ); - } - bft[7 ] = h->ioaccel_maxsg +8 ; -calc_bucket_map (bft,ARRAY_SIZE (bft), h->ioaccel_maxsg,8 , - h->ioaccel1_blockFetchTable); +if (trans_support & CFGTBL_Trans_io_accel1) { +/* Set up I/O accelerator mode */ +for (i =0 ; i < h->nreply_queues; i++) { +writel (i, h->vaddr +IOACCEL_MODE1_REPLY_QUEUE_INDEX ); + h->reply_queue[i].current_entry = +readl (h->vaddr +IOACCEL_MODE1_PRODUCER_INDEX ); + } + bft[7 ] = h->ioaccel_maxsg +8 ; +calc_bucket_map (bft,ARRAY_SIZE (bft), h->ioaccel_maxsg,8 , + h->ioaccel1_blockFetchTable); -/* initialize all reply queue entries to unused */ -memset (h->reply_pool, (u8 )IOACCEL_MODE1_REPLY_UNUSED , - h->reply_pool_size); +/* initialize all reply queue entries to unused */ +memset (h->reply_pool, (u8 )IOACCEL_MODE1_REPLY_UNUSED , + h->reply_pool_size); -/* set all the constant fields in the accelerator command -* frames once at init time to save CPU cycles later. -*/ -for (i =0 ; i < h->nr_cmds; i++) { -struct io_accel1_cmd *cp = &h->ioaccel_cmd_pool[i]; - - cp->function =IOACCEL1_FUNCTION_SCSIIO ; - cp->err_info = (u32) (h->errinfo_pool_dhandle + - (i *sizeof (struct ErrorInfo ))); - cp->err_info_len =sizeof (struct ErrorInfo ); - cp->sgl_offset =IOACCEL1_SGLOFFSET ; - cp->host_context_flags =IOACCEL1_HCFLAGS_CISS_FORMAT ; - cp->timeout_sec =0 ; - cp->ReplyQueue =0 ; - cp->Tag.lower = (i <<DIRECT_LOOKUP_SHIFT ) |DIRECT_LOOKUP_BIT ; - cp->Tag.upper =0 ; - cp->host_addr.lower = (u32) (h->ioaccel_cmd_pool_dhandle + - (i *sizeof (struct io_accel1_cmd ))); - cp->host_addr.upper =0 ; +/* set all the constant fields in the accelerator command +* frames once at init time to save CPU cycles later. +*/ +for (i =0 ; i < h->nr_cmds; i++) { +struct io_accel1_cmd *cp = &h->ioaccel_cmd_pool[i]; + + cp->function =IOACCEL1_FUNCTION_SCSIIO ; + cp->err_info = (u32) (h->errinfo_pool_dhandle + + (i *sizeof (struct ErrorInfo ))); + cp->err_info_len =sizeof (struct ErrorInfo ); + cp->sgl_offset =IOACCEL1_SGLOFFSET ; + cp->host_context_flags =IOACCEL1_HCFLAGS_CISS_FORMAT ; + cp->timeout_sec =0 ; + cp->ReplyQueue =0 ; + cp->Tag.lower = (i <<DIRECT_LOOKUP_SHIFT ) | +DIRECT_LOOKUP_BIT ; + cp->Tag.upper =0 ; + cp->host_addr.lower = + (u32) (h->ioaccel_cmd_pool_dhandle + + (i *sizeof (struct io_accel1_cmd ))); + cp->host_addr.upper =0 ; + } + }else if (trans_support & CFGTBL_Trans_io_accel2) { +u64 cfg_offset, cfg_base_addr_index; +u32 bft2_offset, cfg_base_addr; +int rc; + + rc =hpsa_find_cfg_addrs (h->pdev, h->vaddr, &cfg_base_addr, + &cfg_base_addr_index, &cfg_offset); +BUILD_BUG_ON (offsetof(struct io_accel2_cmd , sg) !=64 ); + bft2[15 ] = h->ioaccel_maxsg +HPSA_IOACCEL2_HEADER_SZ ; +calc_bucket_map (bft2,ARRAY_SIZE (bft2), h->ioaccel_maxsg, +4 , h->ioaccel2_blockFetchTable); + bft2_offset =readl (&h->cfgtable->io_accel_request_size_offset); +BUILD_BUG_ON (offsetof(struct CfgTable , + io_accel_request_size_offset) !=0xb8 ); + h->ioaccel2_bft2_regs = +remap_pci_mem (pci_resource_start (h->pdev, + cfg_base_addr_index) + + cfg_offset + bft2_offset, +ARRAY_SIZE (bft2) * +sizeof (*h->ioaccel2_bft2_regs)); +for (i =0 ; i <ARRAY_SIZE (bft2); i++) +writel (bft2[i], &h->ioaccel2_bft2_regs[i]); } +writel (CFGTBL_ChangeReq, h->vaddr +SA5_DOORBELL ); +hpsa_wait_for_mode_change_ack (h); }static int hpsa_alloc_ioaccel_cmd_and_bft (struct ctlr_info *h)
drivers/scsi/hpsa.h +1 -0
@@ -142,6 +142,7 @@ struct ctlr_info {u32 *blockFetchTable;u32 *ioaccel1_blockFetchTable;u32 *ioaccel2_blockFetchTable; +u32 *ioaccel2_bft2_regs;unsigned char *hba_inquiry_data;u32 driver_support;u32 fw_support;
drivers/scsi/hpsa_cmd.h +1 -1
@@ -547,7 +547,7 @@ struct hpsa_tmf_struct {/* Configuration Table Structure */ struct HostWrite {u32 TransportRequest; -u32 Reserved; +u32 command_pool_addr_hi;u32 CoalIntDelay;u32 CoalIntCount; };
PATCH 17/35 hpsa: get ioaccel mode 2 i/o working
In reply to Stephen M. CameronFrom: Scott Teel <[email protected]>
--- drivers/scsi/hpsa.c | 325 ++++++++++++++++++++++++++++++++++++++++++++--- drivers/scsi/hpsa.h | 20 +++ drivers/scsi/hpsa_cmd.h | 1 3 files changed, 327 insertions(+), 19 deletions(-)
drivers/scsi/hpsa.c +306 -19
@@ -222,6 +222,9 @@ static void hpsa_wait_for_mode_change_ack(struct ctlr_info *h);#define BOARD_READY 1static void hpsa_drain_commands (struct ctlr_info *h);static void hpsa_flush_cache (struct ctlr_info *h); +static int hpsa_scsi_ioaccel_queue_command (struct ctlr_info *h, +struct CommandList *c,u32 ioaccel_handle,u8 *cdb,int cdb_len, +u8 *scsi3addr);static inline struct ctlr_info *sdev_to_hba (struct scsi_device *sdev) {
@@ -622,6 +625,32 @@ static inline u32 next_command(struct ctlr_info *h, u8 q)return a; } +/* +* There are some special bits in the bus address of the +* command that we have to set for the controller to know +* how to process the command: +* +* Normal performant mode: +* bit 0: 1 means performant mode, 0 means simple mode. +* bits 1-3 = block fetch table entry +* bits 4-6 = command type (== 0) +* +* ioaccel1 mode: +* bit 0 = "performant mode" bit. +* bits 1-3 = block fetch table entry +* bits 4-6 = command type (== 110) +* (command type is needed because ioaccel1 mode +* commands are submitted through the same register as normal +* mode commands, so this is how the controller knows whether +* the command is normal mode or ioaccel1 mode.) +* +* ioaccel2 mode: +* bit 0 = "performant mode" bit. +* bits 1-4 = block fetch table entry (note extra bit) +* bits 4-6 = not needed, because ioaccel2 mode has +* a separate special register for submitting commands. +*/ +/* set_performant_mode: Modify the tag for cciss performant * set bit 0 for pull model, bits 3-1 for block fetch * register number
@@ -636,6 +665,41 @@ static void set_performant_mode(struct ctlr_info *h, struct CommandList *c) } } +static void set_ioaccel1_performant_mode (struct ctlr_info *h, +struct CommandList *c) +{ +struct io_accel1_cmd *cp = &h->ioaccel_cmd_pool[c->cmdindex]; + +/* Tell the controller to post the reply to the queue for this +* processor. This seems to give the best I/O throughput. +*/ + cp->ReplyQueue =smp_processor_id () % h->nreply_queues; +/* Set the bits in the address sent down to include: +* - performant mode bit (bit 0) +* - pull count (bits 1-3) +* - command type (bits 4-6) +*/ + c->busaddr |=1 | (h->ioaccel1_blockFetchTable[c->Header.SGList] <<1 ) | +IOACCEL1_BUSADDR_CMDTYPE ; +} + +static void set_ioaccel2_performant_mode (struct ctlr_info *h, +struct CommandList *c) +{ +struct io_accel2_cmd *cp = &h->ioaccel2_cmd_pool[c->cmdindex]; + +/* Tell the controller to post the reply to the queue for this +* processor. This seems to give the best I/O throughput. +*/ + cp->reply_queue =smp_processor_id () % h->nreply_queues; +/* Set the bits in the address sent down to include: +* - performant mode bit not used in ioaccel mode 2 +* - pull count (bits 0-3) +* - command type isn't needed for ioaccel2 +*/ + c->busaddr |= (h->ioaccel2_blockFetchTable[cp->sg_count]); +} +static int is_firmware_flash_cmd (u8 *cdb) {return cdb[0 ] ==BMIC_WRITE && cdb[6 ] ==BMIC_FLASH_FIRMWARE ;
@@ -670,7 +734,16 @@ static void enqueue_cmd_and_start_io(struct ctlr_info *h, {unsigned long flags; -set_performant_mode (h, c); +switch (c->cmd_type) { +case CMD_IOACCEL1 : +set_ioaccel1_performant_mode (h, c); +break ; +case CMD_IOACCEL2 : +set_ioaccel2_performant_mode (h, c); +break ; +default : +set_performant_mode (h, c); + }dial_down_lockup_detection_during_fw_flash (h, c);spin_lock_irqsave (&h->lock, flags);addQ (&h->reqQ, c);
@@ -1228,6 +1301,123 @@ static void hpsa_unmap_sg_chain_block(struct ctlr_info *h,pci_unmap_single (h->pdev, temp64.val, chain_sg->Len,PCI_DMA_TODEVICE ); } +static void handle_ioaccel_mode2_error (struct ctlr_info *h, +struct CommandList *c, +struct scsi_cmnd *cmd, +struct io_accel2_cmd *c2) +{ +int data_len; + +switch (c2->error_data.serv_response) { +case IOACCEL2_SERV_RESPONSE_COMPLETE : +switch (c2->error_data.status) { +case IOACCEL2_STATUS_SR_TASK_COMP_GOOD : +break ; +case IOACCEL2_STATUS_SR_TASK_COMP_CHK_COND : +dev_warn (&h->pdev->dev, +"%s: task complete with check condition.\n" , +"HP SSD Smart Path" ); +if (c2->error_data.data_present != +IOACCEL2_SENSE_DATA_PRESENT ) +break ; +/* copy the sense data */ + data_len = c2->error_data.sense_data_len; +if (data_len >SCSI_SENSE_BUFFERSIZE ) + data_len =SCSI_SENSE_BUFFERSIZE ; +if (data_len >sizeof (c2->error_data.sense_data_buff)) + data_len = +sizeof (c2->error_data.sense_data_buff); +memcpy (cmd->sense_buffer, + c2->error_data.sense_data_buff, data_len); + cmd->result |=SAM_STAT_CHECK_CONDITION ; +break ; +case IOACCEL2_STATUS_SR_TASK_COMP_BUSY : +dev_warn (&h->pdev->dev, +"%s: task complete with BUSY status.\n" , +"HP SSD Smart Path" ); +break ; +case IOACCEL2_STATUS_SR_TASK_COMP_RES_CON : +dev_warn (&h->pdev->dev, +"%s: task complete with reservation conflict.\n" , +"HP SSD Smart Path" ); +break ; +case IOACCEL2_STATUS_SR_TASK_COMP_SET_FULL : +/* Make scsi midlayer do unlimited retries */ + cmd->result =DID_IMM_RETRY <<16 ; +break ; +case IOACCEL2_STATUS_SR_TASK_COMP_ABORTED : +dev_warn (&h->pdev->dev, +"%s: task complete with aborted status.\n" , +"HP SSD Smart Path" ); +break ; +default : +dev_warn (&h->pdev->dev, +"%s: task complete with unrecognized status: 0x%02x\n" , +"HP SSD Smart Path" , c2->error_data.status); +break ; + } +break ; +case IOACCEL2_SERV_RESPONSE_FAILURE : +/* don't expect to get here. */ +dev_warn (&h->pdev->dev, +"unexpected delivery or target failure, status = 0x%02x\n" , + c2->error_data.status); +break ; +case IOACCEL2_SERV_RESPONSE_TMF_COMPLETE : +break ; +case IOACCEL2_SERV_RESPONSE_TMF_SUCCESS : +break ; +case IOACCEL2_SERV_RESPONSE_TMF_REJECTED : +dev_warn (&h->pdev->dev,"task management function rejected.\n" ); +break ; +case IOACCEL2_SERV_RESPONSE_TMF_WRONG_LUN : +dev_warn (&h->pdev->dev,"task management function invalid LUN\n" ); +break ; +default : +dev_warn (&h->pdev->dev, +"%s: Unrecognized server response: 0x%02x\n" , +"HP SSD Smart Path" , c2->error_data.serv_response); +break ; + } +} + +static void process_ioaccel2_completion (struct ctlr_info *h, +struct CommandList *c,struct scsi_cmnd *cmd, +struct hpsa_scsi_dev_t *dev) +{ +struct io_accel2_cmd *c2 = &h->ioaccel2_cmd_pool[c->cmdindex]; + +/* check for good status */ +if (likely (c2->error_data.serv_response ==0 && + c2->error_data.status ==0 )) { +cmd_free (h, c); + cmd->scsi_done (cmd); +return ; + } + +/* Any RAID offload error results in retry which will use +* the normal I/O path so the controller can handle whatever's +* wrong. +*/ +if (is_logical_dev_addr_mode (dev->scsi3addr) && + c2->error_data.serv_response == +IOACCEL2_SERV_RESPONSE_FAILURE ) { +if (c2->error_data.status != +IOACCEL2_STATUS_SR_IOACCEL_DISABLED ) +dev_warn (&h->pdev->dev, +"%s: Error 0x%02x, Retrying on standard path.\n" , +"HP SSD Smart Path" , c2->error_data.status); + dev->offload_enabled =0 ; + cmd->result =DID_SOFT_ERROR <<16 ; +cmd_free (h, c); + cmd->scsi_done (cmd); +return ; + } +handle_ioaccel_mode2_error (h, c, cmd, c2); +cmd_free (h, c); + cmd->scsi_done (cmd); +} +static void complete_scsi_command (struct CommandList *cp) {struct scsi_cmnd *cmd;
@@ -1252,6 +1442,10 @@ static void complete_scsi_command(struct CommandList *cp) cmd->result = (DID_OK <<16 );/* host byte */ cmd->result |= (COMMAND_COMPLETE <<8 );/* msg byte */ + +if (cp->cmd_type ==CMD_IOACCEL2 ) +return process_ioaccel2_completion (h, cp, cmd, dev); + cmd->result |= ei->ScsiStatus;/* copy the sense data whether we need to or not. */
@@ -2463,10 +2657,7 @@ static int fixup_ioaccel_cdb(u8 *cdb, int *cdb_len)return 0 ; } -/* -* Queue a command to the I/O accelerator path. -*/ -static int hpsa_scsi_ioaccel_queue_command (struct ctlr_info *h, +static int hpsa_scsi_ioaccel1_queue_command (struct ctlr_info *h,struct CommandList *c,u32 ioaccel_handle,u8 *cdb,int cdb_len,u8 *scsi3addr) {
@@ -2538,6 +2729,7 @@ static int hpsa_scsi_ioaccel_queue_command(struct ctlr_info *h, control |=IOACCEL1_CONTROL_NODATAXFER ; } + c->Header.SGList = use_sg;/* Fill out the command structure to submit */ cp->dev_handle = ioaccel_handle &0xFFFF ; cp->transfer_len = total_len;
@@ -2546,19 +2738,7 @@ static int hpsa_scsi_ioaccel_queue_command(struct ctlr_info *h, cp->control = control;memcpy (cp->CDB, cdb, cdb_len);memcpy (cp->CISS_LUN, scsi3addr,8 ); - -/* Tell the controller to post the reply to the queue for this -* processor. This seems to give the best I/O throughput. -*/ - cp->ReplyQueue =smp_processor_id () % h->nreply_queues; - -/* Set the bits in the address sent down to include: -* - performant mode bit (bit 0) -* - pull count (bits 1-3) -* - command type (bits 4-6) -*/ - c->busaddr |=1 | (h->ioaccel1_blockFetchTable[use_sg] <<1 ) | -IOACCEL1_BUSADDR_CMDTYPE ; +/* Tag was already set at init time. */ enqueue_cmd_and_start_io (h, c);return 0 ; }
@@ -2577,6 +2757,106 @@ static int hpsa_scsi_ioaccel_direct_map(struct ctlr_info *h, cmd->cmnd, cmd->cmd_len, dev->scsi3addr); } +static int hpsa_scsi_ioaccel2_queue_command (struct ctlr_info *h, +struct CommandList *c,u32 ioaccel_handle,u8 *cdb,int cdb_len, +u8 *scsi3addr) +{ +struct scsi_cmnd *cmd = c->scsi_cmd; +struct io_accel2_cmd *cp = &h->ioaccel2_cmd_pool[c->cmdindex]; +struct ioaccel2_sg_element *curr_sg; +int use_sg, i; +struct scatterlist *sg; +u64 addr64; +u32 len; +u32 total_len =0 ; + +if (scsi_sg_count (cmd) > h->ioaccel_maxsg) +return IO_ACCEL_INELIGIBLE ; + +if (fixup_ioaccel_cdb (cdb, &cdb_len)) +return IO_ACCEL_INELIGIBLE ; + c->cmd_type =CMD_IOACCEL2 ; +/* Adjust the DMA address to point to the accelerated command buffer */ + c->busaddr = (u32 ) h->ioaccel2_cmd_pool_dhandle + + (c->cmdindex *sizeof (*cp)); +BUG_ON (c->busaddr &0x0000007F ); + +memset (cp,0 ,sizeof (*cp)); + cp->IU_type =IOACCEL2_IU_TYPE ; + + use_sg =scsi_dma_map (cmd); +if (use_sg <0 ) +return use_sg; + +if (use_sg) { +BUG_ON (use_sg >IOACCEL2_MAXSGENTRIES ); + curr_sg = cp->sg; +scsi_for_each_sg (cmd, sg, use_sg, i) { + addr64 = (u64 )sg_dma_address (sg); + len =sg_dma_len (sg); + total_len += len; + curr_sg->address =cpu_to_le64 (addr64); + curr_sg->length =cpu_to_le32 (len); + curr_sg->reserved[0 ] =0 ; + curr_sg->reserved[1 ] =0 ; + curr_sg->reserved[2 ] =0 ; + curr_sg->chain_indicator =0 ; + curr_sg++; + } + +switch (cmd->sc_data_direction) { +case DMA_TO_DEVICE : + cp->direction =IOACCEL2_DIR_DATA_OUT ; +break ; +case DMA_FROM_DEVICE : + cp->direction =IOACCEL2_DIR_DATA_IN ; +break ; +case DMA_NONE : + cp->direction =IOACCEL2_DIR_NO_DATA ; +break ; +default : +dev_err (&h->pdev->dev,"unknown data direction: %d\n" , + cmd->sc_data_direction); +BUG (); +break ; + } + }else { + cp->direction =IOACCEL2_DIR_NO_DATA ; + } + cp->scsi_nexus = ioaccel_handle; + cp->Tag.lower = (c->cmdindex <<DIRECT_LOOKUP_SHIFT ) | +DIRECT_LOOKUP_BIT ; +memcpy (cp->cdb, cdb,sizeof (cp->cdb)); +memset (cp->cciss_lun,0 ,sizeof (cp->cciss_lun)); + cp->cmd_priority_task_attr =0 ; + +/* fill in sg elements */ + cp->sg_count = (u8 ) use_sg; + + cp->data_len =cpu_to_le32 (total_len); + cp->err_ptr =cpu_to_le64 (c->busaddr + + offsetof(struct io_accel2_cmd , error_data)); + cp->err_len =cpu_to_le32 ((u32 )sizeof (cp->error_data)); + +enqueue_cmd_and_start_io (h, c); +return 0 ; +} + +/* +* Queue a command to the correct I/O accelerator path. +*/ +static int hpsa_scsi_ioaccel_queue_command (struct ctlr_info *h, +struct CommandList *c,u32 ioaccel_handle,u8 *cdb,int cdb_len, +u8 *scsi3addr) +{ +if (h->transMethod & CFGTBL_Trans_io_accel1) +return hpsa_scsi_ioaccel1_queue_command (h, c, ioaccel_handle, + cdb, cdb_len, scsi3addr); +else +return hpsa_scsi_ioaccel2_queue_command (h, c, ioaccel_handle, + cdb, cdb_len, scsi3addr); +} +/* * Attempt to perform offload RAID mapping for a logical volume I/O. */
@@ -4251,7 +4531,8 @@ static inline void finish_cmd(struct CommandList *c)spin_unlock_irqrestore (&h->lock, flags);dial_up_lockup_detection_on_fw_flash_complete (c->h, c); -if (likely (c->cmd_type ==CMD_IOACCEL1 || c->cmd_type ==CMD_SCSI )) +if (likely (c->cmd_type ==CMD_IOACCEL1 || c->cmd_type ==CMD_SCSI + || c->cmd_type ==CMD_IOACCEL2 ))complete_scsi_command (c);else if (c->cmd_type ==CMD_IOCTL_PEND )complete (c->waiting);
@@ -5971,6 +6252,12 @@ static void hpsa_enter_performant_mode(struct ctlr_info *h, u32 trans_support) access = SA5_ioaccel_mode1_access;writel (10 , &h->cfgtable->HostWrite.CoalIntDelay);writel (4 , &h->cfgtable->HostWrite.CoalIntCount); + }else { +if (trans_support & CFGTBL_Trans_io_accel2) { + access = SA5_ioaccel_mode2_access; +writel (10 , &h->cfgtable->HostWrite.CoalIntDelay); +writel (4 , &h->cfgtable->HostWrite.CoalIntCount); + } }writel (CFGTBL_ChangeReq, h->vaddr +SA5_DOORBELL );hpsa_wait_for_mode_change_ack (h);
drivers/scsi/hpsa.h +20 -0
@@ -282,6 +282,18 @@ static void SA5_submit_command(struct ctlr_info *h, (void )readl (h->vaddr +SA5_SCRATCHPAD_OFFSET ); } +static void SA5_submit_command_ioaccel2 (struct ctlr_info *h, +struct CommandList *c) +{ +dev_dbg (&h->pdev->dev,"Sending %x, tag = %x\n" , c->busaddr, + c->Header.Tag.lower); +if (c->cmd_type ==CMD_IOACCEL2 ) +writel (c->busaddr, h->vaddr +IOACCEL2_INBOUND_POSTQ_32 ); +else +writel (c->busaddr, h->vaddr +SA5_REQUEST_PORT_OFFSET ); + (void )readl (h->vaddr +SA5_SCRATCHPAD_OFFSET ); +} +/* * This card is the opposite of the other cards. * 0 turns interrupts on...
@@ -475,6 +487,14 @@ static struct access_method SA5_ioaccel_mode1_access = { SA5_ioaccel_mode1_completed, }; +static struct access_method SA5_ioaccel_mode2_access = { + SA5_submit_command_ioaccel2, + SA5_performant_intr_mask, + SA5_fifo_full, + SA5_performant_intr_pending, + SA5_performant_completed, +}; +static struct access_method SA5_performant_access = { SA5_submit_command, SA5_performant_intr_mask,
drivers/scsi/hpsa_cmd.h +1 -0
@@ -478,6 +478,7 @@ struct io_accel2_scsi_response {#define IOACCEL2_STATUS_SR_TASK_COMP_RES_CON 0x18#define IOACCEL2_STATUS_SR_TASK_COMP_SET_FULL 0x28#define IOACCEL2_STATUS_SR_TASK_COMP_ABORTED 0x40 +#define IOACCEL2_STATUS_SR_IOACCEL_DISABLED 0x0Eu8 data_present;/* low 2 bits */ #define IOACCEL2_NO_DATAPRESENT 0x000#define IOACCEL2_RESPONSE_DATAPRESENT 0x001
PATCH 18/35 hpsa: teach hpsa_device_reset to do either target or lun reset
In reply to Stephen M. CameronFrom: Scott Teel <[email protected]>
--- drivers/scsi/hpsa.c | 10 ++++++---- 1 files changed, 6 insertions(+), 4 deletions(-)
drivers/scsi/hpsa.c +6 -4
@@ -1858,7 +1858,8 @@ out:return rc; } -static int hpsa_send_reset (struct ctlr_info *h,unsigned char *scsi3addr) +static int hpsa_send_reset (struct ctlr_info *h,unsigned char *scsi3addr, +u8 reset_type) {int rc =IO_OK ;struct CommandList *c;
@@ -1872,8 +1873,9 @@ static int hpsa_send_reset(struct ctlr_info *h, unsigned char *scsi3addr) }/* fill_cmd can't fail here, no data buffer to map. */ - (void )fill_cmd (c,HPSA_DEVICE_RESET_MSG , h, -NULL ,0 ,0 , scsi3addr,TYPE_MSG ); + (void )fill_cmd (c,HPSA_DEVICE_RESET_MSG , h,NULL ,0 ,0 , + scsi3addr,TYPE_MSG ); + c->Request.CDB[1 ] = reset_type;/* fill_cmd defaults to LUN reset */ hpsa_scsi_do_simple_cmd_core (h, c);/* no unmap needed here because no data xfer. */
@@ -3390,7 +3392,7 @@ static int hpsa_eh_device_reset_handler(struct scsi_cmnd *scsicmd)dev_warn (&h->pdev->dev,"resetting device %d:%d:%d:%d\n" , h->scsi_host->host_no, dev->bus, dev->target, dev->lun);/* send a reset to the SCSI LUN which the command was sent to */ - rc =hpsa_send_reset (h, dev->scsi3addr); + rc =hpsa_send_reset (h, dev->scsi3addr,HPSA_RESET_TYPE_LUN );if (rc ==0 &&wait_for_device_to_become_ready (h, dev->scsi3addr) ==0 )return SUCCESS ;
PATCH 19/35 hpsa: add task management for ioaccel mode 2
In reply to Stephen M. CameronFrom: Scott Teel <[email protected]>
Underlying firmware cannot handle task abort on accelerated path (SSD Smart Path). Change abort requests for accelerated path commands to physical target reset. Send reset request on normal IO path.
--- drivers/scsi/hpsa.c | 166 ++++++++++++++++++++++++++++++++++++++++++++++- drivers/scsi/hpsa_cmd.h | 7 +- 2 files changed, 167 insertions(+), 6 deletions(-)
drivers/scsi/hpsa.c +163 -3
@@ -2307,6 +2307,85 @@ static int add_ext_target_dev(struct ctlr_info *h, }/* +* Get address of physical disk used for an ioaccel2 mode command: +* 1. Extract ioaccel2 handle from the command. +* 2. Find a matching ioaccel2 handle from list of physical disks. +* 3. Return: +* 1 and set scsi3addr to address of matching physical +* 0 if no matching physical disk was found. +*/ +static int hpsa_get_pdisk_of_ioaccel2 (struct ctlr_info *h, +struct CommandList *ioaccel2_cmd_to_abort,unsigned char *scsi3addr) +{ +struct ReportExtendedLUNdata *physicals =NULL ; +int responsesize =24 ;/* size of physical extended response */ +int extended =2 ;/* flag forces reporting 'other dev info'. */ +int reportsize =sizeof (*physicals) +HPSA_MAX_PHYS_LUN * responsesize; +u32 nphysicals =0 ;/* number of reported physical devs */ +int found =0 ;/* found match (1) or not (0) */ +u32 find;/* handle we need to match */ +int i; +struct scsi_cmnd *scmd;/* scsi command within request being aborted */ +struct hpsa_scsi_dev_t *d;/* device of request being aborted */ +struct io_accel2_cmd *c2a;/* ioaccel2 command to abort */ +u32 it_nexus;/* 4 byte device handle for the ioaccel2 cmd */ +u32 scsi_nexus;/* 4 byte device handle for the ioaccel2 cmd */ + +if (ioaccel2_cmd_to_abort->cmd_type !=CMD_IOACCEL2 ) +return 0 ;/* no match */ + +/* point to the ioaccel2 device handle */ + c2a = &h->ioaccel2_cmd_pool[ioaccel2_cmd_to_abort->cmdindex]; +if (c2a ==NULL ) +return 0 ;/* no match */ + + scmd = (struct scsi_cmnd *) ioaccel2_cmd_to_abort->scsi_cmd; +if (scmd ==NULL ) +return 0 ;/* no match */ + + d = scmd->device->hostdata; +if (d ==NULL ) +return 0 ;/* no match */ + + it_nexus =cpu_to_le32 ((u32 ) d->ioaccel_handle); + scsi_nexus =cpu_to_le32 ((u32 ) c2a->scsi_nexus); + find = c2a->scsi_nexus; + +/* Get the list of physical devices */ + physicals =kzalloc (reportsize,GFP_KERNEL ); +if (hpsa_scsi_do_report_phys_luns (h, (struct ReportLUNdata *) physicals, + reportsize, extended)) { +dev_err (&h->pdev->dev, +"Can't lookup %s device handle: report physical LUNs failed.\n" , +"HP SSD Smart Path" ); +kfree (physicals); +return 0 ; + } + nphysicals =be32_to_cpu (*((__be32 *)physicals->LUNListLength)) / + responsesize; + + +/* find ioaccel2 handle in list of physicals: */ +for (i =0 ; i < nphysicals; i++) { +/* handle is in bytes 28-31 of each lun */ +if (memcmp (&((struct ReportExtendedLUNdata *) + physicals)->LUN[i][20 ], &find,4 ) !=0 ) { +continue ;/* didn't match */ + } + found =1 ; +memcpy (scsi3addr, &((struct ReportExtendedLUNdata *) + physicals)->LUN[i][0 ],8 ); +break ;/* found it */ + } + +kfree (physicals); +if (found) +return 1 ; +else +return 0 ; + +} +/* * Do CISS_REPORT_PHYS and CISS_REPORT_LOG. Data is returned in physdev, * logdev. The number of luns in physdev and logdev are returned in * *nphysicals and *nlogicals, respectively.
@@ -3423,12 +3502,20 @@ static void hpsa_get_tag(struct ctlr_info *h, &h->ioaccel_cmd_pool[c->cmdindex]; *tagupper = cm1->Tag.upper; *taglower = cm1->Tag.lower; - }else { - *tagupper = c->Header.Tag.upper; - *taglower = c->Header.Tag.lower; +return ; + } +if (c->cmd_type ==CMD_IOACCEL2 ) { +struct io_accel2_cmd *cm2 = (struct io_accel2_cmd *) + &h->ioaccel2_cmd_pool[c->cmdindex]; + *tagupper = cm2->Tag.upper; + *taglower = cm2->Tag.lower; +return ; } + *tagupper = c->Header.Tag.upper; + *taglower = c->Header.Tag.lower; } +static int hpsa_send_abort (struct ctlr_info *h,unsigned char *scsi3addr,struct CommandList *abort,int swizzle) {
@@ -3524,6 +3611,71 @@ static struct CommandList *hpsa_find_cmd_in_queue_by_tag(struct ctlr_info *h,return NULL ; } +/* ioaccel2 path firmware cannot handle abort task requests. +* Change abort requests to physical target reset, and send to the +* address of the physical disk used for the ioaccel 2 command. +* Return 0 on success (IO_OK) +* -1 on failure +*/ + +static int hpsa_send_reset_as_abort_ioaccel2 (struct ctlr_info *h, +unsigned char *scsi3addr,struct CommandList *abort) +{ +int rc =IO_OK ; +struct scsi_cmnd *scmd;/* scsi command within request being aborted */ +struct hpsa_scsi_dev_t *dev;/* device to which scsi cmd was sent */ +unsigned char phys_scsi3addr[8 ];/* addr of phys disk with volume */ +unsigned char *psa = &phys_scsi3addr[0 ]; + +/* Get a pointer to the hpsa logical device. */ + scmd = (struct scsi_cmnd *) abort->scsi_cmd; + dev = (struct hpsa_scsi_dev_t *)(scmd->device->hostdata); +if (dev ==NULL ) { +dev_warn (&h->pdev->dev, +"Cannot abort: no device pointer for command.\n" ); +return -1 ;/* not abortable */ + } + +if (!dev->offload_enabled) { +dev_warn (&h->pdev->dev, +"Can't abort: device is not operating in HP SSD Smart Path mode.\n" ); +return -1 ;/* not abortable */ + } + +/* Incoming scsi3addr is logical addr. We need physical disk addr. */ +if (!hpsa_get_pdisk_of_ioaccel2 (h, abort, psa)) { +dev_warn (&h->pdev->dev,"Can't abort: Failed lookup of physical address.\n" ); +return -1 ;/* not abortable */ + } + +/* send the reset */ + rc =hpsa_send_reset (h, psa,HPSA_RESET_TYPE_TARGET ); +if (rc !=0 ) { +dev_warn (&h->pdev->dev, +"Reset as abort: Failed on physical device at scsi3addr 0x%02x%02x%02x%02x%02x%02x%02x%02x\n" , + psa[0 ], psa[1 ], psa[2 ], psa[3 ], + psa[4 ], psa[5 ], psa[6 ], psa[7 ]); +return rc;/* failed to reset */ + } + +/* wait for device to recover */ +if (wait_for_device_to_become_ready (h, psa) !=0 ) { +dev_warn (&h->pdev->dev, +"Reset as abort: Failed: Device never recovered from reset: 0x%02x%02x%02x%02x%02x%02x%02x%02x\n" , + psa[0 ], psa[1 ], psa[2 ], psa[3 ], + psa[4 ], psa[5 ], psa[6 ], psa[7 ]); +return -1 ;/* failed to recover */ + } + +/* device recovered */ +dev_info (&h->pdev->dev, +"Reset as abort: Device recovered from reset: scsi3addr 0x%02x%02x%02x%02x%02x%02x%02x%02x\n" , + psa[0 ], psa[1 ], psa[2 ], psa[3 ], + psa[4 ], psa[5 ], psa[6 ], psa[7 ]); + +return rc;/* success */ +} +/* Some Smart Arrays need the abort tag swizzled, and some don't. It's hard to * tell which kind we're dealing with, so we send the abort both ways. There * shouldn't be any collisions between swizzled and unswizzled tags due to the
@@ -3537,6 +3689,14 @@ static int hpsa_send_abort_both_ways(struct ctlr_info *h,struct CommandList *c;int rc =0 , rc2 =0 ; +/* ioccelerator mode 2 commands should be aborted via the +* accelerated path, since RAID path is unaware of these commands, +* but underlying firmware can't handle abort TMF. +* Change abort to physical device reset. +*/ +if (abort->cmd_type ==CMD_IOACCEL2 ) +return hpsa_send_reset_as_abort_ioaccel2 (h, scsi3addr, abort); +/* we do not expect to find the swizzled tag in our queue, but * check anyway just to be sure the assumptions which make this * the case haven't become wrong.
drivers/scsi/hpsa_cmd.h +4 -3
@@ -82,8 +82,9 @@#define ATTR_ACA 0x07/* cdb type */ -#define TYPE_CMD 0x00 -#define TYPE_MSG 0x01 +#define TYPE_CMD 0x00 +#define TYPE_MSG 0x01 +#define TYPE_IOACCEL2_CMD 0x81/* 0x81 is not used by hardware */ /* Message Types */ #define HPSA_TASK_MANAGEMENT 0x00
@@ -525,7 +526,7 @@ struct io_accel2_cmd {* FIXME: this can't be all I need mfm */ #define IOACCEL2_IU_TYPE 0x40 -#define IU_TYPE_TMF 0x41 +#define IOACCEL2_IU_TMF_TYPE 0x41#define IOACCEL2_DIR_NO_DATA 0x00#define IOACCEL2_DIR_DATA_IN 0x01#define IOACCEL2_DIR_DATA_OUT 0x02
Re: [PATCH 19/35] hpsa: add task management for ioaccel mode 2
Quoted 58 lines · Stephen M. Cameron
From: Scott Teel <[email protected]>
Underlying firmware cannot handle task abort on accelerated path (SSD Smart Path). Change abort requests for accelerated path commands to physical target reset. Send reset request on normal IO path.
Signed-off-by Scott Teel <[email protected]>Signed-off-by Mike Miller <[email protected]>--- drivers/scsi/hpsa.c | 166 ++++++++++++++++++++++++++++++++++++++++++++++- drivers/scsi/hpsa_cmd.h | 7 +- 2 files changed, 167 insertions(+), 6 deletions(-)drivers/scsi/hpsa.c +36
-0@@ -2307,6 +2307,85 @@ static int add_ext_target_dev(struct ctlr_info *h, }/* +* Get address of physical disk used for an ioaccel2 mode command: +* 1. Extract ioaccel2 handle from the command. +* 2. Find a matching ioaccel2 handle from list of physical disks. +* 3. Return: +* 1 and set scsi3addr to address of matching physical +* 0 if no matching physical disk was found. +*/ +static int hpsa_get_pdisk_of_ioaccel2 (struct ctlr_info *h, +struct CommandList *ioaccel2_cmd_to_abort,unsigned char *scsi3addr) +{ +struct ReportExtendedLUNdata *physicals =NULL ; +int responsesize =24 ;/* size of physical extended response */ +int extended =2 ;/* flag forces reporting 'other dev info'. */ +int reportsize =sizeof (*physicals) +HPSA_MAX_PHYS_LUN * responsesize; +u32 nphysicals =0 ;/* number of reported physical devs */ +int found =0 ;/* found match (1) or not (0) */ +u32 find;/* handle we need to match */ +int i; +struct scsi_cmnd *scmd;/* scsi command within request being aborted */ +struct hpsa_scsi_dev_t *d;/* device of request being aborted */ +struct io_accel2_cmd *c2a;/* ioaccel2 command to abort */ +u32 it_nexus;/* 4 byte device handle for the ioaccel2 cmd */ +u32 scsi_nexus;/* 4 byte device handle for the ioaccel2 cmd */ + +if (ioaccel2_cmd_to_abort->cmd_type !=CMD_IOACCEL2 ) +return 0 ;/* no match */ + +/* point to the ioaccel2 device handle */ + c2a = &h->ioaccel2_cmd_pool[ioaccel2_cmd_to_abort->cmdindex]; +if (c2a ==NULL ) +return 0 ;/* no match */ + + scmd = (struct scsi_cmnd *) ioaccel2_cmd_to_abort->scsi_cmd; +if (scmd ==NULL ) +return 0 ;/* no match */ +
drivers/scsi/hpsa.c static int add_ext_target_dev(struct ctlr_info *h, · line 2355
Quoted 10 lines
drivers/scsi/hpsa.c +10
-0+ d = scmd->device->hostdata; +if (d ==NULL ) +return 0 ;/* no match */ + + it_nexus =cpu_to_le32 ((u32 ) d->ioaccel_handle); + scsi_nexus =cpu_to_le32 ((u32 ) c2a->scsi_nexus); + find = c2a->scsi_nexus; + +/* Get the list of physical devices */ + physicals =kzalloc (reportsize,GFP_KERNEL );
Hi, please add a test for physicals != NULL
Tomas
Quoted 177 lines
drivers/scsi/hpsa.c +117
-3+if (hpsa_scsi_do_report_phys_luns (h, (struct ReportLUNdata *) physicals, + reportsize, extended)) { +dev_err (&h->pdev->dev, +"Can't lookup %s device handle: report physical LUNs failed.\n" , +"HP SSD Smart Path" ); +kfree (physicals); +return 0 ; + } + nphysicals =be32_to_cpu (*((__be32 *)physicals->LUNListLength)) / + responsesize; + + +/* find ioaccel2 handle in list of physicals: */ +for (i =0 ; i < nphysicals; i++) { +/* handle is in bytes 28-31 of each lun */ +if (memcmp (&((struct ReportExtendedLUNdata *) + physicals)->LUN[i][20 ], &find,4 ) !=0 ) { +continue ;/* didn't match */ + } + found =1 ; +memcpy (scsi3addr, &((struct ReportExtendedLUNdata *) + physicals)->LUN[i][0 ],8 ); +break ;/* found it */ + } + +kfree (physicals); +if (found) +return 1 ; +else +return 0 ; + +} +/* * Do CISS_REPORT_PHYS and CISS_REPORT_LOG. Data is returned in physdev, * logdev. The number of luns in physdev and logdev are returned in * *nphysicals and *nlogicals, respectively. @@ -3423,12 +3502,20 @@ static void hpsa_get_tag(struct ctlr_info *h, &h->ioaccel_cmd_pool[c->cmdindex]; *tagupper = cm1->Tag.upper; *taglower = cm1->Tag.lower; - }else { - *tagupper = c->Header.Tag.upper; - *taglower = c->Header.Tag.lower; +return ; + } +if (c->cmd_type ==CMD_IOACCEL2 ) { +struct io_accel2_cmd *cm2 = (struct io_accel2_cmd *) + &h->ioaccel2_cmd_pool[c->cmdindex]; + *tagupper = cm2->Tag.upper; + *taglower = cm2->Tag.lower; +return ; } + *tagupper = c->Header.Tag.upper; + *taglower = c->Header.Tag.lower; } +static int hpsa_send_abort (struct ctlr_info *h,unsigned char *scsi3addr,struct CommandList *abort,int swizzle) {@@ -3524,6 +3611,71 @@ static struct CommandList *hpsa_find_cmd_in_queue_by_tag(struct ctlr_info *h,return NULL ; } +/* ioaccel2 path firmware cannot handle abort task requests. +* Change abort requests to physical target reset, and send to the +* address of the physical disk used for the ioaccel 2 command. +* Return 0 on success (IO_OK) +* -1 on failure +*/ + +static int hpsa_send_reset_as_abort_ioaccel2 (struct ctlr_info *h, +unsigned char *scsi3addr,struct CommandList *abort) +{ +int rc =IO_OK ; +struct scsi_cmnd *scmd;/* scsi command within request being aborted */ +struct hpsa_scsi_dev_t *dev;/* device to which scsi cmd was sent */ +unsigned char phys_scsi3addr[8 ];/* addr of phys disk with volume */ +unsigned char *psa = &phys_scsi3addr[0 ]; + +/* Get a pointer to the hpsa logical device. */ + scmd = (struct scsi_cmnd *) abort->scsi_cmd; + dev = (struct hpsa_scsi_dev_t *)(scmd->device->hostdata); +if (dev ==NULL ) { +dev_warn (&h->pdev->dev, +"Cannot abort: no device pointer for command.\n" ); +return -1 ;/* not abortable */ + } + +if (!dev->offload_enabled) { +dev_warn (&h->pdev->dev, +"Can't abort: device is not operating in HP SSD Smart Path mode.\n" ); +return -1 ;/* not abortable */ + } + +/* Incoming scsi3addr is logical addr. We need physical disk addr. */ +if (!hpsa_get_pdisk_of_ioaccel2 (h, abort, psa)) { +dev_warn (&h->pdev->dev,"Can't abort: Failed lookup of physical address.\n" ); +return -1 ;/* not abortable */ + } + +/* send the reset */ + rc =hpsa_send_reset (h, psa,HPSA_RESET_TYPE_TARGET ); +if (rc !=0 ) { +dev_warn (&h->pdev->dev, +"Reset as abort: Failed on physical device at scsi3addr 0x%02x%02x%02x%02x%02x%02x%02x%02x\n" , + psa[0 ], psa[1 ], psa[2 ], psa[3 ], + psa[4 ], psa[5 ], psa[6 ], psa[7 ]); +return rc;/* failed to reset */ + } + +/* wait for device to recover */ +if (wait_for_device_to_become_ready (h, psa) !=0 ) { +dev_warn (&h->pdev->dev, +"Reset as abort: Failed: Device never recovered from reset: 0x%02x%02x%02x%02x%02x%02x%02x%02x\n" , + psa[0 ], psa[1 ], psa[2 ], psa[3 ], + psa[4 ], psa[5 ], psa[6 ], psa[7 ]); +return -1 ;/* failed to recover */ + } + +/* device recovered */ +dev_info (&h->pdev->dev, +"Reset as abort: Device recovered from reset: scsi3addr 0x%02x%02x%02x%02x%02x%02x%02x%02x\n" , + psa[0 ], psa[1 ], psa[2 ], psa[3 ], + psa[4 ], psa[5 ], psa[6 ], psa[7 ]); + +return rc;/* success */ +} +/* Some Smart Arrays need the abort tag swizzled, and some don't. It's hard to * tell which kind we're dealing with, so we send the abort both ways. There * shouldn't be any collisions between swizzled and unswizzled tags due to the @@ -3537,6 +3689,14 @@ static int hpsa_send_abort_both_ways(struct ctlr_info *h,struct CommandList *c;int rc =0 , rc2 =0 ; +/* ioccelerator mode 2 commands should be aborted via the +* accelerated path, since RAID path is unaware of these commands, +* but underlying firmware can't handle abort TMF. +* Change abort to physical device reset. +*/ +if (abort->cmd_type ==CMD_IOACCEL2 ) +return hpsa_send_reset_as_abort_ioaccel2 (h, scsi3addr, abort); +/* we do not expect to find the swizzled tag in our queue, but * check anyway just to be sure the assumptions which make this * the case haven't become wrong. drivers/scsi/hpsa_cmd.h +4
-4@@ -82,8 +82,9 @@#define ATTR_ACA 0x07/* cdb type */ -#define TYPE_CMD 0x00 -#define TYPE_MSG 0x01 +#define TYPE_CMD 0x00 +#define TYPE_MSG 0x01 +#define TYPE_IOACCEL2_CMD 0x81/* 0x81 is not used by hardware */ /* Message Types */ #define HPSA_TASK_MANAGEMENT 0x00@@ -525,7 +526,7 @@ struct io_accel2_cmd {* FIXME: this can't be all I need mfm */ #define IOACCEL2_IU_TYPE 0x40 -#define IU_TYPE_TMF 0x41 +#define IOACCEL2_IU_TMF_TYPE 0x41#define IOACCEL2_DIR_NO_DATA 0x00#define IOACCEL2_DIR_DATA_IN 0x01#define IOACCEL2_DIR_DATA_OUT 0x02 --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 20/35 hpsa: make device update copy the raid map also
In reply to Stephen M. CameronFrom: Stephen M. Cameron <[email protected]>
Otherwise we could wind up using incorrect raid map data, and then very bad things would likely happen.
--- drivers/scsi/hpsa.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
drivers/scsi/hpsa.c +3 -0
@@ -891,6 +891,9 @@ static void hpsa_scsi_update_entry(struct ctlr_info *h, int hostno,/* Raid offload parameters changed. */ h->dev[entry]->offload_config = new_entry->offload_config; h->dev[entry]->offload_enabled = new_entry->offload_enabled; + h->dev[entry]->ioaccel_handle = new_entry->ioaccel_handle; + h->dev[entry]->offload_to_mirror = new_entry->offload_to_mirror; + h->dev[entry]->raid_map = new_entry->raid_map; dev_info(&h->pdev->dev, "%s device c%db%dt%dl%d updated.\n", scsi_device_type(new_entry->devtype), hostno, new_entry->bus,
PATCH 21/35 hpsa: complete the ioaccel raidmap code
In reply to Stephen M. CameronFrom: Scott Teel <[email protected]>
Load balance across members of a N-way mirror set, and handle the meta-RAID levels: R10, R50, R60.
--- drivers/scsi/hpsa.c | 174 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 168 insertions(+), 6 deletions(-)
drivers/scsi/hpsa.c +168 -6
@@ -423,6 +423,13 @@ static inline int is_logical_dev_addr_mode(unsigned char scsi3addr[])static const char *raid_label[] = {"0" ,"4" ,"1(1+0)" ,"5" ,"5+1" ,"ADG" ,"1(ADM)" ,"UNKNOWN" }; +#define HPSA_RAID_0 0 +#define HPSA_RAID_4 1 +#define HPSA_RAID_1 2/* also used for RAID 10 */ +#define HPSA_RAID_5 3/* also used for RAID 50 */ +#define HPSA_RAID_51 4 +#define HPSA_RAID_6 5/* also used for RAID 60 */ +#define HPSA_RAID_ADM 6/* also used for RAID 1+0 ADM */ #define RAID_UNKNOWN (ARRAY_SIZE(raid_label) - 1) static ssize_t raid_level_show(struct device *dev,
@@ -2941,6 +2948,31 @@ static int hpsa_scsi_ioaccel_queue_command(struct ctlr_info *h, cdb, cdb_len, scsi3addr); } +static void raid_map_helper (struct raid_map_data *map, +int offload_to_mirror,u32 *map_index,u32 *current_group) +{ +if (offload_to_mirror ==0 ) { +/* use physical disk in the first mirrored group. */ + *map_index %= map->data_disks_per_row; +return ; + } +do { +/* determine mirror group that *map_index indicates */ + *current_group = *map_index / map->data_disks_per_row; +if (offload_to_mirror == *current_group) +continue ; +if (*current_group < (map->layout_map_count -1 )) { +/* select map index from next group */ + *map_index += map->data_disks_per_row; + (*current_group)++; + }else { +/* select map index from first group */ + *map_index %= map->data_disks_per_row; + *current_group =0 ; + } + }while (offload_to_mirror != *current_group); +} +/* * Attempt to perform offload RAID mapping for a logical volume I/O. */
@@ -2959,6 +2991,14 @@ static int hpsa_scsi_ioaccel_raid_map(struct ctlr_info *h,u64 first_row, last_row;u32 first_row_offset, last_row_offset;u32 first_column, last_column; +u64 r0_first_row, r0_last_row; +u32 r5or6_blocks_per_row; +u64 r5or6_first_row, r5or6_last_row; +u32 r5or6_first_row_offset, r5or6_last_row_offset; +u32 r5or6_first_column, r5or6_last_column; +u32 total_disks_per_row; +u32 stripesize; +u32 first_group, last_group, current_group;u32 map_row;u32 disk_handle;u64 disk_block;
@@ -2968,6 +3008,7 @@ static int hpsa_scsi_ioaccel_raid_map(struct ctlr_info *h,#if BITS_PER_LONG ==32 u64 tmpdiv;#endif +int offload_to_mirror;BUG_ON (!(dev->offload_config && dev->offload_enabled));
@@ -3070,19 +3111,140 @@ static int hpsa_scsi_ioaccel_raid_map(struct ctlr_info *h,return IO_ACCEL_INELIGIBLE ;/* proceeding with driver mapping */ + total_disks_per_row = map->data_disks_per_row + + map->metadata_disks_per_row; map_row = ((u32)(first_row >> map->parity_rotation_shift)) % map->row_cnt; - map_index = (map_row * (map->data_disks_per_row + - map->metadata_disks_per_row)) + first_column; -if (dev->raid_level ==2 ) { -/* simple round-robin balancing of RAID 1+0 reads across -* primary and mirror members. this is appropriate for SSD -* but not optimal for HDD. + map_index = (map_row * total_disks_per_row) + first_column; + +switch (dev->raid_level) { +case HPSA_RAID_0 : +break ;/* nothing special to do */ +case HPSA_RAID_1 : +/* Handles load balance across RAID 1 members. +* (2-drive R1 and R10 with even # of drives.) +* Appropriate for SSDs, not optimal for HDDs */ +BUG_ON (map->layout_map_count !=2 );if (dev->offload_to_mirror) map_index += map->data_disks_per_row; dev->offload_to_mirror = !dev->offload_to_mirror; +break ; +case HPSA_RAID_ADM : +/* Handles N-way mirrors (R1-ADM) +* and R10 with # of drives divisible by 3.) +*/ +BUG_ON (map->layout_map_count !=3 ); + + offload_to_mirror = dev->offload_to_mirror; +raid_map_helper (map, offload_to_mirror, + &map_index, ¤t_group); +/* set mirror group to use next time */ + offload_to_mirror = + (offload_to_mirror >= map->layout_map_count -1 ) + ?0 : offload_to_mirror +1 ; +/* FIXME: remove after debug/dev */ +BUG_ON (offload_to_mirror >= map->layout_map_count); +dev_warn (&h->pdev->dev, +"DEBUG: Using physical disk map index %d from mirror group %d\n" , + map_index, offload_to_mirror); + dev->offload_to_mirror = offload_to_mirror; +/* Avoid direct use of dev->offload_to_mirror within this +* function since multiple threads might simultaneously +* increment it beyond the range of dev->layout_map_count -1. +*/ +break ; +case HPSA_RAID_5 : +case HPSA_RAID_6 : +if (map->layout_map_count <=1 ) +break ; + +/* Verify first and last block are in same RAID group */ + r5or6_blocks_per_row = + map->strip_size * map->data_disks_per_row; +BUG_ON (r5or6_blocks_per_row ==0 ); + stripesize = r5or6_blocks_per_row * map->layout_map_count; +#if BITS_PER_LONG ==32 + tmpdiv = first_block; + first_group =do_div (tmpdiv, stripesize); + tmpdiv = first_group; + (void )do_div (tmpdiv, r5or6_blocks_per_row); + first_group = tmpdiv; + tmpdiv = last_block; + last_group =do_div (tmpdiv, stripesize); + tmpdiv = last_group; + (void )do_div (tmpdiv, r5or6_blocks_per_row); + last_group = tmpdiv; +#else + first_group = (first_block % stripesize) / r5or6_blocks_per_row; + last_group = (last_block % stripesize) / r5or6_blocks_per_row; + if (first_group != last_group) +#endif +return IO_ACCEL_INELIGIBLE ; + +/* Verify request is in a single row of RAID 5/6 */ +#if BITS_PER_LONG ==32 + tmpdiv = first_block; + (void )do_div (tmpdiv, stripesize); + first_row = r5or6_first_row = r0_first_row = tmpdiv; + tmpdiv = last_block; + (void )do_div (tmpdiv, stripesize); + r5or6_last_row = r0_last_row = tmpdiv; +#else + first_row = r5or6_first_row = r0_first_row = + first_block / stripesize; + r5or6_last_row = r0_last_row = last_block / stripesize; +#endif +if (r5or6_first_row != r5or6_last_row) +return IO_ACCEL_INELIGIBLE ; + + +/* Verify request is in a single column */ +#if BITS_PER_LONG ==32 + tmpdiv = first_block; + first_row_offset =do_div (tmpdiv, stripesize); + tmpdiv = first_row_offset; + first_row_offset = (u32 )do_div (tmpdiv, r5or6_blocks_per_row); + r5or6_first_row_offset = first_row_offset; + tmpdiv = last_block; + r5or6_last_row_offset =do_div (tmpdiv, stripesize); + tmpdiv = r5or6_last_row_offset; + r5or6_last_row_offset =do_div (tmpdiv, r5or6_blocks_per_row); + tmpdiv = r5or6_first_row_offset; + (void )do_div (tmpdiv, map->strip_size); + first_column = r5or6_first_column = tmpdiv; + tmpdiv = r5or6_last_row_offset; + (void )do_div (tmpdiv, map->strip_size); + r5or6_last_column = tmpdiv; +#else + first_row_offset = r5or6_first_row_offset = + (u32)((first_block % stripesize) % + r5or6_blocks_per_row); + + r5or6_last_row_offset = + (u32)((last_block % stripesize) % + r5or6_blocks_per_row); + + first_column = r5or6_first_column = + r5or6_first_row_offset / map->strip_size; + r5or6_last_column = + r5or6_last_row_offset / map->strip_size; +#endif +if (r5or6_first_column != r5or6_last_column) +return IO_ACCEL_INELIGIBLE ; + +/* Request is eligible */ + map_row = ((u32)(first_row >> map->parity_rotation_shift)) % + map->row_cnt; + + map_index = (first_group * + (map->row_cnt * total_disks_per_row)) + + (map_row * total_disks_per_row) + first_column; +break ; +default : +return IO_ACCEL_INELIGIBLE ; } + disk_handle = dd[map_index].ioaccel_handle; disk_block = map->disk_starting_blk + (first_row * map->strip_size) + (first_row_offset - (first_column * map->strip_size));
PATCH 22/35 hpsa: allow user to disable accelerated i/o path
In reply to Stephen M. CameronFrom: Scott Teel <[email protected]>
Allow SSD Smart Path for a controller to be disabled by the user, regardless of settings in controller firmware or array configuration.
To disable: echo 0 > /sys/class/scsi_host/host<id>/acciopath_status To re-enable: echo 1 > /sys/class/scsi_host/host<id>/acciopath_status To check state: cat /sys/class/scsi_host/host<id>/acciopath_status
--- Documentation/ABI/testing/sysfs-class-scsi_host | 16 ++++++++ drivers/scsi/hpsa.c | 45 ++++++++++++++++++++++- drivers/scsi/hpsa.h | 1 + 3 files changed, 61 insertions(+), 1 deletions(-)
Documentation/ABI/testing/sysfs-class-scsi_host +16 -0
@@ -11,3 +11,19 @@ Description: guaranteed. The 'isci_id' attribute unambiguously identifies the controller index: '0' for the first controller, '1' for the second. + +What: /sys/class/scsi_host/hostX/acciopath_status +Date: November 2013 +Contact: Stephen M. Cameron <[email protected]> +Description: This file contains the current status of the "SSD Smart Path" + feature of HP Smart Array RAID controllers using the hpsa + driver. SSD Smart Path, when enabled permits the driver to + send i/o requests directly to physical devices that are part + of a logical drive, bypassing the controllers firmware RAID + stack for a performance advantage when possible. A value of + '1' indicates the feature is enabled, and the controller may + use the direct i/o path to physical devices. A value of zero + means the feature is disabled and the controller may not use + the direct i/o path to physical devices. This setting is + controller wide, affecting all configured logical drives on the + controller. This file is readable and writable.
drivers/scsi/hpsa.c +44 -1
81 lines not on this page · raw message
drivers/scsi/hpsa.h +1 -0
@@ -181,6 +181,7 @@ struct ctlr_info {#define HPSATMF_LOG_QRY_TSET (1 << 24)#define HPSATMF_LOG_QRY_ASYNC (1 << 25)u32 events; +int acciopath_status; };#define HPSA_ABORT_MSG 0#define HPSA_DEVICE_RESET_MSG 1
PATCH 23/35 hpsa: rescan devices on ioaccel2 error
In reply to Stephen M. CameronFrom: Scott Teel <[email protected]>
Allow driver to schedule a rescan whenever a request fails on the ioaccel2 path. This eliminates the possibility of driver getting stuck in non-ioaccel mode.
IOaccel mode (HP SSD Smart Path) is disabled by driver upon error detection. Driver relied on idea that request would be retried through normal path, and a subsequent error would occur on that path, and be processed by controller firmware. As part of that process, controller disables ioaccel mode and later reinstates it, signalling driver to change modes.
In some error cases, the error will not duplicate on the standard path, so the driver could get stuck in non-ioaccel mode.
To avoid that, we allow driver to request a rescan during the next run of the rescan thread.
--- drivers/scsi/hpsa.c | 12 ++++++++++-- drivers/scsi/hpsa.h | 1 + 2 files changed, 11 insertions(+), 2 deletions(-)
drivers/scsi/hpsa.c +10 -2
@@ -1457,6 +1457,7 @@ static void process_ioaccel2_completion(struct ctlr_info *h,"%s: Error 0x%02x, Retrying on standard path.\n" , "HP SSD Smart Path", c2->error_data.status); dev->offload_enabled =0 ; + h->drv_req_rescan =1 ;/* schedule controller for a rescan */ cmd->result =DID_SOFT_ERROR <<16 ;cmd_free (h, c); cmd->scsi_done (cmd);
@@ -6135,6 +6136,9 @@ static int hpsa_kickoff_rescan(struct ctlr_info *h)int i;char *event_type; +/* Clear the driver-requested rescan flag */ + h->drv_req_rescan =0 ; +/* Ask the controller to clear the events we're handling. */ if ((h->transMethod & (CFGTBL_Trans_io_accel1 | CFGTBL_Trans_io_accel2)) &&
@@ -6182,7 +6186,9 @@ static int hpsa_kickoff_rescan(struct ctlr_info *h)/* Check a register on the controller to see if there are configuration * changes (added/changed/removed logical drives, etc.) which mean that -* we should rescan the controller for devices. If so, add the controller +* we should rescan the controller for devices. +* Also check flag for driver-initiated rescan. +* If either flag or controller event indicate rescan, add the controller * to the list of controllers needing to be rescanned, and gets a * reference to the associated scsi_host. */
@@ -6192,7 +6198,7 @@ static void hpsa_ctlr_needs_rescan(struct ctlr_info *h)return ; h->events =readl (&(h->cfgtable->event_notify)); -if (!h->events) +if (!h->events && !h->drv_req_rescan)return ;/*
@@ -6366,6 +6372,8 @@ reinit_after_soft_reset:/* Enable Accelerated IO path at driver layer */ h->acciopath_status =1 ; + h->drv_req_rescan =0 ; +/* Turn the interrupts on so we can service requests */ h->access.set_intr_mask (h,HPSA_INTR_ON );
drivers/scsi/hpsa.h +1 -0
@@ -182,6 +182,7 @@ struct ctlr_info {#define HPSATMF_LOG_QRY_ASYNC (1 << 25)u32 events;int acciopath_status; +int drv_req_rescan;/* flag for driver to request rescan event */ };#define HPSA_ABORT_MSG 0#define HPSA_DEVICE_RESET_MSG 1
PATCH 24/35 hpsa: allow VPD page zero to be queried
In reply to Stephen M. CameronFrom: Stephen M. Cameron <[email protected]>
Code was confused and assumed that page zero was not VPD page and all non-zero pages were VPD pages.
--- drivers/scsi/hpsa.c | 17 +++++++++-------- 1 files changed, 9 insertions(+), 8 deletions(-)
drivers/scsi/hpsa.c +9 -8
@@ -183,8 +183,9 @@ static void cmd_special_free(struct ctlr_info *h, struct CommandList *c);static struct CommandList *cmd_alloc (struct ctlr_info *h);static struct CommandList *cmd_special_alloc (struct ctlr_info *h);static int fill_cmd (struct CommandList *c,u8 cmd,struct ctlr_info *h, -void *buff,size_t size,u8 page_code,unsigned char *scsi3addr, +void *buff,size_t size,u16 page_code,unsigned char *scsi3addr,int cmd_type); +#define VPD_PAGE (1 << 8)static int hpsa_scsi_queue_command (struct Scsi_Host *h,struct scsi_cmnd *cmd);static void hpsa_scan_start (struct Scsi_Host *);
@@ -1878,7 +1879,7 @@ static void hpsa_scsi_interpret_error(struct CommandList *cp) }static int hpsa_scsi_do_inquiry (struct ctlr_info *h,unsigned char *scsi3addr, -unsigned char page,unsigned char *buf, +u16 page,unsigned char *buf,unsigned char bufsize) {int rc =IO_OK ;
@@ -1948,7 +1949,7 @@ static void hpsa_get_raid_level(struct ctlr_info *h, buf =kzalloc (64 ,GFP_KERNEL );if (!buf)return ; - rc =hpsa_scsi_do_inquiry (h, scsi3addr,0xC1 , buf,64 ); + rc =hpsa_scsi_do_inquiry (h, scsi3addr,VPD_PAGE |0xC1 , buf,64 );if (rc ==0 ) *raid_level = buf[8 ];if (*raid_level >RAID_UNKNOWN )
@@ -2077,7 +2078,7 @@ static void hpsa_get_ioaccel_status(struct ctlr_info *h,if (!buf)return ; rc =hpsa_scsi_do_inquiry (h, scsi3addr, -HPSA_VPD_LV_IOACCEL_STATUS , buf,64 ); +VPD_PAGE |HPSA_VPD_LV_IOACCEL_STATUS , buf,64 );if (rc !=0 ) goto out;
@@ -2110,7 +2111,7 @@ static int hpsa_get_device_id(struct ctlr_info *h, unsigned char *scsi3addr, buf =kzalloc (64 ,GFP_KERNEL );if (!buf)return -1 ; - rc =hpsa_scsi_do_inquiry (h, scsi3addr,0x83 , buf,64 ); + rc =hpsa_scsi_do_inquiry (h, scsi3addr,VPD_PAGE |0x83 , buf,64 );if (rc ==0 )memcpy (device_id, &buf[8 ], buflen);kfree (buf);
@@ -4629,7 +4630,7 @@ static int hpsa_send_host_reset(struct ctlr_info *h, unsigned char *scsi3addr, }static int fill_cmd (struct CommandList *c,u8 cmd,struct ctlr_info *h, -void *buff,size_t size,u8 page_code,unsigned char *scsi3addr, +void *buff,size_t size,u16 page_code,unsigned char *scsi3addr,int cmd_type) {int pci_dir =XFER_NONE ;
@@ -4652,9 +4653,9 @@ static int fill_cmd(struct CommandList *c, u8 cmd, struct ctlr_info *h,switch (cmd) {case HPSA_INQUIRY :/* are we trying to read a vital product page */ -if (page_code !=0 ) { +if (page_code &VPD_PAGE ) { c->Request.CDB[1 ] =0x01 ; - c->Request.CDB[2 ] = page_code; + c->Request.CDB[2 ] = (page_code &0xff ); } c->Request.CDBLen =6 ; c->Request.Type.Attribute =ATTR_SIMPLE ;
PATCH 25/35 hpsa: do not inquire for unsupported ioaccel status vpd page
In reply to Stephen M. CameronFrom: Stephen M. Cameron <[email protected]>
--- drivers/scsi/hpsa.c | 45 +++++++++++++++++++++++++++++++++++++++++++++ drivers/scsi/hpsa_cmd.h | 2 ++ 2 files changed, 47 insertions(+), 0 deletions(-)
drivers/scsi/hpsa.c +45 -0
@@ -2064,6 +2064,49 @@ static int hpsa_get_raid_map(struct ctlr_info *h,return rc; } +static int hpsa_vpd_page_supported (struct ctlr_info *h, +unsigned char scsi3addr[],u8 page) +{ +int rc; +int i; +int pages; +unsigned char *buf, bufsize; + + buf =kzalloc (256 ,GFP_KERNEL ); +if (!buf) +return 0 ; + +/* Get the size of the page list first */ + rc =hpsa_scsi_do_inquiry (h, scsi3addr, +VPD_PAGE |HPSA_VPD_SUPPORTED_PAGES , + buf,HPSA_VPD_HEADER_SZ ); +if (rc !=0 ) + goto exit_unsupported; + pages = buf[3 ]; +if ((pages +HPSA_VPD_HEADER_SZ ) <=255 ) + bufsize = pages +HPSA_VPD_HEADER_SZ ; +else + bufsize =255 ; + +/* Get the whole VPD page list */ + rc =hpsa_scsi_do_inquiry (h, scsi3addr, +VPD_PAGE |HPSA_VPD_SUPPORTED_PAGES , + buf, bufsize); +if (rc !=0 ) + goto exit_unsupported; + + pages = buf[3 ]; +for (i =1 ; i <= pages; i++) +if (buf[3 + i] == page) + goto exit_supported; +exit_unsupported: +kfree (buf); +return 0 ; +exit_supported: +kfree (buf); +return 1 ; +} +static void hpsa_get_ioaccel_status (struct ctlr_info *h,unsigned char *scsi3addr,struct hpsa_scsi_dev_t *this_device) {
@@ -2077,6 +2120,8 @@ static void hpsa_get_ioaccel_status(struct ctlr_info *h, buf =kzalloc (64 ,GFP_KERNEL );if (!buf)return ; +if (!hpsa_vpd_page_supported (h, scsi3addr,HPSA_VPD_LV_IOACCEL_STATUS )) + goto out; rc =hpsa_scsi_do_inquiry (h, scsi3addr,VPD_PAGE |HPSA_VPD_LV_IOACCEL_STATUS , buf,64 );if (rc !=0 )
drivers/scsi/hpsa_cmd.h +2 -0
@@ -144,8 +144,10 @@#define CFGTBL_BusType_Fibre2G 0x00000200l/* VPD Inquiry types */ +#define HPSA_VPD_SUPPORTED_PAGES 0x00#define HPSA_VPD_LV_DEVICE_GEOMETRY 0xC1#define HPSA_VPD_LV_IOACCEL_STATUS 0xC2 +#define HPSA_VPD_HEADER_SZ 4struct vals32 {u32 lower;
PATCH 26/35 hpsa: retry certain ioaccel error cases on the RAID path
In reply to Stephen M. CameronFrom: Scott Teel <[email protected]>
Change the handling of HP SSD Smart Path errors with status:
0x02 CHECK CONDITION
0x08 BUSY
0x18 RESERVATION CONFLICT
0x40 TASK ABORTED
So that they get retried on the RAID Path.
--- drivers/scsi/hpsa.c | 45 +++++++++++++++++++++++++++++++++++++++------ 1 files changed, 39 insertions(+), 6 deletions(-)
drivers/scsi/hpsa.c +39 -6
@@ -1351,12 +1351,18 @@ static void hpsa_unmap_sg_chain_block(struct ctlr_info *h,pci_unmap_single (h->pdev, temp64.val, chain_sg->Len,PCI_DMA_TODEVICE ); } -static void handle_ioaccel_mode2_error (struct ctlr_info *h, + +/* Decode the various types of errors on ioaccel2 path. +* Return 1 for any error that should generate a RAID path retry. +* Return 0 for errors that don't require a RAID path retry. +*/ +static int handle_ioaccel_mode2_error (struct ctlr_info *h,struct CommandList *c,struct scsi_cmnd *cmd,struct io_accel2_cmd *c2) {int data_len; +int retry =0 ;switch (c2->error_data.serv_response) {case IOACCEL2_SERV_RESPONSE_COMPLETE :
@@ -1380,16 +1386,19 @@ static void handle_ioaccel_mode2_error(struct ctlr_info *h,memcpy (cmd->sense_buffer, c2->error_data.sense_data_buff, data_len); cmd->result |=SAM_STAT_CHECK_CONDITION ; + retry =1 ;break ;case IOACCEL2_STATUS_SR_TASK_COMP_BUSY :dev_warn (&h->pdev->dev,"%s: task complete with BUSY status.\n" ,"HP SSD Smart Path" ); + retry =1 ;break ;case IOACCEL2_STATUS_SR_TASK_COMP_RES_CON :dev_warn (&h->pdev->dev,"%s: task complete with reservation conflict.\n" ,"HP SSD Smart Path" ); + retry =1 ;break ;case IOACCEL2_STATUS_SR_TASK_COMP_SET_FULL :/* Make scsi midlayer do unlimited retries */
@@ -1399,11 +1408,13 @@ static void handle_ioaccel_mode2_error(struct ctlr_info *h,dev_warn (&h->pdev->dev,"%s: task complete with aborted status.\n" ,"HP SSD Smart Path" ); + retry =1 ;break ;default :dev_warn (&h->pdev->dev,"%s: task complete with unrecognized status: 0x%02x\n" ,"HP SSD Smart Path" , c2->error_data.status); + retry =1 ;break ; }break ;
@@ -1412,6 +1423,7 @@ static void handle_ioaccel_mode2_error(struct ctlr_info *h,dev_warn (&h->pdev->dev,"unexpected delivery or target failure, status = 0x%02x\n" , c2->error_data.status); + retry =1 ;break ;case IOACCEL2_SERV_RESPONSE_TMF_COMPLETE :break ;
@@ -1419,6 +1431,7 @@ static void handle_ioaccel_mode2_error(struct ctlr_info *h,break ;case IOACCEL2_SERV_RESPONSE_TMF_REJECTED :dev_warn (&h->pdev->dev,"task management function rejected.\n" ); + retry =1 ;break ;case IOACCEL2_SERV_RESPONSE_TMF_WRONG_LUN :dev_warn (&h->pdev->dev,"task management function invalid LUN\n" );
@@ -1426,9 +1439,13 @@ static void handle_ioaccel_mode2_error(struct ctlr_info *h,default :dev_warn (&h->pdev->dev,"%s: Unrecognized server response: 0x%02x\n" , -"HP SSD Smart Path" , c2->error_data.serv_response); +"HP SSD Smart Path" , + c2->error_data.serv_response); + retry =1 ;break ; } + +return retry;/* retry on raid path? */ } static void process_ioaccel2_completion(struct ctlr_info *h,
@@ -1436,6 +1453,7 @@ static void process_ioaccel2_completion(struct ctlr_info *h, struct hpsa_scsi_dev_t *dev) {struct io_accel2_cmd *c2 = &h->ioaccel2_cmd_pool[c->cmdindex]; +int raid_retry =0 ;/* check for good status */ if (likely(c2->error_data.serv_response == 0 &&
@@ -1452,11 +1470,16 @@ static void process_ioaccel2_completion(struct ctlr_info *h,if (is_logical_dev_addr_mode (dev->scsi3addr) && c2->error_data.serv_response ==IOACCEL2_SERV_RESPONSE_FAILURE ) { -if (c2->error_data.status != -IOACCEL2_STATUS_SR_IOACCEL_DISABLED ) +if (c2->error_data.status == +IOACCEL2_STATUS_SR_IOACCEL_DISABLED ) +dev_warn (&h->pdev->dev, +"%s: Path is unavailable, retrying on standard path.\n" , +"HP SSD Smart Path" ); +else dev_warn (&h->pdev->dev, -"%s: Error 0x%02x, Retrying on standard path.\n" , +"%s: Error 0x%02x, retrying on standard path.\n" ,"HP SSD Smart Path" , c2->error_data.status); + dev->offload_enabled =0 ; h->drv_req_rescan =1 ;/* schedule controller for a rescan */ cmd->result =DID_SOFT_ERROR <<16 ;
@@ -1464,7 +1487,17 @@ static void process_ioaccel2_completion(struct ctlr_info *h, cmd->scsi_done (cmd);return ; } -handle_ioaccel_mode2_error (h, c, cmd, c2); + raid_retry =handle_ioaccel_mode2_error (h, c, cmd, c2); +/* If error found, disable Smart Path, schedule a rescan, +* and force a retry on the standard path. +*/ +if (raid_retry) { +dev_warn (&h->pdev->dev,"%s: Retrying on standard path.\n" , +"HP SSD Smart Path" ); + dev->offload_enabled =0 ;/* Disable Smart Path */ + h->drv_req_rescan =1 ;/* schedule controller rescan */ + cmd->result =DID_SOFT_ERROR <<16 ; + }cmd_free (h, c); cmd->scsi_done (cmd); }
PATCH 27/35 hpsa: update source file copyrights
In reply to Stephen M. CameronFrom: Scott Teel <[email protected]>
--- drivers/scsi/hpsa.c | 2 +- drivers/scsi/hpsa.h | 2 +- drivers/scsi/hpsa_cmd.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
drivers/scsi/hpsa.c +1 -1
@@ -1,6 +1,6 @@/* * Disk Array driver for HP Smart Array SAS controllers -* Copyright 2000, 2009 Hewlett-Packard Development Company, L.P. +* Copyright 2000, 2014 Hewlett-Packard Development Company, L.P. * * 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
drivers/scsi/hpsa.h +1 -1
@@ -1,6 +1,6 @@/* * Disk Array driver for HP Smart Array SAS controllers -* Copyright 2000, 2009 Hewlett-Packard Development Company, L.P. +* Copyright 2000, 2014 Hewlett-Packard Development Company, L.P. * * 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
drivers/scsi/hpsa_cmd.h +1 -1
@@ -1,6 +1,6 @@/* * Disk Array driver for HP Smart Array SAS controllers -* Copyright 2000, 2009 Hewlett-Packard Development Company, L.P. +* Copyright 2000, 2014 Hewlett-Packard Development Company, L.P. * * 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
PATCH 28/35 hpsa: add controller base data-at-rest encryption compatibility ioaccel2
In reply to Stephen M. CameronFrom: Scott Teel <[email protected]>
Add controller-based data-at-rest encryption compatibility to ioaccel2 path (HP SSD Smart Path).
Encryption feature requires driver to supply additional fields for encryption enable, tweak index, and data encryption key index in the ioaccel2 request structure.
Encryption enable flag and data encryption key index come from raid_map data structure from raid offload command.
During ioaccel2 submission, check device structure's raid map to see if encryption is enabled for the device. If so, call new function below.
Add function set_encrypt_ioaccel2 to set encryption flag, data encryption key index, and calculate tweak value from request's logical block address.
--- drivers/scsi/hpsa.c | 179 +++++++++++++++++++++++++++++++++++++++++++++-- drivers/scsi/hpsa_cmd.h | 19 ++++- 2 files changed, 184 insertions(+), 14 deletions(-)
drivers/scsi/hpsa.c +170 -9
@@ -2027,6 +2027,14 @@ static void hpsa_debug_map_buff(struct ctlr_info *h, int rc, le16_to_cpu(map_buff->row_cnt));dev_info (&h->pdev->dev,"layout_map_count = %u\n" ,le16_to_cpu (map_buff->layout_map_count)); +dev_info (&h->pdev->dev,"flags = %u\n" , +le16_to_cpu (map_buff->flags)); +if (map_buff->flags &RAID_MAP_FLAG_ENCRYPT_ON ) +dev_info (&h->pdev->dev,"encrypytion = ON\n" ); +else +dev_info (&h->pdev->dev,"encrypytion = OFF\n" ); +dev_info (&h->pdev->dev,"dekindex = %u\n" , +le16_to_cpu (map_buff->dekindex)); map_cnt =le16_to_cpu (map_buff->layout_map_count);for (map =0 ; map < map_cnt; map++) {
@@ -2967,6 +2975,128 @@ static int hpsa_scsi_ioaccel_direct_map(struct ctlr_info *h, cmd->cmnd, cmd->cmd_len, dev->scsi3addr); } +/* +* Set encryption parameters for the ioaccel2 request +*/ +static void set_encrypt_ioaccel2 (struct ctlr_info *h, +struct CommandList *c,struct io_accel2_cmd *cp) +{ +struct scsi_cmnd *cmd = c->scsi_cmd; +struct hpsa_scsi_dev_t *dev = cmd->device->hostdata; +struct raid_map_data *map = &dev->raid_map; +u64 first_block; + +BUG_ON (!(dev->offload_config && dev->offload_enabled)); + +/* Are we doing encryption on this device */ +if (!(map->flags &RAID_MAP_FLAG_ENCRYPT_ON )) +return ; +/* Set the data encryption key index. */ + cp->dekindex = map->dekindex; + +/* Set the encryption enable flag, encoded into direction field. */ + cp->direction |=IOACCEL2_DIRECTION_ENCRYPT_MASK ; + +/* Set encryption tweak values based on logical block address +* If block size is 512, tweak value is LBA. +* For other block sizes, tweak is (LBA * block size)/ 512) +*/ +switch (cmd->cmnd[0 ]) { +/* Required? 6-byte cdbs eliminated by fixup_ioaccel_cdb */ +case WRITE_6 : +case READ_6 : +if (map->volume_blk_size ==512 ) { + cp->tweak_lower = + (((u32 ) cmd->cmnd[2 ]) <<8 ) | + cmd->cmnd[3 ]; + cp->tweak_upper =0 ; + }else { + first_block = + (((u64 ) cmd->cmnd[2 ]) <<8 ) | + cmd->cmnd[3 ]; + first_block = (first_block * map->volume_blk_size)/512 ; + cp->tweak_lower = (u32 )first_block; + cp->tweak_upper = (u32)(first_block >>32 ); + } +break ; +case WRITE_10 : +case READ_10 : +if (map->volume_blk_size ==512 ) { + cp->tweak_lower = + (((u32 ) cmd->cmnd[2 ]) <<24 ) | + (((u32 ) cmd->cmnd[3 ]) <<16 ) | + (((u32 ) cmd->cmnd[4 ]) <<8 ) | + cmd->cmnd[5 ]; + cp->tweak_upper =0 ; + }else { + first_block = + (((u64 ) cmd->cmnd[2 ]) <<24 ) | + (((u64 ) cmd->cmnd[3 ]) <<16 ) | + (((u64 ) cmd->cmnd[4 ]) <<8 ) | + cmd->cmnd[5 ]; + first_block = (first_block * map->volume_blk_size)/512 ; + cp->tweak_lower = (u32 )first_block; + cp->tweak_upper = (u32)(first_block >>32 ); + } +break ; +/* Required? 12-byte cdbs eliminated by fixup_ioaccel_cdb */ +case WRITE_12 : +case READ_12 : +if (map->volume_blk_size ==512 ) { + cp->tweak_lower = + (((u32 ) cmd->cmnd[2 ]) <<24 ) | + (((u32 ) cmd->cmnd[3 ]) <<16 ) | + (((u32 ) cmd->cmnd[4 ]) <<8 ) | + cmd->cmnd[5 ]; + cp->tweak_upper =0 ; + }else { + first_block = + (((u64 ) cmd->cmnd[2 ]) <<24 ) | + (((u64 ) cmd->cmnd[3 ]) <<16 ) | + (((u64 ) cmd->cmnd[4 ]) <<8 ) | + cmd->cmnd[5 ]; + first_block = (first_block * map->volume_blk_size)/512 ; + cp->tweak_lower = (u32 )first_block; + cp->tweak_upper = (u32)(first_block >>32 ); + } +break ; +case WRITE_16 : +case READ_16 : +if (map->volume_blk_size ==512 ) { + cp->tweak_lower = + (((u32 ) cmd->cmnd[6 ]) <<24 ) | + (((u32 ) cmd->cmnd[7 ]) <<16 ) | + (((u32 ) cmd->cmnd[8 ]) <<8 ) | + cmd->cmnd[9 ]; + cp->tweak_upper = + (((u32 ) cmd->cmnd[2 ]) <<24 ) | + (((u32 ) cmd->cmnd[3 ]) <<16 ) | + (((u32 ) cmd->cmnd[4 ]) <<8 ) | + cmd->cmnd[5 ]; + }else { + first_block = + (((u64 ) cmd->cmnd[2 ]) <<56 ) | + (((u64 ) cmd->cmnd[3 ]) <<48 ) | + (((u64 ) cmd->cmnd[4 ]) <<40 ) | + (((u64 ) cmd->cmnd[5 ]) <<32 ) | + (((u64 ) cmd->cmnd[6 ]) <<24 ) | + (((u64 ) cmd->cmnd[7 ]) <<16 ) | + (((u64 ) cmd->cmnd[8 ]) <<8 ) | + cmd->cmnd[9 ]; + first_block = (first_block * map->volume_blk_size)/512 ; + cp->tweak_lower = (u32 )first_block; + cp->tweak_upper = (u32)(first_block >>32 ); + } +break ; +default : +dev_err (&h->pdev->dev, +"ERROR: %s: IOACCEL request CDB size not supported for encryption\n" , + __func__); +BUG (); +break ; + } +} +static int hpsa_scsi_ioaccel2_queue_command (struct ctlr_info *h,struct CommandList *c,u32 ioaccel_handle,u8 *cdb,int cdb_len,u8 *scsi3addr)
@@ -3016,13 +3146,16 @@ static int hpsa_scsi_ioaccel2_queue_command(struct ctlr_info *h,switch (cmd->sc_data_direction) {case DMA_TO_DEVICE : - cp->direction =IOACCEL2_DIR_DATA_OUT ; + cp->direction &= ~IOACCEL2_DIRECTION_MASK ; + cp->direction |=IOACCEL2_DIR_DATA_OUT ;break ;case DMA_FROM_DEVICE : - cp->direction =IOACCEL2_DIR_DATA_IN ; + cp->direction &= ~IOACCEL2_DIRECTION_MASK ; + cp->direction |=IOACCEL2_DIR_DATA_IN ;break ;case DMA_NONE : - cp->direction =IOACCEL2_DIR_NO_DATA ; + cp->direction &= ~IOACCEL2_DIRECTION_MASK ; + cp->direction |=IOACCEL2_DIR_NO_DATA ;break ;default : dev_err(&h->pdev->dev, "unknown data direction: %d\n",
@@ -3031,10 +3164,15 @@ static int hpsa_scsi_ioaccel2_queue_command(struct ctlr_info *h,break ; } }else { - cp->direction =IOACCEL2_DIR_NO_DATA ; + cp->direction &= ~IOACCEL2_DIRECTION_MASK ; + cp->direction |=IOACCEL2_DIR_NO_DATA ; } + +/* Set encryption parameters, if necessary */ +set_encrypt_ioaccel2 (h, c, cp); + cp->scsi_nexus = ioaccel_handle; - cp->Tag.lower = (c->cmdindex <<DIRECT_LOOKUP_SHIFT ) | + cp->Tag = (c->cmdindex <<DIRECT_LOOKUP_SHIFT ) |DIRECT_LOOKUP_BIT ;memcpy (cp->cdb, cdb,sizeof (cp->cdb));memset (cp->cciss_lun,0 ,sizeof (cp->cciss_lun));
@@ -3792,8 +3930,9 @@ static void hpsa_get_tag(struct ctlr_info *h,if (c->cmd_type ==CMD_IOACCEL2 ) {struct io_accel2_cmd *cm2 = (struct io_accel2_cmd *) &h->ioaccel2_cmd_pool[c->cmdindex]; - *tagupper = cm2->Tag.upper; - *taglower = cm2->Tag.lower; +/* upper tag not used in ioaccel2 mode */ +memset (tagupper,0 ,sizeof (*tagupper)); + *taglower = cm2->Tag;return ; } *tagupper = c->Header.Tag.upper;
@@ -3841,8 +3980,8 @@ static int hpsa_send_abort(struct ctlr_info *h, unsigned char *scsi3addr,break ; }cmd_special_free (h, c); -dev_dbg (&h->pdev->dev,"%s: Tag:0x%08x:%08x: Finished.\n" , __func__, - abort->Header.Tag.upper, abort->Header.Tag.lower); +dev_dbg (&h->pdev->dev,"%s: Tag:0x%08x:%08x: Finished.\n" , + __func__, tagupper, taglower);return rc; }
@@ -6968,6 +7107,28 @@ static void __exit hpsa_cleanup(void)static void __attribute__((unused))verify_offsets (void ) {#define VERIFY_OFFSET (member, offset) \ + BUILD_BUG_ON(offsetof(struct raid_map_data, member) != offset) + +VERIFY_OFFSET (structure_size,0 ); +VERIFY_OFFSET (volume_blk_size,4 ); +VERIFY_OFFSET (volume_blk_cnt,8 ); +VERIFY_OFFSET (phys_blk_shift,16 ); +VERIFY_OFFSET (parity_rotation_shift,17 ); +VERIFY_OFFSET (strip_size,18 ); +VERIFY_OFFSET (disk_starting_blk,20 ); +VERIFY_OFFSET (disk_blk_cnt,28 ); +VERIFY_OFFSET (data_disks_per_row,36 ); +VERIFY_OFFSET (metadata_disks_per_row,38 ); +VERIFY_OFFSET (row_cnt,40 ); +VERIFY_OFFSET (layout_map_count,42 ); +VERIFY_OFFSET (flags,44 ); +VERIFY_OFFSET (dekindex,46 ); +/* VERIFY_OFFSET(reserved, 48 */ +VERIFY_OFFSET (data,64 ); + +#undef VERIFY_OFFSET + +#define VERIFY_OFFSET (member, offset) \ BUILD_BUG_ON(offsetof(struct io_accel2_cmd, member) != offset)VERIFY_OFFSET (IU_type,0 );
drivers/scsi/hpsa_cmd.h +14 -5
@@ -209,7 +209,10 @@ struct raid_map_data {u16 row_cnt;/* rows in each layout map */ u16 layout_map_count;/* layout maps (1 map per mirror/parity * group) */ -u8 reserved[20 ]; +u16 flags;/* Bit 0 set if encryption enabled */ +#define RAID_MAP_FLAG_ENCRYPT_ON 0x01 +u16 dekindex;/* Data encryption key index. */ +u8 reserved[16 ];struct raid_map_disk_data data[RAID_MAP_MAX_ENTRIES ]; };
@@ -502,11 +505,17 @@ struct io_accel2_scsi_response {*/ struct io_accel2_cmd {u8 IU_type;/* IU Type */ -u8 direction;/* Transfer direction, 2 bits */ +u8 direction;/* direction, memtype, and encryption */ +#define IOACCEL2_DIRECTION_MASK 0x03/* bits 0,1: direction */ +#define IOACCEL2_DIRECTION_MEMTYPE_MASK 0x04/* bit 2: memtype source/dest */ +/* 0b=PCIe, 1b=DDR */ +#define IOACCEL2_DIRECTION_ENCRYPT_MASK 0x08/* bit 3: encryption flag */ +/* 0=off, 1=on */ u8 reply_queue;/* Reply Queue ID */ u8 reserved1;/* Reserved */ u32 scsi_nexus;/* Device Handle */ -struct vals32 Tag;/* cciss tag */ +u32 Tag;/* cciss tag, lower 4 bytes only */ +u32 tweak_lower;/* Encryption tweak, lower 4 bytes */ u8 cdb[16 ];/* SCSI Command Descriptor Block */ u8 cciss_lun[8 ];/* 8 byte SCSI address */ u32 data_len;/* Total bytes to transfer */
@@ -514,10 +523,10 @@ struct io_accel2_cmd {#define IOACCEL2_PRIORITY_MASK 0x78#define IOACCEL2_ATTR_MASK 0x07u8 sg_count;/* Number of sg elements */ -u8 reserved3[2 ];/* Reserved */ +u16 dekindex;/* Data encryption key index */ u64 err_ptr;/* Error Pointer */ u32 err_len;/* Error Length*/ -u8 reserved4[4 ];/* Reserved */ +u32 tweak_upper;/* Encryption tweak, upper 4 bytes */ struct ioaccel2_sg_element sg[IOACCEL2_MAXSGENTRIES ];struct io_accel2_scsi_response error_data;u8 pad[IOACCEL2_PAD ];
PATCH 29/35 hpsa: when switching out of accel mode await only accel command completions
In reply to Stephen M. CameronFrom: Stephen M. Cameron <[email protected]>
Don't wait for *all* commands to complete, only for accelerated mode commands.
--- drivers/scsi/hpsa.c | 22 ++++++++++++++++------ 1 files changed, 16 insertions(+), 6 deletions(-)
drivers/scsi/hpsa.c +16 -6
@@ -221,7 +221,7 @@ static inline void finish_cmd(struct CommandList *c);static void hpsa_wait_for_mode_change_ack (struct ctlr_info *h);#define BOARD_NOT_READY 0#define BOARD_READY 1 -static void hpsa_drain_commands (struct ctlr_info *h); +static void hpsa_drain_accel_commands (struct ctlr_info *h);static void hpsa_flush_cache (struct ctlr_info *h); static int hpsa_scsi_ioaccel_queue_command(struct ctlr_info *h, struct CommandList *c, u32 ioaccel_handle, u8 *cdb, int cdb_len,
@@ -6371,7 +6371,7 @@ static int hpsa_kickoff_rescan(struct ctlr_info *h)scsi_block_requests (h->scsi_host);for (i =0 ; i < h->ndevices; i++) h->dev[i]->offload_enabled =0 ; -hpsa_drain_commands (h); +hpsa_drain_accel_commands (h);/* Set 'accelerator path config change' bit */ dev_warn(&h->pdev->dev, "Acknowledging event: 0x%08x (HP SSD Smart Path %s)\n",
@@ -7075,16 +7075,26 @@ clean_up:kfree (h->blockFetchTable); } -static void hpsa_drain_commands (struct ctlr_info *h) +static int is_accelerated_cmd (struct CommandList *c) { -int cmds_out; +return c->cmd_type ==CMD_IOACCEL1 || c->cmd_type ==CMD_IOACCEL2 ; +} + +static void hpsa_drain_accel_commands (struct ctlr_info *h) +{ +struct CommandList *c =NULL ;unsigned long flags; +int accel_cmds_out;do {/* wait for all outstanding commands to drain out */ + accel_cmds_out =0 ;spin_lock_irqsave (&h->lock, flags); - cmds_out = h->commands_outstanding; +list_for_each_entry (c, &h->cmpQ, list) + accel_cmds_out +=is_accelerated_cmd (c); +list_for_each_entry (c, &h->reqQ, list) + accel_cmds_out +=is_accelerated_cmd (c);spin_unlock_irqrestore (&h->lock, flags); -if (cmds_out <=0 ) +if (accel_cmds_out <=0 )break ;msleep (100 ); }while (1 );
PATCH 30/35 hpsa: only do device rescan for certain events
In reply to Stephen M. CameronFrom: Stephen M. Cameron <[email protected]>
Do no rescan on every events -- way too many rescans are triggered if we don't filter the events. Limit rescans to be triggered by the following set of events:
* controller state change
* enclosure hot plug
* physical drive state change
* logical drive state change
* redundant controller state change
* accelerated io enabled/disabled
* accelerated io configuration change
--- drivers/scsi/hpsa.c | 2 +- drivers/scsi/hpsa.h | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletions(-)
drivers/scsi/hpsa.c +1 -1
@@ -6416,7 +6416,7 @@ static void hpsa_ctlr_needs_rescan(struct ctlr_info *h)return ; h->events =readl (&(h->cfgtable->event_notify)); -if (!h->events && !h->drv_req_rescan) +if (!(h->events &RESCAN_REQUIRED_EVENT_BITS ) && !h->drv_req_rescan)return ;/*
drivers/scsi/hpsa.h +16 -0
@@ -181,6 +181,22 @@ struct ctlr_info {#define HPSATMF_LOG_QRY_TSET (1 << 24)#define HPSATMF_LOG_QRY_ASYNC (1 << 25)u32 events; +#define CTLR_STATE_CHANGE_EVENT (1 << 0) +#define CTLR_ENCLOSURE_HOT_PLUG_EVENT (1 << 1) +#define CTLR_STATE_CHANGE_EVENT_PHYSICAL_DRV (1 << 4) +#define CTLR_STATE_CHANGE_EVENT_LOGICAL_DRV (1 << 5) +#define CTLR_STATE_CHANGE_EVENT_REDUNDANT_CNTRL (1 << 6) +#define CTLR_STATE_CHANGE_EVENT_AIO_ENABLED_DISABLED (1 << 30) +#define CTLR_STATE_CHANGE_EVENT_AIO_CONFIG_CHANGE (1 << 31) + +#define RESCAN_REQUIRED_EVENT_BITS \ + (CTLR_STATE_CHANGE_EVENT | \ + CTLR_ENCLOSURE_HOT_PLUG_EVENT | \ + CTLR_STATE_CHANGE_EVENT_PHYSICAL_DRV | \ + CTLR_STATE_CHANGE_EVENT_LOGICAL_DRV | \ + CTLR_STATE_CHANGE_EVENT_REDUNDANT_CNTRL | \ + CTLR_STATE_CHANGE_EVENT_AIO_ENABLED_DISABLED | \ + CTLR_STATE_CHANGE_EVENT_AIO_CONFIG_CHANGE)int acciopath_status;int drv_req_rescan;/* flag for driver to request rescan event */ };
PATCH 31/35 hpsa: improve error messages for driver initiated commands
In reply to Stephen M. CameronFrom: Stephen M. Cameron <[email protected]>
On encountering unexpected error conditions from driver initiated commands, print something useful like CDB and sense data rather than something useless like the kernel virtual address of the command buffer.
--- drivers/scsi/hpsa.c | 71 ++++++++++++++++++++++++++++++++------------------- 1 files changed, 44 insertions(+), 27 deletions(-)
drivers/scsi/hpsa.c +44 -27
@@ -1847,17 +1847,37 @@ static void hpsa_scsi_do_simple_cmd_with_retry(struct ctlr_info *h,hpsa_pci_unmap (h->pdev, c,1 , data_direction); } -static void hpsa_scsi_interpret_error (struct CommandList *cp) +static void hpsa_print_cmd (struct ctlr_info *h,char *txt, +struct CommandList *c) { -struct ErrorInfo *ei; +const u8 *cdb = c->Request.CDB; +const u8 *lun = c->Header.LUN.LunAddrBytes; + +dev_warn (&h->pdev->dev,"%s: LUN:%02x%02x%02x%02x%02x%02x%02x%02x" +" CDB:%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x\n" , + txt, lun[0 ], lun[1 ], lun[2 ], lun[3 ], + lun[4 ], lun[5 ], lun[6 ], lun[7 ], + cdb[0 ], cdb[1 ], cdb[2 ], cdb[3 ], + cdb[4 ], cdb[5 ], cdb[6 ], cdb[7 ], + cdb[8 ], cdb[9 ], cdb[10 ], cdb[11 ], + cdb[12 ], cdb[13 ], cdb[14 ], cdb[15 ]); +} + +static void hpsa_scsi_interpret_error (struct ctlr_info *h, +struct CommandList *cp) +{ +const struct ErrorInfo *ei = cp->err_info;struct device *d = &cp->h->pdev->dev; +const u8 *sd = ei->SenseInfo; - ei = cp->err_info;switch (ei->CommandStatus) {case CMD_TARGET_STATUS : -dev_warn (d,"cmd %p has completed with errors\n" , cp); -dev_warn (d,"cmd %p has SCSI Status = %x\n" , cp, - ei->ScsiStatus); +hpsa_print_cmd (h,"SCSI status" , cp); +if (ei->ScsiStatus ==SAM_STAT_CHECK_CONDITION ) +dev_warn (d,"SCSI Status = 02, Sense key = %02x, ASC = %02x, ASCQ = %02x\n" , + sd[2 ] &0x0f , sd[12 ], sd[13 ]); +else +dev_warn (d,"SCSI Status = %02x\n" , ei->ScsiStatus);if (ei->ScsiStatus ==0 )dev_warn (d,"SCSI status is abnormally zero. " "(probably indicates selection timeout "
@@ -1865,48 +1885,45 @@ static void hpsa_scsi_interpret_error(struct CommandList *cp) "firmware bug, circa July, 2001.)\n");break ;case CMD_DATA_UNDERRUN :/* let mid layer handle it. */ -dev_info (d,"UNDERRUN\n" );break ;case CMD_DATA_OVERRUN : -dev_warn (d,"cp %p has completed with data overrun\n" , cp); +hpsa_print_cmd (h,"overrun condition" , cp);break ;case CMD_INVALID : {/* controller unfortunately reports SCSI passthru's * to non-existent targets as invalid commands. */ -dev_warn (d,"cp %p is reported invalid (probably means " -"target device no longer present)\n" , cp); -/* print_bytes((unsigned char *) cp, sizeof(*cp), 1, 0); -print_cmd(cp); */ +hpsa_print_cmd (h,"invalid command" , cp); +dev_warn (d,"probably means device no longer present\n" ); }break ;case CMD_PROTOCOL_ERR : -dev_warn (d,"cp %p has protocol error \n" , cp); +hpsa_print_cmd (h,"protocol error" , cp);break ;case CMD_HARDWARE_ERR : -/* cmd->result = DID_ERROR << 16; */ -dev_warn (d,"cp %p had hardware error\n" , cp); +hpsa_print_cmd (h,"hardware error" , cp);break ;case CMD_CONNECTION_LOST : -dev_warn (d,"cp %p had connection lost\n" , cp); +hpsa_print_cmd (h,"connection lost" , cp);break ;case CMD_ABORTED : -dev_warn (d,"cp %p was aborted\n" , cp); +hpsa_print_cmd (h,"aborted" , cp);break ;case CMD_ABORT_FAILED : -dev_warn (d,"cp %p reports abort failed\n" , cp); +hpsa_print_cmd (h,"abort failed" , cp);break ;case CMD_UNSOLICITED_ABORT : -dev_warn (d,"cp %p aborted due to an unsolicited abort\n" , cp); +hpsa_print_cmd (h,"unsolicited abort" , cp);break ;case CMD_TIMEOUT : -dev_warn (d,"cp %p timed out\n" , cp); +hpsa_print_cmd (h,"timed out" , cp);break ;case CMD_UNABORTABLE : -dev_warn (d,"Command unabortable\n" ); +hpsa_print_cmd (h,"unabortable" , cp);break ;default : -dev_warn (d,"cp %p returned unknown status %x\n" , cp, +hpsa_print_cmd (h,"unknown status" , cp); +dev_warn (d,"Unknown command status %x\n" , ei->CommandStatus); } }
@@ -1934,7 +1951,7 @@ static int hpsa_scsi_do_inquiry(struct ctlr_info *h, unsigned char *scsi3addr,hpsa_scsi_do_simple_cmd_with_retry (h, c,PCI_DMA_FROMDEVICE ); ei = c->err_info;if (ei->CommandStatus !=0 && ei->CommandStatus !=CMD_DATA_UNDERRUN ) { -hpsa_scsi_interpret_error (c); +hpsa_scsi_interpret_error (h, c); rc =-1 ; } out:
@@ -1965,7 +1982,7 @@ static int hpsa_send_reset(struct ctlr_info *h, unsigned char *scsi3addr, ei = c->err_info;if (ei->CommandStatus !=0 ) { -hpsa_scsi_interpret_error (c); +hpsa_scsi_interpret_error (h, c); rc =-1 ; }cmd_special_free (h, c);
@@ -2089,7 +2106,7 @@ static int hpsa_get_raid_map(struct ctlr_info *h,hpsa_scsi_do_simple_cmd_with_retry (h, c,PCI_DMA_FROMDEVICE ); ei = c->err_info;if (ei->CommandStatus !=0 && ei->CommandStatus !=CMD_DATA_UNDERRUN ) { -hpsa_scsi_interpret_error (c); +hpsa_scsi_interpret_error (h, c);cmd_special_free (h, c);return -1 ; }
@@ -2231,7 +2248,7 @@ static int hpsa_scsi_do_report_luns(struct ctlr_info *h, int logical, ei = c->err_info;if (ei->CommandStatus !=0 && ei->CommandStatus !=CMD_DATA_UNDERRUN ) { -hpsa_scsi_interpret_error (c); +hpsa_scsi_interpret_error (h, c); rc =-1 ; }else {if (buf->extended_response_flag != extended_response) {
@@ -3975,7 +3992,7 @@ static int hpsa_send_abort(struct ctlr_info *h, unsigned char *scsi3addr,default :dev_dbg (&h->pdev->dev,"%s: Tag:0x%08x:%08x: interpreting error.\n" , __func__, tagupper, taglower); -hpsa_scsi_interpret_error (c); +hpsa_scsi_interpret_error (h, c); rc =-1 ;break ; }
PATCH 32/35 hpsa add sysfs debug switch for raid map debugging messages
In reply to Stephen M. CameronFrom: Stephen M. Cameron <[email protected]>
--- drivers/scsi/hpsa.c | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++ drivers/scsi/hpsa.h | 1 + 2 files changed, 65 insertions(+), 0 deletions(-)
drivers/scsi/hpsa.c +64 -0
@@ -312,6 +312,31 @@ static ssize_t host_store_hp_ssd_smart_path_status(struct device *dev,return count; } +static ssize_t host_store_raid_offload_debug (struct device *dev, +struct device_attribute *attr, +const char *buf,size_t count) +{ +int debug_level, len; +struct ctlr_info *h; +struct Scsi_Host *shost =class_to_shost (dev); +char tmpbuf[10 ]; + +if (!capable (CAP_SYS_ADMIN ) || !capable (CAP_SYS_RAWIO )) +return -EACCES ; + len = count >sizeof (tmpbuf) -1 ?sizeof (tmpbuf) -1 : count; +strncpy (tmpbuf, buf, len); + tmpbuf[len] ='\0' ; +if (sscanf (tmpbuf,"%d" , &debug_level) !=1 ) +return -EINVAL ; +if (debug_level <0 ) + debug_level =0 ; + h =shost_to_hba (shost); + h->raid_offload_debug = debug_level; +dev_warn (&h->pdev->dev,"hpsa: Set raid_offload_debug level = %d\n" , + h->raid_offload_debug); +return count; +} +static ssize_t host_store_rescan (struct device *dev,struct device_attribute *attr,const char *buf,size_t count)
@@ -585,6 +610,8 @@ static DEVICE_ATTR(hp_ssd_smart_path_enabled, S_IRUGO, static DEVICE_ATTR(hp_ssd_smart_path_status, S_IWUSR|S_IRUGO|S_IROTH, host_show_hp_ssd_smart_path_status, host_store_hp_ssd_smart_path_status); +static DEVICE_ATTR(raid_offload_debug, S_IWUSR, NULL, + host_store_raid_offload_debug); static DEVICE_ATTR(firmware_revision, S_IRUGO, host_show_firmware_revision, NULL); static DEVICE_ATTR(commands_outstanding, S_IRUGO,
@@ -609,6 +636,7 @@ static struct device_attribute *hpsa_shost_attrs[] = { &dev_attr_transport_mode, &dev_attr_resettable, &dev_attr_hp_ssd_smart_path_status, + &dev_attr_raid_offload_debug, NULL, };
@@ -2020,6 +2048,10 @@ static void hpsa_debug_map_buff(struct ctlr_info *h, int rc,if (rc !=0 )return ; +/* Show details only if debugging has been activated. */ +if (h->raid_offload_debug <2 ) +return ; +dev_info (&h->pdev->dev,"structure_size = %u\n" ,le32_to_cpu (map_buff->structure_size)); dev_info(&h->pdev->dev, "volume_blk_size = %u\n",
@@ -2505,6 +2537,17 @@ static int hpsa_get_pdisk_of_ioaccel2(struct ctlr_info *h, scsi_nexus =cpu_to_le32 ((u32 ) c2a->scsi_nexus); find = c2a->scsi_nexus; +if (h->raid_offload_debug >0 ) +dev_info (&h->pdev->dev, +"%s: scsi_nexus:0x%08x device id: 0x%02x%02x%02x%02x %02x%02x%02x%02x %02x%02x%02x%02x %02x%02x%02x%02x\n" , + __func__, scsi_nexus, + d->device_id[0 ], d->device_id[1 ], d->device_id[2 ], + d->device_id[3 ], d->device_id[4 ], d->device_id[5 ], + d->device_id[6 ], d->device_id[7 ], d->device_id[8 ], + d->device_id[9 ], d->device_id[10 ], d->device_id[11 ], + d->device_id[12 ], d->device_id[13 ], d->device_id[14 ], + d->device_id[15 ]); +/* Get the list of physical devices */ physicals =kzalloc (reportsize,GFP_KERNEL ); if (hpsa_scsi_do_report_phys_luns(h, (struct ReportLUNdata *) physicals,
@@ -2529,6 +2572,15 @@ static int hpsa_get_pdisk_of_ioaccel2(struct ctlr_info *h, found =1 ;memcpy (scsi3addr, &((struct ReportExtendedLUNdata *) physicals)->LUN[i][0 ],8 ); +if (h->raid_offload_debug >0 ) +dev_info (&h->pdev->dev, +"%s: Searched h=0x%08x, Found h=0x%08x, scsiaddr 0x%02x%02x%02x%02x%02x%02x%02x%02x\n" , + __func__, find, + ((struct ReportExtendedLUNdata *) + physicals)->LUN[i][20 ], + scsi3addr[0 ], scsi3addr[1 ], scsi3addr[2 ], + scsi3addr[3 ], scsi3addr[4 ], scsi3addr[5 ], + scsi3addr[6 ], scsi3addr[7 ]);break ;/* found it */ }
@@ -4077,6 +4129,13 @@ static int hpsa_send_reset_as_abort_ioaccel2(struct ctlr_info *h,return -1 ;/* not abortable */ } +if (h->raid_offload_debug >0 ) +dev_info (&h->pdev->dev, +"Reset as abort: Abort requested on C%d:B%d:T%d:L%d scsi3addr 0x%02x%02x%02x%02x%02x%02x%02x%02x\n" , + h->scsi_host->host_no, dev->bus, dev->target, dev->lun, + scsi3addr[0 ], scsi3addr[1 ], scsi3addr[2 ], scsi3addr[3 ], + scsi3addr[4 ], scsi3addr[5 ], scsi3addr[6 ], scsi3addr[7 ]); +if (!dev->offload_enabled) {dev_warn (&h->pdev->dev,"Can't abort: device is not operating in HP SSD Smart Path mode.\n" );
@@ -4090,6 +4149,11 @@ static int hpsa_send_reset_as_abort_ioaccel2(struct ctlr_info *h, }/* send the reset */ +if (h->raid_offload_debug >0 ) +dev_info (&h->pdev->dev, +"Reset as abort: Resetting physical device at scsi3addr 0x%02x%02x%02x%02x%02x%02x%02x%02x\n" , + psa[0 ], psa[1 ], psa[2 ], psa[3 ], + psa[4 ], psa[5 ], psa[6 ], psa[7 ]); rc =hpsa_send_reset (h, psa,HPSA_RESET_TYPE_TARGET );if (rc !=0 ) { dev_warn(&h->pdev->dev,
drivers/scsi/hpsa.h +1 -0
@@ -199,6 +199,7 @@ struct ctlr_info { CTLR_STATE_CHANGE_EVENT_AIO_CONFIG_CHANGE) int acciopath_status;int drv_req_rescan;/* flag for driver to request rescan event */ +int raid_offload_debug; };#define HPSA_ABORT_MSG 0#define HPSA_DEVICE_RESET_MSG 1
PATCH 33/35 pci: add HP/3PAR vendor id to pci_ids.h
In reply to Stephen M. CameronFrom: Stephen M. Cameron <[email protected]>
--- include/linux/pci_ids.h | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
include/linux/pci_ids.h +1 -0
@@ -726,6 +726,7 @@#define PCI_DEVICE_ID_SI_7018 0x7018#define PCI_VENDOR_ID_HP 0x103c +#define PCI_VENDOR_ID_HP_3PAR 0x1590#define PCI_DEVICE_ID_HP_VISUALIZE_EG 0x1005#define PCI_DEVICE_ID_HP_VISUALIZE_FX6 0x1006#define PCI_DEVICE_ID_HP_VISUALIZE_FX4 0x1008
PATCH 34/35 hpsa: Add support for a few HP Storage controllers
In reply to Stephen M. CameronFrom: Stephen M. Cameron <[email protected]>
--- drivers/scsi/hpsa.c | 10 ++++++++++ 1 files changed, 10 insertions(+), 0 deletions(-)
drivers/scsi/hpsa.c +10 -0
@@ -119,6 +119,11 @@ static const struct pci_device_id hpsa_pci_device_id[] = { {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSI, 0x103C, 0x21C7}, {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSI, 0x103C, 0x21C8}, {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_CISSI, 0x103C, 0x21C9}, + {PCI_VENDOR_ID_HP_3PAR, 0x0075, 0x1590, 0x0076}, + {PCI_VENDOR_ID_HP_3PAR, 0x0075, 0x1590, 0x0087}, + {PCI_VENDOR_ID_HP_3PAR, 0x0075, 0x1590, 0x007D}, + {PCI_VENDOR_ID_HP_3PAR, 0x0075, 0x1590, 0x0088}, + {PCI_VENDOR_ID_HP, 0x333f, 0x103c, 0x333f}, {PCI_VENDOR_ID_HP, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_STORAGE_RAID << 8, 0xffff << 8, 0}, {0,}
@@ -164,6 +169,11 @@ static struct board_type products[] = { {0x21C7103C, "Smart Array", &SA5_access}, {0x21C8103C, "Smart Array", &SA5_access}, {0x21C9103C, "Smart Array", &SA5_access}, + {0x00761590, "HP Storage P1224 Array Controller", &SA5_access}, + {0x00871590, "HP Storage P1224e Array Controller", &SA5_access}, + {0x007D1590, "HP Storage P1228 Array Controller", &SA5_access}, + {0x00881590, "HP Storage P1228e Array Controller", &SA5_access}, + {0x333f103c, "HP StorageWorks 1210m Array Controller", &SA5_access}, {0xFFFF103C, "Unknown Smart Array", &SA5_access}, };
PATCH 35/35 hpsa: fixup MSI-X registration
In reply to Stephen M. CameronFrom: Hannes Reinecke <[email protected]>
Commit 254f796b9f22b1944c64caabc356a56caaa2facd updated the driver to use 16 MSI-X vectors, despite the fact that older controllers would provide only 4.
This was causing MSI-X registration to drop down to INTx mode. But as the controller support performant mode, the initialisation will become confused and cause the machine to stall during boot.
This patch fixes up the MSI-X registration to re-issue the pci_enable_msix() call with the correct number of MSI-X vectors. With that the hpsa driver continues to works on older controllers like the P200.
--- drivers/scsi/hpsa.c | 31 +++++++++++++++++-------------- 1 files changed, 17 insertions(+), 14 deletions(-)
drivers/scsi/hpsa.c +17 -14
@@ -744,7 +744,7 @@ static void set_performant_mode(struct ctlr_info *h, struct CommandList *c) {if (likely (h->transMethod & CFGTBL_Trans_Performant)) { c->busaddr |=1 | (h->blockFetchTable[c->Header.SGList] <<1 ); -if (likely (h->msix_vector)) +if (likely (h->msix_vector >0 )) c->Header.ReplyQueue =raw_smp_processor_id () % h->nreply_queues; }
@@ -5816,21 +5816,24 @@ static void hpsa_interrupt_mode(struct ctlr_info *h) goto default_int_mode;if (pci_find_capability (h->pdev,PCI_CAP_ID_MSIX )) {dev_info (&h->pdev->dev,"MSIX\n" ); + h->msix_vector =MAX_REPLY_QUEUES ; err =pci_enable_msix (h->pdev, hpsa_msix_entries, -MAX_REPLY_QUEUES ); -if (!err) { -for (i =0 ; i <MAX_REPLY_QUEUES ; i++) - h->intr[i] = hpsa_msix_entries[i].vector; - h->msix_vector =1 ; -return ; - } + h->msix_vector);if (err >0 ) {dev_warn (&h->pdev->dev,"only %d MSI-X vectors " "available\n" , err); - goto default_int_mode; + h->msix_vector = err; + err =pci_enable_msix (h->pdev, hpsa_msix_entries, + h->msix_vector); + } +if (!err) { +for (i =0 ; i < h->msix_vector; i++) + h->intr[i] = hpsa_msix_entries[i].vector; +return ; }else {dev_warn (&h->pdev->dev,"MSI-X init failed %d\n" , err); + h->msix_vector =0 ; goto default_int_mode; } }
@@ -6276,15 +6279,15 @@ static int hpsa_request_irq(struct ctlr_info *h,for (i =0 ; i <MAX_REPLY_QUEUES ; i++) h->q[i] = (u8 ) i; -if (h->intr_mode ==PERF_MODE_INT && h->msix_vector) { +if (h->intr_mode ==PERF_MODE_INT && h->msix_vector >0 ) {/* If performant mode and MSI-X, use multiple reply queues */ -for (i =0 ; i <MAX_REPLY_QUEUES ; i++) +for (i =0 ; i < h->msix_vector; i++) rc =request_irq (h->intr[i], msixhandler,0 , h->devname, &h->q[i]); }else {/* Use single reply pool */ -if (h->msix_vector || h->msi_vector) { +if (h->msix_vector >0 || h->msi_vector) { rc =request_irq (h->intr[h->intr_mode], msixhandler,0 , h->devname, &h->q[h->intr_mode]);
@@ -6337,7 +6340,7 @@ static void free_irqs(struct ctlr_info *h)return ; } -for (i =0 ; i <MAX_REPLY_QUEUES ; i++) +for (i =0 ; i < h->msix_vector; i++)free_irq (h->intr[i], &h->q[i]); }
@@ -7134,7 +7137,7 @@ static void hpsa_put_ctlr_into_performant_mode(struct ctlr_info *h) }/* TODO, check that this next line h->nreply_queues is correct */ - h->nreply_queues = h->msix_vector ?MAX_REPLY_QUEUES :1 ; + h->nreply_queues = h->msix_vector >0 ? h->msix_vector :1 ;hpsa_get_max_perf_mode_cmds (h);/* Performant mode ring buffer and supporting data structures */ h->reply_pool_size = h->max_commands *sizeof (u64) * h->nreply_queues;