From patchwork Wed Dec 27 04:34:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raghava Aditya Renukunta X-Patchwork-Id: 10133395 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 063E3602BD for ; Wed, 27 Dec 2017 04:35:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E067B2D864 for ; Wed, 27 Dec 2017 04:35:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D47B82DA60; Wed, 27 Dec 2017 04:35:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C7FF02DA56 for ; Wed, 27 Dec 2017 04:35:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751819AbdL0EfO (ORCPT ); Tue, 26 Dec 2017 23:35:14 -0500 Received: from mail-sn1nam01on0058.outbound.protection.outlook.com ([104.47.32.58]:39984 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751495AbdL0EfL (ORCPT ); Tue, 26 Dec 2017 23:35:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mscc365.onmicrosoft.com; s=selector1-microsemi-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=1/NKnz77lJLQZFCIAgBJe+C/+ilLcXkzaUSthYgfi0k=; b=HcrBlOYRK6e8vvkOSm2dZZK3gAnYqrw/80H0wuUD3C5lLso+fl2U2XVTQ0RDVdNlPjcvxTox6bg/A2E2uI1TB1RptexGhtkDdCVgOGemtsO2G08sKlF5moVv4qhrnUTZRPuJGVZnzOyrJnTzCTOGDN3Abx+JNv6qaDKAAQhY7qg= Received: from CY4PR02CA0006.namprd02.prod.outlook.com (2603:10b6:903:18::16) by BN1PR0201MB0739.namprd02.prod.outlook.com (2a01:111:e400:56::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.345.14; Wed, 27 Dec 2017 04:35:07 +0000 Received: from BL2FFO11FD049.protection.gbl (2a01:111:f400:7c09::140) by CY4PR02CA0006.outlook.office365.com (2603:10b6:903:18::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.366.8 via Frontend Transport; Wed, 27 Dec 2017 04:35:07 +0000 Authentication-Results: spf=pass (sender IP is 208.19.100.21) smtp.mailfrom=microsemi.com; wdc.com; dkim=none (message not signed) header.d=none;wdc.com; dmarc=bestguesspass action=none header.from=microsemi.com; Received-SPF: Pass (protection.outlook.com: domain of microsemi.com designates 208.19.100.21 as permitted sender) receiver=protection.outlook.com; client-ip=208.19.100.21; helo=avsrvexchhts1.microsemi.net; Received: from avsrvexchhts1.microsemi.net (208.19.100.21) by BL2FFO11FD049.mail.protection.outlook.com (10.173.161.211) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.20.345.12 via Frontend Transport; Wed, 27 Dec 2017 04:34:47 +0000 Received: from localhost (10.181.72.13) by avsrvexchhts1.microsemi.net (10.100.34.105) with Microsoft SMTP Server (TLS) id 14.3.361.1; Tue, 26 Dec 2017 20:34:55 -0800 From: Raghava Aditya Renukunta To: , , CC: , , , "Guilherme G . Piccoli" , Bart Van Assche Subject: [PATCH v2 09/30] scsi: aacraid: Create bmic submission function from bmic identify Date: Tue, 26 Dec 2017 20:34:30 -0800 Message-ID: <20171227043451.27813-10-RaghavaAditya.Renukunta@microsemi.com> X-Mailer: git-send-email 2.9.4 In-Reply-To: <20171227043451.27813-1-RaghavaAditya.Renukunta@microsemi.com> References: <20171227043451.27813-1-RaghavaAditya.Renukunta@microsemi.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:208.19.100.21; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(346002)(376002)(39850400004)(39380400002)(396003)(2980300002)(438002)(199004)(189003)(6666003)(59450400001)(316002)(478600001)(106466001)(69596002)(53936002)(48376002)(104016004)(50466002)(4326008)(2906002)(86362001)(575784001)(47776003)(97736004)(2201001)(77096006)(5660300001)(68736007)(106002)(2950100002)(305945005)(81156014)(356003)(36756003)(8676002)(57986006)(81166006)(1076002)(8936002)(76176011)(16586007)(72206003)(110136005)(76506005)(51416003)(50226002)(54906003); DIR:OUT; SFP:1101; SCL:1; SRVR:BN1PR0201MB0739; H:avsrvexchhts1.microsemi.net; FPR:; SPF:Pass; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD049; 1:i/+JGZcYWDMjyVajbcQ87iv2R0MRKXlm8t/NmI+7EIhghH4n6lUsUadUAgyH2QAQ7tqmHochJNwtmPNI6YfdFIflb0kzxTIkt2ZNg7FrAxhXRQJsI52dqu/3Imu3Y7tH X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a6711e2b-a2bb-4a6e-7dcd-08d54ce32990 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(4608076)(2017052603307)(7153060); SRVR:BN1PR0201MB0739; X-Microsoft-Exchange-Diagnostics: 1; BN1PR0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GMvyGdNUtWxAB6UNntIL1217cAOrnu4gDkn/HCG3dKWeBevI+Mv+fePxPVlv6CZl2dAM8f0ErtzLNZiM28GB0dOBOcmxNYiH0OIGGk3tSy0L4iHVJOlEeWncKUXmTPtiwqxZIoMNE9pCoTpXIIATP7OZVLSUBtVG90UDOyDJXznuETJv4OmOxIRWC/JMY24mbYXk3BvyTFZxg4YSP0+ehPvLC4uqf1+3GF2ST3tH1R6yWhaCKEc1u/XxPc4rdXKj3IEDGpu8U5RiUhh1DRKiCMxHbugkcA2yMs5XoE/lvGiUhuvcMEkfu6vhfgerQK8AkU7wnJ30DTBFuZI0PhnzZFPo+i//C6qJmsrg/2MDn+7jo+bvlulJ+sSmpCAwlh41Qria/qHRBIM8d8ZWM1uNPCDJUSWQmmnIQKtCoPPxtXldo0XeYFN44tEsRqFhEfeRreGZd8R4UVxq4hKNhK4goxhirZl4THssf5wkvW158HXIgtGhe/w7rtPLOE/nG2D55XTWouJgfwqk7s7TB/dpe6f3Q4K4c7rhpHpazA+A7yOLT2YCv/gZxYSK07Rtj73z4ki7w3P48zkky5GsWNT6HwI= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(72170198267865); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040470)(2401047)(8121501046)(5005006)(10201501046)(3002001)(3231023)(944501075)(93006095)(93004095)(6055026)(6041268)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123562045)(20161123558120)(20161123564045)(6072148)(201708071742011); SRVR:BN1PR0201MB0739; BCL:0; PCL:0; RULEID:(100000803101)(100110400095); SRVR:BN1PR0201MB0739; X-Microsoft-Exchange-Diagnostics: 1; BN1PR0201MB0739; 4:Ifti/xUwCEvPhWrpeYOgh8aIq5sROp1Z/2OT2eUaQSCTn+tjWyVBDcmRR+MZpvOqwmlA9M+cVNr31al1fREt0eUmMPtFpb7JqX/GavUE0BG5CPkmZKJoIbkGbnCS/phZz4SWXmPjFawKnEG/uGieqllJqCOaEWXmwRhvNhi4vUjMBdk2GJOq/wbi/lF69bVD3gNfCxZKIiHDYsSG5TFaje5wro+aeOWn8FQ3WSdAefLj0SaXfkTIHiTB8gttscRBqDuvwFNbm7WqKEi6DvaC9TRXJ4nyukE5MQTXi2Jko//6ZG7AXdql+bsR7yJC+HjP X-Forefront-PRVS: 0534947130 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN1PR0201MB0739; 23:GVmQS8KDXjPc8XE8Sspm1ipxrhRtM4l3STXGhCI?= =?us-ascii?Q?2q1aODQL94yYhfcPhfkJUBcfOc8ascMy2MSrxTqIqvxlnk6TPw5Z14vM1l2g?= =?us-ascii?Q?lDVwjoJj17+UY/UQvPpVpaqhh9JLBaGMrLBo8bcwbsplu5+iHCs8EldBSh67?= =?us-ascii?Q?gB6auFZZF4Q6QI214nGuXPcBRY6Uy7Nrlq93CAAZ60NsK26c6T9C3xQjaB39?= =?us-ascii?Q?peBCS2kot9vw1US6FNkIvPhTBVQAtKSNuzd689SokGZ7K6j9j9KVBSLUj4t5?= =?us-ascii?Q?VD+Si4hw6934wqfSPNAoIFMZwdNc5Jpk09zxA5AP12WjcklYkIC1PfxpKm3M?= =?us-ascii?Q?Rnwvu2Rc61Sem7aSEqzAB+JBVljYscGCsspeJvJsAQglSJiGHC4Q+ZfPanBW?= =?us-ascii?Q?wiVW4iqjaf/KcwNnn/PU3EcS+Ii6jw3XCnSvn3OVq6H2l/TnI9aL7ZK+Trqi?= =?us-ascii?Q?xZJJJ6KlDVq8xAV3S8bapUsDDgRAVjF1kskbmDSKJiNaRFXmYlr9yrhPb0mi?= =?us-ascii?Q?VN0w3fi3jhr1HVYQElPYocR8HWXFLSHeM7lqRH1HMsFriq4AoF+S5ECOkhuC?= =?us-ascii?Q?Ty3npXP+G43JU9Yx9LSV0/eTLaj8TM6pPjm0WRs0/3s4z+DTO1q29wwpahWf?= =?us-ascii?Q?FOOrqUZossAmT2+Q+V/w2yMn7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8dMECVltUCNM4dlvWgTpGb5yS3WhxDUpqzRha35YwYaElSXapEauY0ysYbQeO8L61WNpf6MTEG0TbRAHQ9uHBk9IvlgwiWA=; 24:rM6vbwiHWItdCGkaFMfzawuolOECmsLW2Nw3u7Rattn87BjsvD9swhRO9xP4lzwLDGaWXMEZrvFHzkhm5AiVe3ahnqw1H1O1JiFOSwg3HpM=; 7:0EzwCpAZp3GzX77hJoHqUJxuhx/GCr7/3gv6oMEll9GYlqXHkvpIdoD6S4EPXbcez2NE9CvKseYPxG1iandFTdjZqbHH4gUzeztSJiOV55ublR4DdfLf+S6Q4ETZizu1vmhHKRgwzY2GyOu1u26Lh/bMjB1xfpS1No4kk/B3Omf6DHXewDpvoLYRaP0DkaI0xCtMw+lO4PCoYYD8SaAxWhCUaouH5IWMm96G6i9d0mt7aVZMNPCj4PRPl+lv3GaC SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: microsemi.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Dec 2017 04:34:47.8139 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a6711e2b-a2bb-4a6e-7dcd-08d54ce32990 X-MS-Exchange-CrossTenant-Id: f267a5c8-86d8-4cc9-af71-1fd2c67c8fad X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f267a5c8-86d8-4cc9-af71-1fd2c67c8fad; Ip=[208.19.100.21]; Helo=[avsrvexchhts1.microsemi.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN1PR0201MB0739 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP safw command submission is duplicated across many functions. Move the safw submission code from bmic identify into its own function for common use Signed-off-by: Raghava Aditya Renukunta --- Changes in V2: None drivers/scsi/aacraid/aachba.c | 147 +++++++++++++++++++++++++++-------------- drivers/scsi/aacraid/aacraid.h | 7 +- 2 files changed, 105 insertions(+), 49 deletions(-) diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c index 7173ae5..e02158d 100644 --- a/drivers/scsi/aacraid/aachba.c +++ b/drivers/scsi/aacraid/aachba.c @@ -1667,60 +1667,116 @@ static int aac_adapter_hba(struct fib *fib, struct scsi_cmnd *cmd) (void *) cmd); } -int aac_issue_bmic_identify(struct aac_dev *dev, u32 bus, u32 target) +static int aac_send_safw_bmic_cmd(struct aac_dev *dev, + struct aac_srb_unit *srbu, void *xfer_buf, int xfer_len) { - struct fib *fibptr; - struct aac_srb *srbcmd; - struct sgmap64 *sg64; - struct aac_ciss_identify_pd *identify_resp; - dma_addr_t addr; - u32 vbus, vid; - u16 fibsize, datasize; - int rcode = -ENOMEM; - + struct fib *fibptr; + dma_addr_t addr; + int rcode; + int fibsize; + struct aac_srb *srb; + struct aac_srb_reply *srb_reply; + struct sgmap64 *sg64; + u32 vbus; + u32 vid; + + if (!dev->sa_firmware) + return 0; + /* allocate FIB */ fibptr = aac_fib_alloc(dev); if (!fibptr) - goto out; + return -ENOMEM; - fibsize = sizeof(struct aac_srb) - - sizeof(struct sgentry) + sizeof(struct sgentry64); - datasize = sizeof(struct aac_ciss_identify_pd); + aac_fib_init(fibptr); + fibptr->hw_fib_va->header.XferState &= + ~cpu_to_le32(FastResponseCapable); - identify_resp = dma_alloc_coherent(&dev->pdev->dev, datasize, &addr, - GFP_KERNEL); - if (!identify_resp) - goto fib_free_ptr; + fibsize = sizeof(struct aac_srb) - sizeof(struct sgentry) + + sizeof(struct sgentry64); - vbus = (u32)le16_to_cpu(dev->supplement_adapter_info.virt_device_bus); - vid = (u32)le16_to_cpu(dev->supplement_adapter_info.virt_device_target); + /* allocate DMA buffer for response */ + addr = dma_map_single(&dev->pdev->dev, xfer_buf, xfer_len, + DMA_BIDIRECTIONAL); + if (dma_mapping_error(&dev->pdev->dev, addr)) { + rcode = -ENOMEM; + goto fib_error; + } - aac_fib_init(fibptr); + srb = fib_data(fibptr); + memcpy(srb, &srbu->srb, sizeof(struct aac_srb)); - srbcmd = (struct aac_srb *) fib_data(fibptr); - srbcmd->function = cpu_to_le32(SRBF_ExecuteScsi); - srbcmd->channel = cpu_to_le32(vbus); - srbcmd->id = cpu_to_le32(vid); - srbcmd->lun = 0; - srbcmd->flags = cpu_to_le32(SRB_DataIn); - srbcmd->timeout = cpu_to_le32(10); - srbcmd->retry_limit = 0; - srbcmd->cdb_size = cpu_to_le32(12); - srbcmd->count = cpu_to_le32(datasize); + vbus = (u32)le16_to_cpu( + dev->supplement_adapter_info.virt_device_bus); + vid = (u32)le16_to_cpu( + dev->supplement_adapter_info.virt_device_target); - memset(srbcmd->cdb, 0, sizeof(srbcmd->cdb)); - srbcmd->cdb[0] = 0x26; - srbcmd->cdb[2] = (u8)((AAC_MAX_LUN + target) & 0x00FF); - srbcmd->cdb[6] = CISS_IDENTIFY_PHYSICAL_DEVICE; + /* set the common request fields */ + srb->channel = cpu_to_le32(vbus); + srb->id = cpu_to_le32(vid); + srb->lun = 0; + srb->function = cpu_to_le32(SRBF_ExecuteScsi); + srb->timeout = 0; + srb->retry_limit = 0; + srb->cdb_size = cpu_to_le32(16); + srb->count = cpu_to_le32(xfer_len); + + sg64 = (struct sgmap64 *)&srb->sg; + sg64->count = cpu_to_le32(1); + sg64->sg[0].addr[1] = cpu_to_le32(upper_32_bits(addr)); + sg64->sg[0].addr[0] = cpu_to_le32(lower_32_bits(addr)); + sg64->sg[0].count = cpu_to_le32(xfer_len); - sg64 = (struct sgmap64 *)&srbcmd->sg; - sg64->count = cpu_to_le32(1); - sg64->sg[0].addr[1] = cpu_to_le32((u32)(((addr) >> 16) >> 16)); - sg64->sg[0].addr[0] = cpu_to_le32((u32)(addr & 0xffffffff)); - sg64->sg[0].count = cpu_to_le32(datasize); + /* + * Copy the updated data for other dumping or other usage if needed + */ + memcpy(&srbu->srb, srb, sizeof(struct aac_srb)); + + /* issue request to the controller */ + rcode = aac_fib_send(ScsiPortCommand64, fibptr, fibsize, FsaNormal, + 1, 1, NULL, NULL); + + if (rcode == -ERESTARTSYS) + rcode = -ERESTART; + + if (unlikely(rcode < 0)) + goto bmic_error; + + srb_reply = (struct aac_srb_reply *)fib_data(fibptr); + memcpy(&srbu->srb_reply, srb_reply, sizeof(struct aac_srb_reply)); + +bmic_error: + dma_unmap_single(&dev->pdev->dev, addr, xfer_len, DMA_BIDIRECTIONAL); +fib_error: + aac_fib_complete(fibptr); + aac_fib_free(fibptr); + return rcode; +} + +static int aac_issue_bmic_identify(struct aac_dev *dev, u32 bus, u32 target) +{ + int rcode = -ENOMEM; + u16 datasize; + struct aac_srb_unit srbu; + struct aac_srb *srbcmd; + struct aac_ciss_identify_pd *identify_resp; + + datasize = sizeof(struct aac_ciss_identify_pd); + identify_resp = kmalloc(datasize, GFP_KERNEL); + if (!identify_resp) + goto out; + + memset(&srbu, 0, sizeof(struct aac_srb_unit)); - rcode = aac_fib_send(ScsiPortCommand64, - fibptr, fibsize, FsaNormal, 1, 1, NULL, NULL); + srbcmd = &srbu.srb; + srbcmd->flags = cpu_to_le32(SRB_DataIn); + srbcmd->cdb[0] = 0x26; + srbcmd->cdb[2] = (u8)((AAC_MAX_LUN + target) & 0x00FF); + srbcmd->cdb[6] = CISS_IDENTIFY_PHYSICAL_DEVICE; + + rcode = aac_send_safw_bmic_cmd(dev, &srbu, identify_resp, datasize); + if (unlikely(rcode < 0)) + goto out; if (identify_resp->current_queue_depth_limit <= 0 || identify_resp->current_queue_depth_limit > 32) @@ -1729,12 +1785,7 @@ int aac_issue_bmic_identify(struct aac_dev *dev, u32 bus, u32 target) dev->hba_map[bus][target].qd_limit = identify_resp->current_queue_depth_limit; - dma_free_coherent(&dev->pdev->dev, datasize, identify_resp, addr); - - aac_fib_complete(fibptr); - -fib_free_ptr: - aac_fib_free(fibptr); + kfree(identify_resp); out: return rcode; } diff --git a/drivers/scsi/aacraid/aacraid.h b/drivers/scsi/aacraid/aacraid.h index 403a639..bc2a0bc 100644 --- a/drivers/scsi/aacraid/aacraid.h +++ b/drivers/scsi/aacraid/aacraid.h @@ -2021,6 +2021,12 @@ struct aac_srb_reply __le32 sense_data_size; u8 sense_data[AAC_SENSE_BUFFERSIZE]; // Can this be SCSI_SENSE_BUFFERSIZE }; + +struct aac_srb_unit { + struct aac_srb srb; + struct aac_srb_reply srb_reply; +}; + /* * SRB Flags */ @@ -2634,7 +2640,6 @@ static inline int aac_adapter_check_health(struct aac_dev *dev) int aac_acquire_irq(struct aac_dev *dev); void aac_free_irq(struct aac_dev *dev); int aac_report_phys_luns(struct aac_dev *dev, struct fib *fibptr, int rescan); -int aac_issue_bmic_identify(struct aac_dev *dev, u32 bus, u32 target); const char *aac_driverinfo(struct Scsi_Host *); void aac_fib_vector_assign(struct aac_dev *dev); struct fib *aac_fib_alloc(struct aac_dev *dev);