From patchwork Fri Dec 7 22:29:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Don Brace X-Patchwork-Id: 10718971 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 7113C109C for ; Fri, 7 Dec 2018 22:29:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5F1FB2F0A8 for ; Fri, 7 Dec 2018 22:29:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 533372F2E3; Fri, 7 Dec 2018 22:29:39 +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 C69832F0A8 for ; Fri, 7 Dec 2018 22:29:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726110AbeLGW3i (ORCPT ); Fri, 7 Dec 2018 17:29:38 -0500 Received: from mail-eopbgr730074.outbound.protection.outlook.com ([40.107.73.74]:39200 "EHLO NAM05-DM3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726093AbeLGW3h (ORCPT ); Fri, 7 Dec 2018 17:29:37 -0500 Received: from BL2PR19CA0009.namprd19.prod.outlook.com (2603:10b6:201:f::19) by DM5PR19MB0938.namprd19.prod.outlook.com (2603:10b6:3:32::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1404.22; Fri, 7 Dec 2018 22:29:33 +0000 Received: from BN1BFFO11FD006.protection.gbl (2a01:111:f400:7c10::1:152) by BL2PR19CA0009.outlook.office365.com (2603:10b6:201:f::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.1404.20 via Frontend Transport; Fri, 7 Dec 2018 22:29:33 +0000 Authentication-Results: spf=pass (sender IP is 208.19.100.23) 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.100.23 as permitted sender) receiver=protection.outlook.com; client-ip=208.19.100.23; helo=AVMBX3.microsemi.net; Received: from AVMBX3.microsemi.net (208.19.100.23) by BN1BFFO11FD006.mail.protection.outlook.com (10.58.144.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.1404.13 via Frontend Transport; Fri, 7 Dec 2018 22:29:33 +0000 Received: from AVMBX2.microsemi.net (10.100.34.32) by AVMBX3.microsemi.net (10.100.34.33) 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 14:29:31 -0800 Received: from [127.0.1.1] (10.238.32.34) by avmbx2.microsemi.net (10.100.34.32) with Microsoft SMTP Server id 15.1.1531.3 via Frontend Transport; Fri, 7 Dec 2018 14:29:31 -0800 Subject: [PATCH 14/20] smartpqi: allow for larger raid maps From: Don Brace To: , , , , , , , , , , , CC: Date: Fri, 7 Dec 2018 16:29:31 -0600 Message-ID: <154422177108.1218.16653108167308174979.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.100.23;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(979002)(7916004)(376002)(346002)(39860400002)(136003)(396003)(2980300002)(189003)(199004)(33896004)(106466001)(47776003)(486006)(186003)(77096007)(97736004)(26005)(44832011)(478600001)(476003)(103116003)(2486003)(23676004)(8936002)(356004)(126002)(69596002)(8676002)(68736007)(81166006)(81156014)(76176011)(9686003)(316002)(50466002)(230700001)(16576012)(58126008)(106002)(110136005)(53936002)(5660300001)(305945005)(446003)(4326008)(2906002)(86362001)(11346002)(33716001)(14444005)(2201001)(336012)(921003)(1121003)(2101003)(83996005)(969003)(989001)(999001)(1009001)(1019001);DIR:OUT;SFP:1101;SCL:1;SRVR:DM5PR19MB0938;H:AVMBX3.microsemi.net;FPR:;SPF:Pass;LANG:en;PTR:InfoDomainNonexistent;MX:1;A:1; X-Microsoft-Exchange-Diagnostics: 1;BN1BFFO11FD006;1:8or5j1p6/nAhemraiZeLLwBbYJTPpjSnzy2EsFeOrm0TRjgemkOciaV8R1oZjVIMP7N/v3eSWUEwzoUHu9KipVI2p/Lb+IPafEFCtMh06sfhD9sJ0QphioO6AdEJeFvu X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 665f1f14-3544-42d9-1c6c-08d65c93763f X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(2390098)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4608076)(2017052603328)(7153060);SRVR:DM5PR19MB0938; X-Microsoft-Exchange-Diagnostics: 1;DM5PR19MB0938;3:gjuIaR+xAhtvo9iHVP1N86nyz4is98H+3W/kVVmehwb6GkotQeP8jdND8dmofNIzv2mUnRl5gf0PIGZoPvM2CwqNJW8CqUj086TXlPO1YetuBkVpxp82zVaMqok0Qivr26OjTeoX1DV2EFlx80AabW3FNQshZgTElDgbqBSYflAPUZb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jXE418N4kFN98skoGTlBF3waKjLlQ4dcBFyNg0TGEWL/AM0vFygGKUNJcHUxci+zjtMpS/C4QI3fZYPSTpDroXbRx/vyAGdK/p7ALDphFXd60IosiaTQ5O9YawXCqD6rkuEuhKelGNJ8H+E5r1i8ctQRaekm64hoWSDh/bIzK7Fn/1H6mwzPcavjOfbX45mOJZM81LBXAeYatSGxvrXhU/yEA+PwI+6WLF6e1xZdB0hbR+SkXU+h0JwH5eHlIlYPClpLJ7aN2vu08hrBOBCwDLSH2vO41zOZcF91qSrlfU9eoFLhu8UBS6Jlh6/yXvv77EYcBpBP17qycFYyOloHEwtp2sz1+iYONRC+u7i1fbXtQkZdoe4vo398sG8IZL4= 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)(93006095)(93004095)(3002001)(10201501046)(3231455)(999002)(944501520)(52105112)(6055026)(148016)(149066)(150057)(6041310)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123558120)(20161123564045)(201708071742011)(7699051)(76991095);SRVR:DM5PR19MB0938;BCL:0;PCL:0;RULEID:;SRVR:DM5PR19MB0938; X-Microsoft-Exchange-Diagnostics: 1;DM5PR19MB0938;4:ih5yT7WxlTY/y9nMzV7LkjXij7LdVKeQCPF6bdn47mYFMtocDCY7yxl65iRauJEakbP4KNqrGw6A99xUHmyl1GAklpmUO/u/CyuYopfcYgrve0jWisLLoMm5Dfxq6+1QoD1+GTBncgWcy2Dt3GCdARA5zW0BJfoP3h3rD54emkNmZoGz7tQOCRu2CxArMN5m6Ugep96snRlN7ZzRN+qos7F5htO3yKdG85ddqD9PmpAmhfJvFd4fKHbR6sefG/GDmFNe1YCk7D1Mg49oftf+Rg== X-Forefront-PRVS: 0879599414 X-Microsoft-Exchange-Diagnostics: =?utf-8?q?1=3BDM5PR19MB0938=3B23=3AQku7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PnMa88AGJl1QEf5Gm2TfrULVClGFpBYRCbrAVuDUD4m0jUcnFp+1MV2MSaNT1T4co4vKht0FTPLwoEKkb8JocMesHVvM0ExT5wKHcED3TrAdFxXPdfbusY3Mm2dKgHPaqvWS3SABaocziaPTuJi5pA/Fgx1XoUaNYG/Yc1VRlFnMp+BdgY8XkW6O3PcJqfrGElPE7ScoFVJjg1rPkkgC+LlQTIzLpAttua7oKaSZ3xDPnSY/mAc6VsYbkzg06T9C3hl4+mD1xBO0xrZu4H4Az6ZlC0TCyyd43HAI1xWd0xp/I2+OnTiRA/1yE4fTKw1RpKLqGy0w==;5:Ok6iJwXYPas9wO6gCm/h/Ac5i7JJckd3IAGsM+Pjr06AX8KzSF0oJZmhHNW+ykkCb6kUmbIZJJKvSmHuHKLiiKbwFLLsyaUVAHpAudbOt9Op8+S0zK1RPjNxsQT4jx/6BwDKI7l3JbEBu6Wf+VZs/lGmFYS6ppwDuaJHpn8MLHo=;7:5n5tKE/dLg9SplIN4TuVFUb1WZI5t9P/+RO+YWLUrUXc6u8XLiFsJfe7EvQSZagZc4F7aA7yAXpDQmZ+jYGvc5noKp+GyGViu9wpZlpSTA/AwYKZ6a8/MXgNfl75G+PCW0N+Yw/lW7/xQoEVgEvozw== SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: microsemi.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Dec 2018 22:29:33.1111 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 665f1f14-3544-42d9-1c6c-08d65c93763f 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.23];Helo=[AVMBX3.microsemi.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR19MB0938 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: Ajish Koshy Reviewed-by: Murthy Bhat Reviewed-by: Mahesh Rajashekhara Reviewed-by: Dave Carroll Reviewed-by: Scott Teel Reviewed-by: Kevin Barnett Signed-off-by: Ajish Koshy Signed-off-by: Don Brace --- drivers/scsi/smartpqi/smartpqi_init.c | 59 ++++++++++++++++----------------- 1 file changed, 28 insertions(+), 31 deletions(-) diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c index 5f7ae5946ddc..45c797bc1483 100644 --- a/drivers/scsi/smartpqi/smartpqi_init.c +++ b/drivers/scsi/smartpqi/smartpqi_init.c @@ -1115,8 +1115,6 @@ static int pqi_validate_raid_map(struct pqi_ctrl_info *ctrl_info, char *err_msg; u32 raid_map_size; u32 r5or6_blocks_per_row; - unsigned int num_phys_disks; - unsigned int num_raid_map_entries; raid_map_size = get_unaligned_le32(&raid_map->structure_size); @@ -1125,22 +1123,6 @@ static int pqi_validate_raid_map(struct pqi_ctrl_info *ctrl_info, goto bad_raid_map; } - if (raid_map_size > sizeof(*raid_map)) { - err_msg = "RAID map too large"; - goto bad_raid_map; - } - - num_phys_disks = get_unaligned_le16(&raid_map->layout_map_count) * - (get_unaligned_le16(&raid_map->data_disks_per_row) + - get_unaligned_le16(&raid_map->metadata_disks_per_row)); - num_raid_map_entries = num_phys_disks * - get_unaligned_le16(&raid_map->row_cnt); - - if (num_raid_map_entries > RAID_MAP_MAX_ENTRIES) { - err_msg = "invalid number of map entries in RAID map"; - goto bad_raid_map; - } - if (device->raid_level == SA_RAID_1) { if (get_unaligned_le16(&raid_map->layout_map_count) != 2) { err_msg = "invalid RAID-1 map"; @@ -1179,27 +1161,45 @@ static int pqi_get_raid_map(struct pqi_ctrl_info *ctrl_info, struct pqi_scsi_dev *device) { int rc; - enum dma_data_direction dir; - struct pqi_raid_path_request request; + u32 raid_map_size; struct raid_map *raid_map; raid_map = kmalloc(sizeof(*raid_map), GFP_KERNEL); if (!raid_map) return -ENOMEM; - rc = pqi_build_raid_path_request(ctrl_info, &request, - CISS_GET_RAID_MAP, device->scsi3addr, raid_map, - sizeof(*raid_map), 0, &dir); + rc = pqi_send_scsi_raid_request(ctrl_info, CISS_GET_RAID_MAP, + device->scsi3addr, raid_map, sizeof(*raid_map), + 0, NULL, NO_TIMEOUT); + if (rc) goto error; - rc = pqi_submit_raid_request_synchronous(ctrl_info, &request.header, 0, - NULL, NO_TIMEOUT); + raid_map_size = get_unaligned_le32(&raid_map->structure_size); - pqi_pci_unmap(ctrl_info->pci_dev, request.sg_descriptors, 1, dir); + if (raid_map_size > sizeof(*raid_map)) { - if (rc) - goto error; + kfree(raid_map); + + raid_map = kmalloc(raid_map_size, GFP_KERNEL); + if (!raid_map) + return -ENOMEM; + + rc = pqi_send_scsi_raid_request(ctrl_info, CISS_GET_RAID_MAP, + device->scsi3addr, raid_map, raid_map_size, + 0, NULL, NO_TIMEOUT); + if (rc) + goto error; + + if (get_unaligned_le32(&raid_map->structure_size) + != raid_map_size) { + dev_warn(&ctrl_info->pci_dev->dev, + "Requested %d bytes, received %d bytes", + raid_map_size, + get_unaligned_le32(&raid_map->structure_size)); + goto error; + } + } rc = pqi_validate_raid_map(ctrl_info, device, raid_map); if (rc) @@ -2459,9 +2459,6 @@ static int pqi_raid_bypass_submit_scsi_cmd(struct pqi_ctrl_info *ctrl_info, (map_row * total_disks_per_row) + first_column; } - if (unlikely(map_index >= RAID_MAP_MAX_ENTRIES)) - return PQI_RAID_BYPASS_INELIGIBLE; - aio_handle = raid_map->disk_data[map_index].aio_handle; disk_block = get_unaligned_le64(&raid_map->disk_starting_blk) + first_row * strip_size +