History

Merge tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi

Pull more SCSI updates from James Bottomley: "The set of core changes here is Christoph's submission path cleanups. These introduced a couple of regressions when first proposed so they got held over from the initial merge window pull request to give more testing time, which they've now had and Syzbot has confirmed the regression it detected is fixed. The other main changes are two driver updates (arcmsr, pm80xx) and assorted minor clean ups" * tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: (38 commits) scsi: qla2xxx: Fix return of uninitialized value in rval scsi: core: Set sc_data_direction to DMA_NONE for no-transfer commands scsi: sr: Initialize ->cmd_len scsi: arcmsr: Update driver version to v1.50.00.02-20200819 scsi: arcmsr: Add support for ARC-1886 series RAID controllers scsi: arcmsr: Fix device hot-plug monitoring timer stop scsi: arcmsr: Remove unnecessary syntax scsi: pm80xx: Driver version update scsi: pm80xx: Increase the number of outstanding I/O supported to 1024 scsi: pm80xx: Remove DMA memory allocation for ccb and device structures scsi: pm80xx: Increase number of supported queues scsi: sym53c8xx_2: Fix sizeof() mismatch scsi: isci: Fix a typo in a comment scsi: qla4xxx: Fix inconsistent format argument type scsi: myrb: Fix inconsistent format argument types scsi: myrb: Remove redundant assignment to variable timeout scsi: bfa: Fix error return in bfad_pci_init() scsi: fcoe: Simplify the return expression of fcoe_sysfs_setup() scsi: snic: Simplify the return expression of svnic_cq_alloc() scsi: fnic: Simplify the return expression of vnic_wq_copy_alloc() ...

Linus Torvalds committed 6 years ago

Commit af995382 parents bd7e8c9 1ef16a429 files · +818 −584Browse files

Unified · Split

29 files
  1. drivers/scsi/53c700.c +0 −4
  2. drivers/scsi/arcmsr/arcmsr.h +99 −3
  3. drivers/scsi/arcmsr/arcmsr_hba.c +290 −87
  4. drivers/scsi/bfa/bfad.c +1 −0
  5. drivers/scsi/dc395x.c +1 −24
  6. drivers/scsi/fcoe/fcoe_sysfs.c +1 −7
  7. drivers/scsi/fnic/vnic_wq_copy.c +1 −7
  8. drivers/scsi/gdth.c +76 −75
  9. drivers/scsi/initio.c +1 −13
  10. drivers/scsi/isci/remote_node_table.h +1 −1
  11. drivers/scsi/myrb.c +2 −3
  12. drivers/scsi/pm8001/pm8001_ctl.c +4 −2
  13. drivers/scsi/pm8001/pm8001_defs.h +13 −14
  14. drivers/scsi/pm8001/pm8001_hwi.c +20 −18
  15. drivers/scsi/pm8001/pm8001_init.c +150 −71
  16. drivers/scsi/pm8001/pm8001_sas.h +11 −4
  17. drivers/scsi/pm8001/pm80xx_hwi.c +56 −53
  18. drivers/scsi/qla2xxx/qla_dfs.c +8 −60
  19. drivers/scsi/qla2xxx/qla_isr.c +15 −27
  20. drivers/scsi/qla2xxx/qla_nvme.c +4 −4
  21. drivers/scsi/qla2xxx/qla_nx2.c +1 −1
  22. drivers/scsi/qla4xxx/ql4_nx.c +1 −1
  23. drivers/scsi/scsi_lib.c +35 −73
  24. drivers/scsi/sd.c +15 −12
  25. drivers/scsi/snic/vnic_cq.c +1 −7
  26. drivers/scsi/sr.c +7 −10
  27. drivers/scsi/sym53c8xx_2/sym_hipd.c +1 −1
  28. drivers/target/target_core_rd.c +1 −1
  29. include/scsi/scsi_cmnd.h +2 −1
drivers/scsi/53c700.c+0−4
@@ -1506,10 +1506,8 @@ NCR_700_intr(int irq, void *dev_id) · 1505 unmodified lines
15061506 __u8 sstat0 = 0, dstat = 0;
15071507 __u32 dsp;
15081508 struct scsi_cmnd *SCp = hostdata->cmd;
1509− enum NCR_700_Host_State state;
15101509
15111510 handled = 1;
1512− state = hostdata->state;
15131511 SCp = hostdata->cmd;
15141512
15151513 if(istat & SCSI_INT_PENDING) {
@@ -1760,7 +1758,6 @@ NCR_700_queuecommand_lck(struct scsi_cmnd *SCp, void (*done)(struct scsi_cmnd *) · 244 unmodified lines
17601758 struct NCR_700_Host_Parameters *hostdata =
17611759 (struct NCR_700_Host_Parameters *)SCp->device->host->hostdata[0];
17621760 __u32 move_ins;
1763− enum dma_data_direction direction;
17641761 struct NCR_700_command_slot *slot;
17651762
17661763 if(hostdata->command_slot_count >= NCR_700_COMMAND_SLOTS_PER_HOST) {
@@ -1877,7 +1874,6 @@ NCR_700_queuecommand_lck(struct scsi_cmnd *SCp, void (*done)(struct scsi_cmnd *) · 110 unmodified lines
18771874 }
18781875
18791876 /* now build the scatter gather list */
1880− direction = SCp->sc_data_direction;
18811877 if(move_ins != 0) {
18821878 int i;
18831879 int sg_count;
drivers/scsi/arcmsr/arcmsr.h+99−3
@@ -49,7 +49,7 @@ struct device_attribute; · 48 unmodified lines
4949 #define ARCMSR_MAX_OUTSTANDING_CMD 1024
5050 #define ARCMSR_DEFAULT_OUTSTANDING_CMD 128
5151 #define ARCMSR_MIN_OUTSTANDING_CMD 32
52−#define ARCMSR_DRIVER_VERSION "v1.40.00.10-20190116"
52+#define ARCMSR_DRIVER_VERSION "v1.50.00.02-20200819"
5353 #define ARCMSR_SCSI_INITIATOR_ID 255
5454 #define ARCMSR_MAX_XFER_SECTORS 512
5555 #define ARCMSR_MAX_XFER_SECTORS_B 4096
@@ -80,6 +80,7 @@ struct device_attribute; · 24 unmodified lines
8080 #ifndef PCI_DEVICE_ID_ARECA_1884
8181 #define PCI_DEVICE_ID_ARECA_1884 0x1884
8282 #endif
83+#define PCI_DEVICE_ID_ARECA_1886 0x188A
8384 #define ARCMSR_HOURS (1000 * 60 * 60 * 4)
8485 #define ARCMSR_MINUTES (1000 * 60 * 60)
8586 /*
@@ -436,6 +437,21 @@ struct FIRMWARE_INFO · 350 unmodified lines
436437 #define ARCMSR_HBEMU_DOORBELL_SYNC 0x100
437438 #define ARCMSR_ARC188X_RESET_ADAPTER 0x00000004
438439 #define ARCMSR_ARC1884_DiagWrite_ENABLE 0x00000080
440+
441+/*
442+*******************************************************************************
443+** SPEC. for Areca Type F adapter
444+*******************************************************************************
445+*/
446+#define ARCMSR_SIGNATURE_1886 0x188617D3
447+// Doorbell and interrupt definition are same as Type E adapter
448+/* ARC-1886 doorbell sync */
449+#define ARCMSR_HBFMU_DOORBELL_SYNC 0x100
450+//set host rw buffer physical address at inbound message 0, 1 (low,high)
451+#define ARCMSR_HBFMU_DOORBELL_SYNC1 0x300
452+#define ARCMSR_HBFMU_MESSAGE_FIRMWARE_OK 0x80000000
453+#define ARCMSR_HBFMU_MESSAGE_NO_VOLUME_CHANGE 0x20000000
454+
439455 /*
440456 *******************************************************************************
441457 ** ARECA SCSI COMMAND DESCRIPTOR BLOCK size 0x1F8 (504)
@@ -720,6 +736,80 @@ struct MessageUnit_E{ · 278 unmodified lines
720736 uint32_t msgcode_rwbuffer[256]; /*2200 23FF*/
721737 };
722738
739+/*
740+*********************************************************************
741+** Messaging Unit (MU) of Type F processor(LSI)
742+*********************************************************************
743+*/
744+struct MessageUnit_F {
745+ uint32_t iobound_doorbell; /*0000 0003*/
746+ uint32_t write_sequence_3xxx; /*0004 0007*/
747+ uint32_t host_diagnostic_3xxx; /*0008 000B*/
748+ uint32_t posted_outbound_doorbell; /*000C 000F*/
749+ uint32_t master_error_attribute; /*0010 0013*/
750+ uint32_t master_error_address_low; /*0014 0017*/
751+ uint32_t master_error_address_high; /*0018 001B*/
752+ uint32_t hcb_size; /*001C 001F*/
753+ uint32_t inbound_doorbell; /*0020 0023*/
754+ uint32_t diagnostic_rw_data; /*0024 0027*/
755+ uint32_t diagnostic_rw_address_low; /*0028 002B*/
756+ uint32_t diagnostic_rw_address_high; /*002C 002F*/
757+ uint32_t host_int_status; /*0030 0033*/
758+ uint32_t host_int_mask; /*0034 0037*/
759+ uint32_t dcr_data; /*0038 003B*/
760+ uint32_t dcr_address; /*003C 003F*/
761+ uint32_t inbound_queueport; /*0040 0043*/
762+ uint32_t outbound_queueport; /*0044 0047*/
763+ uint32_t hcb_pci_address_low; /*0048 004B*/
764+ uint32_t hcb_pci_address_high; /*004C 004F*/
765+ uint32_t iop_int_status; /*0050 0053*/
766+ uint32_t iop_int_mask; /*0054 0057*/
767+ uint32_t iop_inbound_queue_port; /*0058 005B*/
768+ uint32_t iop_outbound_queue_port; /*005C 005F*/
769+ uint32_t inbound_free_list_index; /*0060 0063*/
770+ uint32_t inbound_post_list_index; /*0064 0067*/
771+ uint32_t reply_post_producer_index; /*0068 006B*/
772+ uint32_t reply_post_consumer_index; /*006C 006F*/
773+ uint32_t inbound_doorbell_clear; /*0070 0073*/
774+ uint32_t i2o_message_unit_control; /*0074 0077*/
775+ uint32_t last_used_message_source_address_low; /*0078 007B*/
776+ uint32_t last_used_message_source_address_high; /*007C 007F*/
777+ uint32_t pull_mode_data_byte_count[4]; /*0080 008F*/
778+ uint32_t message_dest_address_index; /*0090 0093*/
779+ uint32_t done_queue_not_empty_int_counter_timer; /*0094 0097*/
780+ uint32_t utility_A_int_counter_timer; /*0098 009B*/
781+ uint32_t outbound_doorbell; /*009C 009F*/
782+ uint32_t outbound_doorbell_clear; /*00A0 00A3*/
783+ uint32_t message_source_address_index; /*00A4 00A7*/
784+ uint32_t message_done_queue_index; /*00A8 00AB*/
785+ uint32_t reserved0; /*00AC 00AF*/
786+ uint32_t inbound_msgaddr0; /*00B0 00B3*/
787+ uint32_t inbound_msgaddr1; /*00B4 00B7*/
788+ uint32_t outbound_msgaddr0; /*00B8 00BB*/
789+ uint32_t outbound_msgaddr1; /*00BC 00BF*/
790+ uint32_t inbound_queueport_low; /*00C0 00C3*/
791+ uint32_t inbound_queueport_high; /*00C4 00C7*/
792+ uint32_t outbound_queueport_low; /*00C8 00CB*/
793+ uint32_t outbound_queueport_high; /*00CC 00CF*/
794+ uint32_t iop_inbound_queue_port_low; /*00D0 00D3*/
795+ uint32_t iop_inbound_queue_port_high; /*00D4 00D7*/
796+ uint32_t iop_outbound_queue_port_low; /*00D8 00DB*/
797+ uint32_t iop_outbound_queue_port_high; /*00DC 00DF*/
798+ uint32_t message_dest_queue_port_low; /*00E0 00E3*/
799+ uint32_t message_dest_queue_port_high; /*00E4 00E7*/
800+ uint32_t last_used_message_dest_address_low; /*00E8 00EB*/
801+ uint32_t last_used_message_dest_address_high; /*00EC 00EF*/
802+ uint32_t message_done_queue_base_address_low; /*00F0 00F3*/
803+ uint32_t message_done_queue_base_address_high; /*00F4 00F7*/
804+ uint32_t host_diagnostic; /*00F8 00FB*/
805+ uint32_t write_sequence; /*00FC 00FF*/
806+ uint32_t reserved1[46]; /*0100 01B7*/
807+ uint32_t reply_post_producer_index1; /*01B8 01BB*/
808+ uint32_t reply_post_consumer_index1; /*01BC 01BF*/
809+};
810+
811+#define MESG_RW_BUFFER_SIZE (256 * 3)
812+
723813 typedef struct deliver_completeQ {
724814 uint16_t cmdFlag;
725815 uint16_t cmdSMID;
@@ -739,6 +829,7 @@ struct AdapterControlBlock · 13 unmodified lines
739829 #define ACB_ADAPTER_TYPE_C 0x00000002 /* hbc L IOP */
740830 #define ACB_ADAPTER_TYPE_D 0x00000003 /* hbd M IOP */
741831 #define ACB_ADAPTER_TYPE_E 0x00000004 /* hba L IOP */
832+#define ACB_ADAPTER_TYPE_F 0x00000005 /* hba L IOP */
742833 u32 ioqueue_size;
743834 struct pci_dev * pdev;
744835 struct Scsi_Host * host;
@@ -760,10 +851,16 @@ struct AdapterControlBlock · 15 unmodified lines
760851 struct MessageUnit_C __iomem *pmuC;
761852 struct MessageUnit_D *pmuD;
762853 struct MessageUnit_E __iomem *pmuE;
854+ struct MessageUnit_F __iomem *pmuF;
763855 };
764856 /* message unit ATU inbound base address0 */
765857 void __iomem *mem_base0;
766858 void __iomem *mem_base1;
859+ //0x000 - COMPORT_IN (Host sent to ROC)
860+ uint32_t *message_wbuffer;
861+ //0x100 - COMPORT_OUT (ROC sent to Host)
862+ uint32_t *message_rbuffer;
863+ uint32_t *msgcode_rwbuffer; //0x200 - BIOS_AREA
767864 uint32_t acb_flags;
768865 u16 dev_id;
769866 uint8_t adapter_index;
@@ -836,8 +933,6 @@ struct AdapterControlBlock · 66 unmodified lines
836933 #define FW_NORMAL 0x0000
837934 #define FW_BOG 0x0001
838935 #define FW_DEADLOCK 0x0010
839− atomic_t rq_map_token;
840− atomic_t ante_token_value;
841936 uint32_t maxOutstanding;
842937 int vector_count;
843938 uint32_t maxFreeCCB;
@@ -848,6 +943,7 @@ struct AdapterControlBlock · 4 unmodified lines
848943 uint32_t out_doorbell;
849944 uint32_t completionQ_entry;
850945 pCompletion_Q pCompletionQ;
946+ uint32_t completeQ_size;
851947 };/* HW_DEVICE_EXTENSION */
852948 /*
853949 *******************************************************************************
drivers/scsi/arcmsr/arcmsr_hba.c+290−87
@@ -133,6 +133,7 @@ static void arcmsr_hbaC_message_isr(struct AdapterControlBlock *pACB); · 132 unmodified lines
133133 static void arcmsr_hbaD_message_isr(struct AdapterControlBlock *acb);
134134 static void arcmsr_hbaE_message_isr(struct AdapterControlBlock *acb);
135135 static void arcmsr_hbaE_postqueue_isr(struct AdapterControlBlock *acb);
136+static void arcmsr_hbaF_postqueue_isr(struct AdapterControlBlock *acb);
136137 static void arcmsr_hardware_reset(struct AdapterControlBlock *acb);
137138 static const char *arcmsr_info(struct Scsi_Host *);
138139 static irqreturn_t arcmsr_interrupt(struct AdapterControlBlock *acb);
@@ -209,6 +210,8 @@ static struct pci_device_id arcmsr_device_id_table[] = { · 70 unmodified lines
209210 .driver_data = ACB_ADAPTER_TYPE_C},
210211 {PCI_DEVICE(PCI_VENDOR_ID_ARECA, PCI_DEVICE_ID_ARECA_1884),
211212 .driver_data = ACB_ADAPTER_TYPE_E},
213+ {PCI_DEVICE(PCI_VENDOR_ID_ARECA, PCI_DEVICE_ID_ARECA_1886),
214+ .driver_data = ACB_ADAPTER_TYPE_F},
212215 {0, 0}, /* Terminating entry */
213216 };
214217 MODULE_DEVICE_TABLE(pci, arcmsr_device_id_table);
@@ -232,12 +235,12 @@ static void arcmsr_free_io_queue(struct AdapterControlBlock *acb) · 17 unmodified lines
232235 switch (acb->adapter_type) {
233236 case ACB_ADAPTER_TYPE_B:
234237 case ACB_ADAPTER_TYPE_D:
235− case ACB_ADAPTER_TYPE_E: {
238+ case ACB_ADAPTER_TYPE_E:
239+ case ACB_ADAPTER_TYPE_F:
236240 dma_free_coherent(&acb->pdev->dev, acb->ioqueue_size,
237241 acb->dma_coherent2, acb->dma_coherent_handle2);
238242 break;
239243 }
240− }
241244 }
242245
243246 static bool arcmsr_remap_pciregion(struct AdapterControlBlock *acb)
@@ -310,6 +313,19 @@ static bool arcmsr_remap_pciregion(struct AdapterControlBlock *acb) · 66 unmodified lines
310313 acb->out_doorbell = 0;
311314 break;
312315 }
316+ case ACB_ADAPTER_TYPE_F: {
317+ acb->pmuF = ioremap(pci_resource_start(pdev, 0), pci_resource_len(pdev, 0));
318+ if (!acb->pmuF) {
319+ pr_notice("arcmsr%d: memory mapping region fail\n",
320+ acb->host->host_no);
321+ return false;
322+ }
323+ writel(0, &acb->pmuF->host_int_status); /* clear interrupt */
324+ writel(ARCMSR_HBFMU_DOORBELL_SYNC, &acb->pmuF->iobound_doorbell);
325+ acb->in_doorbell = 0;
326+ acb->out_doorbell = 0;
327+ break;
328+ }
313329 }
314330 return true;
315331 }
@@ -317,26 +333,25 @@ static bool arcmsr_remap_pciregion(struct AdapterControlBlock *acb) · 1 unmodified line
317333 static void arcmsr_unmap_pciregion(struct AdapterControlBlock *acb)
318334 {
319335 switch (acb->adapter_type) {
320− case ACB_ADAPTER_TYPE_A:{
336+ case ACB_ADAPTER_TYPE_A:
321337 iounmap(acb->pmuA);
322− }
323− break;
324− case ACB_ADAPTER_TYPE_B:{
338+ break;
339+ case ACB_ADAPTER_TYPE_B:
325340 iounmap(acb->mem_base0);
326341 iounmap(acb->mem_base1);
327− }
328−
329− break;
330− case ACB_ADAPTER_TYPE_C:{
342+ break;
343+ case ACB_ADAPTER_TYPE_C:
331344 iounmap(acb->pmuC);
332− }
333− break;
345+ break;
334346 case ACB_ADAPTER_TYPE_D:
335347 iounmap(acb->mem_base0);
336348 break;
337349 case ACB_ADAPTER_TYPE_E:
338350 iounmap(acb->pmuE);
339351 break;
352+ case ACB_ADAPTER_TYPE_F:
353+ iounmap(acb->pmuF);
354+ break;
340355 }
341356 }
342357
@@ -552,23 +567,20 @@ static void arcmsr_flush_adapter_cache(struct AdapterControlBlock *acb) · 209 unmodified lines
552567 {
553568 switch (acb->adapter_type) {
554569
555− case ACB_ADAPTER_TYPE_A: {
570+ case ACB_ADAPTER_TYPE_A:
556571 arcmsr_hbaA_flush_cache(acb);
557− }
558572 break;
559−
560− case ACB_ADAPTER_TYPE_B: {
573+ case ACB_ADAPTER_TYPE_B:
561574 arcmsr_hbaB_flush_cache(acb);
562− }
563575 break;
564− case ACB_ADAPTER_TYPE_C: {
576+ case ACB_ADAPTER_TYPE_C:
565577 arcmsr_hbaC_flush_cache(acb);
566− }
567578 break;
568579 case ACB_ADAPTER_TYPE_D:
569580 arcmsr_hbaD_flush_cache(acb);
570581 break;
571582 case ACB_ADAPTER_TYPE_E:
583+ case ACB_ADAPTER_TYPE_F:
572584 arcmsr_hbaE_flush_cache(acb);
573585 break;
574586 }
@@ -626,6 +638,27 @@ static void arcmsr_hbaD_assign_regAddr(struct AdapterControlBlock *acb) · 51 unmodified lines
626638 reg->msgcode_rwbuffer = MEM_BASE0(ARCMSR_ARC1214_MESSAGE_RWBUFFER);
627639 }
628640
641+static void arcmsr_hbaF_assign_regAddr(struct AdapterControlBlock *acb)
642+{
643+ dma_addr_t host_buffer_dma;
644+ struct MessageUnit_F __iomem *pmuF;
645+
646+ memset(acb->dma_coherent2, 0xff, acb->completeQ_size);
647+ acb->message_wbuffer = (uint32_t *)round_up((unsigned long)acb->dma_coherent2 +
648+ acb->completeQ_size, 4);
649+ acb->message_rbuffer = ((void *)acb->message_wbuffer) + 0x100;
650+ acb->msgcode_rwbuffer = ((void *)acb->message_wbuffer) + 0x200;
651+ memset((void *)acb->message_wbuffer, 0, MESG_RW_BUFFER_SIZE);
652+ host_buffer_dma = round_up(acb->dma_coherent_handle2 + acb->completeQ_size, 4);
653+ pmuF = acb->pmuF;
654+ /* host buffer low address, bit0:1 all buffer active */
655+ writel(lower_32_bits(host_buffer_dma | 1), &pmuF->inbound_msgaddr0);
656+ /* host buffer high address */
657+ writel(upper_32_bits(host_buffer_dma), &pmuF->inbound_msgaddr1);
658+ /* set host buffer physical address */
659+ writel(ARCMSR_HBFMU_DOORBELL_SYNC1, &pmuF->iobound_doorbell);
660+}
661+
629662 static bool arcmsr_alloc_io_queue(struct AdapterControlBlock *acb)
630663 {
631664 bool rtn = true;
@@ -679,6 +712,28 @@ static bool arcmsr_alloc_io_queue(struct AdapterControlBlock *acb) · 47 unmodified lines
679712 acb->doneq_index = 0;
680713 }
681714 break;
715+ case ACB_ADAPTER_TYPE_F: {
716+ uint32_t QueueDepth;
717+ uint32_t depthTbl[] = {256, 512, 1024, 128, 64, 32};
718+
719+ arcmsr_wait_firmware_ready(acb);
720+ QueueDepth = depthTbl[readl(&acb->pmuF->outbound_msgaddr1) & 7];
721+ acb->completeQ_size = sizeof(struct deliver_completeQ) * QueueDepth + 128;
722+ acb->ioqueue_size = roundup(acb->completeQ_size + MESG_RW_BUFFER_SIZE, 32);
723+ dma_coherent = dma_alloc_coherent(&pdev->dev, acb->ioqueue_size,
724+ &dma_coherent_handle, GFP_KERNEL);
725+ if (!dma_coherent) {
726+ pr_notice("arcmsr%d: DMA allocation failed\n", acb->host->host_no);
727+ return false;
728+ }
729+ acb->dma_coherent_handle2 = dma_coherent_handle;
730+ acb->dma_coherent2 = dma_coherent;
731+ acb->pCompletionQ = dma_coherent;
732+ acb->completionQ_entry = acb->completeQ_size / sizeof(struct deliver_completeQ);
733+ acb->doneq_index = 0;
734+ arcmsr_hbaF_assign_regAddr(acb);
735+ }
736+ break;
682737 default:
683738 break;
684739 }
@@ -713,7 +768,8 @@ static int arcmsr_alloc_ccb_pool(struct AdapterControlBlock *acb) · 28 unmodified lines
713768 acb->host->sg_tablesize = max_sg_entrys;
714769 roundup_ccbsize = roundup(sizeof(struct CommandControlBlock) + (max_sg_entrys - 1) * sizeof(struct SG64ENTRY), 32);
715770 acb->uncache_size = roundup_ccbsize * acb->maxFreeCCB;
716− acb->uncache_size += acb->ioqueue_size;
771+ if (acb->adapter_type != ACB_ADAPTER_TYPE_F)
772+ acb->uncache_size += acb->ioqueue_size;
717773 dma_coherent = dma_alloc_coherent(&pdev->dev, acb->uncache_size, &dma_coherent_handle, GFP_KERNEL);
718774 if(!dma_coherent){
719775 printk(KERN_NOTICE "arcmsr%d: dma_alloc_coherent got error\n", acb->host->host_no);
@@ -736,6 +792,7 @@ static int arcmsr_alloc_ccb_pool(struct AdapterControlBlock *acb) · 16 unmodified lines
736792 case ACB_ADAPTER_TYPE_C:
737793 case ACB_ADAPTER_TYPE_D:
738794 case ACB_ADAPTER_TYPE_E:
795+ case ACB_ADAPTER_TYPE_F:
739796 ccb_tmp->cdb_phyaddr = cdb_phyaddr;
740797 break;
741798 }
@@ -754,8 +811,10 @@ static int arcmsr_alloc_ccb_pool(struct AdapterControlBlock *acb) · 12 unmodified lines
754811 ccb_tmp = (struct CommandControlBlock *)((unsigned long)ccb_tmp + roundup_ccbsize);
755812 dma_coherent_handle = next_ccb_phy;
756813 }
757− acb->dma_coherent_handle2 = dma_coherent_handle;
758− acb->dma_coherent2 = ccb_tmp;
814+ if (acb->adapter_type != ACB_ADAPTER_TYPE_F) {
815+ acb->dma_coherent_handle2 = dma_coherent_handle;
816+ acb->dma_coherent2 = ccb_tmp;
817+ }
759818 switch (acb->adapter_type) {
760819 case ACB_ADAPTER_TYPE_B:
761820 acb->pmuB = (struct MessageUnit_B *)acb->dma_coherent2;
@@ -785,7 +844,6 @@ static void arcmsr_message_isr_bh_fn(struct work_struct *work) · 23 unmodified lines
785844 struct scsi_device *psdev;
786845 char diff, temp;
787846
788− acb->acb_flags &= ~ACB_F_MSG_GET_CONFIG;
789847 switch (acb->adapter_type) {
790848 case ACB_ADAPTER_TYPE_A: {
791849 struct MessageUnit_A __iomem *reg = acb->pmuA;
@@ -822,8 +880,12 @@ static void arcmsr_message_isr_bh_fn(struct work_struct *work) · 30 unmodified lines
822880 devicemap = (char __iomem *)(&reg->msgcode_rwbuffer[21]);
823881 break;
824882 }
883+ case ACB_ADAPTER_TYPE_F: {
884+ signature = (uint32_t __iomem *)(&acb->msgcode_rwbuffer[0]);
885+ devicemap = (char __iomem *)(&acb->msgcode_rwbuffer[21]);
886+ break;
887+ }
825888 }
826− atomic_inc(&acb->rq_map_token);
827889 if (readl(signature) != ARCMSR_SIGNATURE_GET_CONFIG)
828890 return;
829891 for (target = 0; target < ARCMSR_MAX_TARGETID - 1;
@@ -854,6 +916,7 @@ static void arcmsr_message_isr_bh_fn(struct work_struct *work) · 24 unmodified lines
854916 devicemap++;
855917 acb_dev_map++;
856918 }
919+ acb->acb_flags &= ~ACB_F_MSG_GET_CONFIG;
857920 }
858921
859922 static int
@@ -906,8 +969,6 @@ out_free_irq: · 46 unmodified lines
906969 static void arcmsr_init_get_devmap_timer(struct AdapterControlBlock *pacb)
907970 {
908971 INIT_WORK(&pacb->arcmsr_do_message_isr_bh, arcmsr_message_isr_bh_fn);
909− atomic_set(&pacb->rq_map_token, 16);
910− atomic_set(&pacb->ante_token_value, 16);
911972 pacb->fw_flag = FW_NORMAL;
912973 timer_setup(&pacb->eternal_timer, arcmsr_request_device_map, 0);
913974 pacb->eternal_timer.expires = jiffies + msecs_to_jiffies(6 * HZ);
@@ -1009,7 +1070,8 @@ static int arcmsr_probe(struct pci_dev *pdev, const struct pci_device_id *id) · 95 unmodified lines
10091070 if(!error){
10101071 goto free_hbb_mu;
10111072 }
1012− arcmsr_free_io_queue(acb);
1073+ if (acb->adapter_type != ACB_ADAPTER_TYPE_F)
1074+ arcmsr_free_io_queue(acb);
10131075 error = arcmsr_alloc_ccb_pool(acb);
10141076 if(error){
10151077 goto unmap_pci_region;
@@ -1122,6 +1184,14 @@ static int arcmsr_resume(struct pci_dev *pdev) · 106 unmodified lines
11221184 acb->out_doorbell = 0;
11231185 acb->doneq_index = 0;
11241186 break;
1187+ case ACB_ADAPTER_TYPE_F:
1188+ writel(0, &acb->pmuF->host_int_status);
1189+ writel(ARCMSR_HBFMU_DOORBELL_SYNC, &acb->pmuF->iobound_doorbell);
1190+ acb->in_doorbell = 0;
1191+ acb->out_doorbell = 0;
1192+ acb->doneq_index = 0;
1193+ arcmsr_hbaF_assign_regAddr(acb);
1194+ break;
11251195 }
11261196 arcmsr_iop_init(acb);
11271197 arcmsr_init_get_devmap_timer(acb);
@@ -1134,6 +1204,8 @@ controller_stop: · 6 unmodified lines
11341204 controller_unregister:
11351205 scsi_remove_host(host);
11361206 arcmsr_free_ccb_pool(acb);
1207+ if (acb->adapter_type == ACB_ADAPTER_TYPE_F)
1208+ arcmsr_free_io_queue(acb);
11371209 arcmsr_unmap_pciregion(acb);
11381210 pci_release_regions(pdev);
11391211 scsi_host_put(host);
@@ -1213,25 +1285,20 @@ static uint8_t arcmsr_abort_allcmd(struct AdapterControlBlock *acb) · 73 unmodified lines
12131285 {
12141286 uint8_t rtnval = 0;
12151287 switch (acb->adapter_type) {
1216− case ACB_ADAPTER_TYPE_A: {
1288+ case ACB_ADAPTER_TYPE_A:
12171289 rtnval = arcmsr_hbaA_abort_allcmd(acb);
1218− }
12191290 break;
1220−
1221− case ACB_ADAPTER_TYPE_B: {
1291+ case ACB_ADAPTER_TYPE_B:
12221292 rtnval = arcmsr_hbaB_abort_allcmd(acb);
1223− }
12241293 break;
1225−
1226− case ACB_ADAPTER_TYPE_C: {
1294+ case ACB_ADAPTER_TYPE_C:
12271295 rtnval = arcmsr_hbaC_abort_allcmd(acb);
1228− }
12291296 break;
1230−
12311297 case ACB_ADAPTER_TYPE_D:
12321298 rtnval = arcmsr_hbaD_abort_allcmd(acb);
12331299 break;
12341300 case ACB_ADAPTER_TYPE_E:
1301+ case ACB_ADAPTER_TYPE_F:
12351302 rtnval = arcmsr_hbaE_abort_allcmd(acb);
12361303 break;
12371304 }
@@ -1307,7 +1374,8 @@ static u32 arcmsr_disable_outbound_ints(struct AdapterControlBlock *acb) · 69 unmodified lines
13071374 writel(ARCMSR_ARC1214_ALL_INT_DISABLE, reg->pcief0_int_enable);
13081375 }
13091376 break;
1310− case ACB_ADAPTER_TYPE_E: {
1377+ case ACB_ADAPTER_TYPE_E:
1378+ case ACB_ADAPTER_TYPE_F: {
13111379 struct MessageUnit_E __iomem *reg = acb->pmuE;
13121380 orig_mask = readl(&reg->host_int_mask);
13131381 writel(orig_mask | ARCMSR_HBEMU_OUTBOUND_DOORBELL_ISR | ARCMSR_HBEMU_OUTBOUND_POSTQUEUE_ISR, &reg->host_int_mask);
@@ -1514,6 +1582,9 @@ static void arcmsr_done4abort_postqueue(struct AdapterControlBlock *acb) · 200 unmodified lines
15141582 case ACB_ADAPTER_TYPE_E:
15151583 arcmsr_hbaE_postqueue_isr(acb);
15161584 break;
1585+ case ACB_ADAPTER_TYPE_F:
1586+ arcmsr_hbaF_postqueue_isr(acb);
1587+ break;
15171588 }
15181589 }
15191590
@@ -1568,6 +1639,8 @@ static void arcmsr_free_pcidev(struct AdapterControlBlock *acb) · 48 unmodified lines
15681639 pdev = acb->pdev;
15691640 arcmsr_free_irq(pdev, acb);
15701641 arcmsr_free_ccb_pool(acb);
1642+ if (acb->adapter_type == ACB_ADAPTER_TYPE_F)
1643+ arcmsr_free_io_queue(acb);
15711644 arcmsr_unmap_pciregion(acb);
15721645 pci_release_regions(pdev);
15731646 scsi_host_put(host);
@@ -1625,6 +1698,8 @@ static void arcmsr_remove(struct pci_dev *pdev) · 51 unmodified lines
16251698 }
16261699 arcmsr_free_irq(pdev, acb);
16271700 arcmsr_free_ccb_pool(acb);
1701+ if (acb->adapter_type == ACB_ADAPTER_TYPE_F)
1702+ arcmsr_free_io_queue(acb);
16281703 arcmsr_unmap_pciregion(acb);
16291704 pci_release_regions(pdev);
16301705 scsi_host_put(host);
@@ -1702,7 +1777,8 @@ static void arcmsr_enable_outbound_ints(struct AdapterControlBlock *acb, · 71 unmodified lines
17021777 writel(intmask_org | mask, reg->pcief0_int_enable);
17031778 break;
17041779 }
1705− case ACB_ADAPTER_TYPE_E: {
1780+ case ACB_ADAPTER_TYPE_E:
1781+ case ACB_ADAPTER_TYPE_F: {
17061782 struct MessageUnit_E __iomem *reg = acb->pmuE;
17071783
17081784 mask = ~(ARCMSR_HBEMU_OUTBOUND_DOORBELL_ISR | ARCMSR_HBEMU_OUTBOUND_POSTQUEUE_ISR);
@@ -1846,6 +1922,19 @@ static void arcmsr_post_ccb(struct AdapterControlBlock *acb, struct CommandContr · 137 unmodified lines
18461922 writel(ccb_post_stamp, &pmu->inbound_queueport_low);
18471923 break;
18481924 }
1925+ case ACB_ADAPTER_TYPE_F: {
1926+ struct MessageUnit_F __iomem *pmu = acb->pmuF;
1927+ u32 ccb_post_stamp, arc_cdb_size;
1928+
1929+ if (ccb->arc_cdb_size <= 0x300)
1930+ arc_cdb_size = (ccb->arc_cdb_size - 1) >> 6 | 1;
1931+ else
1932+ arc_cdb_size = (((ccb->arc_cdb_size + 0xff) >> 8) + 2) << 1 | 1;
1933+ ccb_post_stamp = (ccb->smid | arc_cdb_size);
1934+ writel(0, &pmu->inbound_queueport_high);
1935+ writel(ccb_post_stamp, &pmu->inbound_queueport_low);
1936+ break;
1937+ }
18491938 }
18501939 }
18511940
@@ -1916,23 +2005,20 @@ static void arcmsr_hbaE_stop_bgrb(struct AdapterControlBlock *pACB) · 64 unmodified lines
19162005 static void arcmsr_stop_adapter_bgrb(struct AdapterControlBlock *acb)
19172006 {
19182007 switch (acb->adapter_type) {
1919− case ACB_ADAPTER_TYPE_A: {
2008+ case ACB_ADAPTER_TYPE_A:
19202009 arcmsr_hbaA_stop_bgrb(acb);
1921− }
19222010 break;
1923−
1924− case ACB_ADAPTER_TYPE_B: {
2011+ case ACB_ADAPTER_TYPE_B:
19252012 arcmsr_hbaB_stop_bgrb(acb);
1926− }
19272013 break;
1928− case ACB_ADAPTER_TYPE_C: {
2014+ case ACB_ADAPTER_TYPE_C:
19292015 arcmsr_hbaC_stop_bgrb(acb);
1930− }
19312016 break;
19322017 case ACB_ADAPTER_TYPE_D:
19332018 arcmsr_hbaD_stop_bgrb(acb);
19342019 break;
19352020 case ACB_ADAPTER_TYPE_E:
2021+ case ACB_ADAPTER_TYPE_F:
19362022 arcmsr_hbaE_stop_bgrb(acb);
19372023 break;
19382024 }
@@ -1951,7 +2037,6 @@ static void arcmsr_iop_message_read(struct AdapterControlBlock *acb) · 12 unmodified lines
19512037 writel(ARCMSR_INBOUND_DRIVER_DATA_READ_OK, &reg->inbound_doorbell);
19522038 }
19532039 break;
1954−
19552040 case ACB_ADAPTER_TYPE_B: {
19562041 struct MessageUnit_B *reg = acb->pmuB;
19572042 writel(ARCMSR_DRV2IOP_DATA_READ_OK, reg->drv2iop_doorbell);
@@ -1969,7 +2054,8 @@ static void arcmsr_iop_message_read(struct AdapterControlBlock *acb) · 11 unmodified lines
19692054 reg->inbound_doorbell);
19702055 }
19712056 break;
1972− case ACB_ADAPTER_TYPE_E: {
2057+ case ACB_ADAPTER_TYPE_E:
2058+ case ACB_ADAPTER_TYPE_F: {
19732059 struct MessageUnit_E __iomem *reg = acb->pmuE;
19742060 acb->out_doorbell ^= ARCMSR_HBEMU_DRV2IOP_DATA_READ_OK;
19752061 writel(acb->out_doorbell, &reg->iobound_doorbell);
@@ -2015,7 +2101,8 @@ static void arcmsr_iop_message_wrote(struct AdapterControlBlock *acb) · 39 unmodified lines
20152101 reg->inbound_doorbell);
20162102 }
20172103 break;
2018− case ACB_ADAPTER_TYPE_E: {
2104+ case ACB_ADAPTER_TYPE_E:
2105+ case ACB_ADAPTER_TYPE_F: {
20192106 struct MessageUnit_E __iomem *reg = acb->pmuE;
20202107 acb->out_doorbell ^= ARCMSR_HBEMU_DRV2IOP_DATA_WRITE_OK;
20212108 writel(acb->out_doorbell, &reg->iobound_doorbell);
@@ -2034,7 +2121,6 @@ struct QBUFFER __iomem *arcmsr_get_iop_rqbuffer(struct AdapterControlBlock *acb) · 12 unmodified lines
20342121 qbuffer = (struct QBUFFER __iomem *)&reg->message_rbuffer;
20352122 }
20362123 break;
2037−
20382124 case ACB_ADAPTER_TYPE_B: {
20392125 struct MessageUnit_B *reg = acb->pmuB;
20402126 qbuffer = (struct QBUFFER __iomem *)reg->message_rbuffer;
@@ -2055,6 +2141,10 @@ struct QBUFFER __iomem *arcmsr_get_iop_rqbuffer(struct AdapterControlBlock *acb) · 14 unmodified lines
20552141 qbuffer = (struct QBUFFER __iomem *)&reg->message_rbuffer;
20562142 }
20572143 break;
2144+ case ACB_ADAPTER_TYPE_F: {
2145+ qbuffer = (struct QBUFFER __iomem *)acb->message_rbuffer;
2146+ }
2147+ break;
20582148 }
20592149 return qbuffer;
20602150 }
@@ -2069,7 +2159,6 @@ static struct QBUFFER __iomem *arcmsr_get_iop_wqbuffer(struct AdapterControlBloc · 8 unmodified lines
20692159 pqbuffer = (struct QBUFFER __iomem *) &reg->message_wbuffer;
20702160 }
20712161 break;
2072−
20732162 case ACB_ADAPTER_TYPE_B: {
20742163 struct MessageUnit_B *reg = acb->pmuB;
20752164 pqbuffer = (struct QBUFFER __iomem *)reg->message_wbuffer;
@@ -2090,6 +2179,9 @@ static struct QBUFFER __iomem *arcmsr_get_iop_wqbuffer(struct AdapterControlBloc · 14 unmodified lines
20902179 pqbuffer = (struct QBUFFER __iomem *)&reg->message_wbuffer;
20912180 }
20922181 break;
2182+ case ACB_ADAPTER_TYPE_F:
2183+ pqbuffer = (struct QBUFFER __iomem *)acb->message_wbuffer;
2184+ break;
20932185 }
20942186 return pqbuffer;
20952187 }
@@ -2504,6 +2596,36 @@ static void arcmsr_hbaE_postqueue_isr(struct AdapterControlBlock *acb) · 408 unmodified lines
25042596 spin_unlock_irqrestore(&acb->doneq_lock, flags);
25052597 }
25062598
2599+static void arcmsr_hbaF_postqueue_isr(struct AdapterControlBlock *acb)
2600+{
2601+ uint32_t doneq_index;
2602+ uint16_t cmdSMID;
2603+ int error;
2604+ struct MessageUnit_F __iomem *phbcmu;
2605+ struct CommandControlBlock *ccb;
2606+ unsigned long flags;
2607+
2608+ spin_lock_irqsave(&acb->doneq_lock, flags);
2609+ doneq_index = acb->doneq_index;
2610+ phbcmu = acb->pmuF;
2611+ while (1) {
2612+ cmdSMID = acb->pCompletionQ[doneq_index].cmdSMID;
2613+ if (cmdSMID == 0xffff)
2614+ break;
2615+ ccb = acb->pccb_pool[cmdSMID];
2616+ error = (acb->pCompletionQ[doneq_index].cmdFlag &
2617+ ARCMSR_CCBREPLY_FLAG_ERROR_MODE1) ? true : false;
2618+ arcmsr_drain_donequeue(acb, ccb, error);
2619+ acb->pCompletionQ[doneq_index].cmdSMID = 0xffff;
2620+ doneq_index++;
2621+ if (doneq_index >= acb->completionQ_entry)
2622+ doneq_index = 0;
2623+ }
2624+ acb->doneq_index = doneq_index;
2625+ writel(doneq_index, &phbcmu->reply_post_consumer_index);
2626+ spin_unlock_irqrestore(&acb->doneq_lock, flags);
2627+}
2628+
25072629 /*
25082630 **********************************************************************************
25092631 ** Handle a message interrupt
@@ -2694,21 +2816,46 @@ static irqreturn_t arcmsr_hbaE_handle_isr(struct AdapterControlBlock *pACB) · 184 unmodified lines
26942816 return IRQ_HANDLED;
26952817 }
26962818
2819+static irqreturn_t arcmsr_hbaF_handle_isr(struct AdapterControlBlock *pACB)
2820+{
2821+ uint32_t host_interrupt_status;
2822+ struct MessageUnit_F __iomem *phbcmu = pACB->pmuF;
2823+
2824+ host_interrupt_status = readl(&phbcmu->host_int_status) &
2825+ (ARCMSR_HBEMU_OUTBOUND_POSTQUEUE_ISR |
2826+ ARCMSR_HBEMU_OUTBOUND_DOORBELL_ISR);
2827+ if (!host_interrupt_status)
2828+ return IRQ_NONE;
2829+ do {
2830+ /* MU post queue interrupts*/
2831+ if (host_interrupt_status & ARCMSR_HBEMU_OUTBOUND_POSTQUEUE_ISR)
2832+ arcmsr_hbaF_postqueue_isr(pACB);
2833+
2834+ /* MU ioctl transfer doorbell interrupts*/
2835+ if (host_interrupt_status & ARCMSR_HBEMU_OUTBOUND_DOORBELL_ISR)
2836+ arcmsr_hbaE_doorbell_isr(pACB);
2837+
2838+ host_interrupt_status = readl(&phbcmu->host_int_status);
2839+ } while (host_interrupt_status & (ARCMSR_HBEMU_OUTBOUND_POSTQUEUE_ISR |
2840+ ARCMSR_HBEMU_OUTBOUND_DOORBELL_ISR));
2841+ return IRQ_HANDLED;
2842+}
2843+
26972844 static irqreturn_t arcmsr_interrupt(struct AdapterControlBlock *acb)
26982845 {
26992846 switch (acb->adapter_type) {
27002847 case ACB_ADAPTER_TYPE_A:
27012848 return arcmsr_hbaA_handle_isr(acb);
2702− break;
27032849 case ACB_ADAPTER_TYPE_B:
27042850 return arcmsr_hbaB_handle_isr(acb);
2705− break;
27062851 case ACB_ADAPTER_TYPE_C:
27072852 return arcmsr_hbaC_handle_isr(acb);
27082853 case ACB_ADAPTER_TYPE_D:
27092854 return arcmsr_hbaD_handle_isr(acb);
27102855 case ACB_ADAPTER_TYPE_E:
27112856 return arcmsr_hbaE_handle_isr(acb);
2857+ case ACB_ADAPTER_TYPE_F:
2858+ return arcmsr_hbaF_handle_isr(acb);
27122859 default:
27132860 return IRQ_NONE;
27142861 }
@@ -3257,6 +3404,31 @@ static bool arcmsr_hbaE_get_config(struct AdapterControlBlock *pACB) · 542 unmodified lines
32573404 return true;
32583405 }
32593406
3407+static bool arcmsr_hbaF_get_config(struct AdapterControlBlock *pACB)
3408+{
3409+ struct MessageUnit_F __iomem *reg = pACB->pmuF;
3410+ uint32_t intmask_org;
3411+
3412+ /* disable all outbound interrupt */
3413+ intmask_org = readl(&reg->host_int_mask); /* disable outbound message0 int */
3414+ writel(intmask_org | ARCMSR_HBEMU_ALL_INTMASKENABLE, &reg->host_int_mask);
3415+ /* wait firmware ready */
3416+ arcmsr_wait_firmware_ready(pACB);
3417+ /* post "get config" instruction */
3418+ writel(ARCMSR_INBOUND_MESG0_GET_CONFIG, &reg->inbound_msgaddr0);
3419+
3420+ pACB->out_doorbell ^= ARCMSR_HBEMU_DRV2IOP_MESSAGE_CMD_DONE;
3421+ writel(pACB->out_doorbell, &reg->iobound_doorbell);
3422+ /* wait message ready */
3423+ if (!arcmsr_hbaE_wait_msgint_ready(pACB)) {
3424+ pr_notice("arcmsr%d: wait get adapter firmware miscellaneous data timeout\n",
3425+ pACB->host->host_no);
3426+ return false;
3427+ }
3428+ arcmsr_get_adapter_config(pACB, pACB->msgcode_rwbuffer);
3429+ return true;
3430+}
3431+
32603432 static bool arcmsr_get_firmware_spec(struct AdapterControlBlock *acb)
32613433 {
32623434 bool rtn = false;
@@ -3277,6 +3449,9 @@ static bool arcmsr_get_firmware_spec(struct AdapterControlBlock *acb) · 14 unmodified lines
32773449 case ACB_ADAPTER_TYPE_E:
32783450 rtn = arcmsr_hbaE_get_config(acb);
32793451 break;
3452+ case ACB_ADAPTER_TYPE_F:
3453+ rtn = arcmsr_hbaF_get_config(acb);
3454+ break;
32803455 default:
32813456 break;
32823457 }
@@ -3634,23 +3809,20 @@ static int arcmsr_polling_ccbdone(struct AdapterControlBlock *acb, · 351 unmodified lines
36343809 int rtn = 0;
36353810 switch (acb->adapter_type) {
36363811
3637− case ACB_ADAPTER_TYPE_A: {
3812+ case ACB_ADAPTER_TYPE_A:
36383813 rtn = arcmsr_hbaA_polling_ccbdone(acb, poll_ccb);
3639− }
36403814 break;
3641−
3642− case ACB_ADAPTER_TYPE_B: {
3815+ case ACB_ADAPTER_TYPE_B:
36433816 rtn = arcmsr_hbaB_polling_ccbdone(acb, poll_ccb);
3644− }
36453817 break;
3646− case ACB_ADAPTER_TYPE_C: {
3818+ case ACB_ADAPTER_TYPE_C:
36473819 rtn = arcmsr_hbaC_polling_ccbdone(acb, poll_ccb);
3648− }
36493820 break;
36503821 case ACB_ADAPTER_TYPE_D:
36513822 rtn = arcmsr_hbaD_polling_ccbdone(acb, poll_ccb);
36523823 break;
36533824 case ACB_ADAPTER_TYPE_E:
3825+ case ACB_ADAPTER_TYPE_F:
36543826 rtn = arcmsr_hbaE_polling_ccbdone(acb, poll_ccb);
36553827 break;
36563828 }
@@ -3731,6 +3903,16 @@ static void arcmsr_set_iop_datetime(struct timer_list *t) · 74 unmodified lines
37313903 writel(pacb->out_doorbell, &reg->iobound_doorbell);
37323904 break;
37333905 }
3906+ case ACB_ADAPTER_TYPE_F: {
3907+ struct MessageUnit_F __iomem *reg = pacb->pmuF;
3908+
3909+ pacb->msgcode_rwbuffer[0] = datetime.b.msg_time[0];
3910+ pacb->msgcode_rwbuffer[1] = datetime.b.msg_time[1];
3911+ writel(ARCMSR_INBOUND_MESG0_SYNC_TIMER, &reg->inbound_msgaddr0);
3912+ pacb->out_doorbell ^= ARCMSR_HBEMU_DRV2IOP_MESSAGE_CMD_DONE;
3913+ writel(pacb->out_doorbell, &reg->iobound_doorbell);
3914+ break;
3915+ }
37343916 }
37353917 if (sys_tz.tz_minuteswest)
37363918 next_time = ARCMSR_HOURS;
@@ -3756,6 +3938,7 @@ static int arcmsr_iop_confirm(struct AdapterControlBlock *acb) · 19 unmodified lines
37563938 dma_coherent_handle = acb->dma_coherent_handle2;
37573939 break;
37583940 case ACB_ADAPTER_TYPE_E:
3941+ case ACB_ADAPTER_TYPE_F:
37593942 dma_coherent_handle = acb->dma_coherent_handle +
37603943 offsetof(struct CommandControlBlock, arcmsr_cdb);
37613944 break;
@@ -3873,11 +4056,8 @@ static int arcmsr_iop_confirm(struct AdapterControlBlock *acb) · 111 unmodified lines
38734056 writel(cdb_phyaddr, &reg->msgcode_rwbuffer[2]);
38744057 writel(cdb_phyaddr_hi32, &reg->msgcode_rwbuffer[3]);
38754058 writel(acb->ccbsize, &reg->msgcode_rwbuffer[4]);
3876− dma_coherent_handle = acb->dma_coherent_handle2;
3877− cdb_phyaddr = (uint32_t)(dma_coherent_handle & 0xffffffff);
3878− cdb_phyaddr_hi32 = (uint32_t)((dma_coherent_handle >> 16) >> 16);
3879− writel(cdb_phyaddr, &reg->msgcode_rwbuffer[5]);
3880− writel(cdb_phyaddr_hi32, &reg->msgcode_rwbuffer[6]);
4059+ writel(lower_32_bits(acb->dma_coherent_handle2), &reg->msgcode_rwbuffer[5]);
4060+ writel(upper_32_bits(acb->dma_coherent_handle2), &reg->msgcode_rwbuffer[6]);
38814061 writel(acb->ioqueue_size, &reg->msgcode_rwbuffer[7]);
38824062 writel(ARCMSR_INBOUND_MESG0_SET_CONFIG, &reg->inbound_msgaddr0);
38834063 acb->out_doorbell ^= ARCMSR_HBEMU_DRV2IOP_MESSAGE_CMD_DONE;
@@ -3889,6 +4069,27 @@ static int arcmsr_iop_confirm(struct AdapterControlBlock *acb) · 5 unmodified lines
38894069 }
38904070 }
38914071 break;
4072+ case ACB_ADAPTER_TYPE_F: {
4073+ struct MessageUnit_F __iomem *reg = acb->pmuF;
4074+
4075+ acb->msgcode_rwbuffer[0] = ARCMSR_SIGNATURE_SET_CONFIG;
4076+ acb->msgcode_rwbuffer[1] = ARCMSR_SIGNATURE_1886;
4077+ acb->msgcode_rwbuffer[2] = cdb_phyaddr;
4078+ acb->msgcode_rwbuffer[3] = cdb_phyaddr_hi32;
4079+ acb->msgcode_rwbuffer[4] = acb->ccbsize;
4080+ acb->msgcode_rwbuffer[5] = lower_32_bits(acb->dma_coherent_handle2);
4081+ acb->msgcode_rwbuffer[6] = upper_32_bits(acb->dma_coherent_handle2);
4082+ acb->msgcode_rwbuffer[7] = acb->completeQ_size;
4083+ writel(ARCMSR_INBOUND_MESG0_SET_CONFIG, &reg->inbound_msgaddr0);
4084+ acb->out_doorbell ^= ARCMSR_HBEMU_DRV2IOP_MESSAGE_CMD_DONE;
4085+ writel(acb->out_doorbell, &reg->iobound_doorbell);
4086+ if (!arcmsr_hbaE_wait_msgint_ready(acb)) {
4087+ pr_notice("arcmsr%d: 'set command Q window' timeout\n",
4088+ acb->host->host_no);
4089+ return 1;
4090+ }
4091+ }
4092+ break;
38924093 }
38934094 return 0;
38944095 }
@@ -3937,7 +4138,8 @@ static void arcmsr_wait_firmware_ready(struct AdapterControlBlock *acb) · 42 unmodified lines
39374138 ARCMSR_ARC1214_MESSAGE_FIRMWARE_OK) == 0);
39384139 }
39394140 break;
3940− case ACB_ADAPTER_TYPE_E: {
4141+ case ACB_ADAPTER_TYPE_E:
4142+ case ACB_ADAPTER_TYPE_F: {
39414143 struct MessageUnit_E __iomem *reg = acb->pmuE;
39424144 do {
39434145 if (!(acb->acb_flags & ACB_F_IOP_INITED))
@@ -3952,24 +4154,10 @@ static void arcmsr_wait_firmware_ready(struct AdapterControlBlock *acb) · 8 unmodified lines
39524154 static void arcmsr_request_device_map(struct timer_list *t)
39534155 {
39544156 struct AdapterControlBlock *acb = from_timer(acb, t, eternal_timer);
3955− if (unlikely(atomic_read(&acb->rq_map_token) == 0) ||
3956− (acb->acb_flags & ACB_F_BUS_RESET) ||
3957− (acb->acb_flags & ACB_F_ABORT)) {
3958− mod_timer(&acb->eternal_timer,
3959− jiffies + msecs_to_jiffies(6 * HZ));
4157+ if (acb->acb_flags & (ACB_F_MSG_GET_CONFIG | ACB_F_BUS_RESET | ACB_F_ABORT)) {
4158+ mod_timer(&acb->eternal_timer, jiffies + msecs_to_jiffies(6 * HZ));
39604159 } else {
39614160 acb->fw_flag = FW_NORMAL;
3962− if (atomic_read(&acb->ante_token_value) ==
3963− atomic_read(&acb->rq_map_token)) {
3964− atomic_set(&acb->rq_map_token, 16);
3965− }
3966− atomic_set(&acb->ante_token_value,
3967− atomic_read(&acb->rq_map_token));
3968− if (atomic_dec_and_test(&acb->rq_map_token)) {
3969− mod_timer(&acb->eternal_timer, jiffies +
3970− msecs_to_jiffies(6 * HZ));
3971− return;
3972− }
39734161 switch (acb->adapter_type) {
39744162 case ACB_ADAPTER_TYPE_A: {
39754163 struct MessageUnit_A __iomem *reg = acb->pmuA;
@@ -3999,10 +4187,23 @@ static void arcmsr_request_device_map(struct timer_list *t) · 23 unmodified lines
39994187 writel(acb->out_doorbell, &reg->iobound_doorbell);
40004188 break;
40014189 }
4190+ case ACB_ADAPTER_TYPE_F: {
4191+ struct MessageUnit_F __iomem *reg = acb->pmuF;
4192+ uint32_t outMsg1 = readl(&reg->outbound_msgaddr1);
4193+
4194+ if (!(outMsg1 & ARCMSR_HBFMU_MESSAGE_FIRMWARE_OK) ||
4195+ (outMsg1 & ARCMSR_HBFMU_MESSAGE_NO_VOLUME_CHANGE))
4196+ goto nxt6s;
4197+ writel(ARCMSR_INBOUND_MESG0_GET_CONFIG, &reg->inbound_msgaddr0);
4198+ acb->out_doorbell ^= ARCMSR_HBEMU_DRV2IOP_MESSAGE_CMD_DONE;
4199+ writel(acb->out_doorbell, &reg->iobound_doorbell);
4200+ break;
4201+ }
40024202 default:
40034203 return;
40044204 }
40054205 acb->acb_flags |= ACB_F_MSG_GET_CONFIG;
4206+nxt6s:
40064207 mod_timer(&acb->eternal_timer, jiffies + msecs_to_jiffies(6 * HZ));
40074208 }
40084209 }
@@ -4084,6 +4285,7 @@ static void arcmsr_start_adapter_bgrb(struct AdapterControlBlock *acb) · 75 unmodified lines
40844285 arcmsr_hbaD_start_bgrb(acb);
40854286 break;
40864287 case ACB_ADAPTER_TYPE_E:
4288+ case ACB_ADAPTER_TYPE_F:
40874289 arcmsr_hbaE_start_bgrb(acb);
40884290 break;
40894291 }
@@ -4163,7 +4365,8 @@ static void arcmsr_clear_doorbell_queue_buffer(struct AdapterControlBlock *acb) · 73 unmodified lines
41634365 }
41644366 }
41654367 break;
4166− case ACB_ADAPTER_TYPE_E: {
4368+ case ACB_ADAPTER_TYPE_E:
4369+ case ACB_ADAPTER_TYPE_F: {
41674370 struct MessageUnit_E __iomem *reg = acb->pmuE;
41684371 uint32_t i, tmp;
41694372
@@ -4290,7 +4493,8 @@ static bool arcmsr_reset_in_progress(struct AdapterControlBlock *acb) · 120 unmodified lines
42904493 true : false;
42914494 }
42924495 break;
4293− case ACB_ADAPTER_TYPE_E:{
4496+ case ACB_ADAPTER_TYPE_E:
4497+ case ACB_ADAPTER_TYPE_F:{
42944498 struct MessageUnit_E __iomem *reg = acb->pmuE;
42954499 rtn = (readl(&reg->host_diagnostic_3xxx) &
42964500 ARCMSR_ARC188X_RESET_ADAPTER) ? true : false;
@@ -4389,8 +4593,6 @@ wait_reset_done: · 92 unmodified lines
43894593 goto wait_reset_done;
43904594 }
43914595 arcmsr_iop_init(acb);
4392− atomic_set(&acb->rq_map_token, 16);
4393− atomic_set(&acb->ante_token_value, 16);
43944596 acb->fw_flag = FW_NORMAL;
43954597 mod_timer(&acb->eternal_timer, jiffies +
43964598 msecs_to_jiffies(6 * HZ));
@@ -4399,8 +4601,6 @@ wait_reset_done: · 2 unmodified lines
43994601 pr_notice("arcmsr: scsi bus reset eh returns with success\n");
44004602 } else {
44014603 acb->acb_flags &= ~ACB_F_BUS_RESET;
4402− atomic_set(&acb->rq_map_token, 16);
4403− atomic_set(&acb->ante_token_value, 16);
44044604 acb->fw_flag = FW_NORMAL;
44054605 mod_timer(&acb->eternal_timer, jiffies +
44064606 msecs_to_jiffies(6 * HZ));
@@ -4493,6 +4693,9 @@ static const char *arcmsr_info(struct Scsi_Host *host) · 86 unmodified lines
44934693 case PCI_DEVICE_ID_ARECA_1884:
44944694 type = "SAS/SATA";
44954695 break;
4696+ case PCI_DEVICE_ID_ARECA_1886:
4697+ type = "NVMe/SAS/SATA";
4698+ break;
44964699 default:
44974700 type = "unknown";
44984701 raid6 = 0;
drivers/scsi/bfa/bfad.c+1−0
@@ -749,6 +749,7 @@ bfad_pci_init(struct pci_dev *pdev, struct bfad_s *bfad) · 748 unmodified lines
749749
750750 if (bfad->pci_bar0_kva == NULL) {
751751 printk(KERN_ERR "Fail to map bar0\n");
752+ rc = -ENODEV;
752753 goto out_release_region;
753754 }
754755
drivers/scsi/dc395x.c+1−24
@@ -4721,30 +4721,7 @@ static struct pci_driver dc395x_driver = { · 4720 unmodified lines
47214721 .probe = dc395x_init_one,
47224722 .remove = dc395x_remove_one,
47234723 };
4724−
4725−
4726−/**
4727− * dc395x_module_init - Module initialization function
4728− *
4729− * Used by both module and built-in driver to initialise this driver.
4730− **/
4731−static int __init dc395x_module_init(void)
4732−{
4733− return pci_register_driver(&dc395x_driver);
4734−}
4735−
4736−
4737−/**
4738− * dc395x_module_exit - Module cleanup function.
4739− **/
4740−static void __exit dc395x_module_exit(void)
4741−{
4742− pci_unregister_driver(&dc395x_driver);
4743−}
4744−
4745−
4746−module_init(dc395x_module_init);
4747−module_exit(dc395x_module_exit);
4724+module_pci_driver(dc395x_driver);
47484725
47494726 MODULE_AUTHOR("C.L. Huang / Erich Chen / Kurt Garloff");
47504727 MODULE_DESCRIPTION("SCSI host adapter driver for Tekram TRM-S1040 based adapters: Tekram DC395 and DC315 series");
drivers/scsi/fcoe/fcoe_sysfs.c+1−7
@@ -1053,16 +1053,10 @@ EXPORT_SYMBOL_GPL(fcoe_fcf_device_add); · 1052 unmodified lines
10531053
10541054 int __init fcoe_sysfs_setup(void)
10551055 {
1056− int error;
1057−
10581056 atomic_set(&ctlr_num, 0);
10591057 atomic_set(&fcf_num, 0);
10601058
1061− error = bus_register(&fcoe_bus_type);
1062− if (error)
1063− return error;
1064−
1065− return 0;
1059+ return bus_register(&fcoe_bus_type);
10661060 }
10671061
10681062 void __exit fcoe_sysfs_teardown(void)
drivers/scsi/fnic/vnic_wq_copy.c+1−7
@@ -79,8 +79,6 @@ int vnic_wq_copy_alloc(struct vnic_dev *vdev, struct vnic_wq_copy *wq, · 78 unmodified lines
7979 unsigned int index, unsigned int desc_count,
8080 unsigned int desc_size)
8181 {
82− int err;
83−
8482 wq->index = index;
8583 wq->vdev = vdev;
8684 wq->to_use_index = wq->to_clean_index = 0;
@@ -92,11 +90,7 @@ int vnic_wq_copy_alloc(struct vnic_dev *vdev, struct vnic_wq_copy *wq, · 5 unmodified lines
9290
9391 vnic_wq_copy_disable(wq);
9492
95− err = vnic_dev_alloc_desc_ring(vdev, &wq->ring, desc_count, desc_size);
96− if (err)
97− return err;
98−
99− return 0;
93+ return vnic_dev_alloc_desc_ring(vdev, &wq->ring, desc_count, desc_size);
10094 }
10195
10296 void vnic_wq_copy_init(struct vnic_wq_copy *wq, unsigned int cq_index,
drivers/scsi/gdth.c+76−75
@@ -3168,81 +3168,6 @@ static inline void gdth_timer_init(void) · 3167 unmodified lines
31683168 }
31693169 #endif
31703170
3171−static void __init internal_setup(char *str,int *ints)
3172−{
3173− int i;
3174− char *cur_str, *argv;
3175−
3176− TRACE2(("internal_setup() str %s ints[0] %d\n",
3177− str ? str:"NULL", ints ? ints[0]:0));
3178−
3179− /* analyse string */
3180− argv = str;
3181− while (argv && (cur_str = strchr(argv, ':'))) {
3182− int val = 0, c = *++cur_str;
3183−
3184− if (c == 'n' || c == 'N')
3185− val = 0;
3186− else if (c == 'y' || c == 'Y')
3187− val = 1;
3188− else
3189− val = (int)simple_strtoul(cur_str, NULL, 0);
3190−
3191− if (!strncmp(argv, "disable:", 8))
3192− disable = val;
3193− else if (!strncmp(argv, "reserve_mode:", 13))
3194− reserve_mode = val;
3195− else if (!strncmp(argv, "reverse_scan:", 13))
3196− reverse_scan = val;
3197− else if (!strncmp(argv, "hdr_channel:", 12))
3198− hdr_channel = val;
3199− else if (!strncmp(argv, "max_ids:", 8))
3200− max_ids = val;
3201− else if (!strncmp(argv, "rescan:", 7))
3202− rescan = val;
3203− else if (!strncmp(argv, "shared_access:", 14))
3204− shared_access = val;
3205− else if (!strncmp(argv, "reserve_list:", 13)) {
3206− reserve_list[0] = val;
3207− for (i = 1; i < MAX_RES_ARGS; i++) {
3208− cur_str = strchr(cur_str, ',');
3209− if (!cur_str)
3210− break;
3211− if (!isdigit((int)*++cur_str)) {
3212− --cur_str;
3213− break;
3214− }
3215− reserve_list[i] =
3216− (int)simple_strtoul(cur_str, NULL, 0);
3217− }
3218− if (!cur_str)
3219− break;
3220− argv = ++cur_str;
3221− continue;
3222− }
3223−
3224− if ((argv = strchr(argv, ',')))
3225− ++argv;
3226− }
3227−}
3228−
3229−int __init option_setup(char *str)
3230−{
3231− int ints[MAXHA];
3232− char *cur = str;
3233− int i = 1;
3234−
3235− TRACE2(("option_setup() str %s\n", str ? str:"NULL"));
3236−
3237− while (cur && isdigit(*cur) && i < MAXHA) {
3238− ints[i++] = simple_strtoul(cur, NULL, 0);
3239− if ((cur = strchr(cur, ',')) != NULL) cur++;
3240− }
3241−
3242− ints[0] = i - 1;
3243− internal_setup(cur, ints);
3244− return 1;
3245−}
32463171
32473172 static const char *gdth_ctr_name(gdth_ha_str *ha)
32483173 {
@@ -4317,5 +4242,81 @@ module_init(gdth_init); · 1068 unmodified lines
43174242 module_exit(gdth_exit);
43184243
43194244 #ifndef MODULE
4245+static void __init internal_setup(char *str,int *ints)
4246+{
4247+ int i;
4248+ char *cur_str, *argv;
4249+
4250+ TRACE2(("internal_setup() str %s ints[0] %d\n",
4251+ str ? str:"NULL", ints ? ints[0]:0));
4252+
4253+ /* analyse string */
4254+ argv = str;
4255+ while (argv && (cur_str = strchr(argv, ':'))) {
4256+ int val = 0, c = *++cur_str;
4257+
4258+ if (c == 'n' || c == 'N')
4259+ val = 0;
4260+ else if (c == 'y' || c == 'Y')
4261+ val = 1;
4262+ else
4263+ val = (int)simple_strtoul(cur_str, NULL, 0);
4264+
4265+ if (!strncmp(argv, "disable:", 8))
4266+ disable = val;
4267+ else if (!strncmp(argv, "reserve_mode:", 13))
4268+ reserve_mode = val;
4269+ else if (!strncmp(argv, "reverse_scan:", 13))
4270+ reverse_scan = val;
4271+ else if (!strncmp(argv, "hdr_channel:", 12))
4272+ hdr_channel = val;
4273+ else if (!strncmp(argv, "max_ids:", 8))
4274+ max_ids = val;
4275+ else if (!strncmp(argv, "rescan:", 7))
4276+ rescan = val;
4277+ else if (!strncmp(argv, "shared_access:", 14))
4278+ shared_access = val;
4279+ else if (!strncmp(argv, "reserve_list:", 13)) {
4280+ reserve_list[0] = val;
4281+ for (i = 1; i < MAX_RES_ARGS; i++) {
4282+ cur_str = strchr(cur_str, ',');
4283+ if (!cur_str)
4284+ break;
4285+ if (!isdigit((int)*++cur_str)) {
4286+ --cur_str;
4287+ break;
4288+ }
4289+ reserve_list[i] =
4290+ (int)simple_strtoul(cur_str, NULL, 0);
4291+ }
4292+ if (!cur_str)
4293+ break;
4294+ argv = ++cur_str;
4295+ continue;
4296+ }
4297+
4298+ if ((argv = strchr(argv, ',')))
4299+ ++argv;
4300+ }
4301+}
4302+
4303+static int __init option_setup(char *str)
4304+{
4305+ int ints[MAXHA];
4306+ char *cur = str;
4307+ int i = 1;
4308+
4309+ TRACE2(("option_setup() str %s\n", str ? str:"NULL"));
4310+
4311+ while (cur && isdigit(*cur) && i < MAXHA) {
4312+ ints[i++] = simple_strtoul(cur, NULL, 0);
4313+ if ((cur = strchr(cur, ',')) != NULL) cur++;
4314+ }
4315+
4316+ ints[0] = i - 1;
4317+ internal_setup(cur, ints);
4318+ return 1;
4319+}
4320+
43204321 __setup("gdth=", option_setup);
43214322 #endif
drivers/scsi/initio.c+1−13
@@ -2962,20 +2962,8 @@ static struct pci_driver initio_pci_driver = { · 2961 unmodified lines
29622962 .probe = initio_probe_one,
29632963 .remove = initio_remove_one,
29642964 };
2965−
2966−static int __init initio_init_driver(void)
2967−{
2968− return pci_register_driver(&initio_pci_driver);
2969−}
2970−
2971−static void __exit initio_exit_driver(void)
2972−{
2973− pci_unregister_driver(&initio_pci_driver);
2974−}
2965+module_pci_driver(initio_pci_driver);
29752966
29762967 MODULE_DESCRIPTION("Initio INI-9X00U/UW SCSI device driver");
29772968 MODULE_AUTHOR("Initio Corporation");
29782969 MODULE_LICENSE("GPL");
2979−
2980−module_init(initio_init_driver);
2981−module_exit(initio_exit_driver);
drivers/scsi/isci/remote_node_table.h+1−1
@@ -61,7 +61,7 @@ · 60 unmodified lines
6161 /**
6262 *
6363 *
64− * Remote node sets are sets of remote node index in the remtoe node table The
64+ * Remote node sets are sets of remote node index in the remote node table. The
6565 * SCU hardware requires that STP remote node entries take three consecutive
6666 * remote node index so the table is arranged in sets of three. The bits are
6767 * used as 0111 0111 to make a byte and the bits define the set of three remote
drivers/scsi/myrb.c+2−3
@@ -1050,7 +1050,7 @@ static int myrb_get_hba_config(struct myrb_hba *cb) · 1049 unmodified lines
10501050 enquiry2->fw.turn_id = 0;
10511051 }
10521052 snprintf(cb->fw_version, sizeof(cb->fw_version),
1053− "%d.%02d-%c-%02d",
1053+ "%u.%02u-%c-%02u",
10541054 enquiry2->fw.major_version,
10551055 enquiry2->fw.minor_version,
10561056 enquiry2->fw.firmware_type,
@@ -2167,7 +2167,7 @@ static ssize_t ctlr_num_show(struct device *dev, · 1110 unmodified lines
21672167 struct Scsi_Host *shost = class_to_shost(dev);
21682168 struct myrb_hba *cb = shost_priv(shost);
21692169
2170− return snprintf(buf, 20, "%d\n", cb->ctlr_num);
2170+ return snprintf(buf, 20, "%u\n", cb->ctlr_num);
21712171 }
21722172 static DEVICE_ATTR_RO(ctlr_num);
21732173
@@ -2732,7 +2732,6 @@ static int DAC960_LA_hw_init(struct pci_dev *pdev, · 558 unmodified lines
27322732 DAC960_LA_disable_intr(base);
27332733 DAC960_LA_ack_hw_mbox_status(base);
27342734 udelay(1000);
2735− timeout = 0;
27362735 while (DAC960_LA_init_in_progress(base) &&
27372736 timeout < MYRB_MAILBOX_TIMEOUT) {
27382737 if (DAC960_LA_read_error_status(base, &error,
drivers/scsi/pm8001/pm8001_ctl.c+4−2
@@ -408,9 +408,10 @@ static ssize_t pm8001_ctl_ib_queue_log_show(struct device *cdev, · 407 unmodified lines
408408 int offset;
409409 char *str = buf;
410410 int start = 0;
411+ u32 ib_offset = pm8001_ha->ib_offset;
411412 #define IB_MEMMAP(c) \
412413 (*(u32 *)((u8 *)pm8001_ha-> \
413− memoryMap.region[IB].virt_ptr + \
414+ memoryMap.region[ib_offset].virt_ptr + \
414415 pm8001_ha->evtlog_ib_offset + (c)))
415416
416417 for (offset = 0; offset < IB_OB_READ_TIMES; offset++) {
@@ -442,9 +443,10 @@ static ssize_t pm8001_ctl_ob_queue_log_show(struct device *cdev, · 25 unmodified lines
442443 int offset;
443444 char *str = buf;
444445 int start = 0;
446+ u32 ob_offset = pm8001_ha->ob_offset;
445447 #define OB_MEMMAP(c) \
446448 (*(u32 *)((u8 *)pm8001_ha-> \
447− memoryMap.region[OB].virt_ptr + \
449+ memoryMap.region[ob_offset].virt_ptr + \
448450 pm8001_ha->evtlog_ob_offset + (c)))
449451
450452 for (offset = 0; offset < IB_OB_READ_TIMES; offset++) {
drivers/scsi/pm8001/pm8001_defs.h+13−14
@@ -75,12 +75,10 @@ enum port_type { · 74 unmodified lines
7575 };
7676
7777 /* driver compile-time configuration */
78−#define PM8001_MAX_CCB 256 /* max ccbs supported */
78+#define PM8001_MAX_CCB 1024 /* max ccbs supported */
7979 #define PM8001_MPI_QUEUE 1024 /* maximum mpi queue entries */
80−#define PM8001_MAX_INB_NUM 1
81−#define PM8001_MAX_OUTB_NUM 1
82−#define PM8001_MAX_SPCV_INB_NUM 1
83−#define PM8001_MAX_SPCV_OUTB_NUM 4
80+#define PM8001_MAX_INB_NUM 64
81+#define PM8001_MAX_OUTB_NUM 64
8482 #define PM8001_CAN_QUEUE 508 /* SCSI Queue depth */
8583
8684 /* Inbound/Outbound queue size */
@@ -92,26 +90,27 @@ enum port_type { · 5 unmodified lines
9290 #define PM8001_MAX_PORTS 16 /* max. possible ports */
9391 #define PM8001_MAX_DEVICES 2048 /* max supported device */
9492 #define PM8001_MAX_MSIX_VEC 64 /* max msi-x int for spcv/ve */
93+#define PM8001_RESERVE_SLOT 8
9594
96−#define USI_MAX_MEMCNT_BASE 5
97−#define IB (USI_MAX_MEMCNT_BASE + 1)
98−#define CI (IB + PM8001_MAX_SPCV_INB_NUM)
99−#define OB (CI + PM8001_MAX_SPCV_INB_NUM)
100−#define PI (OB + PM8001_MAX_SPCV_OUTB_NUM)
101−#define USI_MAX_MEMCNT (PI + PM8001_MAX_SPCV_OUTB_NUM)
10295 #define CONFIG_SCSI_PM8001_MAX_DMA_SG 528
10396 #define PM8001_MAX_DMA_SG CONFIG_SCSI_PM8001_MAX_DMA_SG
97+
10498 enum memory_region_num {
10599 AAP1 = 0x0, /* application acceleration processor */
106100 IOP, /* IO processor */
107101 NVMD, /* NVM device */
108− DEV_MEM, /* memory for devices */
109− CCB_MEM, /* memory for command control block */
110102 FW_FLASH, /* memory for fw flash update */
111− FORENSIC_MEM /* memory for fw forensic data */
103+ FORENSIC_MEM, /* memory for fw forensic data */
104+ USI_MAX_MEMCNT_BASE
112105 };
113106 #define PM8001_EVENT_LOG_SIZE (128 * 1024)
114107
108+/**
109+ * maximum DMA memory regions(number of IBQ + number of IBQ CI
110+ * + number of OBQ + number of OBQ PI)
111+ */
112+#define USI_MAX_MEMCNT (USI_MAX_MEMCNT_BASE + ((2 * PM8001_MAX_INB_NUM) \
113+ + (2 * PM8001_MAX_OUTB_NUM)))
115114 /*error code*/
116115 enum mpi_err {
117116 MPI_IO_STATUS_SUCCESS = 0x0,
drivers/scsi/pm8001/pm8001_hwi.c+20−18
@@ -189,6 +189,10 @@ static void init_default_table_values(struct pm8001_hba_info *pm8001_ha) · 188 unmodified lines
189189 u32 offsetib, offsetob;
190190 void __iomem *addressib = pm8001_ha->inbnd_q_tbl_addr;
191191 void __iomem *addressob = pm8001_ha->outbnd_q_tbl_addr;
192+ u32 ib_offset = pm8001_ha->ib_offset;
193+ u32 ob_offset = pm8001_ha->ob_offset;
194+ u32 ci_offset = pm8001_ha->ci_offset;
195+ u32 pi_offset = pm8001_ha->pi_offset;
192196
193197 pm8001_ha->main_cfg_tbl.pm8001_tbl.inbound_q_nppd_hppd = 0;
194198 pm8001_ha->main_cfg_tbl.pm8001_tbl.outbound_hw_event_pid0_3 = 0;
@@ -223,19 +227,19 @@ static void init_default_table_values(struct pm8001_hba_info *pm8001_ha) · 28 unmodified lines
223227 pm8001_ha->inbnd_q_tbl[i].element_pri_size_cnt =
224228 PM8001_MPI_QUEUE | (pm8001_ha->iomb_size << 16) | (0x00<<30);
225229 pm8001_ha->inbnd_q_tbl[i].upper_base_addr =
226− pm8001_ha->memoryMap.region[IB + i].phys_addr_hi;
230+ pm8001_ha->memoryMap.region[ib_offset + i].phys_addr_hi;
227231 pm8001_ha->inbnd_q_tbl[i].lower_base_addr =
228− pm8001_ha->memoryMap.region[IB + i].phys_addr_lo;
232+ pm8001_ha->memoryMap.region[ib_offset + i].phys_addr_lo;
229233 pm8001_ha->inbnd_q_tbl[i].base_virt =
230− (u8 *)pm8001_ha->memoryMap.region[IB + i].virt_ptr;
234+ (u8 *)pm8001_ha->memoryMap.region[ib_offset + i].virt_ptr;
231235 pm8001_ha->inbnd_q_tbl[i].total_length =
232− pm8001_ha->memoryMap.region[IB + i].total_len;
236+ pm8001_ha->memoryMap.region[ib_offset + i].total_len;
233237 pm8001_ha->inbnd_q_tbl[i].ci_upper_base_addr =
234− pm8001_ha->memoryMap.region[CI + i].phys_addr_hi;
238+ pm8001_ha->memoryMap.region[ci_offset + i].phys_addr_hi;
235239 pm8001_ha->inbnd_q_tbl[i].ci_lower_base_addr =
236− pm8001_ha->memoryMap.region[CI + i].phys_addr_lo;
240+ pm8001_ha->memoryMap.region[ci_offset + i].phys_addr_lo;
237241 pm8001_ha->inbnd_q_tbl[i].ci_virt =
238− pm8001_ha->memoryMap.region[CI + i].virt_ptr;
242+ pm8001_ha->memoryMap.region[ci_offset + i].virt_ptr;
239243 offsetib = i * 0x20;
240244 pm8001_ha->inbnd_q_tbl[i].pi_pci_bar =
241245 get_pci_bar_index(pm8001_mr32(addressib,
@@ -249,21 +253,21 @@ static void init_default_table_values(struct pm8001_hba_info *pm8001_ha) · 7 unmodified lines
249253 pm8001_ha->outbnd_q_tbl[i].element_size_cnt =
250254 PM8001_MPI_QUEUE | (pm8001_ha->iomb_size << 16) | (0x01<<30);
251255 pm8001_ha->outbnd_q_tbl[i].upper_base_addr =
252− pm8001_ha->memoryMap.region[OB + i].phys_addr_hi;
256+ pm8001_ha->memoryMap.region[ob_offset + i].phys_addr_hi;
253257 pm8001_ha->outbnd_q_tbl[i].lower_base_addr =
254− pm8001_ha->memoryMap.region[OB + i].phys_addr_lo;
258+ pm8001_ha->memoryMap.region[ob_offset + i].phys_addr_lo;
255259 pm8001_ha->outbnd_q_tbl[i].base_virt =
256− (u8 *)pm8001_ha->memoryMap.region[OB + i].virt_ptr;
260+ (u8 *)pm8001_ha->memoryMap.region[ob_offset + i].virt_ptr;
257261 pm8001_ha->outbnd_q_tbl[i].total_length =
258− pm8001_ha->memoryMap.region[OB + i].total_len;
262+ pm8001_ha->memoryMap.region[ob_offset + i].total_len;
259263 pm8001_ha->outbnd_q_tbl[i].pi_upper_base_addr =
260− pm8001_ha->memoryMap.region[PI + i].phys_addr_hi;
264+ pm8001_ha->memoryMap.region[pi_offset + i].phys_addr_hi;
261265 pm8001_ha->outbnd_q_tbl[i].pi_lower_base_addr =
262− pm8001_ha->memoryMap.region[PI + i].phys_addr_lo;
266+ pm8001_ha->memoryMap.region[pi_offset + i].phys_addr_lo;
263267 pm8001_ha->outbnd_q_tbl[i].interrup_vec_cnt_delay =
264268 0 | (10 << 16) | (i << 24);
265269 pm8001_ha->outbnd_q_tbl[i].pi_virt =
266− pm8001_ha->memoryMap.region[PI + i].virt_ptr;
270+ pm8001_ha->memoryMap.region[pi_offset + i].virt_ptr;
267271 offsetob = i * 0x24;
268272 pm8001_ha->outbnd_q_tbl[i].ci_pci_bar =
269273 get_pci_bar_index(pm8001_mr32(addressob,
@@ -4371,8 +4375,7 @@ static int pm8001_chip_ssp_io_req(struct pm8001_hba_info *pm8001_ha, · 4101 unmodified lines
43714375 /* fill in PRD (scatter/gather) table, if any */
43724376 if (task->num_scatter > 1) {
43734377 pm8001_chip_make_sg(task->scatter, ccb->n_elem, ccb->buf_prd);
4374− phys_addr = ccb->ccb_dma_handle +
4375− offsetof(struct pm8001_ccb_info, buf_prd[0]);
4378+ phys_addr = ccb->ccb_dma_handle;
43764379 ssp_cmd.addr_low = cpu_to_le32(lower_32_bits(phys_addr));
43774380 ssp_cmd.addr_high = cpu_to_le32(upper_32_bits(phys_addr));
43784381 ssp_cmd.esgl = cpu_to_le32(1<<31);
@@ -4445,8 +4448,7 @@ static int pm8001_chip_sata_req(struct pm8001_hba_info *pm8001_ha, · 66 unmodified lines
44454448 /* fill in PRD (scatter/gather) table, if any */
44464449 if (task->num_scatter > 1) {
44474450 pm8001_chip_make_sg(task->scatter, ccb->n_elem, ccb->buf_prd);
4448− phys_addr = ccb->ccb_dma_handle +
4449− offsetof(struct pm8001_ccb_info, buf_prd[0]);
4451+ phys_addr = ccb->ccb_dma_handle;
44504452 sata_cmd.addr_low = lower_32_bits(phys_addr);
44514453 sata_cmd.addr_high = upper_32_bits(phys_addr);
44524454 sata_cmd.esgl = cpu_to_le32(1 << 31);
drivers/scsi/pm8001/pm8001_init.c+150−71
@@ -56,6 +56,7 @@ MODULE_PARM_DESC(link_rate, "Enable link rate.\n" · 55 unmodified lines
5656 " 8: Link rate 12.0G\n");
5757
5858 static struct scsi_transport_template *pm8001_stt;
59+static int pm8001_init_ccb_tag(struct pm8001_hba_info *, struct Scsi_Host *, struct pci_dev *);
5960
6061 /*
6162 * chip info structure to identify chip key functionality as
@@ -264,12 +265,36 @@ static u32 pm8001_request_irq(struct pm8001_hba_info *pm8001_ha); · 202 unmodified lines
264265 static int pm8001_alloc(struct pm8001_hba_info *pm8001_ha,
265266 const struct pci_device_id *ent)
266267 {
267− int i;
268+ int i, count = 0, rc = 0;
269+ u32 ci_offset, ib_offset, ob_offset, pi_offset;
270+ struct inbound_queue_table *circularQ;
271+
268272 spin_lock_init(&pm8001_ha->lock);
269273 spin_lock_init(&pm8001_ha->bitmap_lock);
270274 PM8001_INIT_DBG(pm8001_ha,
271275 pm8001_printk("pm8001_alloc: PHY:%x\n",
272276 pm8001_ha->chip->n_phy));
277+
278+ /* Setup Interrupt */
279+ rc = pm8001_setup_irq(pm8001_ha);
280+ if (rc) {
281+ PM8001_FAIL_DBG(pm8001_ha, pm8001_printk(
282+ "pm8001_setup_irq failed [ret: %d]\n", rc));
283+ goto err_out_shost;
284+ }
285+ /* Request Interrupt */
286+ rc = pm8001_request_irq(pm8001_ha);
287+ if (rc)
288+ goto err_out_shost;
289+
290+ count = pm8001_ha->max_q_num;
291+ /* Queues are chosen based on the number of cores/msix availability */
292+ ib_offset = pm8001_ha->ib_offset = USI_MAX_MEMCNT_BASE;
293+ ci_offset = pm8001_ha->ci_offset = ib_offset + count;
294+ ob_offset = pm8001_ha->ob_offset = ci_offset + count;
295+ pi_offset = pm8001_ha->pi_offset = ob_offset + count;
296+ pm8001_ha->max_memcnt = pi_offset + count;
297+
273298 for (i = 0; i < pm8001_ha->chip->n_phy; i++) {
274299 pm8001_phy_init(pm8001_ha, i);
275300 pm8001_ha->port[i].wide_port_phymap = 0;
@@ -278,9 +303,6 @@ static int pm8001_alloc(struct pm8001_hba_info *pm8001_ha, · 2 unmodified lines
278303 INIT_LIST_HEAD(&pm8001_ha->port[i].list);
279304 }
280305
281− pm8001_ha->tags = kzalloc(PM8001_MAX_CCB, GFP_KERNEL);
282− if (!pm8001_ha->tags)
283− goto err_out;
284306 /* MPI Memory region 1 for AAP Event Log for fw */
285307 pm8001_ha->memoryMap.region[AAP1].num_elements = 1;
286308 pm8001_ha->memoryMap.region[AAP1].element_size = PM8001_EVENT_LOG_SIZE;
@@ -293,54 +315,62 @@ static int pm8001_alloc(struct pm8001_hba_info *pm8001_ha, · 6 unmodified lines
293315 pm8001_ha->memoryMap.region[IOP].total_len = PM8001_EVENT_LOG_SIZE;
294316 pm8001_ha->memoryMap.region[IOP].alignment = 32;
295317
296− for (i = 0; i < PM8001_MAX_SPCV_INB_NUM; i++) {
318+ for (i = 0; i < count; i++) {
319+ circularQ = &pm8001_ha->inbnd_q_tbl[i];
320+ spin_lock_init(&circularQ->iq_lock);
297321 /* MPI Memory region 3 for consumer Index of inbound queues */
298− pm8001_ha->memoryMap.region[CI+i].num_elements = 1;
299− pm8001_ha->memoryMap.region[CI+i].element_size = 4;
300− pm8001_ha->memoryMap.region[CI+i].total_len = 4;
301− pm8001_ha->memoryMap.region[CI+i].alignment = 4;
322+ pm8001_ha->memoryMap.region[ci_offset+i].num_elements = 1;
323+ pm8001_ha->memoryMap.region[ci_offset+i].element_size = 4;
324+ pm8001_ha->memoryMap.region[ci_offset+i].total_len = 4;
325+ pm8001_ha->memoryMap.region[ci_offset+i].alignment = 4;
302326
303327 if ((ent->driver_data) != chip_8001) {
304328 /* MPI Memory region 5 inbound queues */
305− pm8001_ha->memoryMap.region[IB+i].num_elements =
329+ pm8001_ha->memoryMap.region[ib_offset+i].num_elements =
306330 PM8001_MPI_QUEUE;
307− pm8001_ha->memoryMap.region[IB+i].element_size = 128;
308− pm8001_ha->memoryMap.region[IB+i].total_len =
331+ pm8001_ha->memoryMap.region[ib_offset+i].element_size
332+ = 128;
333+ pm8001_ha->memoryMap.region[ib_offset+i].total_len =
309334 PM8001_MPI_QUEUE * 128;
310− pm8001_ha->memoryMap.region[IB+i].alignment = 128;
335+ pm8001_ha->memoryMap.region[ib_offset+i].alignment
336+ = 128;
311337 } else {
312− pm8001_ha->memoryMap.region[IB+i].num_elements =
338+ pm8001_ha->memoryMap.region[ib_offset+i].num_elements =
313339 PM8001_MPI_QUEUE;
314− pm8001_ha->memoryMap.region[IB+i].element_size = 64;
315− pm8001_ha->memoryMap.region[IB+i].total_len =
340+ pm8001_ha->memoryMap.region[ib_offset+i].element_size
341+ = 64;
342+ pm8001_ha->memoryMap.region[ib_offset+i].total_len =
316343 PM8001_MPI_QUEUE * 64;
317− pm8001_ha->memoryMap.region[IB+i].alignment = 64;
344+ pm8001_ha->memoryMap.region[ib_offset+i].alignment = 64;
318345 }
319346 }
320347
321− for (i = 0; i < PM8001_MAX_SPCV_OUTB_NUM; i++) {
348+ for (i = 0; i < count; i++) {
322349 /* MPI Memory region 4 for producer Index of outbound queues */
323− pm8001_ha->memoryMap.region[PI+i].num_elements = 1;
324− pm8001_ha->memoryMap.region[PI+i].element_size = 4;
325− pm8001_ha->memoryMap.region[PI+i].total_len = 4;
326− pm8001_ha->memoryMap.region[PI+i].alignment = 4;
350+ pm8001_ha->memoryMap.region[pi_offset+i].num_elements = 1;
351+ pm8001_ha->memoryMap.region[pi_offset+i].element_size = 4;
352+ pm8001_ha->memoryMap.region[pi_offset+i].total_len = 4;
353+ pm8001_ha->memoryMap.region[pi_offset+i].alignment = 4;
327354
328355 if (ent->driver_data != chip_8001) {
329356 /* MPI Memory region 6 Outbound queues */
330− pm8001_ha->memoryMap.region[OB+i].num_elements =
357+ pm8001_ha->memoryMap.region[ob_offset+i].num_elements =
331358 PM8001_MPI_QUEUE;
332− pm8001_ha->memoryMap.region[OB+i].element_size = 128;
333− pm8001_ha->memoryMap.region[OB+i].total_len =
359+ pm8001_ha->memoryMap.region[ob_offset+i].element_size
360+ = 128;
361+ pm8001_ha->memoryMap.region[ob_offset+i].total_len =
334362 PM8001_MPI_QUEUE * 128;
335− pm8001_ha->memoryMap.region[OB+i].alignment = 128;
363+ pm8001_ha->memoryMap.region[ob_offset+i].alignment
364+ = 128;
336365 } else {
337366 /* MPI Memory region 6 Outbound queues */
338− pm8001_ha->memoryMap.region[OB+i].num_elements =
367+ pm8001_ha->memoryMap.region[ob_offset+i].num_elements =
339368 PM8001_MPI_QUEUE;
340− pm8001_ha->memoryMap.region[OB+i].element_size = 64;
341− pm8001_ha->memoryMap.region[OB+i].total_len =
369+ pm8001_ha->memoryMap.region[ob_offset+i].element_size
370+ = 64;
371+ pm8001_ha->memoryMap.region[ob_offset+i].total_len =
342372 PM8001_MPI_QUEUE * 64;
343− pm8001_ha->memoryMap.region[OB+i].alignment = 64;
373+ pm8001_ha->memoryMap.region[ob_offset+i].alignment = 64;
344374 }
345375
346376 }
@@ -348,19 +378,6 @@ static int pm8001_alloc(struct pm8001_hba_info *pm8001_ha, · 1 unmodified line
348378 pm8001_ha->memoryMap.region[NVMD].num_elements = 1;
349379 pm8001_ha->memoryMap.region[NVMD].element_size = 4096;
350380 pm8001_ha->memoryMap.region[NVMD].total_len = 4096;
351− /* Memory region for devices*/
352− pm8001_ha->memoryMap.region[DEV_MEM].num_elements = 1;
353− pm8001_ha->memoryMap.region[DEV_MEM].element_size = PM8001_MAX_DEVICES *
354− sizeof(struct pm8001_device);
355− pm8001_ha->memoryMap.region[DEV_MEM].total_len = PM8001_MAX_DEVICES *
356− sizeof(struct pm8001_device);
357−
358− /* Memory region for ccb_info*/
359− pm8001_ha->memoryMap.region[CCB_MEM].num_elements = 1;
360− pm8001_ha->memoryMap.region[CCB_MEM].element_size = PM8001_MAX_CCB *
361− sizeof(struct pm8001_ccb_info);
362− pm8001_ha->memoryMap.region[CCB_MEM].total_len = PM8001_MAX_CCB *
363− sizeof(struct pm8001_ccb_info);
364381
365382 /* Memory region for fw flash */
366383 pm8001_ha->memoryMap.region[FW_FLASH].total_len = 4096;
@@ -369,7 +386,7 @@ static int pm8001_alloc(struct pm8001_hba_info *pm8001_ha, · 2 unmodified lines
369386 pm8001_ha->memoryMap.region[FORENSIC_MEM].total_len = 0x10000;
370387 pm8001_ha->memoryMap.region[FORENSIC_MEM].element_size = 0x10000;
371388 pm8001_ha->memoryMap.region[FORENSIC_MEM].alignment = 0x10000;
372− for (i = 0; i < USI_MAX_MEMCNT; i++) {
389+ for (i = 0; i < pm8001_ha->max_memcnt; i++) {
373390 if (pm8001_mem_alloc(pm8001_ha->pdev,
374391 &pm8001_ha->memoryMap.region[i].virt_ptr,
375392 &pm8001_ha->memoryMap.region[i].phys_addr,
@@ -384,27 +401,36 @@ static int pm8001_alloc(struct pm8001_hba_info *pm8001_ha, · 8 unmodified lines
384401 }
385402 }
386403
387− pm8001_ha->devices = pm8001_ha->memoryMap.region[DEV_MEM].virt_ptr;
404+ /* Memory region for devices*/
405+ pm8001_ha->devices = kzalloc(PM8001_MAX_DEVICES
406+ * sizeof(struct pm8001_device), GFP_KERNEL);
407+ if (!pm8001_ha->devices) {
408+ rc = -ENOMEM;
409+ goto err_out_nodev;
410+ }
388411 for (i = 0; i < PM8001_MAX_DEVICES; i++) {
389412 pm8001_ha->devices[i].dev_type = SAS_PHY_UNUSED;
390413 pm8001_ha->devices[i].id = i;
391414 pm8001_ha->devices[i].device_id = PM8001_MAX_DEVICES;
392415 pm8001_ha->devices[i].running_req = 0;
393416 }
394− pm8001_ha->ccb_info = pm8001_ha->memoryMap.region[CCB_MEM].virt_ptr;
395− for (i = 0; i < PM8001_MAX_CCB; i++) {
396− pm8001_ha->ccb_info[i].ccb_dma_handle =
397− pm8001_ha->memoryMap.region[CCB_MEM].phys_addr +
398− i * sizeof(struct pm8001_ccb_info);
399− pm8001_ha->ccb_info[i].task = NULL;
400− pm8001_ha->ccb_info[i].ccb_tag = 0xffffffff;
401− pm8001_ha->ccb_info[i].device = NULL;
402− ++pm8001_ha->tags_num;
403− }
404417 pm8001_ha->flags = PM8001F_INIT_TIME;
405418 /* Initialize tags */
406419 pm8001_tag_init(pm8001_ha);
407420 return 0;
421+
422+err_out_shost:
423+ scsi_remove_host(pm8001_ha->shost);
424+err_out_nodev:
425+ for (i = 0; i < pm8001_ha->max_memcnt; i++) {
426+ if (pm8001_ha->memoryMap.region[i].virt_ptr != NULL) {
427+ pci_free_consistent(pm8001_ha->pdev,
428+ (pm8001_ha->memoryMap.region[i].total_len +
429+ pm8001_ha->memoryMap.region[i].alignment),
430+ pm8001_ha->memoryMap.region[i].virt_ptr,
431+ pm8001_ha->memoryMap.region[i].phys_addr);
432+ }
433+ }
408434 err_out:
409435 return 1;
410436 }
@@ -899,7 +925,8 @@ static int pm8001_configure_phy_settings(struct pm8001_hba_info *pm8001_ha) · 488 unmodified lines
899925 static u32 pm8001_setup_msix(struct pm8001_hba_info *pm8001_ha)
900926 {
901927 u32 number_of_intr;
902− int rc;
928+ int rc, cpu_online_count;
929+ unsigned int allocated_irq_vectors;
903930
904931 /* SPCv controllers supports 64 msi-x */
905932 if (pm8001_ha->chip_id == chip_8001) {
@@ -908,13 +935,21 @@ static u32 pm8001_setup_msix(struct pm8001_hba_info *pm8001_ha) · 2 unmodified lines
908935 number_of_intr = PM8001_MAX_MSIX_VEC;
909936 }
910937
938+ cpu_online_count = num_online_cpus();
939+ number_of_intr = min_t(int, cpu_online_count, number_of_intr);
911940 rc = pci_alloc_irq_vectors(pm8001_ha->pdev, number_of_intr,
912941 number_of_intr, PCI_IRQ_MSIX);
913− number_of_intr = rc;
942+ allocated_irq_vectors = rc;
914943 if (rc < 0)
915944 return rc;
945+
946+ /* Assigns the number of interrupts */
947+ number_of_intr = min_t(int, allocated_irq_vectors, number_of_intr);
916948 pm8001_ha->number_of_intr = number_of_intr;
917949
950+ /* Maximum queue number updating in HBA structure */
951+ pm8001_ha->max_q_num = number_of_intr;
952+
918953 PM8001_INIT_DBG(pm8001_ha, pm8001_printk(
919954 "pci_alloc_irq_vectors request ret:%d no of intr %d\n",
920955 rc, pm8001_ha->number_of_intr));
@@ -1069,13 +1104,6 @@ static int pm8001_pci_probe(struct pci_dev *pdev, · 148 unmodified lines
10691104 rc = -ENOMEM;
10701105 goto err_out_free;
10711106 }
1072− /* Setup Interrupt */
1073− rc = pm8001_setup_irq(pm8001_ha);
1074− if (rc) {
1075− PM8001_FAIL_DBG(pm8001_ha, pm8001_printk(
1076− "pm8001_setup_irq failed [ret: %d]\n", rc));
1077− goto err_out_shost;
1078− }
10791107
10801108 PM8001_CHIP_DISP->chip_soft_rst(pm8001_ha);
10811109 rc = PM8001_CHIP_DISP->chip_init(pm8001_ha);
@@ -1085,16 +1113,13 @@ static int pm8001_pci_probe(struct pci_dev *pdev, · 3 unmodified lines
10851113 goto err_out_ha_free;
10861114 }
10871115
1116+ rc = pm8001_init_ccb_tag(pm8001_ha, shost, pdev);
1117+ if (rc)
1118+ goto err_out_enable;
1119+
10881120 rc = scsi_add_host(shost, &pdev->dev);
10891121 if (rc)
10901122 goto err_out_ha_free;
1091− /* Request Interrupt */
1092− rc = pm8001_request_irq(pm8001_ha);
1093− if (rc) {
1094− PM8001_FAIL_DBG(pm8001_ha, pm8001_printk(
1095− "pm8001_request_irq failed [ret: %d]\n", rc));
1096− goto err_out_shost;
1097− }
10981123
10991124 PM8001_CHIP_DISP->interrupt_enable(pm8001_ha, 0);
11001125 if (pm8001_ha->chip_id != chip_8001) {
@@ -1137,6 +1162,60 @@ err_out_enable: · 36 unmodified lines
11371162 return rc;
11381163 }
11391164
1165+/*
1166+ * pm8001_init_ccb_tag - allocate memory to CCB and tag.
1167+ * @pm8001_ha: our hba card information.
1168+ * @shost: scsi host which has been allocated outside.
1169+ */
1170+static int
1171+pm8001_init_ccb_tag(struct pm8001_hba_info *pm8001_ha, struct Scsi_Host *shost,
1172+ struct pci_dev *pdev)
1173+{
1174+ int i = 0;
1175+ u32 max_out_io, ccb_count;
1176+ u32 can_queue;
1177+
1178+ max_out_io = pm8001_ha->main_cfg_tbl.pm80xx_tbl.max_out_io;
1179+ ccb_count = min_t(int, PM8001_MAX_CCB, max_out_io);
1180+
1181+ /* Update to the scsi host*/
1182+ can_queue = ccb_count - PM8001_RESERVE_SLOT;
1183+ shost->can_queue = can_queue;
1184+
1185+ pm8001_ha->tags = kzalloc(ccb_count, GFP_KERNEL);
1186+ if (!pm8001_ha->tags)
1187+ goto err_out;
1188+
1189+ /* Memory region for ccb_info*/
1190+ pm8001_ha->ccb_info = (struct pm8001_ccb_info *)
1191+ kcalloc(ccb_count, sizeof(struct pm8001_ccb_info), GFP_KERNEL);
1192+ if (!pm8001_ha->ccb_info) {
1193+ PM8001_FAIL_DBG(pm8001_ha, pm8001_printk
1194+ ("Unable to allocate memory for ccb\n"));
1195+ goto err_out_noccb;
1196+ }
1197+ for (i = 0; i < ccb_count; i++) {
1198+ pm8001_ha->ccb_info[i].buf_prd = pci_alloc_consistent(pdev,
1199+ sizeof(struct pm8001_prd) * PM8001_MAX_DMA_SG,
1200+ &pm8001_ha->ccb_info[i].ccb_dma_handle);
1201+ if (!pm8001_ha->ccb_info[i].buf_prd) {
1202+ PM8001_FAIL_DBG(pm8001_ha, pm8001_printk
1203+ ("pm80xx: ccb prd memory allocation error\n"));
1204+ goto err_out;
1205+ }
1206+ pm8001_ha->ccb_info[i].task = NULL;
1207+ pm8001_ha->ccb_info[i].ccb_tag = 0xffffffff;
1208+ pm8001_ha->ccb_info[i].device = NULL;
1209+ ++pm8001_ha->tags_num;
1210+ }
1211+ return 0;
1212+
1213+err_out_noccb:
1214+ kfree(pm8001_ha->devices);
1215+err_out:
1216+ return -ENOMEM;
1217+}
1218+
11401219 static void pm8001_pci_remove(struct pci_dev *pdev)
11411220 {
11421221 struct sas_ha_struct *sha = pci_get_drvdata(pdev);
drivers/scsi/pm8001/pm8001_sas.h+11−4
@@ -58,7 +58,7 @@ · 57 unmodified lines
5858 #include "pm8001_defs.h"
5959
6060 #define DRV_NAME "pm80xx"
61−#define DRV_VERSION "0.1.39"
61+#define DRV_VERSION "0.1.40"
6262 #define PM8001_FAIL_LOGGING 0x01 /* Error message logging */
6363 #define PM8001_INIT_LOGGING 0x02 /* driver init logging */
6464 #define PM8001_DISC_LOGGING 0x04 /* discovery layer logging */
@@ -315,7 +315,7 @@ struct pm8001_ccb_info { · 250 unmodified lines
315315 u32 ccb_tag;
316316 dma_addr_t ccb_dma_handle;
317317 struct pm8001_device *device;
318− struct pm8001_prd buf_prd[PM8001_MAX_DMA_SG];
318+ struct pm8001_prd *buf_prd;
319319 struct fw_control_ex *fw_control_context;
320320 u8 open_retry;
321321 };
@@ -468,6 +468,7 @@ struct inbound_queue_table { · 146 unmodified lines
468468 u32 reserved;
469469 __le32 consumer_index;
470470 u32 producer_idx;
471+ spinlock_t iq_lock;
471472 };
472473 struct outbound_queue_table {
473474 u32 element_size_cnt;
@@ -524,8 +525,8 @@ struct pm8001_hba_info { · 50 unmodified lines
524525 void __iomem *fatal_tbl_addr; /*MPI IVT Table Addr */
525526 union main_cfg_table main_cfg_tbl;
526527 union general_status_table gs_tbl;
527− struct inbound_queue_table inbnd_q_tbl[PM8001_MAX_SPCV_INB_NUM];
528− struct outbound_queue_table outbnd_q_tbl[PM8001_MAX_SPCV_OUTB_NUM];
528+ struct inbound_queue_table inbnd_q_tbl[PM8001_MAX_INB_NUM];
529+ struct outbound_queue_table outbnd_q_tbl[PM8001_MAX_OUTB_NUM];
529530 struct sas_phy_attribute_table phy_attr_table;
530531 /* MPI SAS PHY attributes */
531532 u8 sas_addr[SAS_ADDR_SIZE];
@@ -561,6 +562,12 @@ struct pm8001_hba_info { · 29 unmodified lines
561562 u32 reset_in_progress;
562563 u32 non_fatal_count;
563564 u32 non_fatal_read_length;
565+ u32 max_q_num;
566+ u32 ib_offset;
567+ u32 ob_offset;
568+ u32 ci_offset;
569+ u32 pi_offset;
570+ u32 max_memcnt;
564571 };
565572
566573 struct pm8001_work {
drivers/scsi/pm8001/pm80xx_hwi.c+56−53
@@ -720,7 +720,7 @@ static void read_inbnd_queue_table(struct pm8001_hba_info *pm8001_ha) · 719 unmodified lines
720720 {
721721 int i;
722722 void __iomem *address = pm8001_ha->inbnd_q_tbl_addr;
723− for (i = 0; i < PM8001_MAX_SPCV_INB_NUM; i++) {
723+ for (i = 0; i < PM8001_MAX_INB_NUM; i++) {
724724 u32 offset = i * 0x20;
725725 pm8001_ha->inbnd_q_tbl[i].pi_pci_bar =
726726 get_pci_bar_index(pm8001_mr32(address,
@@ -738,7 +738,7 @@ static void read_outbnd_queue_table(struct pm8001_hba_info *pm8001_ha) · 11 unmodified lines
738738 {
739739 int i;
740740 void __iomem *address = pm8001_ha->outbnd_q_tbl_addr;
741− for (i = 0; i < PM8001_MAX_SPCV_OUTB_NUM; i++) {
741+ for (i = 0; i < PM8001_MAX_OUTB_NUM; i++) {
742742 u32 offset = i * 0x24;
743743 pm8001_ha->outbnd_q_tbl[i].ci_pci_bar =
744744 get_pci_bar_index(pm8001_mr32(address,
@@ -758,6 +758,10 @@ static void init_default_table_values(struct pm8001_hba_info *pm8001_ha) · 13 unmodified lines
758758 u32 offsetib, offsetob;
759759 void __iomem *addressib = pm8001_ha->inbnd_q_tbl_addr;
760760 void __iomem *addressob = pm8001_ha->outbnd_q_tbl_addr;
761+ u32 ib_offset = pm8001_ha->ib_offset;
762+ u32 ob_offset = pm8001_ha->ob_offset;
763+ u32 ci_offset = pm8001_ha->ci_offset;
764+ u32 pi_offset = pm8001_ha->pi_offset;
761765
762766 pm8001_ha->main_cfg_tbl.pm80xx_tbl.upper_event_log_addr =
763767 pm8001_ha->memoryMap.region[AAP1].phys_addr_hi;
@@ -778,23 +782,23 @@ static void init_default_table_values(struct pm8001_hba_info *pm8001_ha) · 14 unmodified lines
778782 /* Disable end to end CRC checking */
779783 pm8001_ha->main_cfg_tbl.pm80xx_tbl.crc_core_dump = (0x1 << 16);
780784
781− for (i = 0; i < PM8001_MAX_SPCV_INB_NUM; i++) {
785+ for (i = 0; i < pm8001_ha->max_q_num; i++) {
782786 pm8001_ha->inbnd_q_tbl[i].element_pri_size_cnt =
783787 PM8001_MPI_QUEUE | (pm8001_ha->iomb_size << 16) | (0x00<<30);
784788 pm8001_ha->inbnd_q_tbl[i].upper_base_addr =
785− pm8001_ha->memoryMap.region[IB + i].phys_addr_hi;
789+ pm8001_ha->memoryMap.region[ib_offset + i].phys_addr_hi;
786790 pm8001_ha->inbnd_q_tbl[i].lower_base_addr =
787− pm8001_ha->memoryMap.region[IB + i].phys_addr_lo;
791+ pm8001_ha->memoryMap.region[ib_offset + i].phys_addr_lo;
788792 pm8001_ha->inbnd_q_tbl[i].base_virt =
789− (u8 *)pm8001_ha->memoryMap.region[IB + i].virt_ptr;
793+ (u8 *)pm8001_ha->memoryMap.region[ib_offset + i].virt_ptr;
790794 pm8001_ha->inbnd_q_tbl[i].total_length =
791− pm8001_ha->memoryMap.region[IB + i].total_len;
795+ pm8001_ha->memoryMap.region[ib_offset + i].total_len;
792796 pm8001_ha->inbnd_q_tbl[i].ci_upper_base_addr =
793− pm8001_ha->memoryMap.region[CI + i].phys_addr_hi;
797+ pm8001_ha->memoryMap.region[ci_offset + i].phys_addr_hi;
794798 pm8001_ha->inbnd_q_tbl[i].ci_lower_base_addr =
795− pm8001_ha->memoryMap.region[CI + i].phys_addr_lo;
799+ pm8001_ha->memoryMap.region[ci_offset + i].phys_addr_lo;
796800 pm8001_ha->inbnd_q_tbl[i].ci_virt =
797− pm8001_ha->memoryMap.region[CI + i].virt_ptr;
801+ pm8001_ha->memoryMap.region[ci_offset + i].virt_ptr;
798802 offsetib = i * 0x20;
799803 pm8001_ha->inbnd_q_tbl[i].pi_pci_bar =
800804 get_pci_bar_index(pm8001_mr32(addressib,
@@ -809,25 +813,25 @@ static void init_default_table_values(struct pm8001_hba_info *pm8001_ha) · 8 unmodified lines
809813 pm8001_ha->inbnd_q_tbl[i].pi_pci_bar,
810814 pm8001_ha->inbnd_q_tbl[i].pi_offset));
811815 }
812− for (i = 0; i < PM8001_MAX_SPCV_OUTB_NUM; i++) {
816+ for (i = 0; i < pm8001_ha->max_q_num; i++) {
813817 pm8001_ha->outbnd_q_tbl[i].element_size_cnt =
814818 PM8001_MPI_QUEUE | (pm8001_ha->iomb_size << 16) | (0x01<<30);
815819 pm8001_ha->outbnd_q_tbl[i].upper_base_addr =
816− pm8001_ha->memoryMap.region[OB + i].phys_addr_hi;
820+ pm8001_ha->memoryMap.region[ob_offset + i].phys_addr_hi;
817821 pm8001_ha->outbnd_q_tbl[i].lower_base_addr =
818− pm8001_ha->memoryMap.region[OB + i].phys_addr_lo;
822+ pm8001_ha->memoryMap.region[ob_offset + i].phys_addr_lo;
819823 pm8001_ha->outbnd_q_tbl[i].base_virt =
820− (u8 *)pm8001_ha->memoryMap.region[OB + i].virt_ptr;
824+ (u8 *)pm8001_ha->memoryMap.region[ob_offset + i].virt_ptr;
821825 pm8001_ha->outbnd_q_tbl[i].total_length =
822− pm8001_ha->memoryMap.region[OB + i].total_len;
826+ pm8001_ha->memoryMap.region[ob_offset + i].total_len;
823827 pm8001_ha->outbnd_q_tbl[i].pi_upper_base_addr =
824− pm8001_ha->memoryMap.region[PI + i].phys_addr_hi;
828+ pm8001_ha->memoryMap.region[pi_offset + i].phys_addr_hi;
825829 pm8001_ha->outbnd_q_tbl[i].pi_lower_base_addr =
826− pm8001_ha->memoryMap.region[PI + i].phys_addr_lo;
830+ pm8001_ha->memoryMap.region[pi_offset + i].phys_addr_lo;
827831 /* interrupt vector based on oq */
828832 pm8001_ha->outbnd_q_tbl[i].interrup_vec_cnt_delay = (i << 24);
829833 pm8001_ha->outbnd_q_tbl[i].pi_virt =
830− pm8001_ha->memoryMap.region[PI + i].virt_ptr;
834+ pm8001_ha->memoryMap.region[pi_offset + i].virt_ptr;
831835 offsetob = i * 0x24;
832836 pm8001_ha->outbnd_q_tbl[i].ci_pci_bar =
833837 get_pci_bar_index(pm8001_mr32(addressob,
@@ -871,7 +875,7 @@ static void update_main_config_table(struct pm8001_hba_info *pm8001_ha) · 37 unmodified lines
871875 pm8001_ha->main_cfg_tbl.pm80xx_tbl.pcs_event_log_severity);
872876 /* Update Fatal error interrupt vector */
873877 pm8001_ha->main_cfg_tbl.pm80xx_tbl.fatal_err_interrupt |=
874− ((pm8001_ha->number_of_intr - 1) << 8);
878+ ((pm8001_ha->max_q_num - 1) << 8);
875879 pm8001_mw32(address, MAIN_FATAL_ERROR_INTERRUPT,
876880 pm8001_ha->main_cfg_tbl.pm80xx_tbl.fatal_err_interrupt);
877881 PM8001_DEV_DBG(pm8001_ha, pm8001_printk(
@@ -1010,8 +1014,12 @@ static int mpi_init_check(struct pm8001_hba_info *pm8001_ha) · 132 unmodified lines
10101014 value &= SPCv_MSGU_CFG_TABLE_UPDATE;
10111015 } while ((value != 0) && (--max_wait_count));
10121016
1013− if (!max_wait_count)
1014− return -1;
1017+ if (!max_wait_count) {
1018+ /* additional check */
1019+ PM8001_FAIL_DBG(pm8001_ha, pm8001_printk(
1020+ "Inb doorbell clear not toggled[value:%x]\n", value));
1021+ return -EBUSY;
1022+ }
10151023 /* check the MPI-State for initialization upto 100ms*/
10161024 max_wait_count = 100 * 1000;/* 100 msec */
10171025 do {
@@ -1022,12 +1030,12 @@ static int mpi_init_check(struct pm8001_hba_info *pm8001_ha) · 4 unmodified lines
10221030 } while ((GST_MPI_STATE_INIT !=
10231031 (gst_len_mpistate & GST_MPI_STATE_MASK)) && (--max_wait_count));
10241032 if (!max_wait_count)
1025− return -1;
1033+ return -EBUSY;
10261034
10271035 /* check MPI Initialization error */
10281036 gst_len_mpistate = gst_len_mpistate >> 16;
10291037 if (0x0000 != gst_len_mpistate)
1030− return -1;
1038+ return -EBUSY;
10311039
10321040 return 0;
10331041 }
@@ -1469,11 +1477,10 @@ static int pm80xx_chip_init(struct pm8001_hba_info *pm8001_ha) · 435 unmodified lines
14691477
14701478 /* update main config table ,inbound table and outbound table */
14711479 update_main_config_table(pm8001_ha);
1472− for (i = 0; i < PM8001_MAX_SPCV_INB_NUM; i++)
1480+ for (i = 0; i < pm8001_ha->max_q_num; i++) {
14731481 update_inbnd_queue_table(pm8001_ha, i);
1474− for (i = 0; i < PM8001_MAX_SPCV_OUTB_NUM; i++)
14751482 update_outbnd_queue_table(pm8001_ha, i);
1476−
1483+ }
14771484 /* notify firmware update finished and check initialization status */
14781485 if (0 == mpi_init_check(pm8001_ha)) {
14791486 PM8001_INIT_DBG(pm8001_ha,
@@ -4191,7 +4198,7 @@ static int process_oq(struct pm8001_hba_info *pm8001_ha, u8 vec) · 2711 unmodified lines
41914198 unsigned long flags;
41924199 u32 regval;
41934200
4194− if (vec == (pm8001_ha->number_of_intr - 1)) {
4201+ if (vec == (pm8001_ha->max_q_num - 1)) {
41954202 regval = pm8001_cr32(pm8001_ha, 0, MSGU_SCRATCH_PAD_1);
41964203 if ((regval & SCRATCH_PAD_MIPSALL_READY) !=
41974204 SCRATCH_PAD_MIPSALL_READY) {
@@ -4274,6 +4281,7 @@ static int pm80xx_chip_smp_req(struct pm8001_hba_info *pm8001_ha, · 76 unmodified lines
42744281 char *preq_dma_addr = NULL;
42754282 __le64 tmp_addr;
42764283 u32 i, length;
4284+ unsigned long flags;
42774285
42784286 memset(&smp_cmd, 0, sizeof(smp_cmd));
42794287 /*
@@ -4369,8 +4377,10 @@ static int pm80xx_chip_smp_req(struct pm8001_hba_info *pm8001_ha, · 89 unmodified lines
43694377
43704378 build_smp_cmd(pm8001_dev->device_id, smp_cmd.tag,
43714379 &smp_cmd, pm8001_ha->smp_exp_mode, length);
4380+ spin_lock_irqsave(&circularQ->iq_lock, flags);
43724381 rc = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc, &smp_cmd,
43734382 sizeof(smp_cmd), 0);
4383+ spin_unlock_irqrestore(&circularQ->iq_lock, flags);
43744384 if (rc)
43754385 goto err_out_2;
43764386 return 0;
@@ -4434,7 +4444,8 @@ static int pm80xx_chip_ssp_io_req(struct pm8001_hba_info *pm8001_ha, · 57 unmodified lines
44344444 u64 phys_addr, start_addr, end_addr;
44354445 u32 end_addr_high, end_addr_low;
44364446 struct inbound_queue_table *circularQ;
4437− u32 q_index;
4447+ unsigned long flags;
4448+ u32 q_index, cpu_id;
44384449 u32 opc = OPC_INB_SSPINIIOSTART;
44394450 memset(&ssp_cmd, 0, sizeof(ssp_cmd));
44404451 memcpy(ssp_cmd.ssp_iu.lun, task->ssp_task.LUN, 8);
@@ -4453,7 +4464,8 @@ static int pm80xx_chip_ssp_io_req(struct pm8001_hba_info *pm8001_ha, · 12 unmodified lines
44534464 ssp_cmd.ssp_iu.efb_prio_attr |= (task->ssp_task.task_attr & 7);
44544465 memcpy(ssp_cmd.ssp_iu.cdb, task->ssp_task.cmd->cmnd,
44554466 task->ssp_task.cmd->cmd_len);
4456− q_index = (u32) (pm8001_dev->id & 0x00ffffff) % PM8001_MAX_INB_NUM;
4467+ cpu_id = smp_processor_id();
4468+ q_index = (u32) (cpu_id) % (pm8001_ha->max_q_num);
44574469 circularQ = &pm8001_ha->inbnd_q_tbl[q_index];
44584470
44594471 /* Check if encryption is set */
@@ -4471,8 +4483,7 @@ static int pm80xx_chip_ssp_io_req(struct pm8001_hba_info *pm8001_ha, · 11 unmodified lines
44714483 if (task->num_scatter > 1) {
44724484 pm8001_chip_make_sg(task->scatter,
44734485 ccb->n_elem, ccb->buf_prd);
4474− phys_addr = ccb->ccb_dma_handle +
4475− offsetof(struct pm8001_ccb_info, buf_prd[0]);
4486+ phys_addr = ccb->ccb_dma_handle;
44764487 ssp_cmd.enc_addr_low =
44774488 cpu_to_le32(lower_32_bits(phys_addr));
44784489 ssp_cmd.enc_addr_high =
@@ -4501,9 +4512,7 @@ static int pm80xx_chip_ssp_io_req(struct pm8001_hba_info *pm8001_ha, · 22 unmodified lines
45014512 end_addr_high, end_addr_low));
45024513 pm8001_chip_make_sg(task->scatter, 1,
45034514 ccb->buf_prd);
4504− phys_addr = ccb->ccb_dma_handle +
4505− offsetof(struct pm8001_ccb_info,
4506− buf_prd[0]);
4515+ phys_addr = ccb->ccb_dma_handle;
45074516 ssp_cmd.enc_addr_low =
45084517 cpu_to_le32(lower_32_bits(phys_addr));
45094518 ssp_cmd.enc_addr_high =
@@ -4531,8 +4540,7 @@ static int pm80xx_chip_ssp_io_req(struct pm8001_hba_info *pm8001_ha, · 21 unmodified lines
45314540 if (task->num_scatter > 1) {
45324541 pm8001_chip_make_sg(task->scatter, ccb->n_elem,
45334542 ccb->buf_prd);
4534− phys_addr = ccb->ccb_dma_handle +
4535− offsetof(struct pm8001_ccb_info, buf_prd[0]);
4543+ phys_addr = ccb->ccb_dma_handle;
45364544 ssp_cmd.addr_low =
45374545 cpu_to_le32(lower_32_bits(phys_addr));
45384546 ssp_cmd.addr_high =
@@ -4560,9 +4568,7 @@ static int pm80xx_chip_ssp_io_req(struct pm8001_hba_info *pm8001_ha, · 21 unmodified lines
45604568 end_addr_high, end_addr_low));
45614569 pm8001_chip_make_sg(task->scatter, 1,
45624570 ccb->buf_prd);
4563− phys_addr = ccb->ccb_dma_handle +
4564− offsetof(struct pm8001_ccb_info,
4565− buf_prd[0]);
4571+ phys_addr = ccb->ccb_dma_handle;
45664572 ssp_cmd.addr_low =
45674573 cpu_to_le32(lower_32_bits(phys_addr));
45684574 ssp_cmd.addr_high =
@@ -4576,9 +4582,10 @@ static int pm80xx_chip_ssp_io_req(struct pm8001_hba_info *pm8001_ha, · 7 unmodified lines
45764582 ssp_cmd.esgl = 0;
45774583 }
45784584 }
4579− q_index = (u32) (pm8001_dev->id & 0x00ffffff) % PM8001_MAX_OUTB_NUM;
4585+ spin_lock_irqsave(&circularQ->iq_lock, flags);
45804586 ret = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc,
45814587 &ssp_cmd, sizeof(ssp_cmd), q_index);
4588+ spin_unlock_irqrestore(&circularQ->iq_lock, flags);
45824589 return ret;
45834590 }
45844591
@@ -4590,7 +4597,7 @@ static int pm80xx_chip_sata_req(struct pm8001_hba_info *pm8001_ha, · 5 unmodified lines
45904597 struct pm8001_device *pm8001_ha_dev = dev->lldd_dev;
45914598 u32 tag = ccb->ccb_tag;
45924599 int ret;
4593− u32 q_index;
4600+ u32 q_index, cpu_id;
45944601 struct sata_start_req sata_cmd;
45954602 u32 hdr_tag, ncg_tag = 0;
45964603 u64 phys_addr, start_addr, end_addr;
@@ -4601,7 +4608,8 @@ static int pm80xx_chip_sata_req(struct pm8001_hba_info *pm8001_ha, · 4 unmodified lines
46014608 unsigned long flags;
46024609 u32 opc = OPC_INB_SATA_HOST_OPSTART;
46034610 memset(&sata_cmd, 0, sizeof(sata_cmd));
4604− q_index = (u32) (pm8001_ha_dev->id & 0x00ffffff) % PM8001_MAX_INB_NUM;
4611+ cpu_id = smp_processor_id();
4612+ q_index = (u32) (cpu_id) % (pm8001_ha->max_q_num);
46054613 circularQ = &pm8001_ha->inbnd_q_tbl[q_index];
46064614
46074615 if (task->data_dir == DMA_NONE) {
@@ -4652,8 +4660,7 @@ static int pm80xx_chip_sata_req(struct pm8001_hba_info *pm8001_ha, · 44 unmodified lines
46524660 if (task->num_scatter > 1) {
46534661 pm8001_chip_make_sg(task->scatter,
46544662 ccb->n_elem, ccb->buf_prd);
4655− phys_addr = ccb->ccb_dma_handle +
4656− offsetof(struct pm8001_ccb_info, buf_prd[0]);
4663+ phys_addr = ccb->ccb_dma_handle;
46574664 sata_cmd.enc_addr_low = lower_32_bits(phys_addr);
46584665 sata_cmd.enc_addr_high = upper_32_bits(phys_addr);
46594666 sata_cmd.enc_esgl = cpu_to_le32(1 << 31);
@@ -4678,9 +4685,7 @@ static int pm80xx_chip_sata_req(struct pm8001_hba_info *pm8001_ha, · 18 unmodified lines
46784685 end_addr_high, end_addr_low));
46794686 pm8001_chip_make_sg(task->scatter, 1,
46804687 ccb->buf_prd);
4681− phys_addr = ccb->ccb_dma_handle +
4682− offsetof(struct pm8001_ccb_info,
4683− buf_prd[0]);
4688+ phys_addr = ccb->ccb_dma_handle;
46844689 sata_cmd.enc_addr_low =
46854690 lower_32_bits(phys_addr);
46864691 sata_cmd.enc_addr_high =
@@ -4718,8 +4723,7 @@ static int pm80xx_chip_sata_req(struct pm8001_hba_info *pm8001_ha, · 31 unmodified lines
47184723 if (task->num_scatter > 1) {
47194724 pm8001_chip_make_sg(task->scatter,
47204725 ccb->n_elem, ccb->buf_prd);
4721− phys_addr = ccb->ccb_dma_handle +
4722− offsetof(struct pm8001_ccb_info, buf_prd[0]);
4726+ phys_addr = ccb->ccb_dma_handle;
47234727 sata_cmd.addr_low = lower_32_bits(phys_addr);
47244728 sata_cmd.addr_high = upper_32_bits(phys_addr);
47254729 sata_cmd.esgl = cpu_to_le32(1 << 31);
@@ -4744,9 +4748,7 @@ static int pm80xx_chip_sata_req(struct pm8001_hba_info *pm8001_ha, · 18 unmodified lines
47444748 end_addr_high, end_addr_low));
47454749 pm8001_chip_make_sg(task->scatter, 1,
47464750 ccb->buf_prd);
4747− phys_addr = ccb->ccb_dma_handle +
4748− offsetof(struct pm8001_ccb_info,
4749− buf_prd[0]);
4751+ phys_addr = ccb->ccb_dma_handle;
47504752 sata_cmd.addr_low =
47514753 lower_32_bits(phys_addr);
47524754 sata_cmd.addr_high =
@@ -4817,9 +4819,10 @@ static int pm80xx_chip_sata_req(struct pm8001_hba_info *pm8001_ha, · 64 unmodified lines
48174819 }
48184820 }
48194821 }
4820− q_index = (u32) (pm8001_ha_dev->id & 0x00ffffff) % PM8001_MAX_OUTB_NUM;
4822+ spin_lock_irqsave(&circularQ->iq_lock, flags);
48214823 ret = pm8001_mpi_build_cmd(pm8001_ha, circularQ, opc,
48224824 &sata_cmd, sizeof(sata_cmd), q_index);
4825+ spin_unlock_irqrestore(&circularQ->iq_lock, flags);
48234826 return ret;
48244827 }
48254828
drivers/scsi/qla2xxx/qla_dfs.c+8−60
@@ -170,20 +170,7 @@ qla2x00_dfs_tgt_sess_show(struct seq_file *s, void *unused) · 169 unmodified lines
170170 return 0;
171171 }
172172
173−static int
174−qla2x00_dfs_tgt_sess_open(struct inode *inode, struct file *file)
175−{
176− scsi_qla_host_t *vha = inode->i_private;
177−
178− return single_open(file, qla2x00_dfs_tgt_sess_show, vha);
179−}
180−
181−static const struct file_operations dfs_tgt_sess_ops = {
182− .open = qla2x00_dfs_tgt_sess_open,
183− .read = seq_read,
184− .llseek = seq_lseek,
185− .release = single_release,
186−};
173+DEFINE_SHOW_ATTRIBUTE(qla2x00_dfs_tgt_sess);
187174
188175 static int
189176 qla2x00_dfs_tgt_port_database_show(struct seq_file *s, void *unused)
@@ -239,20 +226,7 @@ out_free_id_list: · 49 unmodified lines
239226 return 0;
240227 }
241228
242−static int
243−qla2x00_dfs_tgt_port_database_open(struct inode *inode, struct file *file)
244−{
245− scsi_qla_host_t *vha = inode->i_private;
246−
247− return single_open(file, qla2x00_dfs_tgt_port_database_show, vha);
248−}
249−
250−static const struct file_operations dfs_tgt_port_database_ops = {
251− .open = qla2x00_dfs_tgt_port_database_open,
252− .read = seq_read,
253− .llseek = seq_lseek,
254− .release = single_release,
255−};
229+DEFINE_SHOW_ATTRIBUTE(qla2x00_dfs_tgt_port_database);
256230
257231 static int
258232 qla_dfs_fw_resource_cnt_show(struct seq_file *s, void *unused)
@@ -301,20 +275,7 @@ qla_dfs_fw_resource_cnt_show(struct seq_file *s, void *unused) · 42 unmodified lines
301275 return 0;
302276 }
303277
304−static int
305−qla_dfs_fw_resource_cnt_open(struct inode *inode, struct file *file)
306−{
307− struct scsi_qla_host *vha = inode->i_private;
308−
309− return single_open(file, qla_dfs_fw_resource_cnt_show, vha);
310−}
311−
312−static const struct file_operations dfs_fw_resource_cnt_ops = {
313− .open = qla_dfs_fw_resource_cnt_open,
314− .read = seq_read,
315− .llseek = seq_lseek,
316− .release = single_release,
317−};
278+DEFINE_SHOW_ATTRIBUTE(qla_dfs_fw_resource_cnt);
318279
319280 static int
320281 qla_dfs_tgt_counters_show(struct seq_file *s, void *unused)
@@ -391,20 +352,7 @@ qla_dfs_tgt_counters_show(struct seq_file *s, void *unused) · 70 unmodified lines
391352 return 0;
392353 }
393354
394−static int
395−qla_dfs_tgt_counters_open(struct inode *inode, struct file *file)
396−{
397− struct scsi_qla_host *vha = inode->i_private;
398−
399− return single_open(file, qla_dfs_tgt_counters_show, vha);
400−}
401−
402−static const struct file_operations dfs_tgt_counters_ops = {
403− .open = qla_dfs_tgt_counters_open,
404− .read = seq_read,
405− .llseek = seq_lseek,
406− .release = single_release,
407−};
355+DEFINE_SHOW_ATTRIBUTE(qla_dfs_tgt_counters);
408356
409357 static int
410358 qla2x00_dfs_fce_show(struct seq_file *s, void *unused)
@@ -606,19 +554,19 @@ create_dir: · 195 unmodified lines
606554
607555 create_nodes:
608556 ha->dfs_fw_resource_cnt = debugfs_create_file("fw_resource_count",
609− S_IRUSR, ha->dfs_dir, vha, &dfs_fw_resource_cnt_ops);
557+ S_IRUSR, ha->dfs_dir, vha, &qla_dfs_fw_resource_cnt_fops);
610558
611559 ha->dfs_tgt_counters = debugfs_create_file("tgt_counters", S_IRUSR,
612− ha->dfs_dir, vha, &dfs_tgt_counters_ops);
560+ ha->dfs_dir, vha, &qla_dfs_tgt_counters_fops);
613561
614562 ha->tgt.dfs_tgt_port_database = debugfs_create_file("tgt_port_database",
615− S_IRUSR, ha->dfs_dir, vha, &dfs_tgt_port_database_ops);
563+ S_IRUSR, ha->dfs_dir, vha, &qla2x00_dfs_tgt_port_database_fops);
616564
617565 ha->dfs_fce = debugfs_create_file("fce", S_IRUSR, ha->dfs_dir, vha,
618566 &dfs_fce_ops);
619567
620568 ha->tgt.dfs_tgt_sess = debugfs_create_file("tgt_sess",
621− S_IRUSR, ha->dfs_dir, vha, &dfs_tgt_sess_ops);
569+ S_IRUSR, ha->dfs_dir, vha, &qla2x00_dfs_tgt_sess_fops);
622570
623571 if (IS_QLA27XX(ha) || IS_QLA83XX(ha) || IS_QLA28XX(ha)) {
624572 ha->tgt.dfs_naqp = debugfs_create_file("naqp",
drivers/scsi/qla2xxx/qla_isr.c+15−27
@@ -1838,6 +1838,7 @@ qla24xx_mbx_iocb_entry(scsi_qla_host_t *vha, struct req_que *req, · 1837 unmodified lines
18381838 struct mbx_24xx_entry *pkt)
18391839 {
18401840 const char func[] = "MBX-IOCB2";
1841+ struct qla_hw_data *ha = vha->hw;
18411842 srb_t *sp;
18421843 struct srb_iocb *si;
18431844 u16 sz, i;
@@ -1847,6 +1848,18 @@ qla24xx_mbx_iocb_entry(scsi_qla_host_t *vha, struct req_que *req, · 3 unmodified lines
18471848 if (!sp)
18481849 return;
18491850
1851+ if (sp->type == SRB_SCSI_CMD ||
1852+ sp->type == SRB_NVME_CMD ||
1853+ sp->type == SRB_TM_CMD) {
1854+ ql_log(ql_log_warn, vha, 0x509d,
1855+ "Inconsistent event entry type %d\n", sp->type);
1856+ if (IS_P3P_TYPE(ha))
1857+ set_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags);
1858+ else
1859+ set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags);
1860+ return;
1861+ }
1862+
18501863 si = &sp->u.iocb_cmd;
18511864 sz = min(ARRAY_SIZE(pkt->mb), ARRAY_SIZE(sp->u.iocb_cmd.u.mbx.in_mb));
18521865
@@ -3399,32 +3412,6 @@ void qla24xx_nvme_ls4_iocb(struct scsi_qla_host *vha, · 1546 unmodified lines
33993412 sp->done(sp, comp_status);
34003413 }
34013414
3402−static void qla24xx_process_mbx_iocb_response(struct scsi_qla_host *vha,
3403− struct rsp_que *rsp, struct sts_entry_24xx *pkt)
3404−{
3405− struct qla_hw_data *ha = vha->hw;
3406− srb_t *sp;
3407− static const char func[] = "MBX-IOCB2";
3408−
3409− sp = qla2x00_get_sp_from_handle(vha, func, rsp->req, pkt);
3410− if (!sp)
3411− return;
3412−
3413− if (sp->type == SRB_SCSI_CMD ||
3414− sp->type == SRB_NVME_CMD ||
3415− sp->type == SRB_TM_CMD) {
3416− ql_log(ql_log_warn, vha, 0x509d,
3417− "Inconsistent event entry type %d\n", sp->type);
3418− if (IS_P3P_TYPE(ha))
3419− set_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags);
3420− else
3421− set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags);
3422− return;
3423− }
3424−
3425− qla24xx_mbx_iocb_entry(vha, rsp->req, (struct mbx_24xx_entry *)pkt);
3426−}
3427−
34283415 /**
34293416 * qla24xx_process_response_queue() - Process response queue entries.
34303417 * @vha: SCSI driver HA context
@@ -3534,7 +3521,8 @@ process_err: · 103 unmodified lines
35343521 (struct abort_entry_24xx *)pkt);
35353522 break;
35363523 case MBX_IOCB_TYPE:
3537− qla24xx_process_mbx_iocb_response(vha, rsp, pkt);
3524+ qla24xx_mbx_iocb_entry(vha, rsp->req,
3525+ (struct mbx_24xx_entry *)pkt);
35383526 break;
35393527 case VP_CTRL_IOCB_TYPE:
35403528 qla_ctrlvp_completed(vha, rsp->req,
drivers/scsi/qla2xxx/qla_nvme.c+4−4
@@ -541,7 +541,7 @@ static int qla_nvme_post_cmd(struct nvme_fc_local_port *lport, · 540 unmodified lines
541541 fc_port_t *fcport;
542542 struct srb_iocb *nvme;
543543 struct scsi_qla_host *vha;
544− int rval = -ENODEV;
544+ int rval;
545545 srb_t *sp;
546546 struct qla_qpair *qpair = hw_queue_handle;
547547 struct nvme_private *priv = fd->private;
@@ -549,19 +549,19 @@ static int qla_nvme_post_cmd(struct nvme_fc_local_port *lport, · 1 unmodified line
549549
550550 if (!priv) {
551551 /* nvme association has been torn down */
552− return rval;
552+ return -ENODEV;
553553 }
554554
555555 fcport = qla_rport->fcport;
556556
557557 if (!qpair || !fcport || (qpair && !qpair->fw_started) ||
558558 (fcport && fcport->deleted))
559− return rval;
559+ return -ENODEV;
560560
561561 vha = fcport->vha;
562562
563563 if (!(fcport->nvme_flag & NVME_FLAG_REGISTERED))
564− return rval;
564+ return -ENODEV;
565565
566566 if (test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags) ||
567567 (qpair && !qpair->fw_started) || fcport->deleted)
drivers/scsi/qla2xxx/qla_nx2.c+1−1
@@ -659,7 +659,7 @@ static int · 658 unmodified lines
659659 qla8044_poll_reg(struct scsi_qla_host *vha, uint32_t addr,
660660 int duration, uint32_t test_mask, uint32_t test_result)
661661 {
662− uint32_t value;
662+ uint32_t value = 0;
663663 int timeout_error;
664664 uint8_t retries;
665665 int ret_val = QLA_SUCCESS;
drivers/scsi/qla4xxx/ql4_nx.c+1−1
@@ -3225,7 +3225,7 @@ static void qla4_8xxx_uevent_emit(struct scsi_qla_host *ha, u32 code) · 3224 unmodified lines
32253225
32263226 switch (code) {
32273227 case QL4_UEVENT_CODE_FW_DUMP:
3228− snprintf(event_string, sizeof(event_string), "FW_DUMP=%ld",
3228+ snprintf(event_string, sizeof(event_string), "FW_DUMP=%lu",
32293229 ha->host_no);
32303230 break;
32313231 default:
drivers/scsi/scsi_lib.c+35−73
@@ -293,21 +293,6 @@ int __scsi_execute(struct scsi_device *sdev, const unsigned char *cmd, · 292 unmodified lines
293293 }
294294 EXPORT_SYMBOL(__scsi_execute);
295295
296−/**
297− * scsi_init_cmd_errh - Initialize cmd fields related to error handling.
298− * @cmd: command that is ready to be queued.
299− *
300− * This function has the job of initializing a number of fields related to error
301− * handling. Typically this will be called once for each command, as required.
302− */
303−static void scsi_init_cmd_errh(struct scsi_cmnd *cmd)
304−{
305− scsi_set_resid(cmd, 0);
306− memset(cmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE);
307− if (cmd->cmd_len == 0)
308− cmd->cmd_len = scsi_command_size(cmd->cmnd);
309−}
310−
311296 /*
312297 * Wake up the error handler if necessary. Avoid as follows that the error
313298 * handler is not woken up if host in-flight requests number ==
@@ -530,7 +515,7 @@ static void scsi_uninit_cmd(struct scsi_cmnd *cmd) · 216 unmodified lines
530515 }
531516 }
532517
533−static void scsi_free_sgtables(struct scsi_cmnd *cmd)
518+void scsi_free_sgtables(struct scsi_cmnd *cmd)
534519 {
535520 if (cmd->sdb.table.nents)
536521 sg_free_table_chained(&cmd->sdb.table,
@@ -539,6 +524,7 @@ static void scsi_free_sgtables(struct scsi_cmnd *cmd) · 2 unmodified lines
539524 sg_free_table_chained(&cmd->prot_sdb->table,
540525 SCSI_INLINE_PROT_SG_CNT);
541526 }
527+EXPORT_SYMBOL_GPL(scsi_free_sgtables);
542528
543529 static void scsi_mq_uninit_cmd(struct scsi_cmnd *cmd)
544530 {
@@ -998,7 +984,7 @@ static inline bool scsi_cmd_needs_dma_drain(struct scsi_device *sdev, · 453 unmodified lines
998984 }
999985
1000986 /**
1001− * scsi_init_io - SCSI I/O initialization function.
987+ * scsi_alloc_sgtables - allocate S/G tables for a command
1002988 * @cmd: command descriptor we wish to initialize
1003989 *
1004990 * Returns:
@@ -1006,7 +992,7 @@ static inline bool scsi_cmd_needs_dma_drain(struct scsi_device *sdev, · 1 unmodified line
1006992 * * BLK_STS_RESOURCE - if the failure is retryable
1007993 * * BLK_STS_IOERR - if the failure is fatal
1008994 */
1009−blk_status_t scsi_init_io(struct scsi_cmnd *cmd)
995+blk_status_t scsi_alloc_sgtables(struct scsi_cmnd *cmd)
1010996 {
1011997 struct scsi_device *sdev = cmd->device;
1012998 struct request *rq = cmd->request;
@@ -1098,7 +1084,7 @@ out_free_sgtables: · 85 unmodified lines
10981084 scsi_free_sgtables(cmd);
10991085 return ret;
11001086 }
1101−EXPORT_SYMBOL(scsi_init_io);
1087+EXPORT_SYMBOL(scsi_alloc_sgtables);
11021088
11031089 /**
11041090 * scsi_initialize_rq - initialize struct scsi_cmnd partially
@@ -1186,7 +1172,7 @@ static blk_status_t scsi_setup_scsi_cmnd(struct scsi_device *sdev, · 81 unmodified lines
11861172 * submit a request without an attached bio.
11871173 */
11881174 if (req->bio) {
1189− blk_status_t ret = scsi_init_io(cmd);
1175+ blk_status_t ret = scsi_alloc_sgtables(cmd);
11901176 if (unlikely(ret != BLK_STS_OK))
11911177 return ret;
11921178 } else {
@@ -1196,58 +1182,16 @@ static blk_status_t scsi_setup_scsi_cmnd(struct scsi_device *sdev, · 3 unmodified lines
11961182 }
11971183
11981184 cmd->cmd_len = scsi_req(req)->cmd_len;
1185+ if (cmd->cmd_len == 0)
1186+ cmd->cmd_len = scsi_command_size(cmd->cmnd);
11991187 cmd->cmnd = scsi_req(req)->cmd;
12001188 cmd->transfersize = blk_rq_bytes(req);
12011189 cmd->allowed = scsi_req(req)->retries;
12021190 return BLK_STS_OK;
12031191 }
12041192
1205−/*
1206− * Setup a normal block command. These are simple request from filesystems
1207− * that still need to be translated to SCSI CDBs from the ULD.
1208− */
1209−static blk_status_t scsi_setup_fs_cmnd(struct scsi_device *sdev,
1210− struct request *req)
1211−{
1212− struct scsi_cmnd *cmd = blk_mq_rq_to_pdu(req);
1213−
1214− if (unlikely(sdev->handler && sdev->handler->prep_fn)) {
1215− blk_status_t ret = sdev->handler->prep_fn(sdev, req);
1216− if (ret != BLK_STS_OK)
1217− return ret;
1218− }
1219−
1220− cmd->cmnd = scsi_req(req)->cmd = scsi_req(req)->__cmd;
1221− memset(cmd->cmnd, 0, BLK_MAX_CDB);
1222− return scsi_cmd_to_driver(cmd)->init_command(cmd);
1223−}
1224−
1225−static blk_status_t scsi_setup_cmnd(struct scsi_device *sdev,
1226− struct request *req)
1227−{
1228− struct scsi_cmnd *cmd = blk_mq_rq_to_pdu(req);
1229− blk_status_t ret;
1230−
1231− if (!blk_rq_bytes(req))
1232− cmd->sc_data_direction = DMA_NONE;
1233− else if (rq_data_dir(req) == WRITE)
1234− cmd->sc_data_direction = DMA_TO_DEVICE;
1235− else
1236− cmd->sc_data_direction = DMA_FROM_DEVICE;
1237−
1238− if (blk_rq_is_scsi(req))
1239− ret = scsi_setup_scsi_cmnd(sdev, req);
1240− else
1241− ret = scsi_setup_fs_cmnd(sdev, req);
1242−
1243− if (ret != BLK_STS_OK)
1244− scsi_free_sgtables(cmd);
1245−
1246− return ret;
1247−}
1248−
12491193 static blk_status_t
1250−scsi_prep_state_check(struct scsi_device *sdev, struct request *req)
1194+scsi_device_state_check(struct scsi_device *sdev, struct request *req)
12511195 {
12521196 switch (sdev->sdev_state) {
12531197 case SDEV_OFFLINE:
@@ -1589,7 +1533,7 @@ static unsigned int scsi_mq_inline_sgl_size(struct Scsi_Host *shost) · 335 unmodified lines
15891533 sizeof(struct scatterlist);
15901534 }
15911535
1592−static blk_status_t scsi_mq_prep_fn(struct request *req)
1536+static blk_status_t scsi_prepare_cmd(struct request *req)
15931537 {
15941538 struct scsi_cmnd *cmd = blk_mq_rq_to_pdu(req);
15951539 struct scsi_device *sdev = req->q->queuedata;
@@ -1601,6 +1545,10 @@ static blk_status_t scsi_mq_prep_fn(struct request *req) · 5 unmodified lines
16011545 cmd->request = req;
16021546 cmd->tag = req->tag;
16031547 cmd->prot_op = SCSI_PROT_NORMAL;
1548+ if (blk_rq_bytes(req))
1549+ cmd->sc_data_direction = rq_dma_dir(req);
1550+ else
1551+ cmd->sc_data_direction = DMA_NONE;
16041552
16051553 sg = (void *)cmd + sizeof(struct scsi_cmnd) + shost->hostt->cmd_size;
16061554 cmd->sdb.table.sgl = sg;
@@ -1612,9 +1560,23 @@ static blk_status_t scsi_mq_prep_fn(struct request *req) · 5 unmodified lines
16121560 (struct scatterlist *)(cmd->prot_sdb + 1);
16131561 }
16141562
1615− blk_mq_start_request(req);
1563+ /*
1564+ * Special handling for passthrough commands, which don't go to the ULP
1565+ * at all:
1566+ */
1567+ if (blk_rq_is_scsi(req))
1568+ return scsi_setup_scsi_cmnd(sdev, req);
1569+
1570+ if (sdev->handler && sdev->handler->prep_fn) {
1571+ blk_status_t ret = sdev->handler->prep_fn(sdev, req);
16161572
1617− return scsi_setup_cmnd(sdev, req);
1573+ if (ret != BLK_STS_OK)
1574+ return ret;
1575+ }
1576+
1577+ cmd->cmnd = scsi_req(req)->cmd = scsi_req(req)->__cmd;
1578+ memset(cmd->cmnd, 0, BLK_MAX_CDB);
1579+ return scsi_cmd_to_driver(cmd)->init_command(cmd);
16181580 }
16191581
16201582 static void scsi_mq_done(struct scsi_cmnd *cmd)
@@ -1680,7 +1642,7 @@ static blk_status_t scsi_queue_rq(struct blk_mq_hw_ctx *hctx, · 59 unmodified lines
16801642 * commands.
16811643 */
16821644 if (unlikely(sdev->sdev_state != SDEV_RUNNING)) {
1683− ret = scsi_prep_state_check(sdev, req);
1645+ ret = scsi_device_state_check(sdev, req);
16841646 if (ret != BLK_STS_OK)
16851647 goto out_put_budget;
16861648 }
@@ -1692,13 +1654,12 @@ static blk_status_t scsi_queue_rq(struct blk_mq_hw_ctx *hctx, · 5 unmodified lines
16921654 goto out_dec_target_busy;
16931655
16941656 if (!(req->rq_flags & RQF_DONTPREP)) {
1695− ret = scsi_mq_prep_fn(req);
1657+ ret = scsi_prepare_cmd(req);
16961658 if (ret != BLK_STS_OK)
16971659 goto out_dec_host_busy;
16981660 req->rq_flags |= RQF_DONTPREP;
16991661 } else {
17001662 clear_bit(SCMD_STATE_COMPLETE, &cmd->state);
1701− blk_mq_start_request(req);
17021663 }
17031664
17041665 cmd->flags &= SCMD_PRESERVED_FLAGS;
@@ -1707,9 +1668,11 @@ static blk_status_t scsi_queue_rq(struct blk_mq_hw_ctx *hctx, · 2 unmodified lines
17071668 if (bd->last)
17081669 cmd->flags |= SCMD_LAST;
17091670
1710− scsi_init_cmd_errh(cmd);
1671+ scsi_set_resid(cmd, 0);
1672+ memset(cmd->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE);
17111673 cmd->scsi_done = scsi_mq_done;
17121674
1675+ blk_mq_start_request(req);
17131676 reason = scsi_dispatch_cmd(cmd);
17141677 if (reason) {
17151678 scsi_set_blocked(cmd, reason);
@@ -1970,7 +1933,6 @@ struct scsi_device *scsi_device_from_queue(struct request_queue *q) · 254 unmodified lines
19701933
19711934 return sdev;
19721935 }
1973−EXPORT_SYMBOL_GPL(scsi_device_from_queue);
19741936
19751937 /**
19761938 * scsi_block_requests - Utility function used by low-level drivers to prevent
drivers/scsi/sd.c+15−12
@@ -902,7 +902,7 @@ static blk_status_t sd_setup_unmap_cmnd(struct scsi_cmnd *cmd) · 901 unmodified lines
902902 cmd->transfersize = data_len;
903903 rq->timeout = SD_TIMEOUT;
904904
905− return scsi_init_io(cmd);
905+ return scsi_alloc_sgtables(cmd);
906906 }
907907
908908 static blk_status_t sd_setup_write_same16_cmnd(struct scsi_cmnd *cmd,
@@ -934,7 +934,7 @@ static blk_status_t sd_setup_write_same16_cmnd(struct scsi_cmnd *cmd, · 25 unmodified lines
934934 cmd->transfersize = data_len;
935935 rq->timeout = unmap ? SD_TIMEOUT : SD_WRITE_SAME_TIMEOUT;
936936
937− return scsi_init_io(cmd);
937+ return scsi_alloc_sgtables(cmd);
938938 }
939939
940940 static blk_status_t sd_setup_write_same10_cmnd(struct scsi_cmnd *cmd,
@@ -966,7 +966,7 @@ static blk_status_t sd_setup_write_same10_cmnd(struct scsi_cmnd *cmd, · 25 unmodified lines
966966 cmd->transfersize = data_len;
967967 rq->timeout = unmap ? SD_TIMEOUT : SD_WRITE_SAME_TIMEOUT;
968968
969− return scsi_init_io(cmd);
969+ return scsi_alloc_sgtables(cmd);
970970 }
971971
972972 static blk_status_t sd_setup_write_zeroes_cmnd(struct scsi_cmnd *cmd)
@@ -1107,7 +1107,7 @@ static blk_status_t sd_setup_write_same_cmnd(struct scsi_cmnd *cmd) · 134 unmodified lines
11071107 * knows how much to actually write.
11081108 */
11091109 rq->__data_len = sdp->sector_size;
1110− ret = scsi_init_io(cmd);
1110+ ret = scsi_alloc_sgtables(cmd);
11111111 rq->__data_len = blk_rq_bytes(rq);
11121112
11131113 return ret;
@@ -1226,23 +1226,24 @@ static blk_status_t sd_setup_read_write_cmnd(struct scsi_cmnd *cmd) · 112 unmodified lines
12261226 unsigned int dif;
12271227 bool dix;
12281228
1229− ret = scsi_init_io(cmd);
1229+ ret = scsi_alloc_sgtables(cmd);
12301230 if (ret != BLK_STS_OK)
12311231 return ret;
12321232
1233+ ret = BLK_STS_IOERR;
12331234 if (!scsi_device_online(sdp) || sdp->changed) {
12341235 scmd_printk(KERN_ERR, cmd, "device offline or changed\n");
1235− return BLK_STS_IOERR;
1236+ goto fail;
12361237 }
12371238
12381239 if (blk_rq_pos(rq) + blk_rq_sectors(rq) > get_capacity(rq->rq_disk)) {
12391240 scmd_printk(KERN_ERR, cmd, "access beyond end of device\n");
1240− return BLK_STS_IOERR;
1241+ goto fail;
12411242 }
12421243
12431244 if ((blk_rq_pos(rq) & mask) || (blk_rq_sectors(rq) & mask)) {
12441245 scmd_printk(KERN_ERR, cmd, "request not aligned to the logical block size\n");
1245− return BLK_STS_IOERR;
1246+ goto fail;
12461247 }
12471248
12481249 /*
@@ -1264,7 +1265,7 @@ static blk_status_t sd_setup_read_write_cmnd(struct scsi_cmnd *cmd) · 15 unmodified lines
12641265 if (req_op(rq) == REQ_OP_ZONE_APPEND) {
12651266 ret = sd_zbc_prepare_zone_append(cmd, &lba, nr_blocks);
12661267 if (ret)
1267− return ret;
1268+ goto fail;
12681269 }
12691270
12701271 fua = rq->cmd_flags & REQ_FUA ? 0x8 : 0;
@@ -1292,7 +1293,7 @@ static blk_status_t sd_setup_read_write_cmnd(struct scsi_cmnd *cmd) · 21 unmodified lines
12921293 }
12931294
12941295 if (unlikely(ret != BLK_STS_OK))
1295− return ret;
1296+ goto fail;
12961297
12971298 /*
12981299 * We shouldn't disconnect in the middle of a sector, so with a dumb
@@ -1316,10 +1317,12 @@ static blk_status_t sd_setup_read_write_cmnd(struct scsi_cmnd *cmd) · 17 unmodified lines
13161317 blk_rq_sectors(rq)));
13171318
13181319 /*
1319− * This indicates that the command is ready from our end to be
1320− * queued.
1320+ * This indicates that the command is ready from our end to be queued.
13211321 */
13221322 return BLK_STS_OK;
1323+fail:
1324+ scsi_free_sgtables(cmd);
1325+ return ret;
13231326 }
13241327
13251328 static blk_status_t sd_init_command(struct scsi_cmnd *cmd)
drivers/scsi/snic/vnic_cq.c+1−7
@@ -31,8 +31,6 @@ void svnic_cq_free(struct vnic_cq *cq) · 30 unmodified lines
3131 int svnic_cq_alloc(struct vnic_dev *vdev, struct vnic_cq *cq,
3232 unsigned int index, unsigned int desc_count, unsigned int desc_size)
3333 {
34− int err;
35−
3634 cq->index = index;
3735 cq->vdev = vdev;
3836
@@ -43,11 +41,7 @@ int svnic_cq_alloc(struct vnic_dev *vdev, struct vnic_cq *cq, · 4 unmodified lines
4341 return -EINVAL;
4442 }
4543
46− err = svnic_dev_alloc_desc_ring(vdev, &cq->ring, desc_count, desc_size);
47− if (err)
48− return err;
49−
50− return 0;
44+ return svnic_dev_alloc_desc_ring(vdev, &cq->ring, desc_count, desc_size);
5145 }
5246
5347 void svnic_cq_init(struct vnic_cq *cq, unsigned int flow_control_enable,
drivers/scsi/sr.c+7−10
@@ -392,15 +392,11 @@ static blk_status_t sr_init_command(struct scsi_cmnd *SCpnt) · 391 unmodified lines
392392 struct request *rq = SCpnt->request;
393393 blk_status_t ret;
394394
395− ret = scsi_init_io(SCpnt);
395+ ret = scsi_alloc_sgtables(SCpnt);
396396 if (ret != BLK_STS_OK)
397− goto out;
397+ return ret;
398398 cd = scsi_cd(rq->rq_disk);
399399
400− /* from here on until we're complete, any goto out
401− * is used for a killable error condition */
402− ret = BLK_STS_IOERR;
403−
404400 SCSI_LOG_HLQUEUE(1, scmd_printk(KERN_INFO, SCpnt,
405401 "Doing sr request, block = %d\n", block));
406402
@@ -507,14 +503,15 @@ static blk_status_t sr_init_command(struct scsi_cmnd *SCpnt) · 100 unmodified lines
507503 SCpnt->transfersize = cd->device->sector_size;
508504 SCpnt->underflow = this_count << 9;
509505 SCpnt->allowed = MAX_RETRIES;
506+ SCpnt->cmd_len = 10;
510507
511508 /*
512− * This indicates that the command is ready from our end to be
513− * queued.
509+ * This indicates that the command is ready from our end to be queued.
514510 */
515− ret = BLK_STS_OK;
511+ return BLK_STS_OK;
516512 out:
517− return ret;
513+ scsi_free_sgtables(SCpnt);
514+ return BLK_STS_IOERR;
518515 }
519516
520517 static void sr_revalidate_disk(struct scsi_cd *cd)
drivers/scsi/sym53c8xx_2/sym_hipd.c+1−1
@@ -5656,7 +5656,7 @@ int sym_hcb_attach(struct Scsi_Host *shost, struct sym_fw *fw, struct sym_nvram · 5655 unmodified lines
56565656 /*
56575657 * Allocate the array of lists of CCBs hashed by DSA.
56585658 */
5659− np->ccbh = kcalloc(CCB_HASH_SIZE, sizeof(struct sym_ccb **), GFP_KERNEL);
5659+ np->ccbh = kcalloc(CCB_HASH_SIZE, sizeof(*np->ccbh), GFP_KERNEL);
56605660 if (!np->ccbh)
56615661 goto attach_failed;
56625662
drivers/target/target_core_rd.c+1−1
@@ -131,7 +131,7 @@ static int rd_allocate_sgl_table(struct rd_dev *rd_dev, struct rd_dev_sg_table * · 130 unmodified lines
131131 if (sg_per_table < total_sg_needed)
132132 chain_entry = 1;
133133
134− sg = kcalloc(sg_per_table + chain_entry, sizeof(*sg),
134+ sg = kmalloc_array(sg_per_table + chain_entry, sizeof(*sg),
135135 GFP_KERNEL);
136136 if (!sg)
137137 return -ENOMEM;
include/scsi/scsi_cmnd.h+2−1
@@ -165,7 +165,8 @@ extern void *scsi_kmap_atomic_sg(struct scatterlist *sg, int sg_count, · 164 unmodified lines
165165 size_t *offset, size_t *len);
166166 extern void scsi_kunmap_atomic_sg(void *virt);
167167
168−extern blk_status_t scsi_init_io(struct scsi_cmnd *cmd);
168+blk_status_t scsi_alloc_sgtables(struct scsi_cmnd *cmd);
169+void scsi_free_sgtables(struct scsi_cmnd *cmd);
169170
170171 #ifdef CONFIG_SCSI_DMA
171172 extern int scsi_dma_map(struct scsi_cmnd *cmd);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t