Re: [PATCH v2 2/3] arcmsr: adds code for support areca new adapter ARC1203

From: Johannes Thumshirn
Date: Wed Nov 25 2015 - 03:44:06 EST


On Wed, 2015-11-25 at 11:25 +0800, Ching Huang wrote:
> From: Ching Huang <ching2048@xxxxxxxxxxxx>
>
> Support areca new PCIe to SATA RAID adapter ARC1203
>
> Signed-of-by: Ching Huang<ching2048@xxxxxxxxxxxx>
>
> ---
>
> diff -uprN a/drivers/scsi/arcmsr/arcmsr.h b/drivers/scsi/arcmsr/arcmsr.h
> --- a/drivers/scsi/arcmsr/arcmsr.h 2015-11-25 10:52:16.286470000 +0800
> +++ b/drivers/scsi/arcmsr/arcmsr.h 2015-11-25 10:52:13.334470000 +0800
> @@ -74,6 +74,9 @@ struct device_attribute;
> Â#ifndef PCI_DEVICE_ID_ARECA_1214
> Â #define PCI_DEVICE_ID_ARECA_1214 0x1214
> Â#endif
> +#ifndef PCI_DEVICE_ID_ARECA_1203
> + #define PCI_DEVICE_ID_ARECA_1203 0x1203
> +#endif
> Â/*
> Â****************************************************************************
> ******
> Â**
> @@ -245,6 +248,12 @@ struct FIRMWARE_INFO
> Â/* window of "instruction flags" from iop to driver */
> Â#define ARCMSR_IOP2DRV_DOORBELLÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ0x00020408
> Â#define ARCMSR_IOP2DRV_DOORBELL_MASKÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ0x0002040C
> +/* window of "instruction flags" from iop to driver */
> +#define ARCMSR_IOP2DRV_DOORBELL_1203ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ0x00021870
> +#define ARCMSR_IOP2DRV_DOORBELL_MASK_1203ÂÂÂÂÂÂÂÂÂÂÂÂÂ0x00021874
> +/* window of "instruction flags" from driver to iop */
> +#define ARCMSR_DRV2IOP_DOORBELL_1203ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ0x00021878
> +#define ARCMSR_DRV2IOP_DOORBELL_MASK_1203ÂÂÂÂÂÂÂÂÂÂÂÂÂ0x0002187C
> Â/* ARECA FLAG LANGUAGE */
> Â/* ioctl transfer */
> Â#define ARCMSR_IOP2DRV_DATA_WRITE_OKÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ0x00000001
> diff -uprN a/drivers/scsi/arcmsr/arcmsr_hba.c
> b/drivers/scsi/arcmsr/arcmsr_hba.c
> --- a/drivers/scsi/arcmsr/arcmsr_hba.c 2015-11-24 11:35:26.000000000
> +0800
> +++ b/drivers/scsi/arcmsr/arcmsr_hba.c 2015-11-24 18:58:40.640226000
> +0800
> @@ -114,6 +114,7 @@ static void arcmsr_hardware_reset(struct
> Âstatic const char *arcmsr_info(struct Scsi_Host *);
> Âstatic irqreturn_t arcmsr_interrupt(struct AdapterControlBlock *acb);
> Âstatic void arcmsr_free_irq(struct pci_dev *, struct AdapterControlBlock *);
> +static void arcmsr_wait_firmware_ready(struct AdapterControlBlock *acb);
> Âstatic int arcmsr_adjust_disk_queue_depth(struct scsi_device *sdev, int
> queue_depth)
> Â{
> Â if (queue_depth > ARCMSR_MAX_CMD_PERLUN)
> @@ -157,6 +158,8 @@ static struct pci_device_id arcmsr_devic
> Â .driver_data = ACB_ADAPTER_TYPE_B},
> Â {PCI_DEVICE(PCI_VENDOR_ID_ARECA, PCI_DEVICE_ID_ARECA_1202),
> Â .driver_data = ACB_ADAPTER_TYPE_B},
> + {PCI_DEVICE(PCI_VENDOR_ID_ARECA, PCI_DEVICE_ID_ARECA_1203),
> + .driver_data = ACB_ADAPTER_TYPE_B},
> Â {PCI_DEVICE(PCI_VENDOR_ID_ARECA, PCI_DEVICE_ID_ARECA_1210),
> Â .driver_data = ACB_ADAPTER_TYPE_A},
> Â {PCI_DEVICE(PCI_VENDOR_ID_ARECA, PCI_DEVICE_ID_ARECA_1214),
> @@ -2621,7 +2624,7 @@ static bool arcmsr_hbaA_get_config(struc
> Â}
> Âstatic bool arcmsr_hbaB_get_config(struct AdapterControlBlock *acb)
> Â{
> - struct MessageUnit_B *reg = acb->pmuB;
> + struct MessageUnit_B *reg;
> Â struct pci_dev *pdev = acb->pdev;
> Â void *dma_coherent;
> Â dma_addr_t dma_coherent_handle;
> @@ -2649,10 +2652,17 @@ static bool arcmsr_hbaB_get_config(struc
> Â acb->dma_coherent2 = dma_coherent;
> Â reg = (struct MessageUnit_B *)dma_coherent;
> Â acb->pmuB = reg;
> - reg->drv2iop_doorbell= (uint32_t __iomem *)((unsigned long)acb-
> >mem_base0 + ARCMSR_DRV2IOP_DOORBELL);
> - reg->drv2iop_doorbell_mask = (uint32_t __iomem *)((unsigned
> long)acb->mem_base0 + ARCMSR_DRV2IOP_DOORBELL_MASK);
> - reg->iop2drv_doorbell = (uint32_t __iomem *)((unsigned long)acb-
> >mem_base0 + ARCMSR_IOP2DRV_DOORBELL);
> - reg->iop2drv_doorbell_mask = (uint32_t __iomem *)((unsigned
> long)acb->mem_base0 + ARCMSR_IOP2DRV_DOORBELL_MASK);
> + if (acb->pdev->device == PCI_DEVICE_ID_ARECA_1203) {
> + reg->drv2iop_doorbell = (uint32_t __iomem *)((unsigned
> long)acb->mem_base0 + ARCMSR_DRV2IOP_DOORBELL_1203);
> + reg->drv2iop_doorbell_mask = (uint32_t __iomem *)((unsigned
> long)acb->mem_base0 + ARCMSR_DRV2IOP_DOORBELL_MASK_1203);
> + reg->iop2drv_doorbell = (uint32_t __iomem *)((unsigned
> long)acb->mem_base0 + ARCMSR_IOP2DRV_DOORBELL_1203);
> + reg->iop2drv_doorbell_mask = (uint32_t __iomem *)((unsigned
> long)acb->mem_base0 + ARCMSR_IOP2DRV_DOORBELL_MASK_1203);
> + } else {
> + reg->drv2iop_doorbell= (uint32_t __iomem *)((unsigned
> long)acb->mem_base0 + ARCMSR_DRV2IOP_DOORBELL);
> + reg->drv2iop_doorbell_mask = (uint32_t __iomem *)((unsigned
> long)acb->mem_base0 + ARCMSR_DRV2IOP_DOORBELL_MASK);
> + reg->iop2drv_doorbell = (uint32_t __iomem *)((unsigned
> long)acb->mem_base0 + ARCMSR_IOP2DRV_DOORBELL);
> + reg->iop2drv_doorbell_mask = (uint32_t __iomem *)((unsigned
> long)acb->mem_base0 + ARCMSR_IOP2DRV_DOORBELL_MASK);
> + }


This isn't quite readable IMHO. Can't you do:

#define MEM_BASE0(x) (u32 __iomem *)((unsigned long)acb->mem_base0 + (x))
#define MEM_BASE1(x) (u32 __iomem *)((unsigned long)acb->mem_base1 + (x))

and thenÂ

reg->drv2iop_doorbell= MEM_BASE0(ARCMSR_DRV2IOP_DOORBELL);
reg->drv2iop_doorbell_mask = MEM_BASE0(ARCMSR_DRV2IOP_DOORBELL_MASK);
reg->iop2drv_doorbell = MEM_BASE0(ARCMSR_IOP2DRV_DOORBELL);
reg->iop2drv_doorbell_mask = MEM_BASE0(ARCMSR_IOP2DRV_DOORBELL_MASK);
reg->message_wbuffer =ÂÂMEM_BASE1(ARCMSR_MESSAGE_WBUFFER);
reg->message_rbuffer =ÂÂMEM_BASE1(ARCMSR_MESSAGE_RBUFFER);
reg->message_rwbuffer =ÂÂMEM_BASE1(ARCMSR_MESSAGE_RWBUFFER);


(Note this hunk is made without your patch. And not tested)

> Â reg->message_wbuffer = (uint32_t __iomem *)((unsigned long)acb-
> >mem_base1 + ARCMSR_MESSAGE_WBUFFER);
> Â reg->message_rbuffer =ÂÂ(uint32_t __iomem *)((unsigned long)acb-
> >mem_base1 + ARCMSR_MESSAGE_RBUFFER);
> Â reg->message_rwbuffer = (uint32_t __iomem *)((unsigned long)acb-
> >mem_base1 + ARCMSR_MESSAGE_RWBUFFER);
> @@ -2660,11 +2670,17 @@ static bool arcmsr_hbaB_get_config(struc
> Â iop_firm_version = (char __iomem *)(&reg->message_rwbuffer[17]);
> /*firm_version,17,68-83*/
> Â iop_device_map = (char __iomem *)(&reg->message_rwbuffer[21]);
> /*firm_version,21,84-99*/
> Â
> + arcmsr_wait_firmware_ready(acb);
> + writel(ARCMSR_MESSAGE_START_DRIVER_MODE, reg->drv2iop_doorbell);
> + if (!arcmsr_hbaB_wait_msgint_ready(acb)) {
> + printk(KERN_ERR "arcmsr%d: can't set driver mode.\n", acb-
> >host->host_no);
> + goto err_free_dma;
> + }
> Â writel(ARCMSR_MESSAGE_GET_CONFIG, reg->drv2iop_doorbell);
> Â if (!arcmsr_hbaB_wait_msgint_ready(acb)) {
> Â printk(KERN_NOTICE "arcmsr%d: wait 'get adapter firmware \
> Â miscellaneous data' timeout \n", acb->host-
> >host_no);
> - return false;
> + goto err_free_dma;
> Â }
> Â count = 8;
> Â while (count){
> @@ -2707,6 +2723,10 @@ static bool arcmsr_hbaB_get_config(struc
> Â acb->firm_cfg_version = readl(&reg-
> >message_rwbuffer[25]);ÂÂ/*firm_cfg_version,25,100-103*/
> Â /*firm_ide_channels,4,16-19*/
> Â return true;
> +err_free_dma:
> + dma_free_coherent(&acb->pdev->dev, acb->roundup_ccbsize,
> + acb->dma_coherent2, acb->dma_coherent_handle2);
> + return false;
> Â}
> Â
> Âstatic bool arcmsr_hbaC_get_config(struct AdapterControlBlock *pACB)
> @@ -3998,6 +4018,7 @@ static const char *arcmsr_info(struct Sc
> Â case PCI_DEVICE_ID_ARECA_1160:
> Â case PCI_DEVICE_ID_ARECA_1170:
> Â case PCI_DEVICE_ID_ARECA_1201:
> + case PCI_DEVICE_ID_ARECA_1203:
> Â case PCI_DEVICE_ID_ARECA_1220:
> Â case PCI_DEVICE_ID_ARECA_1230:
> Â case PCI_DEVICE_ID_ARECA_1260:
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info atÂÂhttp://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/