From patchwork Fri Dec 7 22:28:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Don Brace X-Patchwork-Id: 10718955 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 09554109C for ; Fri, 7 Dec 2018 22:28:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E963D2D8A2 for ; Fri, 7 Dec 2018 22:28:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DB9F22DA76; Fri, 7 Dec 2018 22:28:55 +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=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, 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 2BA962D8A2 for ; Fri, 7 Dec 2018 22:28:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726081AbeLGW2y (ORCPT ); Fri, 7 Dec 2018 17:28:54 -0500 Received: from mail-eopbgr760058.outbound.protection.outlook.com ([40.107.76.58]:58531 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726008AbeLGW2y (ORCPT ); Fri, 7 Dec 2018 17:28:54 -0500 Received: from BN6PR19CA0092.namprd19.prod.outlook.com (2603:10b6:404:133::30) by BN6PR19MB0931.namprd19.prod.outlook.com (2603:10b6:404:75::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1404.21; Fri, 7 Dec 2018 22:28:46 +0000 Received: from BN1AFFO11FD015.protection.gbl (2a01:111:f400:7c10::177) by BN6PR19CA0092.outlook.office365.com (2603:10b6:404:133::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1404.19 via Frontend Transport; Fri, 7 Dec 2018 22:28:45 +0000 Authentication-Results: spf=pass (sender IP is 208.19.99.221) smtp.mailfrom=microsemi.com; linux.vnet.ibm.com; dkim=none (message not signed) header.d=none;linux.vnet.ibm.com; dmarc=bestguesspass action=none header.from=microsemi.com; Received-SPF: Pass (protection.outlook.com: domain of microsemi.com designates 208.19.99.221 as permitted sender) receiver=protection.outlook.com; client-ip=208.19.99.221; helo=AUSMBX1.microsemi.net; Received: from AUSMBX1.microsemi.net (208.19.99.221) by BN1AFFO11FD015.mail.protection.outlook.com (10.58.52.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.1404.13 via Frontend Transport; Fri, 7 Dec 2018 22:28:45 +0000 Received: from AUSMBX2.microsemi.net (10.201.34.32) by AUSMBX1.microsemi.net (10.201.34.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1531.3; Fri, 7 Dec 2018 16:28:41 -0600 Received: from [127.0.1.1] (10.238.32.34) by ausmbx2.microsemi.net (10.201.34.32) with Microsoft SMTP Server id 15.1.1531.3 via Frontend Transport; Fri, 7 Dec 2018 16:28:41 -0600 Subject: [PATCH 06/20] smartpqi: refactor sending controller raid requests From: Don Brace To: , , , , , , , , , , , CC: Date: Fri, 7 Dec 2018 16:28:41 -0600 Message-ID: <154422172132.1218.18346212909813247484.stgit@brunhilda> In-Reply-To: <154422079293.1218.12539829857034151457.stgit@brunhilda> References: <154422079293.1218.12539829857034151457.stgit@brunhilda> User-Agent: StGit/0.19-dirty MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:208.19.99.221;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(7916004)(396003)(376002)(39860400002)(346002)(136003)(2980300002)(199004)(189003)(69596002)(58126008)(305945005)(230700001)(86362001)(103116003)(2486003)(478600001)(23676004)(316002)(2201001)(356004)(106002)(16576012)(110136005)(77096007)(26005)(8676002)(81166006)(81156014)(336012)(8936002)(5660300001)(186003)(33716001)(4326008)(50466002)(126002)(47776003)(2906002)(97736004)(14444005)(76176011)(68736007)(11346002)(106466001)(33896004)(9686003)(53936002)(486006)(44832011)(446003)(476003)(921003)(1121003)(83996005)(2101003);DIR:OUT;SFP:1101;SCL:1;SRVR:BN6PR19MB0931;H:AUSMBX1.microsemi.net;FPR:;SPF:Pass;LANG:en;PTR:InfoDomainNonexistent;A:1;MX:1; X-Microsoft-Exchange-Diagnostics: 1;BN1AFFO11FD015;1:7MlVcvgtE+/5DwMO6xbaEgttLN2wO6wLyv4/Ly8XGiIZcvxoRKWnx5zYNlgtHcSUwj0uqzFQiJcHDYT5zT6hMJDfTZVWSSwxt5GHqvwltF1mPBKZnwqfDzrJLko5xSpz X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 21b65571-73e0-4ea2-064c-08d65c9359f1 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390098)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4608076)(2017052603328)(7153060);SRVR:BN6PR19MB0931; X-Microsoft-Exchange-Diagnostics: 1;BN6PR19MB0931;3:7tv7hMCP3NR4n7ViN4o6FU/vGWPUysr1P1KYPRO9UopsUV4HPLDFeQ/KBEqHrjrdvLVpX5rZUvKTc7Ma8kc+Y1oxV1WsJkMvKI83+aX44R06ZrWBUenVvxUP+SmX8FiqKgClQty4TTmltI8y6X4RuhMv+ZtsmeQ316X3Hd9K4ssP0iD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bvzSBOIZpumUzQDwi89eMN4JOKwNPCmTknD8oxBT0BqXTFAy8aMp+alAw829DJKl8q1EygNCHaR1wAHYRJwkYY323DfzCAKrRBW9pjQHM8WLlz2a+0x92vPjlbHJIIuM85F3HCiILjypwWvljRljWWqZXzV7H8fw2g+wf8i1OR6oMb/C1Z6q9t4l+jd6byvSNMWaxFdlgt9nZ/eziog3QsjwUjlkrX/P+JwMVGXjbkEc4mg6+APzHqU36V8CmnCt//8swD6HC1CTgea0k4hLhruvD4toNOPAM6WiubcEh6+xzBo X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(10201501046)(93006095)(93004095)(3002001)(3231455)(999002)(944501520)(52105112)(6055026)(148016)(149066)(150057)(6041310)(20161123558120)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(201708071742011)(7699051)(76991095);SRVR:BN6PR19MB0931;BCL:0;PCL:0;RULEID:;SRVR:BN6PR19MB0931; X-Microsoft-Exchange-Diagnostics: 1;BN6PR19MB0931;4:WvmJs68mLQIbLDx70fGP0g2kAb+45m3CSscleZ+THTFCUBbvQH1CHP2X39YJkp3B8gtez5dl6Y1sFl1CFPFecQyCoHXW2qEJNSHLzh6a8pEVahpXSC4dLux+ZXsrw8qKJS6Xb45Gw8AgIlE8DkTxDGs/XQ7ZMrQItFKo4zNoS6bikOcJB06clWQ4G8oiJ9dtW4Kg+mhiJy8U3Yl4xizABvBwzk10uS7OnVeMyHqo9RClvkVL8T1KKp/9jVOrNJK2ILrSjAOzcIhmVmCrmgxWJg== X-Forefront-PRVS: 0879599414 X-Microsoft-Exchange-Diagnostics: =?utf-8?q?1=3BBN6PR19MB0931=3B23=3Ai5f+GWT?= =?utf-8?q?wXuw58S1HGN8B6aGIz0ZDHr6FjW60AAFYeiyQEH3tcwY7xxluNpmRvd45X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U1aU+QrKVjYcb7pWm2tuZvJC/t5NQg4JpJ5sM3ZoWD6KM0IVsFhyojeaCeLaU9i2sr0Ylkt1byzdcJ2YJvJW9lO8c54eCEmukTSEeKTWxo28ev6EMwRw==;5:+Fg/0Y5hhnth02jNin8VTdrb6DpTLlkvn7uMNDYSP04pqkOk/wW663XmHfqZDUGn6m44GIOq2I9GpqG4RAdbdbqvzy8Da5Q1EGmNy+298bUeVLOVHwBVTf973UF39wDgE8tpvj8i68m3lJdUm+Wyh2ej9j3UcfDWPjfA/zJI1s4=;7:louIeDurZrblFz1xpFzB+nok97Gj6qV9OjHGslbc+31eyF0Dz9NJxpBEZ9dEHOxxWEv676V32q4h8WjcKzNk3+OWCwQxIY/58GYYgcc+oKwGKH2QGbsvmwXB5M4tvHnwtVvZ2+Vkq0+WMuTb22FnYA== SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: microsemi.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Dec 2018 22:28:45.7169 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 21b65571-73e0-4ea2-064c-08d65c9359f1 X-MS-Exchange-CrossTenant-Id: f267a5c8-86d8-4cc9-af71-1fd2c67c8fad X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f267a5c8-86d8-4cc9-af71-1fd2c67c8fad;Ip=[208.19.99.221];Helo=[AUSMBX1.microsemi.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR19MB0931 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 From: Dave Carroll cleanup the common code which creates a raid path request for the controller LUNID and sends it synchronously, into a common routine; Reviewed-by: Murthy Bhat Reviewed-by: Mahesh Rajashekhara Reviewed-by: Scott Teel Reviewed-by: Kevin Barnett Signed-off-by: Dave Carroll Signed-off-by: Don Brace --- drivers/scsi/smartpqi/smartpqi_init.c | 134 +++++++++++---------------------- 1 file changed, 46 insertions(+), 88 deletions(-) diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c index 9d9e90e13f5c..004a7b9aac26 100644 --- a/drivers/scsi/smartpqi/smartpqi_init.c +++ b/drivers/scsi/smartpqi/smartpqi_init.c @@ -519,44 +519,58 @@ static void pqi_free_io_request(struct pqi_io_request *io_request) atomic_dec(&io_request->refcount); } -static int pqi_identify_controller(struct pqi_ctrl_info *ctrl_info, - struct bmic_identify_controller *buffer) +static int pqi_send_scsi_raid_request(struct pqi_ctrl_info *ctrl_info, u8 cmd, + u8 *scsi3addr, void *buffer, size_t buffer_length, u16 vpd_page, + struct pqi_raid_error_info *error_info, + unsigned long timeout_msecs) { int rc; enum dma_data_direction dir; struct pqi_raid_path_request request; rc = pqi_build_raid_path_request(ctrl_info, &request, - BMIC_IDENTIFY_CONTROLLER, RAID_CTLR_LUNID, buffer, - sizeof(*buffer), 0, &dir); + cmd, scsi3addr, buffer, + buffer_length, vpd_page, &dir); if (rc) return rc; - rc = pqi_submit_raid_request_synchronous(ctrl_info, &request.header, 0, - NULL, NO_TIMEOUT); + rc = pqi_submit_raid_request_synchronous(ctrl_info, &request.header, + 0, error_info, timeout_msecs); pqi_pci_unmap(ctrl_info->pci_dev, request.sg_descriptors, 1, dir); return rc; } -static int pqi_scsi_inquiry(struct pqi_ctrl_info *ctrl_info, - u8 *scsi3addr, u16 vpd_page, void *buffer, size_t buffer_length) +/* Helper functions for pqi_send_scsi_raid_request */ + +static inline int pqi_send_ctrl_raid_request(struct pqi_ctrl_info *ctrl_info, + u8 cmd, void *buffer, size_t buffer_length) { - int rc; - enum dma_data_direction dir; - struct pqi_raid_path_request request; + return pqi_send_scsi_raid_request(ctrl_info, cmd, RAID_CTLR_LUNID, + buffer, buffer_length, 0, NULL, NO_TIMEOUT); +} - rc = pqi_build_raid_path_request(ctrl_info, &request, - INQUIRY, scsi3addr, buffer, buffer_length, vpd_page, - &dir); - if (rc) - return rc; +static inline int pqi_send_ctrl_raid_with_error(struct pqi_ctrl_info *ctrl_info, + u8 cmd, void *buffer, size_t buffer_length, + struct pqi_raid_error_info *error_info) +{ + return pqi_send_scsi_raid_request(ctrl_info, cmd, RAID_CTLR_LUNID, + buffer, buffer_length, 0, error_info, NO_TIMEOUT); +} - rc = pqi_submit_raid_request_synchronous(ctrl_info, &request.header, 0, - NULL, NO_TIMEOUT); - pqi_pci_unmap(ctrl_info->pci_dev, request.sg_descriptors, 1, dir); - return rc; +static inline int pqi_identify_controller(struct pqi_ctrl_info *ctrl_info, + struct bmic_identify_controller *buffer) +{ + return pqi_send_ctrl_raid_request(ctrl_info, BMIC_IDENTIFY_CONTROLLER, + buffer, sizeof(*buffer)); +} + +static inline int pqi_scsi_inquiry(struct pqi_ctrl_info *ctrl_info, + u8 *scsi3addr, u16 vpd_page, void *buffer, size_t buffer_length) +{ + return pqi_send_scsi_raid_request(ctrl_info, INQUIRY, scsi3addr, + buffer, buffer_length, vpd_page, NULL, NO_TIMEOUT); } static int pqi_identify_physical_device(struct pqi_ctrl_info *ctrl_info, @@ -590,9 +604,7 @@ static int pqi_flush_cache(struct pqi_ctrl_info *ctrl_info, enum bmic_flush_cache_shutdown_event shutdown_event) { int rc; - struct pqi_raid_path_request request; struct bmic_flush_cache *flush_cache; - enum dma_data_direction dir; /* * Don't bother trying to flush the cache if the controller is @@ -607,17 +619,9 @@ static int pqi_flush_cache(struct pqi_ctrl_info *ctrl_info, flush_cache->shutdown_event = shutdown_event; - rc = pqi_build_raid_path_request(ctrl_info, &request, - SA_FLUSH_CACHE, RAID_CTLR_LUNID, flush_cache, - sizeof(*flush_cache), 0, &dir); - if (rc) - goto out; + rc = pqi_send_ctrl_raid_request(ctrl_info, SA_FLUSH_CACHE, flush_cache, + sizeof(*flush_cache)); - rc = pqi_submit_raid_request_synchronous(ctrl_info, &request.header, - 0, NULL, NO_TIMEOUT); - - pqi_pci_unmap(ctrl_info->pci_dev, request.sg_descriptors, 1, dir); -out: kfree(flush_cache); return rc; @@ -629,66 +633,32 @@ static int pqi_flush_cache(struct pqi_ctrl_info *ctrl_info, static int pqi_set_diag_rescan(struct pqi_ctrl_info *ctrl_info) { int rc; - struct pqi_raid_path_request request; struct bmic_diag_options *diag; - enum dma_data_direction pci_direction; diag = kzalloc(sizeof(*diag), GFP_KERNEL); if (!diag) return -ENOMEM; - rc = pqi_build_raid_path_request(ctrl_info, &request, - BMIC_SENSE_DIAG_OPTIONS, RAID_CTLR_LUNID, diag, - sizeof(*diag), 0, &pci_direction); - if (rc) - goto out; - - rc = pqi_submit_raid_request_synchronous(ctrl_info, &request.header, - 0, NULL, NO_TIMEOUT); - - pqi_pci_unmap(ctrl_info->pci_dev, request.sg_descriptors, 1, - pci_direction); - + rc = pqi_send_ctrl_raid_request(ctrl_info, BMIC_SENSE_DIAG_OPTIONS, + diag, sizeof(*diag)); if (rc) goto out; diag->options |= cpu_to_le32(PQI_FETCH_PTRAID_DATA); - rc = pqi_build_raid_path_request(ctrl_info, &request, - BMIC_SET_DIAG_OPTIONS, RAID_CTLR_LUNID, diag, - sizeof(*diag), 0, &pci_direction); - if (rc) - goto out; - - rc = pqi_submit_raid_request_synchronous(ctrl_info, &request.header, - 0, NULL, NO_TIMEOUT); - - pqi_pci_unmap(ctrl_info->pci_dev, request.sg_descriptors, 1, - pci_direction); + rc = pqi_send_ctrl_raid_request(ctrl_info, BMIC_SET_DIAG_OPTIONS, + diag, sizeof(*diag)); out: kfree(diag); return rc; } -static int pqi_write_host_wellness(struct pqi_ctrl_info *ctrl_info, +static inline int pqi_write_host_wellness(struct pqi_ctrl_info *ctrl_info, void *buffer, size_t buffer_length) { - int rc; - struct pqi_raid_path_request request; - enum dma_data_direction dir; - - rc = pqi_build_raid_path_request(ctrl_info, &request, - BMIC_WRITE_HOST_WELLNESS, RAID_CTLR_LUNID, buffer, - buffer_length, 0, &dir); - if (rc) - return rc; - - rc = pqi_submit_raid_request_synchronous(ctrl_info, &request.header, - 0, NULL, NO_TIMEOUT); - - pqi_pci_unmap(ctrl_info->pci_dev, request.sg_descriptors, 1, dir); - return rc; + return pqi_send_ctrl_raid_request(ctrl_info, BMIC_WRITE_HOST_WELLNESS, + buffer, buffer_length); } #pragma pack(1) @@ -837,23 +807,11 @@ static inline void pqi_cancel_update_time_worker( cancel_delayed_work_sync(&ctrl_info->update_time_work); } -static int pqi_report_luns(struct pqi_ctrl_info *ctrl_info, u8 cmd, +static inline int pqi_report_luns(struct pqi_ctrl_info *ctrl_info, u8 cmd, void *buffer, size_t buffer_length) { - int rc; - enum dma_data_direction dir; - struct pqi_raid_path_request request; - - rc = pqi_build_raid_path_request(ctrl_info, &request, - cmd, RAID_CTLR_LUNID, buffer, buffer_length, 0, &dir); - if (rc) - return rc; - - rc = pqi_submit_raid_request_synchronous(ctrl_info, &request.header, 0, - NULL, NO_TIMEOUT); - - pqi_pci_unmap(ctrl_info->pci_dev, request.sg_descriptors, 1, dir); - return rc; + return pqi_send_ctrl_raid_request(ctrl_info, cmd, buffer, + buffer_length); } static int pqi_report_phys_logical_luns(struct pqi_ctrl_info *ctrl_info, u8 cmd,