arcmsr: support new adapter ARC12x4 series
PATCH v3 16/17 arcmsr: support new adapter ARC12x4 series
From: Ching Huang <[email protected]>
Add code for supporting Areca new Raid adapter ARC12x4 series.
---
drivers/scsi/arcmsr/arcmsr.h +107 -0
@@ -63,12 +63,17 @@ struct device_attribute;#define ARCMSR_MAX_QBUFFER 4096#define ARCMSR_DEFAULT_SG_ENTRIES 38#define ARCMSR_MAX_HBB_POSTQUEUE 264 +#define ARCMSR_MAX_ARC1214_POSTQUEUE 256 +#define ARCMSR_MAX_ARC1214_DONEQUEUE 257#define ARCMSR_MAX_XFER_LEN 0x26000/* 152K */ #define ARCMSR_CDB_SG_PAGE_LENGTH 256#define ARCMST_NUM_MSIX_VECTORS 4#ifndef PCI_DEVICE_ID_ARECA_1880 #define PCI_DEVICE_ID_ARECA_1880 0x1880#endif +#ifndef PCI_DEVICE_ID_ARECA_1214 +#define PCI_DEVICE_ID_ARECA_1214 0x1214 +#endif /* ********************************************************************************** **
@@ -339,6 +344,56 @@ struct FIRMWARE_INFO#define ARCMSR_HBCMU_MESSAGE_FIRMWARE_OK 0x80000000/* ******************************************************************************* +** SPEC. for Areca Type D adapter +******************************************************************************* +*/ +#define ARCMSR_ARC1214_CHIP_ID 0x00004 +#define ARCMSR_ARC1214_CPU_MEMORY_CONFIGURATION 0x00008 +#define ARCMSR_ARC1214_I2_HOST_INTERRUPT_MASK 0x00034 +#define ARCMSR_ARC1214_SAMPLE_RESET 0x00100 +#define ARCMSR_ARC1214_RESET_REQUEST 0x00108 +#define ARCMSR_ARC1214_MAIN_INTERRUPT_STATUS 0x00200 +#define ARCMSR_ARC1214_PCIE_F0_INTERRUPT_ENABLE 0x0020C +#define ARCMSR_ARC1214_INBOUND_MESSAGE0 0x00400 +#define ARCMSR_ARC1214_INBOUND_MESSAGE1 0x00404 +#define ARCMSR_ARC1214_OUTBOUND_MESSAGE0 0x00420 +#define ARCMSR_ARC1214_OUTBOUND_MESSAGE1 0x00424 +#define ARCMSR_ARC1214_INBOUND_DOORBELL 0x00460 +#define ARCMSR_ARC1214_OUTBOUND_DOORBELL 0x00480 +#define ARCMSR_ARC1214_OUTBOUND_DOORBELL_ENABLE 0x00484 +#define ARCMSR_ARC1214_INBOUND_LIST_BASE_LOW 0x01000 +#define ARCMSR_ARC1214_INBOUND_LIST_BASE_HIGH 0x01004 +#define ARCMSR_ARC1214_INBOUND_LIST_WRITE_POINTER 0x01018 +#define ARCMSR_ARC1214_OUTBOUND_LIST_BASE_LOW 0x01060 +#define ARCMSR_ARC1214_OUTBOUND_LIST_BASE_HIGH 0x01064 +#define ARCMSR_ARC1214_OUTBOUND_LIST_COPY_POINTER 0x0106C +#define ARCMSR_ARC1214_OUTBOUND_LIST_READ_POINTER 0x01070 +#define ARCMSR_ARC1214_OUTBOUND_INTERRUPT_CAUSE 0x01088 +#define ARCMSR_ARC1214_OUTBOUND_INTERRUPT_ENABLE 0x0108C +#define ARCMSR_ARC1214_MESSAGE_WBUFFER 0x02000 +#define ARCMSR_ARC1214_MESSAGE_RBUFFER 0x02100 +#define ARCMSR_ARC1214_MESSAGE_RWBUFFER 0x02200 +/* Host Interrupt Mask */ +#define ARCMSR_ARC1214_ALL_INT_ENABLE 0x00001010 +#define ARCMSR_ARC1214_ALL_INT_DISABLE 0x00000000 +/* Host Interrupt Status */ +#define ARCMSR_ARC1214_OUTBOUND_DOORBELL_ISR 0x00001000 +#define ARCMSR_ARC1214_OUTBOUND_POSTQUEUE_ISR 0x00000010 +/* DoorBell*/ +#define ARCMSR_ARC1214_DRV2IOP_DATA_IN_READY 0x00000001 +#define ARCMSR_ARC1214_DRV2IOP_DATA_OUT_READ 0x00000002 +/*inbound message 0 ready*/ +#define ARCMSR_ARC1214_IOP2DRV_DATA_WRITE_OK 0x00000001 +/*outbound DATA WRITE isr door bell clear*/ +#define ARCMSR_ARC1214_IOP2DRV_DATA_READ_OK 0x00000002 +/*outbound message 0 ready*/ +#define ARCMSR_ARC1214_IOP2DRV_MESSAGE_CMD_DONE 0x02000000 +/*outbound message cmd isr door bell clear*/ +/*ARCMSR_HBAMU_MESSAGE_FIRMWARE_OK*/ +#define ARCMSR_ARC1214_MESSAGE_FIRMWARE_OK 0x80000000 +#define ARCMSR_ARC1214_OUTBOUND_LIST_INTERRUPT_CLEAR 0x00000001 +/* +******************************************************************************* ** ARECA SCSI COMMAND DESCRIPTOR BLOCK size 0x1F8 (504) ******************************************************************************* */
@@ -496,6 +551,55 @@ struct MessageUnit_C{uint32_t msgcode_rwbuffer[256 ];/*2200 23FF*/ };/* +********************************************************************* +** Messaging Unit (MU) of Type D processor +********************************************************************* +*/ +struct InBound_SRB { +uint32_t addressLow;/* pointer to SRB block */ +uint32_t addressHigh; +uint32_t length;/* in DWORDs */ +uint32_t reserved0; +}; + +struct OutBound_SRB { +uint32_t addressLow;/* pointer to SRB block */ +uint32_t addressHigh; +}; + +struct MessageUnit_D { +struct InBound_SRB post_qbuffer[ARCMSR_MAX_ARC1214_POSTQUEUE ]; +volatile struct OutBound_SRB done_qbuffer[ARCMSR_MAX_ARC1214_DONEQUEUE ]; +u16 postq_index; +volatile u16 doneq_index; +u32 __iomem *chip_id;/* 0x00004 */ +u32 __iomem *cpu_mem_config;/* 0x00008 */ +u32 __iomem *i2o_host_interrupt_mask;/* 0x00034 */ +u32 __iomem *sample_at_reset;/* 0x00100 */ +u32 __iomem *reset_request;/* 0x00108 */ +u32 __iomem *host_int_status;/* 0x00200 */ +u32 __iomem *pcief0_int_enable;/* 0x0020C */ +u32 __iomem *inbound_msgaddr0;/* 0x00400 */ +u32 __iomem *inbound_msgaddr1;/* 0x00404 */ +u32 __iomem *outbound_msgaddr0;/* 0x00420 */ +u32 __iomem *outbound_msgaddr1;/* 0x00424 */ +u32 __iomem *inbound_doorbell;/* 0x00460 */ +u32 __iomem *outbound_doorbell;/* 0x00480 */ +u32 __iomem *outbound_doorbell_enable;/* 0x00484 */ +u32 __iomem *inboundlist_base_low;/* 0x01000 */ +u32 __iomem *inboundlist_base_high;/* 0x01004 */ +u32 __iomem *inboundlist_write_pointer;/* 0x01018 */ +u32 __iomem *outboundlist_base_low;/* 0x01060 */ +u32 __iomem *outboundlist_base_high;/* 0x01064 */ +u32 __iomem *outboundlist_copy_pointer;/* 0x0106C */ +u32 __iomem *outboundlist_read_pointer;/* 0x01070 0x01072 */ +u32 __iomem *outboundlist_interrupt_cause;/* 0x1088 */ +u32 __iomem *outboundlist_interrupt_enable;/* 0x108C */ +u32 __iomem *message_wbuffer;/* 0x2000 */ +u32 __iomem *message_rbuffer;/* 0x2100 */ +u32 __iomem *msgcode_rwbuffer;/* 0x2200 */ +}; +/* ******************************************************************************* ** Adapter Control Block *******************************************************************************
@@ -518,12 +622,15 @@ struct AdapterControlBlockuint32_t reg_mu_acc_handle0;spinlock_t eh_lock;spinlock_t ccblist_lock; +spinlock_t postq_lock; +spinlock_t doneq_lock;spinlock_t rqbuffer_lock;spinlock_t wqbuffer_lock;union {struct MessageUnit_A __iomem *pmuA;struct MessageUnit_B *pmuB;struct MessageUnit_C __iomem *pmuC; +struct MessageUnit_D *pmuD; };/* message unit ATU inbound base address0 */ void __iomem *mem_base0;
drivers/scsi/arcmsr/arcmsr_hba.c +748 -7
1,031 lines not on this page · raw message
Quoted 6 lines · Ching Huang
From: Ching Huang <[email protected]>
Add code for supporting Areca new Raid adapter ARC12x4 series.
Signed-off-by Ching Huang <[email protected]>---
Hi Ching,
please look at the comments below -
Quoted 4 lines
}
drivers/scsi/arcmsr/arcmsr_hba.c +0
-0@@ -1039,7 +1147,60 @@ static void arcmsr_done4abort_postqueue( error = (flag_ccb &ARCMSR_CCBREPLY_FLAG_ERROR_MODE1 ) ? true : false;arcmsr_drain_donequeue (acb, pCCB, error);
drivers/scsi/arcmsr/arcmsr_hba.c static void arcmsr_done4abort_postqueue( · line 1157
Quoted 10 lines
drivers/scsi/arcmsr/arcmsr_hba.c +8
-1} - } + } +break ; +case ACB_ADAPTER_TYPE_D : { +struct MessageUnit_D *pmu = acb->pmuD; +uint32_t ccb_cdb_phy, outbound_write_pointer; +uint32_t doneq_index, index_stripped, addressLow, residual; +bool error; +struct CommandControlBlock *pCCB;
I have noticed this^ in this driver already before. Sometimes it makes sense when a variable is declared in a 'case' block but often it is just a waste of space. In this function this is the third 'bool error' declared. Is there a reason for this style (this function is not the worst case) ?
Quoted 48 lines
drivers/scsi/arcmsr/arcmsr_hba.c +46
-0+ outbound_write_pointer = pmu->done_qbuffer[0 ].addressLow +1 ; + doneq_index = pmu->doneq_index; + residual =atomic_read (&acb->ccboutstandingcount); +for (i =0 ; i < residual; i++) { +while ((doneq_index &0xFFF ) != + (outbound_write_pointer &0xFFF )) { +if (doneq_index &0x4000 ) { + index_stripped = doneq_index &0xFFF ; + index_stripped +=1 ; + index_stripped %= +ARCMSR_MAX_ARC1214_DONEQUEUE ; + pmu->doneq_index = index_stripped ? + (index_stripped |0x4000 ) : + (index_stripped +1 ); + }else { + index_stripped = doneq_index; + index_stripped +=1 ; + index_stripped %= +ARCMSR_MAX_ARC1214_DONEQUEUE ; + pmu->doneq_index = index_stripped ? + index_stripped : + ((index_stripped |0x4000 ) +1 ); + } + doneq_index = pmu->doneq_index; + addressLow = pmu->done_qbuffer[doneq_index & +0xFFF ].addressLow; + ccb_cdb_phy = (addressLow &0xFFFFFFF0 ); + pARCMSR_CDB = (struct ARCMSR_CDB *) + (acb->vir2phy_offset + ccb_cdb_phy); + pCCB =container_of (pARCMSR_CDB, + struct CommandControlBlock, arcmsr_cdb); + error = (addressLow & +ARCMSR_CCBREPLY_FLAG_ERROR_MODE1 ) ? + true : false; +arcmsr_drain_donequeue (acb, pCCB, error); +writel (doneq_index, pmu->outboundlist_read_pointer); + } +mdelay (10 ); + outbound_write_pointer = + pmu->done_qbuffer[0 ].addressLow +1 ; + doneq_index = pmu->doneq_index; + } + pmu->postq_index =0 ; + pmu->doneq_index =0x40FF ; + } +break ; } }
...
Quoted 24 lines
drivers/scsi/arcmsr/arcmsr_hba.c +18
-0@@ -1256,6 +1424,38 @@ static void arcmsr_post_ccb(struct Adaptwritel (ccb_post_stamp, &phbcmu->inbound_queueport_low); } } +break ; +case ACB_ADAPTER_TYPE_D : { +struct MessageUnit_D *pmu = acb->pmuD; +u16 index_stripped; +u16 postq_index; +unsigned long flags; +struct InBound_SRB *pinbound_srb; + +spin_lock_irqsave (&acb->postq_lock, flags); + postq_index = pmu->postq_index; + pinbound_srb = (struct InBound_SRB *)&(pmu->post_qbuffer[postq_index &0xFF ]); + pinbound_srb->addressHigh =dma_addr_hi32 (cdb_phyaddr); + pinbound_srb->addressLow =dma_addr_lo32 (cdb_phyaddr); + pinbound_srb->length = ccb->arc_cdb_size >>2 ; + arcmsr_cdb->msgContext =dma_addr_lo32 (cdb_phyaddr); +if (postq_index &0x4000 ) { + index_stripped = postq_index &0xFF ; + index_stripped +=1 ;
drivers/scsi/arcmsr/arcmsr_hba.c static void arcmsr_post_ccb(struct Adapt · line 1454
Quoted 10 lines
drivers/scsi/arcmsr/arcmsr_hba.c +10
-0+ index_stripped %=ARCMSR_MAX_ARC1214_POSTQUEUE ; + pmu->postq_index = index_stripped ? + (index_stripped |0x4000 ) : index_stripped; + }else { + index_stripped = postq_index; + index_stripped +=1 ; + index_stripped %=ARCMSR_MAX_ARC1214_POSTQUEUE ; + pmu->postq_index = index_stripped ? index_stripped : + (index_stripped |0x4000 ); + }
The code above could be a bit easier -
arcmsr_cdb->msgContext = dma_addr_lo32(cdb_phyaddr);
index_stripped = postq_index + 1;
index_stripped &= (ARCMSR_MAX_ARC1214_POSTQUEUE - 1);
if (postq_index & 0x4000)
pmu->postq_index = index_stripped ?
(index_stripped | 0x4000) : index_stripped;
else
pmu->postq_index = index_stripped ?
index_stripped : (index_stripped | 0x4000);or am I wrong? This is repeated in the code many times
Quoted 7 lines
drivers/scsi/arcmsr/arcmsr_hba.c +4
-0+writel (postq_index, pmu->inboundlist_write_pointer); +spin_unlock_irqrestore (&acb->postq_lock, flags); +break ; + } } }
...
Quoted 6 lines
drivers/scsi/arcmsr/arcmsr_hba.c +6
-0+static int arcmsr_hbaD_polling_ccbdone (struct AdapterControlBlock *acb, +struct CommandControlBlock *poll_ccb) +{ +bool error; +uint32_t poll_ccb_done =0 , poll_count =0 , flag_ccb, ccb_cdb_phy; +int rtn, doneq_index, index_stripped, outbound_write_pointer;
drivers/scsi/arcmsr/arcmsr_hba.c polling_hbc_ccb_retry: · line 3198
Quoted 10 lines
drivers/scsi/arcmsr/arcmsr_hba.c +10
-0+unsigned long flags; +struct ARCMSR_CDB *arcmsr_cdb; +struct CommandControlBlock *pCCB; +struct MessageUnit_D *pmu = acb->pmuD; + +polling_hbaD_ccb_retry: + poll_count++; +while (1 ) { + outbound_write_pointer = pmu->done_qbuffer[0 ].addressLow +1 ; + doneq_index = pmu->doneq_index;
You seem to protect the doneq with a spinlock on some other places, arcmsr_hbaD_postqueue_isr and below in this function. Why not here, is it intentional?
Quoted 338 lines
drivers/scsi/arcmsr/arcmsr_hba.c +238
-1+if ((outbound_write_pointer &0xFFF ) == (doneq_index &0xFFF )) { +if (poll_ccb_done) { + rtn =SUCCESS ; +break ; + }else { +msleep (25 ); +if (poll_count >40 ) { + rtn =FAILED ; +break ; + } + goto polling_hbaD_ccb_retry; + } + } +spin_lock_irqsave (&acb->doneq_lock, flags); +if (doneq_index &0x4000 ) { + index_stripped = doneq_index &0xFFF ; + index_stripped +=1 ; + index_stripped %=ARCMSR_MAX_ARC1214_DONEQUEUE ; + pmu->doneq_index = index_stripped ? + (index_stripped |0x4000 ) : + (index_stripped +1 ); + }else { + index_stripped = doneq_index; + index_stripped +=1 ; + index_stripped %=ARCMSR_MAX_ARC1214_DONEQUEUE ; + pmu->doneq_index = index_stripped ? index_stripped : + ((index_stripped |0x4000 ) +1 ); + } +spin_unlock_irqrestore (&acb->doneq_lock, flags); + doneq_index = pmu->doneq_index; + flag_ccb = pmu->done_qbuffer[doneq_index &0xFFF ].addressLow; + ccb_cdb_phy = (flag_ccb &0xFFFFFFF0 ); + arcmsr_cdb = (struct ARCMSR_CDB *)(acb->vir2phy_offset + + ccb_cdb_phy); + pCCB = container_of(arcmsr_cdb, struct CommandControlBlock, + arcmsr_cdb); + poll_ccb_done |= (pCCB == poll_ccb) ?1 :0 ; +if ((pCCB->acb != acb) || + (pCCB->startdone !=ARCMSR_CCB_START )) { +if (pCCB->startdone ==ARCMSR_CCB_ABORTED ) { +pr_notice ("arcmsr%d: scsi id = %d " +"lun = %d ccb = '0x%p' poll command " +"abort successfully\n" + , acb->host->host_no + , pCCB->pcmd->device->id + , (u32 )pCCB->pcmd->device->lun + , pCCB); + pCCB->pcmd->result =DID_ABORT <<16 ; +arcmsr_ccb_complete (pCCB); +continue ; + } +pr_notice ("arcmsr%d: polling an illegal " +"ccb command done ccb = '0x%p' " +"ccboutstandingcount = %d\n" + , acb->host->host_no + , pCCB + ,atomic_read (&acb->ccboutstandingcount)); +continue ; + } + error = (flag_ccb &ARCMSR_CCBREPLY_FLAG_ERROR_MODE1 ) + ? true : false; +arcmsr_report_ccb_state (acb, pCCB, error); + } +return rtn; +} +static int arcmsr_polling_ccbdone (struct AdapterControlBlock *acb,struct CommandControlBlock *poll_ccb) {@@ -2711,6 +3280,10 @@ static int arcmsr_polling_ccbdone(structcase ACB_ADAPTER_TYPE_C : { rtn =arcmsr_hbaC_polling_ccbdone (acb, poll_ccb); } +break ; +case ACB_ADAPTER_TYPE_D : + rtn =arcmsr_hbaD_polling_ccbdone (acb, poll_ccb); +break ; }return rtn; }@@ -2728,6 +3301,7 @@ static int arcmsr_iop_confirm(struct Ada*/ switch (acb->adapter_type) {case ACB_ADAPTER_TYPE_B : +case ACB_ADAPTER_TYPE_D : dma_coherent_handle = acb->dma_coherent_handle2;break ;default :@@ -2817,6 +3391,27 @@ static int arcmsr_iop_confirm(struct Ada } } } +break ; +case ACB_ADAPTER_TYPE_D : { +uint32_t __iomem *rwbuffer; +struct MessageUnit_D *reg = acb->pmuD; + reg->postq_index =0 ; + reg->doneq_index =0 ; + rwbuffer = reg->msgcode_rwbuffer; +writel (ARCMSR_SIGNATURE_SET_CONFIG , rwbuffer++); +writel (cdb_phyaddr_hi32, rwbuffer++); +writel (cdb_phyaddr, rwbuffer++); +writel (cdb_phyaddr + (ARCMSR_MAX_ARC1214_POSTQUEUE * +sizeof (struct InBound_SRB )), rwbuffer++); +writel (0x100 , rwbuffer); +writel (ARCMSR_INBOUND_MESG0_SET_CONFIG , reg->inbound_msgaddr0); +if (!arcmsr_hbaD_wait_msgint_ready (acb)) { +pr_notice ("arcmsr%d: 'set command Q window' timeout\n" , + acb->host->host_no); +return 1 ; + } + } +break ; }return 0 ; }@@ -2848,6 +3443,15 @@ static void arcmsr_wait_firmware_ready(s firmware_state =readl (®->outbound_msgaddr1); }while ((firmware_state &ARCMSR_HBCMU_MESSAGE_FIRMWARE_OK ) ==0 ); } +break ; +case ACB_ADAPTER_TYPE_D : { +struct MessageUnit_D *reg = acb->pmuD; +do { + firmware_state =readl (reg->outbound_msgaddr1); + }while ((firmware_state & +ARCMSR_ARC1214_MESSAGE_FIRMWARE_OK ) ==0 ); + } +break ; } }@@ -2918,6 +3522,35 @@ static void arcmsr_hbaC_request_device_mreturn ; } +static void arcmsr_hbaD_request_device_map (struct AdapterControlBlock *acb) +{ +struct MessageUnit_D *reg = acb->pmuD; + +if (unlikely (atomic_read (&acb->rq_map_token) ==0 ) || + ((acb->acb_flags &ACB_F_BUS_RESET ) !=0 ) || + ((acb->acb_flags &ACB_F_ABORT ) !=0 )) { +mod_timer (&acb->eternal_timer, + jiffies +msecs_to_jiffies (6 *HZ )); + }else { + acb->fw_flag =FW_NORMAL ; +if (atomic_read (&acb->ante_token_value) == +atomic_read (&acb->rq_map_token)) { +atomic_set (&acb->rq_map_token,16 ); + } +atomic_set (&acb->ante_token_value, +atomic_read (&acb->rq_map_token)); +if (atomic_dec_and_test (&acb->rq_map_token)) { +mod_timer (&acb->eternal_timer, jiffies + +msecs_to_jiffies (6 *HZ )); +return ; + } +writel (ARCMSR_INBOUND_MESG0_GET_CONFIG , + reg->inbound_msgaddr0); +mod_timer (&acb->eternal_timer, jiffies + +msecs_to_jiffies (6 *HZ )); + } +} +static void arcmsr_request_device_map (unsigned long pacb) {struct AdapterControlBlock *acb = (struct AdapterControlBlock *)pacb;@@ -2933,6 +3566,10 @@ static void arcmsr_request_device_map(uncase ACB_ADAPTER_TYPE_C : {arcmsr_hbaC_request_device_map (acb); } +break ; +case ACB_ADAPTER_TYPE_D : +arcmsr_hbaD_request_device_map (acb); +break ; } }@@ -2970,6 +3607,19 @@ static void arcmsr_hbaC_start_bgrb(struc }return ; } + +static void arcmsr_hbaD_start_bgrb (struct AdapterControlBlock *pACB) +{ +struct MessageUnit_D *pmu = pACB->pmuD; + + pACB->acb_flags |=ACB_F_MSG_START_BGRB ; +writel (ARCMSR_INBOUND_MESG0_START_BGRB , pmu->inbound_msgaddr0); +if (!arcmsr_hbaD_wait_msgint_ready (pACB)) { +pr_notice ("arcmsr%d: wait 'start adapter " +"background rebulid' timeout\n" , pACB->host->host_no); + } +} +static void arcmsr_start_adapter_bgrb (struct AdapterControlBlock *acb) {switch (acb->adapter_type) {@@ -2981,6 +3631,10 @@ static void arcmsr_start_adapter_bgrb(stbreak ;case ACB_ADAPTER_TYPE_C :arcmsr_hbaC_start_bgrb (acb); +break ; +case ACB_ADAPTER_TYPE_D : +arcmsr_hbaD_start_bgrb (acb); +break ; } }@@ -3026,6 +3680,29 @@ static void arcmsr_clear_doorbell_queue_break ; } } +break ; +case ACB_ADAPTER_TYPE_D : { +struct MessageUnit_D *reg = acb->pmuD; +uint32_t outbound_doorbell, i; +/* empty doorbell Qbuffer if door bell ringed */ + outbound_doorbell =readl (reg->outbound_doorbell); +writel (outbound_doorbell, reg->outbound_doorbell); +writel (ARCMSR_ARC1214_DRV2IOP_DATA_OUT_READ , + reg->inbound_doorbell); +for (i =0 ; i <200 ; i++) { +msleep (20 ); + outbound_doorbell =readl (reg->outbound_doorbell); +if (outbound_doorbell & +ARCMSR_ARC1214_IOP2DRV_DATA_WRITE_OK ) { +writel (outbound_doorbell, + reg->outbound_doorbell); +writel (ARCMSR_ARC1214_DRV2IOP_DATA_OUT_READ , + reg->inbound_doorbell); + }else +break ; + } + } +break ; } }@@ -3056,6 +3733,7 @@ static void arcmsr_hardware_reset(structint i, count =0 ;struct MessageUnit_A __iomem *pmuA = acb->pmuA;struct MessageUnit_C __iomem *pmuC = acb->pmuC; +struct MessageUnit_D *pmuD = acb->pmuD;/* backup pci config data */ printk (KERN_NOTICE "arcmsr%d: executing hw bus reset .....\n" , acb->host->host_no);@@ -3076,6 +3754,8 @@ static void arcmsr_hardware_reset(structwritel (0xD , &pmuC->write_sequence); }while (((readl (&pmuC->host_diagnostic) & ARCMSR_ARC1880_DiagWrite_ENABLE) ==0 ) && (count <5 ));writel (ARCMSR_ARC1880_RESET_ADAPTER , &pmuC->host_diagnostic); + }else if ((acb->dev_id ==0x1214 )) { +writel (0x20 , pmuD->reset_request); }else {pci_write_config_byte (acb->pdev,0x84 ,0x20 ); }@@ -3272,6 +3952,66 @@ sleep: }break ; } +case ACB_ADAPTER_TYPE_D : { +if (acb->acb_flags &ACB_F_BUS_RESET ) { +long timeout; +pr_notice ("arcmsr: there is an bus reset" +" eh proceeding.......\n" ); + timeout =wait_event_timeout (wait_q, (acb->acb_flags + &ACB_F_BUS_RESET ) ==0 ,220 *HZ ); +if (timeout) +return SUCCESS ; + } + acb->acb_flags |=ACB_F_BUS_RESET ; +if (!arcmsr_iop_reset (acb)) { +struct MessageUnit_D *reg; + reg = acb->pmuD; +arcmsr_hardware_reset (acb); + acb->acb_flags &= ~ACB_F_IOP_INITED ; + nap: +ssleep (ARCMSR_SLEEPTIME ); +if ((readl (reg->sample_at_reset) &0x80 ) !=0 ) { +pr_err ("arcmsr%d: waiting for " +"hw bus reset return, retry=%d\n" , + acb->host->host_no, retry_count); +if (retry_count >ARCMSR_RETRYCOUNT ) { + acb->fw_flag =FW_DEADLOCK ; +pr_err ("arcmsr%d: waiting for hw bus" +" reset return, " +"RETRY TERMINATED!!\n" , + acb->host->host_no); +return FAILED ; + } + retry_count++; + goto nap; + } + acb->acb_flags |=ACB_F_IOP_INITED ; +/* disable all outbound interrupt */ + intmask_org =arcmsr_disable_outbound_ints (acb); +arcmsr_get_firmware_spec (acb); +arcmsr_start_adapter_bgrb (acb); +arcmsr_clear_doorbell_queue_buffer (acb); +arcmsr_enable_outbound_ints (acb, intmask_org); +atomic_set (&acb->rq_map_token,16 ); +atomic_set (&acb->ante_token_value,16 ); + acb->fw_flag =FW_NORMAL ; +mod_timer (&acb->eternal_timer, + jiffies +msecs_to_jiffies (6 *HZ )); + acb->acb_flags &= ~ACB_F_BUS_RESET ; + rtn =SUCCESS ; +pr_err ("arcmsr: scsi bus reset " +"eh returns with success\n" ); + }else { + acb->acb_flags &= ~ACB_F_BUS_RESET ; +atomic_set (&acb->rq_map_token,16 ); +atomic_set (&acb->ante_token_value,16 ); + acb->fw_flag =FW_NORMAL ; +mod_timer (&acb->eternal_timer, + jiffies +msecs_to_jiffies (6 *HZ )); + rtn =SUCCESS ; + } +break ; + } }return rtn; }@@ -3348,6 +4088,7 @@ static const char *arcmsr_info(struct Sccase PCI_DEVICE_ID_ARECA_1280 : type ="SATA" ;break ; +case PCI_DEVICE_ID_ARECA_1214 :case PCI_DEVICE_ID_ARECA_1380 :case PCI_DEVICE_ID_ARECA_1381 :case PCI_DEVICE_ID_ARECA_1680 : --To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 22 lines · Tomas Henzl
Quoted 6 lines · Ching Huang
From: Ching Huang <[email protected]>
Add code for supporting Areca new Raid adapter ARC12x4 series.
Signed-off-by Ching Huang <[email protected]>---
Hi Ching,
please look at the comments below -Quoted 11 lines
}
drivers/scsi/arcmsr/arcmsr_hba.c +5
-1@@ -1039,7 +1147,60 @@ static void arcmsr_done4abort_postqueue( error = (flag_ccb &ARCMSR_CCBREPLY_FLAG_ERROR_MODE1 ) ? true : false;arcmsr_drain_donequeue (acb, pCCB, error); } - } + } +break ; +case ACB_ADAPTER_TYPE_D : { +struct MessageUnit_D *pmu = acb->pmuD; +uint32_t ccb_cdb_phy, outbound_write_pointer;
Quoted 8 lines
drivers/scsi/arcmsr/arcmsr_hba.c static void arcmsr_done4abort_postqueue( · line 1157
Quoted 3 lines
drivers/scsi/arcmsr/arcmsr_hba.c +3
-0+uint32_t doneq_index, index_stripped, addressLow, residual; +bool error; +struct CommandControlBlock *pCCB;I have noticed this^ in this driver already before. Sometimes it makes sense when a variable is declared in a 'case' block but often it is just a waste of space. In this function this is the third 'bool error' declared. Is there a reason for this style (this function is not the worst case) ?
Yea, there is many variable are duplicate declaration, I will clean it up.
Quoted 53 lines
Quoted 49 lines
drivers/scsi/arcmsr/arcmsr_hba.c +46
-0+ outbound_write_pointer = pmu->done_qbuffer[0 ].addressLow +1 ; + doneq_index = pmu->doneq_index; + residual =atomic_read (&acb->ccboutstandingcount); +for (i =0 ; i < residual; i++) { +while ((doneq_index &0xFFF ) != + (outbound_write_pointer &0xFFF )) { +if (doneq_index &0x4000 ) { + index_stripped = doneq_index &0xFFF ; + index_stripped +=1 ; + index_stripped %= +ARCMSR_MAX_ARC1214_DONEQUEUE ; + pmu->doneq_index = index_stripped ? + (index_stripped |0x4000 ) : + (index_stripped +1 ); + }else { + index_stripped = doneq_index; + index_stripped +=1 ; + index_stripped %= +ARCMSR_MAX_ARC1214_DONEQUEUE ; + pmu->doneq_index = index_stripped ? + index_stripped : + ((index_stripped |0x4000 ) +1 ); + } + doneq_index = pmu->doneq_index; + addressLow = pmu->done_qbuffer[doneq_index & +0xFFF ].addressLow; + ccb_cdb_phy = (addressLow &0xFFFFFFF0 ); + pARCMSR_CDB = (struct ARCMSR_CDB *) + (acb->vir2phy_offset + ccb_cdb_phy); + pCCB =container_of (pARCMSR_CDB, + struct CommandControlBlock, arcmsr_cdb); + error = (addressLow & +ARCMSR_CCBREPLY_FLAG_ERROR_MODE1 ) ? + true : false; +arcmsr_drain_donequeue (acb, pCCB, error); +writel (doneq_index, pmu->outboundlist_read_pointer); + } +mdelay (10 ); + outbound_write_pointer = + pmu->done_qbuffer[0 ].addressLow +1 ; + doneq_index = pmu->doneq_index; + } + pmu->postq_index =0 ; + pmu->doneq_index =0x40FF ; + } +break ; } }...
Quoted 2 lines
Quoted 9 lines
drivers/scsi/arcmsr/arcmsr_hba.c static void arcmsr_post_ccb(struct Adapt · line 1431
Quoted 9 lines
drivers/scsi/arcmsr/arcmsr_hba.c +5
-0@@ -1256,6 +1424,38 @@ static void arcmsr_post_ccb(struct Adaptwritel (ccb_post_stamp, &phbcmu->inbound_queueport_low); } } +break ; +case ACB_ADAPTER_TYPE_D : { +struct MessageUnit_D *pmu = acb->pmuD; +u16 index_stripped; +u16 postq_index;
u16 postq_index, toggle;
Quoted 17 lines
Quoted 17 lines
drivers/scsi/arcmsr/arcmsr_hba.c +17
-0+unsigned long flags; +struct InBound_SRB *pinbound_srb; + +spin_lock_irqsave (&acb->postq_lock, flags); + postq_index = pmu->postq_index; + pinbound_srb = (struct InBound_SRB *)&(pmu->post_qbuffer[postq_index &0xFF ]); + pinbound_srb->addressHigh =dma_addr_hi32 (cdb_phyaddr); + pinbound_srb->addressLow =dma_addr_lo32 (cdb_phyaddr); + pinbound_srb->length = ccb->arc_cdb_size >>2 ; + arcmsr_cdb->msgContext =dma_addr_lo32 (cdb_phyaddr); +if (postq_index &0x4000 ) { + index_stripped = postq_index &0xFF ; + index_stripped +=1 ; + index_stripped %=ARCMSR_MAX_ARC1214_POSTQUEUE ; + pmu->postq_index = index_stripped ? + (index_stripped |0x4000 ) : index_stripped; + }else {
Quoted 8 lines
drivers/scsi/arcmsr/arcmsr_hba.c static void arcmsr_post_ccb(struct Adapt · line 1454
Quoted 6 lines
drivers/scsi/arcmsr/arcmsr_hba.c +6
-0+ index_stripped = postq_index; + index_stripped +=1 ; + index_stripped %=ARCMSR_MAX_ARC1214_POSTQUEUE ; + pmu->postq_index = index_stripped ? index_stripped : + (index_stripped |0x4000 ); + }The code above could be a bit easier -
Yea. I simplify it to following.
toggle = postq_index & 0x4000; index_stripped = (postq_index & 0xFF) + 1; index_stripped %= ARCMSR_MAX_ARC1214_POSTQUEUE; pmu->postq_index = index_stripped ? (index_stripped | toggle) : (index_stripped | (toggle ^ 0x4000));
Quoted 11 lines
arcmsr_cdb->msgContext = dma_addr_lo32(cdb_phyaddr);
index_stripped = postq_index + 1;
index_stripped &= (ARCMSR_MAX_ARC1214_POSTQUEUE - 1);
if (postq_index & 0x4000)
pmu->postq_index = index_stripped ?
(index_stripped | 0x4000) : index_stripped;
else
pmu->postq_index = index_stripped ?
index_stripped : (index_stripped | 0x4000);Quoted 1 line
or am I wrong? This is repeated in the code many times
Yea. one for postQueue and 3 times for doneQueue. They all can be simplified as above.
Quoted 21 lines
Quoted 9 lines
drivers/scsi/arcmsr/arcmsr_hba.c +4
-0+writel (postq_index, pmu->inboundlist_write_pointer); +spin_unlock_irqrestore (&acb->postq_lock, flags); +break ; + } } }...
Quoted 11 lines
drivers/scsi/arcmsr/arcmsr_hba.c +11
-0+static int arcmsr_hbaD_polling_ccbdone (struct AdapterControlBlock *acb, +struct CommandControlBlock *poll_ccb) +{ +bool error; +uint32_t poll_ccb_done =0 , poll_count =0 , flag_ccb, ccb_cdb_phy; +int rtn, doneq_index, index_stripped, outbound_write_pointer; +unsigned long flags; +struct ARCMSR_CDB *arcmsr_cdb; +struct CommandControlBlock *pCCB; +struct MessageUnit_D *pmu = acb->pmuD; +
Quoted 8 lines
drivers/scsi/arcmsr/arcmsr_hba.c polling_hbc_ccb_retry: · line 3198
Quoted 5 lines
drivers/scsi/arcmsr/arcmsr_hba.c +5
-0+polling_hbaD_ccb_retry: + poll_count++; +while (1 ) { + outbound_write_pointer = pmu->done_qbuffer[0 ].addressLow +1 ; + doneq_index = pmu->doneq_index;You seem to protect the doneq with a spinlock on some other places,
arcmsr_hbaD_postqueue_isrand below in this function. Why not here, is it intentional?
Before came here, the h/w interrupt was disabled. Hence, don't worry about other thread to change doneq_index.
Quoted 340 lines
Quoted 339 lines
drivers/scsi/arcmsr/arcmsr_hba.c +238
-1+if ((outbound_write_pointer &0xFFF ) == (doneq_index &0xFFF )) { +if (poll_ccb_done) { + rtn =SUCCESS ; +break ; + }else { +msleep (25 ); +if (poll_count >40 ) { + rtn =FAILED ; +break ; + } + goto polling_hbaD_ccb_retry; + } + } +spin_lock_irqsave (&acb->doneq_lock, flags); +if (doneq_index &0x4000 ) { + index_stripped = doneq_index &0xFFF ; + index_stripped +=1 ; + index_stripped %=ARCMSR_MAX_ARC1214_DONEQUEUE ; + pmu->doneq_index = index_stripped ? + (index_stripped |0x4000 ) : + (index_stripped +1 ); + }else { + index_stripped = doneq_index; + index_stripped +=1 ; + index_stripped %=ARCMSR_MAX_ARC1214_DONEQUEUE ; + pmu->doneq_index = index_stripped ? index_stripped : + ((index_stripped |0x4000 ) +1 ); + } +spin_unlock_irqrestore (&acb->doneq_lock, flags); + doneq_index = pmu->doneq_index; + flag_ccb = pmu->done_qbuffer[doneq_index &0xFFF ].addressLow; + ccb_cdb_phy = (flag_ccb &0xFFFFFFF0 ); + arcmsr_cdb = (struct ARCMSR_CDB *)(acb->vir2phy_offset + + ccb_cdb_phy); + pCCB = container_of(arcmsr_cdb, struct CommandControlBlock, + arcmsr_cdb); + poll_ccb_done |= (pCCB == poll_ccb) ?1 :0 ; +if ((pCCB->acb != acb) || + (pCCB->startdone !=ARCMSR_CCB_START )) { +if (pCCB->startdone ==ARCMSR_CCB_ABORTED ) { +pr_notice ("arcmsr%d: scsi id = %d " +"lun = %d ccb = '0x%p' poll command " +"abort successfully\n" + , acb->host->host_no + , pCCB->pcmd->device->id + , (u32 )pCCB->pcmd->device->lun + , pCCB); + pCCB->pcmd->result =DID_ABORT <<16 ; +arcmsr_ccb_complete (pCCB); +continue ; + } +pr_notice ("arcmsr%d: polling an illegal " +"ccb command done ccb = '0x%p' " +"ccboutstandingcount = %d\n" + , acb->host->host_no + , pCCB + ,atomic_read (&acb->ccboutstandingcount)); +continue ; + } + error = (flag_ccb &ARCMSR_CCBREPLY_FLAG_ERROR_MODE1 ) + ? true : false; +arcmsr_report_ccb_state (acb, pCCB, error); + } +return rtn; +} +static int arcmsr_polling_ccbdone (struct AdapterControlBlock *acb,struct CommandControlBlock *poll_ccb) {@@ -2711,6 +3280,10 @@ static int arcmsr_polling_ccbdone(structcase ACB_ADAPTER_TYPE_C : { rtn =arcmsr_hbaC_polling_ccbdone (acb, poll_ccb); } +break ; +case ACB_ADAPTER_TYPE_D : + rtn =arcmsr_hbaD_polling_ccbdone (acb, poll_ccb); +break ; }return rtn; }@@ -2728,6 +3301,7 @@ static int arcmsr_iop_confirm(struct Ada*/ switch (acb->adapter_type) {case ACB_ADAPTER_TYPE_B : +case ACB_ADAPTER_TYPE_D : dma_coherent_handle = acb->dma_coherent_handle2;break ;default :@@ -2817,6 +3391,27 @@ static int arcmsr_iop_confirm(struct Ada } } } +break ; +case ACB_ADAPTER_TYPE_D : { +uint32_t __iomem *rwbuffer; +struct MessageUnit_D *reg = acb->pmuD; + reg->postq_index =0 ; + reg->doneq_index =0 ; + rwbuffer = reg->msgcode_rwbuffer; +writel (ARCMSR_SIGNATURE_SET_CONFIG , rwbuffer++); +writel (cdb_phyaddr_hi32, rwbuffer++); +writel (cdb_phyaddr, rwbuffer++); +writel (cdb_phyaddr + (ARCMSR_MAX_ARC1214_POSTQUEUE * +sizeof (struct InBound_SRB )), rwbuffer++); +writel (0x100 , rwbuffer); +writel (ARCMSR_INBOUND_MESG0_SET_CONFIG , reg->inbound_msgaddr0); +if (!arcmsr_hbaD_wait_msgint_ready (acb)) { +pr_notice ("arcmsr%d: 'set command Q window' timeout\n" , + acb->host->host_no); +return 1 ; + } + } +break ; }return 0 ; }@@ -2848,6 +3443,15 @@ static void arcmsr_wait_firmware_ready(s firmware_state =readl (®->outbound_msgaddr1); }while ((firmware_state &ARCMSR_HBCMU_MESSAGE_FIRMWARE_OK ) ==0 ); } +break ; +case ACB_ADAPTER_TYPE_D : { +struct MessageUnit_D *reg = acb->pmuD; +do { + firmware_state =readl (reg->outbound_msgaddr1); + }while ((firmware_state & +ARCMSR_ARC1214_MESSAGE_FIRMWARE_OK ) ==0 ); + } +break ; } }@@ -2918,6 +3522,35 @@ static void arcmsr_hbaC_request_device_mreturn ; } +static void arcmsr_hbaD_request_device_map (struct AdapterControlBlock *acb) +{ +struct MessageUnit_D *reg = acb->pmuD; + +if (unlikely (atomic_read (&acb->rq_map_token) ==0 ) || + ((acb->acb_flags &ACB_F_BUS_RESET ) !=0 ) || + ((acb->acb_flags &ACB_F_ABORT ) !=0 )) { +mod_timer (&acb->eternal_timer, + jiffies +msecs_to_jiffies (6 *HZ )); + }else { + acb->fw_flag =FW_NORMAL ; +if (atomic_read (&acb->ante_token_value) == +atomic_read (&acb->rq_map_token)) { +atomic_set (&acb->rq_map_token,16 ); + } +atomic_set (&acb->ante_token_value, +atomic_read (&acb->rq_map_token)); +if (atomic_dec_and_test (&acb->rq_map_token)) { +mod_timer (&acb->eternal_timer, jiffies + +msecs_to_jiffies (6 *HZ )); +return ; + } +writel (ARCMSR_INBOUND_MESG0_GET_CONFIG , + reg->inbound_msgaddr0); +mod_timer (&acb->eternal_timer, jiffies + +msecs_to_jiffies (6 *HZ )); + } +} +static void arcmsr_request_device_map (unsigned long pacb) {struct AdapterControlBlock *acb = (struct AdapterControlBlock *)pacb;@@ -2933,6 +3566,10 @@ static void arcmsr_request_device_map(uncase ACB_ADAPTER_TYPE_C : {arcmsr_hbaC_request_device_map (acb); } +break ; +case ACB_ADAPTER_TYPE_D : +arcmsr_hbaD_request_device_map (acb); +break ; } }@@ -2970,6 +3607,19 @@ static void arcmsr_hbaC_start_bgrb(struc }return ; } + +static void arcmsr_hbaD_start_bgrb (struct AdapterControlBlock *pACB) +{ +struct MessageUnit_D *pmu = pACB->pmuD; + + pACB->acb_flags |=ACB_F_MSG_START_BGRB ; +writel (ARCMSR_INBOUND_MESG0_START_BGRB , pmu->inbound_msgaddr0); +if (!arcmsr_hbaD_wait_msgint_ready (pACB)) { +pr_notice ("arcmsr%d: wait 'start adapter " +"background rebulid' timeout\n" , pACB->host->host_no); + } +} +static void arcmsr_start_adapter_bgrb (struct AdapterControlBlock *acb) {switch (acb->adapter_type) {@@ -2981,6 +3631,10 @@ static void arcmsr_start_adapter_bgrb(stbreak ;case ACB_ADAPTER_TYPE_C :arcmsr_hbaC_start_bgrb (acb); +break ; +case ACB_ADAPTER_TYPE_D : +arcmsr_hbaD_start_bgrb (acb); +break ; } }@@ -3026,6 +3680,29 @@ static void arcmsr_clear_doorbell_queue_break ; } } +break ; +case ACB_ADAPTER_TYPE_D : { +struct MessageUnit_D *reg = acb->pmuD; +uint32_t outbound_doorbell, i; +/* empty doorbell Qbuffer if door bell ringed */ + outbound_doorbell =readl (reg->outbound_doorbell); +writel (outbound_doorbell, reg->outbound_doorbell); +writel (ARCMSR_ARC1214_DRV2IOP_DATA_OUT_READ , + reg->inbound_doorbell); +for (i =0 ; i <200 ; i++) { +msleep (20 ); + outbound_doorbell =readl (reg->outbound_doorbell); +if (outbound_doorbell & +ARCMSR_ARC1214_IOP2DRV_DATA_WRITE_OK ) { +writel (outbound_doorbell, + reg->outbound_doorbell); +writel (ARCMSR_ARC1214_DRV2IOP_DATA_OUT_READ , + reg->inbound_doorbell); + }else +break ; + } + } +break ; } }@@ -3056,6 +3733,7 @@ static void arcmsr_hardware_reset(structint i, count =0 ;struct MessageUnit_A __iomem *pmuA = acb->pmuA;struct MessageUnit_C __iomem *pmuC = acb->pmuC; +struct MessageUnit_D *pmuD = acb->pmuD;/* backup pci config data */ printk (KERN_NOTICE "arcmsr%d: executing hw bus reset .....\n" , acb->host->host_no);@@ -3076,6 +3754,8 @@ static void arcmsr_hardware_reset(structwritel (0xD , &pmuC->write_sequence); }while (((readl (&pmuC->host_diagnostic) & ARCMSR_ARC1880_DiagWrite_ENABLE) ==0 ) && (count <5 ));writel (ARCMSR_ARC1880_RESET_ADAPTER , &pmuC->host_diagnostic); + }else if ((acb->dev_id ==0x1214 )) { +writel (0x20 , pmuD->reset_request); }else {pci_write_config_byte (acb->pdev,0x84 ,0x20 ); }@@ -3272,6 +3952,66 @@ sleep: }break ; } +case ACB_ADAPTER_TYPE_D : { +if (acb->acb_flags &ACB_F_BUS_RESET ) { +long timeout; +pr_notice ("arcmsr: there is an bus reset" +" eh proceeding.......\n" ); + timeout =wait_event_timeout (wait_q, (acb->acb_flags + &ACB_F_BUS_RESET ) ==0 ,220 *HZ ); +if (timeout) +return SUCCESS ; + } + acb->acb_flags |=ACB_F_BUS_RESET ; +if (!arcmsr_iop_reset (acb)) { +struct MessageUnit_D *reg; + reg = acb->pmuD; +arcmsr_hardware_reset (acb); + acb->acb_flags &= ~ACB_F_IOP_INITED ; + nap: +ssleep (ARCMSR_SLEEPTIME ); +if ((readl (reg->sample_at_reset) &0x80 ) !=0 ) { +pr_err ("arcmsr%d: waiting for " +"hw bus reset return, retry=%d\n" , + acb->host->host_no, retry_count); +if (retry_count >ARCMSR_RETRYCOUNT ) { + acb->fw_flag =FW_DEADLOCK ; +pr_err ("arcmsr%d: waiting for hw bus" +" reset return, " +"RETRY TERMINATED!!\n" , + acb->host->host_no); +return FAILED ; + } + retry_count++; + goto nap; + } + acb->acb_flags |=ACB_F_IOP_INITED ; +/* disable all outbound interrupt */ + intmask_org =arcmsr_disable_outbound_ints (acb); +arcmsr_get_firmware_spec (acb); +arcmsr_start_adapter_bgrb (acb); +arcmsr_clear_doorbell_queue_buffer (acb); +arcmsr_enable_outbound_ints (acb, intmask_org); +atomic_set (&acb->rq_map_token,16 ); +atomic_set (&acb->ante_token_value,16 ); + acb->fw_flag =FW_NORMAL ; +mod_timer (&acb->eternal_timer, + jiffies +msecs_to_jiffies (6 *HZ )); + acb->acb_flags &= ~ACB_F_BUS_RESET ; + rtn =SUCCESS ; +pr_err ("arcmsr: scsi bus reset " +"eh returns with success\n" ); + }else { + acb->acb_flags &= ~ACB_F_BUS_RESET ; +atomic_set (&acb->rq_map_token,16 ); +atomic_set (&acb->ante_token_value,16 ); + acb->fw_flag =FW_NORMAL ; +mod_timer (&acb->eternal_timer, + jiffies +msecs_to_jiffies (6 *HZ )); + rtn =SUCCESS ; + } +break ; + } }return rtn; }@@ -3348,6 +4088,7 @@ static const char *arcmsr_info(struct Sccase PCI_DEVICE_ID_ARECA_1280 : type ="SATA" ;break ; +case PCI_DEVICE_ID_ARECA_1214 :case PCI_DEVICE_ID_ARECA_1380 :case PCI_DEVICE_ID_ARECA_1381 :case PCI_DEVICE_ID_ARECA_1680 : --To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 115 lines · Ching Huang
Quoted 20 lines · Tomas Henzl
Quoted 6 lines · Ching Huang
From: Ching Huang <[email protected]>
Add code for supporting Areca new Raid adapter ARC12x4 series.
Signed-off-by Ching Huang <[email protected]>---
Hi Ching,
please look at the comments below -Quoted 10 lines
}
drivers/scsi/arcmsr/arcmsr_hba.c +4
-1@@ -1039,7 +1147,60 @@ static void arcmsr_done4abort_postqueue( error = (flag_ccb &ARCMSR_CCBREPLY_FLAG_ERROR_MODE1 ) ? true : false;arcmsr_drain_donequeue (acb, pCCB, error); } - } + } +break ; +case ACB_ADAPTER_TYPE_D : { +struct MessageUnit_D *pmu = acb->pmuD;Quoted 8 lines
drivers/scsi/arcmsr/arcmsr_hba.c static void arcmsr_done4abort_postqueue( · line 1157
Quoted 4 lines
drivers/scsi/arcmsr/arcmsr_hba.c +4
-0+uint32_t ccb_cdb_phy, outbound_write_pointer; +uint32_t doneq_index, index_stripped, addressLow, residual; +bool error; +struct CommandControlBlock *pCCB;I have noticed this^ in this driver already before. Sometimes it makes sense when a variable is declared in a 'case' block but often it is just a waste of space. In this function this is the third 'bool error' declared. Is there a reason for this style (this function is not the worst case) ?
Yea, there is many variable are duplicate declaration, I will clean it up.
Quoted 51 lines
Quoted 48 lines
drivers/scsi/arcmsr/arcmsr_hba.c +46
-0+ outbound_write_pointer = pmu->done_qbuffer[0 ].addressLow +1 ; + doneq_index = pmu->doneq_index; + residual =atomic_read (&acb->ccboutstandingcount); +for (i =0 ; i < residual; i++) { +while ((doneq_index &0xFFF ) != + (outbound_write_pointer &0xFFF )) { +if (doneq_index &0x4000 ) { + index_stripped = doneq_index &0xFFF ; + index_stripped +=1 ; + index_stripped %= +ARCMSR_MAX_ARC1214_DONEQUEUE ; + pmu->doneq_index = index_stripped ? + (index_stripped |0x4000 ) : + (index_stripped +1 ); + }else { + index_stripped = doneq_index; + index_stripped +=1 ; + index_stripped %= +ARCMSR_MAX_ARC1214_DONEQUEUE ; + pmu->doneq_index = index_stripped ? + index_stripped : + ((index_stripped |0x4000 ) +1 ); + } + doneq_index = pmu->doneq_index; + addressLow = pmu->done_qbuffer[doneq_index & +0xFFF ].addressLow; + ccb_cdb_phy = (addressLow &0xFFFFFFF0 ); + pARCMSR_CDB = (struct ARCMSR_CDB *) + (acb->vir2phy_offset + ccb_cdb_phy); + pCCB =container_of (pARCMSR_CDB, + struct CommandControlBlock, arcmsr_cdb); + error = (addressLow & +ARCMSR_CCBREPLY_FLAG_ERROR_MODE1 ) ? + true : false; +arcmsr_drain_donequeue (acb, pCCB, error); +writel (doneq_index, pmu->outboundlist_read_pointer); + } +mdelay (10 ); + outbound_write_pointer = + pmu->done_qbuffer[0 ].addressLow +1 ; + doneq_index = pmu->doneq_index; + } + pmu->postq_index =0 ; + pmu->doneq_index =0x40FF ; + } +break ; } }...
Quoted 1 line
Quoted 9 lines
drivers/scsi/arcmsr/arcmsr_hba.c static void arcmsr_post_ccb(struct Adapt · line 1431
Quoted 9 lines
drivers/scsi/arcmsr/arcmsr_hba.c +5
-0@@ -1256,6 +1424,38 @@ static void arcmsr_post_ccb(struct Adaptwritel (ccb_post_stamp, &phbcmu->inbound_queueport_low); } } +break ; +case ACB_ADAPTER_TYPE_D : { +struct MessageUnit_D *pmu = acb->pmuD; +u16 index_stripped; +u16 postq_index;u16 postq_index, toggle;Quoted 16 lines
Quoted 16 lines
drivers/scsi/arcmsr/arcmsr_hba.c +16
-0+unsigned long flags; +struct InBound_SRB *pinbound_srb; + +spin_lock_irqsave (&acb->postq_lock, flags); + postq_index = pmu->postq_index; + pinbound_srb = (struct InBound_SRB *)&(pmu->post_qbuffer[postq_index &0xFF ]); + pinbound_srb->addressHigh =dma_addr_hi32 (cdb_phyaddr); + pinbound_srb->addressLow =dma_addr_lo32 (cdb_phyaddr); + pinbound_srb->length = ccb->arc_cdb_size >>2 ; + arcmsr_cdb->msgContext =dma_addr_lo32 (cdb_phyaddr); +if (postq_index &0x4000 ) { + index_stripped = postq_index &0xFF ; + index_stripped +=1 ; + index_stripped %=ARCMSR_MAX_ARC1214_POSTQUEUE ; + pmu->postq_index = index_stripped ? + (index_stripped |0x4000 ) : index_stripped;Quoted 8 lines
drivers/scsi/arcmsr/arcmsr_hba.c static void arcmsr_post_ccb(struct Adapt · line 1454
Quoted 7 lines
drivers/scsi/arcmsr/arcmsr_hba.c +7
-0+ }else { + index_stripped = postq_index; + index_stripped +=1 ; + index_stripped %=ARCMSR_MAX_ARC1214_POSTQUEUE ; + pmu->postq_index = index_stripped ? index_stripped : + (index_stripped |0x4000 ); + }The code above could be a bit easier -
Quoted 2 lines
Yea. I simplify it to following.
toggle = postq_index & 0x4000;
I might be wrong but the following two lines:
Quoted 1 line
index_stripped = (postq_index & 0xFF) + 1;
the first '&' is not needed, because we use a modulo in a next step
Quoted 1 line
index_stripped %= ARCMSR_MAX_ARC1214_POSTQUEUE;
and module is for certain binary numbers equivalent to '&', so this could be changed into
index_stripped = postq_index + 1; index_stripped &= (ARCMSR_MAX_ARC1214_POSTQUEUE - 1);
( ARCMSR_MAX_ARC1214_POSTQUEUE is equal 0x100)
and this
Quoted 2 lines
pmu->postq_index = index_stripped ? (index_stripped | toggle) : (index_stripped | (toggle ^ 0x4000));
into
pmu->postq_index = index_stripped ? (index_stripped | toggle) : (toggle ^ 0x4000);
Let us stop this discussion, it's not a bug, you may or may not include it in your next series, we can discuss it there.
For another question, please look below.
Quoted 41 lines
Quoted 11 lines
arcmsr_cdb->msgContext = dma_addr_lo32(cdb_phyaddr); index_stripped = postq_index + 1; index_stripped &= (ARCMSR_MAX_ARC1214_POSTQUEUE - 1); if (postq_index & 0x4000) pmu->postq_index = index_stripped ? (index_stripped | 0x4000) : index_stripped; else pmu->postq_index = index_stripped ? index_stripped : (index_stripped | 0x4000);Quoted 1 line
or am I wrong? This is repeated in the code many times
Yea. one for postQueue and 3 times for doneQueue. They all can be simplified as above.
Quoted 20 lines
Quoted 9 lines
drivers/scsi/arcmsr/arcmsr_hba.c +4
-0+writel (postq_index, pmu->inboundlist_write_pointer); +spin_unlock_irqrestore (&acb->postq_lock, flags); +break ; + } } }...
Quoted 10 lines
drivers/scsi/arcmsr/arcmsr_hba.c +10
-0+static int arcmsr_hbaD_polling_ccbdone (struct AdapterControlBlock *acb, +struct CommandControlBlock *poll_ccb) +{ +bool error; +uint32_t poll_ccb_done =0 , poll_count =0 , flag_ccb, ccb_cdb_phy; +int rtn, doneq_index, index_stripped, outbound_write_pointer; +unsigned long flags; +struct ARCMSR_CDB *arcmsr_cdb; +struct CommandControlBlock *pCCB; +struct MessageUnit_D *pmu = acb->pmuD;Quoted 8 lines
drivers/scsi/arcmsr/arcmsr_hba.c polling_hbc_ccb_retry: · line 3198
Quoted 6 lines
drivers/scsi/arcmsr/arcmsr_hba.c +6
-0+ +polling_hbaD_ccb_retry: + poll_count++; +while (1 ) { + outbound_write_pointer = pmu->done_qbuffer[0 ].addressLow +1 ; + doneq_index = pmu->doneq_index;You seem to protect the doneq with a spinlock on some other places,
arcmsr_hbaD_postqueue_isrand below in this function. Why not here, is it intentional?
Quoted 2 lines
Before came here, the h/w interrupt was disabled. Hence, don't worry about other thread to change
doneq_index.
I guess you mean the hw interrupts from your card. If so and if you know that no other thread on another processor can access the doneq_index - why do you use the spinlock just few lines below?
Quoted 343 lines
Quoted 334 lines
Quoted 334 lines
drivers/scsi/arcmsr/arcmsr_hba.c +238
-0+if ((outbound_write_pointer &0xFFF ) == (doneq_index &0xFFF )) { +if (poll_ccb_done) { + rtn =SUCCESS ; +break ; + }else { +msleep (25 ); +if (poll_count >40 ) { + rtn =FAILED ; +break ; + } + goto polling_hbaD_ccb_retry; + } + } +spin_lock_irqsave (&acb->doneq_lock, flags); +if (doneq_index &0x4000 ) { + index_stripped = doneq_index &0xFFF ; + index_stripped +=1 ; + index_stripped %=ARCMSR_MAX_ARC1214_DONEQUEUE ; + pmu->doneq_index = index_stripped ? + (index_stripped |0x4000 ) : + (index_stripped +1 ); + }else { + index_stripped = doneq_index; + index_stripped +=1 ; + index_stripped %=ARCMSR_MAX_ARC1214_DONEQUEUE ; + pmu->doneq_index = index_stripped ? index_stripped : + ((index_stripped |0x4000 ) +1 ); + } +spin_unlock_irqrestore (&acb->doneq_lock, flags); + doneq_index = pmu->doneq_index; + flag_ccb = pmu->done_qbuffer[doneq_index &0xFFF ].addressLow; + ccb_cdb_phy = (flag_ccb &0xFFFFFFF0 ); + arcmsr_cdb = (struct ARCMSR_CDB *)(acb->vir2phy_offset + + ccb_cdb_phy); + pCCB = container_of(arcmsr_cdb, struct CommandControlBlock, + arcmsr_cdb); + poll_ccb_done |= (pCCB == poll_ccb) ?1 :0 ; +if ((pCCB->acb != acb) || + (pCCB->startdone !=ARCMSR_CCB_START )) { +if (pCCB->startdone ==ARCMSR_CCB_ABORTED ) { +pr_notice ("arcmsr%d: scsi id = %d " +"lun = %d ccb = '0x%p' poll command " +"abort successfully\n" + , acb->host->host_no + , pCCB->pcmd->device->id + , (u32 )pCCB->pcmd->device->lun + , pCCB); + pCCB->pcmd->result =DID_ABORT <<16 ; +arcmsr_ccb_complete (pCCB); +continue ; + } +pr_notice ("arcmsr%d: polling an illegal " +"ccb command done ccb = '0x%p' " +"ccboutstandingcount = %d\n" + , acb->host->host_no + , pCCB + ,atomic_read (&acb->ccboutstandingcount)); +continue ; + } + error = (flag_ccb &ARCMSR_CCBREPLY_FLAG_ERROR_MODE1 ) + ? true : false; +arcmsr_report_ccb_state (acb, pCCB, error); + } +return rtn; +} +static int arcmsr_polling_ccbdone (struct AdapterControlBlock *acb,struct CommandControlBlock *poll_ccb) {@@ -2711,6 +3280,10 @@ static int arcmsr_polling_ccbdone(structcase ACB_ADAPTER_TYPE_C : { rtn =arcmsr_hbaC_polling_ccbdone (acb, poll_ccb); } +break ; +case ACB_ADAPTER_TYPE_D : + rtn =arcmsr_hbaD_polling_ccbdone (acb, poll_ccb); +break ; }return rtn; }@@ -2728,6 +3301,7 @@ static int arcmsr_iop_confirm(struct Ada*/ switch (acb->adapter_type) {case ACB_ADAPTER_TYPE_B : +case ACB_ADAPTER_TYPE_D : dma_coherent_handle = acb->dma_coherent_handle2;break ;default :@@ -2817,6 +3391,27 @@ static int arcmsr_iop_confirm(struct Ada } } } +break ; +case ACB_ADAPTER_TYPE_D : { +uint32_t __iomem *rwbuffer; +struct MessageUnit_D *reg = acb->pmuD; + reg->postq_index =0 ; + reg->doneq_index =0 ; + rwbuffer = reg->msgcode_rwbuffer; +writel (ARCMSR_SIGNATURE_SET_CONFIG , rwbuffer++); +writel (cdb_phyaddr_hi32, rwbuffer++); +writel (cdb_phyaddr, rwbuffer++); +writel (cdb_phyaddr + (ARCMSR_MAX_ARC1214_POSTQUEUE * +sizeof (struct InBound_SRB )), rwbuffer++); +writel (0x100 , rwbuffer); +writel (ARCMSR_INBOUND_MESG0_SET_CONFIG , reg->inbound_msgaddr0); +if (!arcmsr_hbaD_wait_msgint_ready (acb)) { +pr_notice ("arcmsr%d: 'set command Q window' timeout\n" , + acb->host->host_no); +return 1 ; + } + } +break ; }return 0 ; }@@ -2848,6 +3443,15 @@ static void arcmsr_wait_firmware_ready(s firmware_state =readl (®->outbound_msgaddr1); }while ((firmware_state &ARCMSR_HBCMU_MESSAGE_FIRMWARE_OK ) ==0 ); } +break ; +case ACB_ADAPTER_TYPE_D : { +struct MessageUnit_D *reg = acb->pmuD; +do { + firmware_state =readl (reg->outbound_msgaddr1); + }while ((firmware_state & +ARCMSR_ARC1214_MESSAGE_FIRMWARE_OK ) ==0 ); + } +break ; } }@@ -2918,6 +3522,35 @@ static void arcmsr_hbaC_request_device_mreturn ; } +static void arcmsr_hbaD_request_device_map (struct AdapterControlBlock *acb) +{ +struct MessageUnit_D *reg = acb->pmuD; + +if (unlikely (atomic_read (&acb->rq_map_token) ==0 ) || + ((acb->acb_flags &ACB_F_BUS_RESET ) !=0 ) || + ((acb->acb_flags &ACB_F_ABORT ) !=0 )) { +mod_timer (&acb->eternal_timer, + jiffies +msecs_to_jiffies (6 *HZ )); + }else { + acb->fw_flag =FW_NORMAL ; +if (atomic_read (&acb->ante_token_value) == +atomic_read (&acb->rq_map_token)) { +atomic_set (&acb->rq_map_token,16 ); + } +atomic_set (&acb->ante_token_value, +atomic_read (&acb->rq_map_token)); +if (atomic_dec_and_test (&acb->rq_map_token)) { +mod_timer (&acb->eternal_timer, jiffies + +msecs_to_jiffies (6 *HZ )); +return ; + } +writel (ARCMSR_INBOUND_MESG0_GET_CONFIG , + reg->inbound_msgaddr0); +mod_timer (&acb->eternal_timer, jiffies + +msecs_to_jiffies (6 *HZ )); + } +} +static void arcmsr_request_device_map (unsigned long pacb) {struct AdapterControlBlock *acb = (struct AdapterControlBlock *)pacb;@@ -2933,6 +3566,10 @@ static void arcmsr_request_device_map(uncase ACB_ADAPTER_TYPE_C : {arcmsr_hbaC_request_device_map (acb); } +break ; +case ACB_ADAPTER_TYPE_D : +arcmsr_hbaD_request_device_map (acb); +break ; } }@@ -2970,6 +3607,19 @@ static void arcmsr_hbaC_start_bgrb(struc }return ; } + +static void arcmsr_hbaD_start_bgrb (struct AdapterControlBlock *pACB) +{ +struct MessageUnit_D *pmu = pACB->pmuD; + + pACB->acb_flags |=ACB_F_MSG_START_BGRB ; +writel (ARCMSR_INBOUND_MESG0_START_BGRB , pmu->inbound_msgaddr0); +if (!arcmsr_hbaD_wait_msgint_ready (pACB)) { +pr_notice ("arcmsr%d: wait 'start adapter " +"background rebulid' timeout\n" , pACB->host->host_no); + } +} +static void arcmsr_start_adapter_bgrb (struct AdapterControlBlock *acb) {switch (acb->adapter_type) {@@ -2981,6 +3631,10 @@ static void arcmsr_start_adapter_bgrb(stbreak ;case ACB_ADAPTER_TYPE_C :arcmsr_hbaC_start_bgrb (acb); +break ; +case ACB_ADAPTER_TYPE_D : +arcmsr_hbaD_start_bgrb (acb); +break ; } }@@ -3026,6 +3680,29 @@ static void arcmsr_clear_doorbell_queue_break ; } } +break ; +case ACB_ADAPTER_TYPE_D : { +struct MessageUnit_D *reg = acb->pmuD; +uint32_t outbound_doorbell, i; +/* empty doorbell Qbuffer if door bell ringed */ + outbound_doorbell =readl (reg->outbound_doorbell); +writel (outbound_doorbell, reg->outbound_doorbell); +writel (ARCMSR_ARC1214_DRV2IOP_DATA_OUT_READ , + reg->inbound_doorbell); +for (i =0 ; i <200 ; i++) { +msleep (20 ); + outbound_doorbell =readl (reg->outbound_doorbell); +if (outbound_doorbell & +ARCMSR_ARC1214_IOP2DRV_DATA_WRITE_OK ) { +writel (outbound_doorbell, + reg->outbound_doorbell); +writel (ARCMSR_ARC1214_DRV2IOP_DATA_OUT_READ , + reg->inbound_doorbell); + }else +break ; + } + } +break ; } }@@ -3056,6 +3733,7 @@ static void arcmsr_hardware_reset(structint i, count =0 ;struct MessageUnit_A __iomem *pmuA = acb->pmuA;struct MessageUnit_C __iomem *pmuC = acb->pmuC; +struct MessageUnit_D *pmuD = acb->pmuD;/* backup pci config data */ printk (KERN_NOTICE "arcmsr%d: executing hw bus reset .....\n" , acb->host->host_no);@@ -3076,6 +3754,8 @@ static void arcmsr_hardware_reset(structwritel (0xD , &pmuC->write_sequence); }while (((readl (&pmuC->host_diagnostic) & ARCMSR_ARC1880_DiagWrite_ENABLE) ==0 ) && (count <5 ));writel (ARCMSR_ARC1880_RESET_ADAPTER , &pmuC->host_diagnostic); + }else if ((acb->dev_id ==0x1214 )) { +writel (0x20 , pmuD->reset_request); }else {pci_write_config_byte (acb->pdev,0x84 ,0x20 ); }@@ -3272,6 +3952,66 @@ sleep: }break ; } +case ACB_ADAPTER_TYPE_D : { +if (acb->acb_flags &ACB_F_BUS_RESET ) { +long timeout; +pr_notice ("arcmsr: there is an bus reset" +" eh proceeding.......\n" ); + timeout =wait_event_timeout (wait_q, (acb->acb_flags + &ACB_F_BUS_RESET ) ==0 ,220 *HZ ); +if (timeout) +return SUCCESS ; + } + acb->acb_flags |=ACB_F_BUS_RESET ; +if (!arcmsr_iop_reset (acb)) { +struct MessageUnit_D *reg; + reg = acb->pmuD; +arcmsr_hardware_reset (acb); + acb->acb_flags &= ~ACB_F_IOP_INITED ; + nap: +ssleep (ARCMSR_SLEEPTIME ); +if ((readl (reg->sample_at_reset) &0x80 ) !=0 ) { +pr_err ("arcmsr%d: waiting for " +"hw bus reset return, retry=%d\n" , + acb->host->host_no, retry_count); +if (retry_count >ARCMSR_RETRYCOUNT ) { + acb->fw_flag =FW_DEADLOCK ; +pr_err ("arcmsr%d: waiting for hw bus" +" reset return, " +"RETRY TERMINATED!!\n" , + acb->host->host_no); +return FAILED ; + } + retry_count++; + goto nap; + } + acb->acb_flags |=ACB_F_IOP_INITED ; +/* disable all outbound interrupt */ + intmask_org =arcmsr_disable_outbound_ints (acb); +arcmsr_get_firmware_spec (acb); +arcmsr_start_adapter_bgrb (acb); +arcmsr_clear_doorbell_queue_buffer (acb); +arcmsr_enable_outbound_ints (acb, intmask_org); +atomic_set (&acb->rq_map_token,16 ); +atomic_set (&acb->ante_token_value,16 ); + acb->fw_flag =FW_NORMAL ; +mod_timer (&acb->eternal_timer, + jiffies +msecs_to_jiffies (6 *HZ )); + acb->acb_flags &= ~ACB_F_BUS_RESET ; + rtn =SUCCESS ; +pr_err ("arcmsr: scsi bus reset " +"eh returns with success\n" ); + }else { + acb->acb_flags &= ~ACB_F_BUS_RESET ; +atomic_set (&acb->rq_map_token,16 ); +atomic_set (&acb->ante_token_value,16 ); + acb->fw_flag =FW_NORMAL ; +mod_timer (&acb->eternal_timer, + jiffies +msecs_to_jiffies (6 *HZ )); + rtn =SUCCESS ; + } +break ; + } }return rtn; }@@ -3348,6 +4088,7 @@ static const char *arcmsr_info(struct Sccase PCI_DEVICE_ID_ARECA_1280 : type ="SATA" ;break ; +case PCI_DEVICE_ID_ARECA_1214 :case PCI_DEVICE_ID_ARECA_1380 :case PCI_DEVICE_ID_ARECA_1381 :case PCI_DEVICE_ID_ARECA_1680 :Quoted 4 lines
Quoted 4 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Ching,
do you have a chance to address Thomas second concern below? As far as I can tell (Thomas, please correct me) that's the last outstanding concern, and I'd really like to merge the arcmsr updates for the Linux 3.18 merge window.
Quoted 6 lines · Christoph Hellwig
Ching,
do you have a chance to address Thomas second concern below? As far as I can tell (Thomas, please correct me) that's the last outstanding concern, and I'd really like to merge the arcmsr updates for the Linux 3.18 merge window.
Correct, still awaiting a response.
Quoted 5 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 9 lines · Tomas Henzl
Quoted 6 lines · Christoph Hellwig
Ching,
do you have a chance to address Thomas second concern below? As far as I can tell (Thomas, please correct me) that's the last outstanding concern, and I'd really like to merge the arcmsr updates for the Linux 3.18 merge window.
Correct, still awaiting a response.
Christoph, Tomas,
Sorry for the late reply.
I think I misunderstand Tomas' meaning.
The spin lock in arcmsr_hbaD_polling_ccbdone() is necessary to protect doneq_index and have to be modified as following.
static int arcmsr_hbaD_polling_ccbdone(struct AdapterControlBlock *acb,
struct CommandControlBlock *poll_ccb)
{
bool error;
uint32_t poll_ccb_done = 0, poll_count = 0, flag_ccb, ccb_cdb_phy;
int rtn, doneq_index, index_stripped, outbound_write_pointer, toggle;
unsigned long flags;
struct ARCMSR_CDB *arcmsr_cdb;
struct CommandControlBlock *pCCB;
struct MessageUnit_D *pmu = acb->pmuD;polling_hbaD_ccb_retry:
poll_count++;
while (1) {
spin_lock_irqsave(&acb->doneq_lock, flags);
outbound_write_pointer = pmu->done_qbuffer[0].addressLow + 1;
doneq_index = pmu->doneq_index;
if ((outbound_write_pointer & 0xFFF) == (doneq_index & 0xFFF)) {
spin_unlock_irqrestore(&acb->doneq_lock, flags);
if (poll_ccb_done) {
rtn = SUCCESS;
break;
} else {
msleep(25);
if (poll_count > 40) {
rtn = FAILED;
break;
}
goto polling_hbaD_ccb_retry;
}
}
toggle = doneq_index & 0x4000;
index_stripped = (doneq_index & 0xFFF) + 1;
index_stripped %= ARCMSR_MAX_ARC1214_DONEQUEUE;
pmu->doneq_index = index_stripped ? (index_stripped | toggle) :
((index_stripped + 1) | (toggle ^ 0x4000));
spin_unlock_irqrestore(&acb->doneq_lock, flags);
doneq_index = pmu->doneq_index;
flag_ccb = pmu->done_qbuffer[doneq_index & 0xFFF].addressLow;
ccb_cdb_phy = (flag_ccb & 0xFFFFFFF0);
arcmsr_cdb = (struct ARCMSR_CDB *)(acb->vir2phy_offset +
ccb_cdb_phy);
pCCB = container_of(arcmsr_cdb, struct CommandControlBlock,
arcmsr_cdb);
poll_ccb_done |= (pCCB == poll_ccb) ? 1 : 0;
if ((pCCB->acb != acb) ||
(pCCB->startdone != ARCMSR_CCB_START)) {
if (pCCB->startdone == ARCMSR_CCB_ABORTED) {
pr_notice("arcmsr%d: scsi id = %d "
"lun = %d ccb = '0x%p' poll command "
"abort successfully\n"
, acb->host->host_no
, pCCB->pcmd->device->id
, (u32)pCCB->pcmd->device->lun
, pCCB);
pCCB->pcmd->result = DID_ABORT << 16;
arcmsr_ccb_complete(pCCB);
continue;
}
pr_notice("arcmsr%d: polling an illegal "
"ccb command done ccb = '0x%p' "
"ccboutstandingcount = %d\n"
, acb->host->host_no
, pCCB
, atomic_read(&acb->ccboutstandingcount));
continue;
}
error = (flag_ccb & ARCMSR_CCBREPLY_FLAG_ERROR_MODE1)
? true : false;
arcmsr_report_ccb_state(acb, pCCB, error);
}
return rtn;
}Quoted 7 lines
Quoted 6 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 8 lines · Ching Huang
Quoted 7 lines · Tomas Henzl
Quoted 6 lines · Christoph Hellwig
Ching,
do you have a chance to address Thomas second concern below? As far as I can tell (Thomas, please correct me) that's the last outstanding concern, and I'd really like to merge the arcmsr updates for the Linux 3.18 merge window.
Quoted 7 lines
Quoted 1 line
Correct, still awaiting a response.
Christoph, Tomas,
Sorry for the late reply.
I think I misunderstand Tomas' meaning.
The spin lock inarcmsr_hbaD_polling_ccbdone()is necessary to protectdoneq_indexand have to be modified as following.
OK, so you are going to repost 16/17 ? If so, please describe all changes you'll do, in that new post.
Quoted 85 lines
static int arcmsr_hbaD_polling_ccbdone(struct AdapterControlBlock *acb,
struct CommandControlBlock*poll_ccb){ bool error; uint32_t poll_ccb_done = 0, poll_count = 0, flag_ccb, ccb_cdb_phy; int rtn, doneq_index, index_stripped, outbound_write_pointer, toggle; unsigned long flags; struct ARCMSR_CDB *arcmsr_cdb; struct CommandControlBlock *pCCB; struct MessageUnit_D *pmu = acb->pmuD;
polling_hbaD_ccb_retry:poll_count++; while (1) { spin_lock_irqsave(&acb->doneq_lock, flags); outbound_write_pointer = pmu->done_qbuffer[0].addressLow + 1; doneq_index = pmu->doneq_index; if ((outbound_write_pointer & 0xFFF) == (doneq_index & 0xFFF)) { spin_unlock_irqrestore(&acb->doneq_lock, flags); if (poll_ccb_done) { rtn = SUCCESS; break; } else { msleep(25); if (poll_count > 40) { rtn = FAILED; break; } goto polling_hbaD_ccb_retry; } } toggle = doneq_index & 0x4000; index_stripped = (doneq_index & 0xFFF) + 1; index_stripped %= ARCMSR_MAX_ARC1214_DONEQUEUE; pmu->doneq_index = index_stripped ? (index_stripped | toggle) : ((index_stripped + 1) | (toggle ^ 0x4000)); spin_unlock_irqrestore(&acb->doneq_lock, flags); doneq_index = pmu->doneq_index; flag_ccb = pmu->done_qbuffer[doneq_index & 0xFFF].addressLow; ccb_cdb_phy = (flag_ccb & 0xFFFFFFF0); arcmsr_cdb = (struct ARCMSR_CDB *)(acb->vir2phy_offset + ccb_cdb_phy); pCCB = container_of(arcmsr_cdb, struct CommandControlBlock, arcmsr_cdb); poll_ccb_done |= (pCCB == poll_ccb) ? 1 : 0; if ((pCCB->acb != acb) || (pCCB->startdone != ARCMSR_CCB_START)) { if (pCCB->startdone == ARCMSR_CCB_ABORTED) { pr_notice("arcmsr%d: scsi id = %d " "lun = %d ccb = '0x%p' poll command " "abort successfully\n" , acb->host->host_no , pCCB->pcmd->device->id , (u32)pCCB->pcmd->device->lun , pCCB); pCCB->pcmd->result = DID_ABORT << 16; arcmsr_ccb_complete(pCCB); continue; } pr_notice("arcmsr%d: polling an illegal " "ccb command done ccb = '0x%p' " "ccboutstandingcount = %d\n" , acb->host->host_no , pCCB , atomic_read(&acb->ccboutstandingcount)); continue; } error = (flag_ccb & ARCMSR_CCBREPLY_FLAG_ERROR_MODE1) ? true : false; arcmsr_report_ccb_state(acb, pCCB, error); } return rtn; }Quoted 4 lines
Quoted 4 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 10 lines · Tomas Henzl
Quoted 9 lines · Ching Huang
Quoted 8 lines · Tomas Henzl
Quoted 6 lines · Christoph Hellwig
Ching,
do you have a chance to address Thomas second concern below? As far as I can tell (Thomas, please correct me) that's the last outstanding concern, and I'd really like to merge the arcmsr updates for the Linux 3.18 merge window.
Correct, still awaiting a response.
Quoted 9 lines
Quoted 6 lines
Christoph, Tomas,
Sorry for the late reply.
I think I misunderstand Tomas' meaning.
The spin lock inarcmsr_hbaD_polling_ccbdone()is necessary to protectdoneq_indexand have to be modified as following.OK, so you are going to repost 16/17 ? If so, please describe all changes you'll do, in that new post.
By previous review, I will post two patches.
One for 13/17 and another for 16/17.
These patches are relative to http://git.infradead.org/users/hch/scsi-queue.git/tree/arcmsr-for-3.18:/drivers/scsi/arcmsr
Quoted 86 lines
Quoted 85 lines
static int arcmsr_hbaD_polling_ccbdone(struct AdapterControlBlock *acb,
struct CommandControlBlock*poll_ccb){ bool error; uint32_t poll_ccb_done = 0, poll_count = 0, flag_ccb, ccb_cdb_phy; int rtn, doneq_index, index_stripped, outbound_write_pointer, toggle; unsigned long flags; struct ARCMSR_CDB *arcmsr_cdb; struct CommandControlBlock *pCCB; struct MessageUnit_D *pmu = acb->pmuD;
polling_hbaD_ccb_retry:poll_count++; while (1) { spin_lock_irqsave(&acb->doneq_lock, flags); outbound_write_pointer = pmu->done_qbuffer[0].addressLow + 1; doneq_index = pmu->doneq_index; if ((outbound_write_pointer & 0xFFF) == (doneq_index & 0xFFF)) { spin_unlock_irqrestore(&acb->doneq_lock, flags); if (poll_ccb_done) { rtn = SUCCESS; break; } else { msleep(25); if (poll_count > 40) { rtn = FAILED; break; } goto polling_hbaD_ccb_retry; } } toggle = doneq_index & 0x4000; index_stripped = (doneq_index & 0xFFF) + 1; index_stripped %= ARCMSR_MAX_ARC1214_DONEQUEUE; pmu->doneq_index = index_stripped ? (index_stripped | toggle) : ((index_stripped + 1) | (toggle ^ 0x4000)); spin_unlock_irqrestore(&acb->doneq_lock, flags); doneq_index = pmu->doneq_index; flag_ccb = pmu->done_qbuffer[doneq_index & 0xFFF].addressLow; ccb_cdb_phy = (flag_ccb & 0xFFFFFFF0); arcmsr_cdb = (struct ARCMSR_CDB *)(acb->vir2phy_offset + ccb_cdb_phy); pCCB = container_of(arcmsr_cdb, struct CommandControlBlock, arcmsr_cdb); poll_ccb_done |= (pCCB == poll_ccb) ? 1 : 0; if ((pCCB->acb != acb) || (pCCB->startdone != ARCMSR_CCB_START)) { if (pCCB->startdone == ARCMSR_CCB_ABORTED) { pr_notice("arcmsr%d: scsi id = %d " "lun = %d ccb = '0x%p' poll command " "abort successfully\n" , acb->host->host_no , pCCB->pcmd->device->id , (u32)pCCB->pcmd->device->lun , pCCB); pCCB->pcmd->result = DID_ABORT << 16; arcmsr_ccb_complete(pCCB); continue; } pr_notice("arcmsr%d: polling an illegal " "ccb command done ccb = '0x%p' " "ccboutstandingcount = %d\n" , acb->host->host_no , pCCB , atomic_read(&acb->ccboutstandingcount)); continue; } error = (flag_ccb & ARCMSR_CCBREPLY_FLAG_ERROR_MODE1) ? true : false; arcmsr_report_ccb_state(acb, pCCB, error); } return rtn; }Quoted 4 lines
Quoted 4 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 8 lines · Tomas Henzl
Quoted 6 lines · Christoph Hellwig
Ching,
do you have a chance to address Thomas second concern below? As far as I can tell (Thomas, please correct me) that's the last outstanding concern, and I'd really like to merge the arcmsr updates for the Linux 3.18 merge window.
Correct, still awaiting a response.
Christoph,
you may add my 'reviewed-by' to the arcmsr series
http://git.infradead.org/users/hch/scsi-queue.git/tree/arcmsr-for-3.18:/drivers/scsi/arcmsr
with the '[PATCH v5 2/2] arcmsr: simplify of updating doneq_index and postq_index' ( https://lkml.org/lkml/2014/9/15/177 ) on top of the series
that last patch fixes the 16/17 from your git.
I hope the series is an iteration in the right direction.
Skip the the '[PATCH v4 1/2] arcmsr: simplify ioctl data read/write', Ching will repost it later.
Tomas
Quoted 9 lines
Quoted 5 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 9 lines · Tomas Henzl
Christoph,
you may add my 'reviewed-by' to the arcmsr series
http://git.infradead.org/users/hch/scsi-queue.git/tree/arcmsr-for-3.18:/drivers/scsi/arcmsr
with the '[PATCH v5 2/2] arcmsr: simplify of updatingdoneq_indexandpostq_index' ( https://lkml.org/lkml/2014/9/15/177 ) on top of the series
that last patch fixes the 16/17 from your git.
I hope the series is an iteration in the right direction.
Skip the the '[PATCH v4 1/2] arcmsr: simplify ioctl data read/write', Ching will repost it later.
Thanks a lot Tomas for all the review, and thanks Ching for the patches and updates. I'll merge the branch and the additional patch today.
Quoted 11 lines · Christoph Hellwig
Quoted 9 lines · Tomas Henzl
Christoph,
you may add my 'reviewed-by' to the arcmsr series
http://git.infradead.org/users/hch/scsi-queue.git/tree/arcmsr-for-3.18:/drivers/scsi/arcmsr
with the '[PATCH v5 2/2] arcmsr: simplify of updatingdoneq_indexandpostq_index' ( https://lkml.org/lkml/2014/9/15/177 ) on top of the series
that last patch fixes the 16/17 from your git.
I hope the series is an iteration in the right direction.
Skip the the '[PATCH v4 1/2] arcmsr: simplify ioctl data read/write', Ching will repost it later.
Quoted 3 lines
Thanks a lot Tomas for all the review, and thanks Ching for the patches and updates. I'll merge the branch and the additional patch today.
Christoph,
The [PATCH v5 2/2] was depend on [PATCH v4 1/2].
If you skip patch 1/2, then patch 2/2 may cause line number mismatch. How should I do? Please advise.
Quoted 3 lines · Ching Huang
The [PATCH v5 2/2] was depend on [PATCH v4 1/2].
If you skip patch 1/2, then patch 2/2 may cause line number mismatch. How should I do? Please advise.
Hi Ching,
[PATCH v5 2/2] applied without a problem. Please look at my drivers-for-3.18 branch and send any additional patches relative to that.