From patchwork Tue May 31 17:50:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Erickson X-Patchwork-Id: 12865964 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EAC75C433EF for ; Tue, 31 May 2022 17:52:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346693AbiEaRwm (ORCPT ); Tue, 31 May 2022 13:52:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346696AbiEaRwj (ORCPT ); Tue, 31 May 2022 13:52:39 -0400 Received: from esa.hc4959-67.iphmx.com (esa.hc4959-67.iphmx.com [216.71.153.94]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 19E5063505; Tue, 31 May 2022 10:52:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=seagate.com; i=@seagate.com; q=dns/txt; s=stxiport; t=1654019557; x=1685555557; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=apvAm9cdEzHrOqB6wduo8MjCfAVwoTdoxPRQfEeWumI=; b=iOA77rETzeIN14orv0A1g4P8NXvHYjSfMpxi4CJqcbQevpxDhaqd+xAM Ak5yGQCLs3uzivom6uCTkIt4H3KTJh13Phkd+/XTdLJ8CdKXvJR2u/KEZ 5RJ4P7I7OxveufDZunqf/N0UDgYjYZlMLFmLtJKPuQo0Fp8uCSkiJp4BT E=; Received: from mail-dm6nam11lp2170.outbound.protection.outlook.com (HELO NAM11-DM6-obe.outbound.protection.outlook.com) ([104.47.57.170]) by ob1.hc4959-67.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 May 2022 10:51:33 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PTW7HE5gnMMgk3R+/JS95upaOWdRanWytb//cb2kdp8AJWOlWl8uwC6qYjpQ1V3WQmRRusWAkyl0bOJ1N4BKYDAZ7gwAd4qWUVdWcXkXxYriYlDaHUrDiavX3HvzcIeDBd4GjofOMRJf+zyUbCv9UFj82NXpvlXvl0VkZhV9OS6vvsFkFrE4JRJUbK8sjpoVwWKGtP1esEfDXI44hzfp8B9kJixJMsOSIzpUeM52h483IeFa+5MkiuBSksjNE574ja3GPiqxHfsdR4L37I31ppwmRKKXaVFm2ORi7RvXX+SmqaC0esLGZhUL6Zwb7co9ExctGIX3AwGEi9aR7LvXqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=eOcYzUr5gTPWkcPCIzwMQc8UsXUwkDKxAR+DIiWwSh0=; b=OWsVWD6O8JsaHGOduKzeG+dmHw/8lGIEmKu2NFgK5rJGz7Kcn2HQdJ/lOcdCMltDX1uSAEpIH6cpy33XKr93kzRw+zm4wHPfGIlJGqe0yojdsOe33Tm/qq7Y0Kugzaay3GeYqTPGj91cURmQuceX5uY6SL9uupotoxbVq+xwHA8Oznhgc81m6vOH+qu9IKrg5glwaP3FnN/R6UZPie7CE8xOIx53AMwdsufamHn6Mkr1W+yJJsbFBdfDKFdIcKwn4JW9OOkUqsI+GgGc4rSKrEzoSr+cPpZiOQsgppSf+3ntzm7BzxtmEsovQU5mTsiR120SF9jnrhEvvEazZjp7Ng== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=softfail (sender ip is 192.55.16.50) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=seagate.com; dmarc=fail (p=reject sp=reject pct=100) action=oreject header.from=seagate.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=seagate.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=eOcYzUr5gTPWkcPCIzwMQc8UsXUwkDKxAR+DIiWwSh0=; b=RqrUJsQjvwmWsdV9fk/BvjXbES1+x1nysGGbC7aYn4pKeQiqVr6ewRxZocf5FilfGUSDJ3rSLw/6unt/G383rg7aJnpighD+bgmjKSi9ufBUt4i6OIcqFORRNmM76MClZnrqAwPYM4G0d9XKjuZVPhju6zDjLeVo2Fuk9HnXODw= Received: from CO2PR04CA0142.namprd04.prod.outlook.com (2603:10b6:104::20) by MN2PR20MB3432.namprd20.prod.outlook.com (2603:10b6:208:262::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.12; Tue, 31 May 2022 17:51:29 +0000 Received: from MW2NAM10FT050.eop-nam10.prod.protection.outlook.com (2603:10b6:104:0:cafe::79) by CO2PR04CA0142.outlook.office365.com (2603:10b6:104::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5293.13 via Frontend Transport; Tue, 31 May 2022 17:51:29 +0000 X-MS-Exchange-Authentication-Results: spf=softfail (sender IP is 192.55.16.50) smtp.mailfrom=seagate.com; dkim=none (message not signed) header.d=none;dmarc=fail action=oreject header.from=seagate.com; Received: from sgspzesaa001.seagate.com (192.55.16.50) by MW2NAM10FT050.mail.protection.outlook.com (10.13.155.13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.12 via Frontend Transport; Tue, 31 May 2022 17:51:28 +0000 Received: from sgspiesaa001.seagate.com ([10.4.144.52]) by sgspzesaa001.seagate.com with ESMTP; 31 May 2022 10:51:48 -0700 X-IronPort-AV: E=Sophos;i="5.91,266,1647327600"; d="scan'208";a="63170337" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False STX-Internal-Mailhost: TRUE Received: from unknown (HELO COL-U500816L003.ad.seagate.com) ([10.4.50.11]) by sgspiesaa001.seagate.com with ESMTP; 31 May 2022 10:44:23 -0700 From: Tyler Erickson To: damien.lemoal@opensource.wdc.com, jejb@linux.ibm.com, martin.petersen@oracle.com Cc: linux-scsi@vger.kernel.org, linux-ide@vger.kernel.org, muhammad.ahmad@seagate.com, tyler.erickson@seagate.com, Tyler Erickson , Michael English Subject: [PATCH 1/2] [PATCH v1 1/2] libata: fix reading concurrent positioning ranges log Date: Tue, 31 May 2022 11:50:08 -0600 Message-Id: <20220531175009.850-2-tyler.erickson@seagate.com> X-Mailer: git-send-email 2.36.0.windows.1 In-Reply-To: <20220531175009.850-1-tyler.erickson@seagate.com> References: <20220531175009.850-1-tyler.erickson@seagate.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: e2f936d3-5b08-4692-ba34-08da432e30b8 X-MS-TrafficTypeDiagnostic: MN2PR20MB3432:EE_ X-Microsoft-Antispam-PRVS: STX-Hosted-IronPort-Oubound: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OvXaElhWgQ1sW7wibiYWnsCyahAFpfr0X9k66h/RTJ3SymIZhGdr5LcfJ80ua5DEDX9CEW9Rw6ywTRTxXnh5EQXM2dq8/VD6ILqoNpgmBzBIxUiHzvxrZXlCpJKJJ/3F0NiainNzMPGdVeMUkwzbujR6hronyQH93Qv4qlZ1arI036RtBCP4LUpCNSXjtlHmZpbdqkko4PuXcuUmfF94GrhNNH9M0GeN43wLDdXPgsum0ogPAQRzuyQGJDVpe1gfFXVaZaiWZKdUI6TPLTRHu8t5ogRrGfu5iufonMN7LHtHDYwhLcO4iWrXtnBDQy+z/i/2GxjN795IGNBvTHuLNkvNR62YlC31hiFauj5fzqN0ktXErei4dNvSbJFoseJVWzGjoWzxGx9a/rz10uwjI47m+UESbKBgA/v2fFwV+35Za1HhBqf3FAMNLfJpwY/4kKo157XLNJ1nAECFkrSErpe3k3oju45pThE/hw0RlU+NHH8miUhVIZZiItAUw4cEs2Ag5QVhIl8eTPlwbnOPDwZ4GGWPUgTciwP2kz8YHTGHRq3A3vtmNzqL4LDP2QYrAYBhTH4lTu+cNJJ+nYqK4p5zIVcysrY3w+NDuWu6/CvhQeJLuzEO8Koc5oTDF0en0YD4HGB+RSEm5I+9xN8Wa1gKRWpih/fdlYQYESDbMer8W2JQQqVt6TwZf7Ziru3G2tNbUtX/G3oJf/qVmYNorg== X-Forefront-Antispam-Report: CIP:192.55.16.50;CTRY:SG;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:sgspzesaa001.seagate.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230001)(36840700001)(46966006)(40470700004)(47076005)(36756003)(1076003)(7696005)(6666004)(2906002)(508600001)(8936002)(107886003)(36860700001)(81166007)(450100002)(316002)(8676002)(186003)(70586007)(356005)(70206006)(40460700003)(44832011)(82310400005)(336012)(4326008)(54906003)(26005)(5660300002)(426003)(2616005)(86362001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: seagate.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 May 2022 17:51:28.3191 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e2f936d3-5b08-4692-ba34-08da432e30b8 X-MS-Exchange-CrossTenant-Id: d466216a-c643-434a-9c2e-057448c17cbe X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=d466216a-c643-434a-9c2e-057448c17cbe;Ip=[192.55.16.50];Helo=[sgspzesaa001.seagate.com] X-MS-Exchange-CrossTenant-AuthSource: MW2NAM10FT050.eop-nam10.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR20MB3432 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org From: Tyler Erickson The concurrent positioning ranges log is not a fixed size and may depend on how many ranges are supported by the device. This patch uses the size reported in the GPL directory to determine the number of pages supported by the device before attempting to read this log page. Also fixing the page length in the SCSI translation for the concurrent positioning ranges VPD page. This resolves this error from the dmesg output: ata6.00: Read log 0x47 page 0x00 failed, Emask 0x1 Signed-off-by: Tyler Erickson Reviewed-by: Muhammad Ahmad Tested-by: Michael English diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index ca64837641be..3d57fa84e2be 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -2003,16 +2003,16 @@ unsigned int ata_read_log_page(struct ata_device *dev, u8 log, return err_mask; } -static bool ata_log_supported(struct ata_device *dev, u8 log) +static int ata_log_supported(struct ata_device *dev, u8 log) { struct ata_port *ap = dev->link->ap; if (dev->horkage & ATA_HORKAGE_NO_LOG_DIR) - return false; + return 0; if (ata_read_log_page(dev, ATA_LOG_DIRECTORY, 0, ap->sector_buf, 1)) - return false; - return get_unaligned_le16(&ap->sector_buf[log * 2]) ? true : false; + return 0; + return get_unaligned_le16(&ap->sector_buf[log * 2]); } static bool ata_identify_page_supported(struct ata_device *dev, u8 page) @@ -2448,15 +2448,20 @@ static void ata_dev_config_cpr(struct ata_device *dev) struct ata_cpr_log *cpr_log = NULL; u8 *desc, *buf = NULL; - if (ata_id_major_version(dev->id) < 11 || - !ata_log_supported(dev, ATA_LOG_CONCURRENT_POSITIONING_RANGES)) + if (ata_id_major_version(dev->id) < 11) + goto out; + + buf_len = ata_log_supported(dev, ATA_LOG_CONCURRENT_POSITIONING_RANGES); + if (buf_len == 0) goto out; /* * Read the concurrent positioning ranges log (0x47). We can have at - * most 255 32B range descriptors plus a 64B header. + * most 255 32B range descriptors plus a 64B header. This log varies in + * size, so use the size reported in the GPL directory. Reading beyond + * the supported length will result in an error. */ - buf_len = (64 + 255 * 32 + 511) & ~511; + buf_len <<= 9; buf = kzalloc(buf_len, GFP_KERNEL); if (!buf) goto out; diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index 06c9d90238d9..0ea9c3115529 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c @@ -2101,7 +2101,7 @@ static unsigned int ata_scsiop_inq_b9(struct ata_scsi_args *args, u8 *rbuf) /* SCSI Concurrent Positioning Ranges VPD page: SBC-5 rev 1 or later */ rbuf[1] = 0xb9; - put_unaligned_be16(64 + (int)cpr_log->nr_cpr * 32 - 4, &rbuf[3]); + put_unaligned_be16(64 + (int)cpr_log->nr_cpr * 32 - 4, &rbuf[2]); for (i = 0; i < cpr_log->nr_cpr; i++, desc += 32) { desc[0] = cpr_log->cpr[i].num; From patchwork Tue May 31 17:50:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Erickson X-Patchwork-Id: 12865965 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D837FC4332F for ; Tue, 31 May 2022 17:52:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346698AbiEaRwo (ORCPT ); Tue, 31 May 2022 13:52:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346699AbiEaRwk (ORCPT ); Tue, 31 May 2022 13:52:40 -0400 X-Greylist: delayed 63 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Tue, 31 May 2022 10:52:38 PDT Received: from esa.hc4959-67.iphmx.com (esa.hc4959-67.iphmx.com [139.138.35.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E18A63BCC; Tue, 31 May 2022 10:52:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=seagate.com; i=@seagate.com; q=dns/txt; s=stxiport; t=1654019558; x=1685555558; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=FEmyW6/boFQyTIeb8pc/UKKAg9Kqu1+J0zJ28RZGNmY=; b=ZdhtvZ4pmFqPs0gIry2dSJibZTQbCxDwlCJP6Qe5uvN/A3LfaBybq7gQ Ick6KGOn7+/CSiFkqd+HTwUWMsBdmpXB7BuWBjcGESvCX+9y3a3+9HWhr kWKLafq1Y8djkma53gZsaMGtXFteVNXVZCjdP9jOLXvnbtGJjRjOvVZA4 Y=; Received: from mail-co1nam11lp2174.outbound.protection.outlook.com (HELO NAM11-CO1-obe.outbound.protection.outlook.com) ([104.47.56.174]) by ob1.hc4959-67.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 May 2022 10:51:34 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TMbj4Fk9+L/RCeDd3QENrew4wewWUe3kxvXpfpzlSVJMO7Zpaz4R35x8RgeDcF5cBQt69kPfsWEWuLDFec+jzM8+LjXe+qghhE3g4NjqC6nrRJQgKn8tER/pbGhhv6D0+MkcTdfZmSkHMG4+35Lykx2gy3+o18zPn7IK8MSCOWZKCViizx50QtrcFanU0X6ch17lv2xDUq2eIU/0TkVWky26Z3JhVjWRUfVHtXFGjjyP0AbK0kXYhebXABIUuzO1C8iWHSkudlik+Idk5tXZ25a8m9ug9GfM1po0VsjPJ9ahJwRV952RnxBHG8CGemZuZoTBYIr2qLPopLi/LG4Spw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Ss2JPsQChgHptBQ4bSJWQwKOXNkwjnHRq/y/iZXp+Kw=; b=gFDb2n8by+2Z3wOCrqxeSJ0rlgnOPzwnGd++GdhM0XCMX8TrqvKQdxMsQgUzq4sJf59Zs/awRx8ResfVXxswfUnYAw6aSFOSmKhcWKLU3H64ts6lcqLDsz8jUcncLJgCYUMaEIMYozKEeXBZoBsR5cptEM1CnIT4a1N6ygCkkIt15z3NNA3vP05jXm5IJtuVzQPAax/gHV+Zetk+UUsLCr19yidJwX82/ofEVusR8fsAfjpiex9WMVRBAjKHWGi5r7TnkVziZGp588t7uaNYvcSLoVVGHslaPmoeIddZqHhTrwFlZxHdPBkyH54DOq639JcgtdUrInIIppleXUAGpg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=softfail (sender ip is 192.55.16.50) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=seagate.com; dmarc=fail (p=reject sp=reject pct=100) action=oreject header.from=seagate.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=seagate.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Ss2JPsQChgHptBQ4bSJWQwKOXNkwjnHRq/y/iZXp+Kw=; b=WkncAmm1C6mbCsRhAJvARRqRs8VLSaQh1rXLKgaI7+UIWpad9bGcVaw6ltSUP9KHl3VtIN6seuSr2zSbliOrpQiV7vkkrHXgHqnjDv7lhh2ut+VQqTG81Req9U695UKR5kWTqZpZ8amGi0n5KgVCQsOapF710jA1zHCcaKT7Ric= Received: from CO2PR04CA0133.namprd04.prod.outlook.com (2603:10b6:104::11) by SA0PR20MB3341.namprd20.prod.outlook.com (2603:10b6:806:72::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5293.19; Tue, 31 May 2022 17:51:32 +0000 Received: from MW2NAM10FT050.eop-nam10.prod.protection.outlook.com (2603:10b6:104:0:cafe::f2) by CO2PR04CA0133.outlook.office365.com (2603:10b6:104::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.12 via Frontend Transport; Tue, 31 May 2022 17:51:32 +0000 X-MS-Exchange-Authentication-Results: spf=softfail (sender IP is 192.55.16.50) smtp.mailfrom=seagate.com; dkim=none (message not signed) header.d=none;dmarc=fail action=oreject header.from=seagate.com; Received: from sgspzesaa001.seagate.com (192.55.16.50) by MW2NAM10FT050.mail.protection.outlook.com (10.13.155.13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.12 via Frontend Transport; Tue, 31 May 2022 17:51:31 +0000 Received: from sgspiesaa001.seagate.com ([10.4.144.52]) by sgspzesaa001.seagate.com with ESMTP; 31 May 2022 10:51:51 -0700 X-IronPort-AV: E=Sophos;i="5.91,266,1647327600"; d="scan'208";a="63170342" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False STX-Internal-Mailhost: TRUE Received: from unknown (HELO COL-U500816L003.ad.seagate.com) ([10.4.50.11]) by sgspiesaa001.seagate.com with ESMTP; 31 May 2022 10:44:27 -0700 From: Tyler Erickson To: damien.lemoal@opensource.wdc.com, jejb@linux.ibm.com, martin.petersen@oracle.com Cc: linux-scsi@vger.kernel.org, linux-ide@vger.kernel.org, muhammad.ahmad@seagate.com, tyler.erickson@seagate.com, Michael English Subject: [PATCH 2/2] [PATCH v1 2/2] sd: Fixing interpretation of VPD B9h length Date: Tue, 31 May 2022 11:50:09 -0600 Message-Id: <20220531175009.850-3-tyler.erickson@seagate.com> X-Mailer: git-send-email 2.36.0.windows.1 In-Reply-To: <20220531175009.850-1-tyler.erickson@seagate.com> References: <20220531175009.850-1-tyler.erickson@seagate.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c7b49cdb-f5aa-4ebf-1333-08da432e329f X-MS-TrafficTypeDiagnostic: SA0PR20MB3341:EE_ X-Microsoft-Antispam-PRVS: STX-Hosted-IronPort-Oubound: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yv7RUtFGoZf/nbBEos/ENCegXr3xLoQmANVEa6tRdywmGGcfdb3LnNkwKfxUsYbr0nLpgxm7Zm9XLOe6pKJfX+8mQO4sQp9q40XrwaM12On2u1VDX6ocp4pa/rkqFOfHnLEcck2uX8ysGIvo0bR/S4g5jc/LlCszVGqiDJEGeM+yqwAOK4dDFwFi2zBoGDCzoCbmWg9TbvRKrz7p5YJfDOXAHRwYOHNFDIP5NELmW3vTpLnpVF54euq+5ik0GKG2bfYkL0lT/tKfI368DGHIxmJSueFNJ6Gq1xy31P2ICo2ZmvHcGc31AsQ4Ns5VDhAm7Lg0a7z2S3Z2c35fhB01MqdccTX55uCfwyOhu2sH5KeuoSDNJ/5zup3khDzS/t7FjTPnDNWQPZC+AQ3jS4eQUqeS2tJBxIO4qr+pf+yeQghtWlzZTeCkGgV7afLIXupefqlLF1J0g/07MdwAkSb0VOxuhaaXWzZlC/QCfjFBmp59i2emybqCRft6pPhHKYeRK1PEve83vFAUMwWOPREJbosS6ia1tShBfB5NUUIAzVKZhSCvpg0ItixCXXCLLsZ9gBk3/MEMFpedunXaJ+f17/rEf1sAhG9K8xOxM4brISAE+nvX0Ge0x6smIhz54p4KeujBxyZM42bpos/bGEfXFBZFwWmiDJL76L0rT/gOcSrvO5A3WKjJQa+hZP1Ex/ZeNJLDaIrG4bHSCuleEIgWqw== X-Forefront-Antispam-Report: CIP:192.55.16.50;CTRY:SG;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:sgspzesaa001.seagate.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230001)(46966006)(40470700004)(36840700001)(86362001)(8676002)(4326008)(6666004)(450100002)(70586007)(81166007)(356005)(70206006)(508600001)(316002)(336012)(36860700001)(426003)(1076003)(107886003)(47076005)(186003)(7696005)(26005)(40460700003)(2616005)(44832011)(8936002)(2906002)(82310400005)(5660300002)(36756003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: seagate.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 May 2022 17:51:31.5064 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c7b49cdb-f5aa-4ebf-1333-08da432e329f X-MS-Exchange-CrossTenant-Id: d466216a-c643-434a-9c2e-057448c17cbe X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=d466216a-c643-434a-9c2e-057448c17cbe;Ip=[192.55.16.50];Helo=[sgspzesaa001.seagate.com] X-MS-Exchange-CrossTenant-AuthSource: MW2NAM10FT050.eop-nam10.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR20MB3341 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Fixing the interpretation of the length of the B9h VPD page (concurrent positioning ranges). Adding 4 is necessary as the first 4 bytes of the page is the header with page number and length information. Adding 3 was likely a misinterpretation of the SBC-5 specification which sets all offsets starting at zero. This fixes the error in dmesg: [ 9.014456] sd 1:0:0:0: [sda] Invalid Concurrent Positioning Ranges VPD page Signed-off-by: Tyler Erickson Reviewed-by: Muhammad Ahmad Tested-by: Michael English diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index dc6e55761fd1..14867e8cd687 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -3067,7 +3067,7 @@ static void sd_read_cpr(struct scsi_disk *sdkp) goto out; /* We must have at least a 64B header and one 32B range descriptor */ - vpd_len = get_unaligned_be16(&buffer[2]) + 3; + vpd_len = get_unaligned_be16(&buffer[2]) + 4; if (vpd_len > buf_len || vpd_len < 64 + 32 || (vpd_len & 31)) { sd_printk(KERN_ERR, sdkp, "Invalid Concurrent Positioning Ranges VPD page\n");