From patchwork Tue Nov 24 11:20:07 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: ching Huang X-Patchwork-Id: 7689851 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 29778BF90C for ; Tue, 24 Nov 2015 11:20:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0BB2E207E3 for ; Tue, 24 Nov 2015 11:20:47 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BAC662049C for ; Tue, 24 Nov 2015 11:20:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754496AbbKXLUS (ORCPT ); Tue, 24 Nov 2015 06:20:18 -0500 Received: from mail-pa0-f42.google.com ([209.85.220.42]:35462 "EHLO mail-pa0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754421AbbKXLUO (ORCPT ); Tue, 24 Nov 2015 06:20:14 -0500 Received: by pacej9 with SMTP id ej9so19837665pac.2 for ; Tue, 24 Nov 2015 03:20:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=areca-com-tw.20150623.gappssmtp.com; s=20150623; h=subject:from:to:cc:in-reply-to:references:content-type:date :message-id:mime-version:content-transfer-encoding; bh=PW0xNE80PIBRgxjXRsHC7+Sc4JoNEv3nTXgy6xfXQgg=; b=dLPeb9+6upBsQ7p9F3My2+4pQsum5kOfYTE31ldtfAC1CpD3LPYO92Ctrnc1EifzDY sugxJG7O0k8raqj8wBjhT29MFhdiNjVGjbwr/eT9ZvN2i+pcsZdv0a95a7AW8+QQS5yt hlg3hnNV6HT+jHGZ6syeIrPhJqX1u3jN9xHurbrTNMsFu5RX+e4+FEs2s4N+TJ3ct8ew Uf+d0upwi5DeLcFFg0nMI2fXAkNmA7SCgWXMZHjCx0PXMz8Qy6kZtd1KEfFptj8MASj2 WVSTb+90luNGZlCWbekEXaw91Lf+/cAA1Veuvpab/U4spSd3SAWLTiD0Hd+Rs+0TuDUf FC8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:from:to:cc:in-reply-to:references :content-type:date:message-id:mime-version:content-transfer-encoding; bh=PW0xNE80PIBRgxjXRsHC7+Sc4JoNEv3nTXgy6xfXQgg=; b=lLbM3uX6Jm3GjLafT1ir6usL6XE5h04fb+zFLvfzT8toYGCPI0XOWUXgYv2nRxpCB/ 411gx8EC1xVGw7Fyp5ej8DeKnYYgKdVPW2KQ3mp/VULVUfiWEjNP3D/Bkk46OH0wRbKM JQX28qZstig7puXPejJrqxzxs2bM8U3aaNSLjX78v2iB+1eTynmPJpSU8uD582CIWsuN kPAqc5SIQ+t7K7mjori3uOzz4PUIxM037AK2XLRCPgWDHBtO8hQqYgSPTGIWVmqJg10M iEMud7GiuvCnAegfLM/1/JRj+IYbsuH8rvXWG79vaJrAewNYZZInZuLcGss41udVqniv mALw== X-Gm-Message-State: ALoCoQlVS9uAEOOA6gtzgY+rXJ05/9ZGDno/1DFrvkQzpiaeQ81dUTn4ZOyt1NNFQUJSyzQAX7hO X-Received: by 10.98.89.75 with SMTP id n72mr22107827pfb.31.1448364013685; Tue, 24 Nov 2015 03:20:13 -0800 (PST) Received: from [192.168.0.65] (60-248-88-209.HINET-IP.hinet.net. [60.248.88.209]) by smtp.gmail.com with ESMTPSA id u67sm13760253pfi.74.2015.11.24.03.20.11 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 24 Nov 2015 03:20:12 -0800 (PST) Subject: Re: [PATCH 2/2] arcmsr: adds code for support areca new adapter ARC1203 From: Ching Huang To: Joe Perches Cc: hch@infradead.org, thenzl@redhat.com, jbottomley@parallels.com, dan.carpenter@oracle.com, agordeev@redhat.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, hch@lst.de In-Reply-To: <1448360674.20113.5.camel@perches.com> References: <1448353024.12861.56.camel@Centos6.3-64> <1448357586.14504.12.camel@perches.com> <1448358798.14472.3.camel@Centos6.3-64> <1448360674.20113.5.camel@perches.com> Date: Tue, 24 Nov 2015 19:20:07 +0800 Message-ID: <1448364007.15088.26.camel@Centos6.3-64> Mime-Version: 1.0 X-Mailer: Evolution 2.28.3 (2.28.3-24.el6) Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Tue, 2015-11-24 at 02:24 -0800, Joe Perches wrote: > On Tue, 2015-11-24 at 17:53 +0800, Ching Huang wrote: > > On Tue, 2015-11-24 at 01:33 -0800, Joe Perches wrote: > > > On Tue, 2015-11-24 at 16:17 +0800, Ching Huang wrote: > > > > From: Ching Huang > > > > > > > > Support areca new PCIe to SATA RAID adapter ARC1203 > > > > > > Why add the dma_free_coherent to an old data path? > > > Is that a general bug fix that should be backported? > > > > That's right. It's need to release the allocated resource for failed > > condition. > > Then the dma_free_coherent addition should be a separate patch. > > Style trivia: > > The goto to another error path like that is odd and > the label is unintelligible. > > Ideally error condition handling would use a goto and > a separate and obviously named label. Use multiple > labels for cases with more complicated unwinding. > > Dan Carpenter has written about this several times. > > For this use, something like: > > writel(ARCMSR_MESSAGE_START_DRIVER_MODE, reg->drv2iop_doorbell); > if (!arcmsr_hbaB_wait_msgint_ready(acb)) { > logging_message(...); > goto > err_free_resource; > } > writel(ARCMSR_MESSAGE_GET_CONFIG, reg->drv2iop_doorbell); > if (!arcmsr_hbaB_wait_msgint_ready(acb)) { > logging_message(...); > goto err_free_resource; > } > > [success path...] > > return true; > > err_free_resource: > dma_free_coherent(...); > > return false; > } > Thanks for Joe's advice. Revised as below. Signed-of-by: Ching Huang --- ** @@ -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); + } 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 *)(®->message_rwbuffer[17]); /*firm_version,17,68-83*/ iop_device_map = (char __iomem *)(®->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(®->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@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff -uprN a/drivers/scsi/arcmsr/arcmsr.h b/drivers/scsi/arcmsr/arcmsr.h --- a/drivers/scsi/arcmsr/arcmsr.h 2015-11-24 11:36:20.000000000 +0800 +++ b/drivers/scsi/arcmsr/arcmsr.h 2015-10-19 15:57:08.000000000 +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 /* **********************************************************************************