From patchwork Thu Jun 2 22:51:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Erickson X-Patchwork-Id: 578419 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 6808ECCA47B for ; Thu, 2 Jun 2022 22:46:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239743AbiFBWqM (ORCPT ); Thu, 2 Jun 2022 18:46:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239741AbiFBWqF (ORCPT ); Thu, 2 Jun 2022 18:46:05 -0400 Received: from esa.hc4959-67.iphmx.com (esa.hc4959-67.iphmx.com [139.138.35.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 57AA137A81; Thu, 2 Jun 2022 15:46:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=seagate.com; i=@seagate.com; q=dns/txt; s=stxiport; t=1654209964; x=1685745964; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=muyxEwkNSN+Avf2jkJXMqhDnz9pMPkJ+tE8jAaGuVzY=; b=myVZkqy/MV3eJ3mObskzzWvg02+4BzGIbMlHB5aFMcO9EFyB0ethBRVd zEyGUiieLRQwL1qrRbpYWK/6h9ADcmFklTNxWi8Q7Niifcom96NHz6OQa 2/F/qnpYtIZ+ePRMXyyPh9vTnXgKyM0MWHLQ/bhTfAlhLGCeMdFyjuYtt A=; Received: from mail-dm6nam10lp2102.outbound.protection.outlook.com (HELO NAM10-DM6-obe.outbound.protection.outlook.com) ([104.47.58.102]) by ob1.hc4959-67.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2022 15:46:03 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=m2YFFsdH3HX0JoWliPwyCDYrbrDjIGiVYW1LJVKrU+c2JyShnY9lMlrZkFON0P+g9GtUoR0KSjuYIxHTfIvtevEUu4sD7Oc3S0FrhVevrJ1BoZf077r6KGiCto7sOBOo6SBwOrglg+0pSRuJZmCpTzieKD8v9j0RpuctNQ5/sCjhrWtWxFT1eYCX5ID1n744MtcU5wyjdGJMGHpAb8WsmszC3TkEIq9/fLbcC4/mj2AiDqnR3yaHM6g4m0kKM8zgC9cbgFBEqpHQltUXsjfZan0p6PKQrExz3xcm6DuV/8a6MygNsNnQ5FqPGIq8JzZqGYCYtx0lMzTEDT1UPOgenA== 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=riWZ6nEuSByJY96cBLYzGJ5F10XOG4LeLE3CGdr1LP0=; b=I5bPOyAvINP2E7q5mxIFlvwyVrhgCNG9ugJOCb0Uw2duJHWwz8cYpxAyWEv7Wo93M2JVuuiN/rHJqr36DM9ch9tezs2NjERTOxlHrBpa8Q3MMtgmFrXjNCf0f4WOX9LHF6MBG5be3xPz0IMbhniSAfDb5x2Bjbek1NHdWdpSgkUISmP/Ef6hcNDfqqRcCuf4CLMg7vPqamcU+QPyL1p/PD1o/68sawIfDr64yJLiYeaqwQP9SQVSu1hDyC3W27MBX8hnaojEYGFmZiLkhfco506UTbm8EykAmaNAcWcs2clmWgYhomMqFSoiuCuc01sioPZoUE1Ddoo+nutvDLICZg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=softfail (sender ip is 192.55.16.51) 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=riWZ6nEuSByJY96cBLYzGJ5F10XOG4LeLE3CGdr1LP0=; b=GF9AS79Hs5zl/oGcfmCDq1XTtOwNMRI/6qhRUORbt96+uXGnWVN1i4Dnc6bsQ9FB2rSLGekrO4D5H7KaOnlFYx/ZdVUujQOZMiDuU4Mfx1FUyyJLrJBFHG6rkwD8X1p3hWjLD4uqPcCKtIo/gdHIeT0JgoOkuI0+Qwlyw2h2zko= Received: from DM6PR02CA0132.namprd02.prod.outlook.com (2603:10b6:5:1b4::34) by BN6PR20MB1235.namprd20.prod.outlook.com (2603:10b6:404:8a::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.13; Thu, 2 Jun 2022 22:46:00 +0000 Received: from DM6NAM10FT031.eop-nam10.prod.protection.outlook.com (2603:10b6:5:1b4:cafe::1c) by DM6PR02CA0132.outlook.office365.com (2603:10b6:5:1b4::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5293.15 via Frontend Transport; Thu, 2 Jun 2022 22:45:59 +0000 X-MS-Exchange-Authentication-Results: spf=softfail (sender IP is 192.55.16.51) smtp.mailfrom=seagate.com; dkim=none (message not signed) header.d=none;dmarc=fail action=oreject header.from=seagate.com; Received: from sgspzesaa002.seagate.com (192.55.16.51) by DM6NAM10FT031.mail.protection.outlook.com (10.13.152.157) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.12 via Frontend Transport; Thu, 2 Jun 2022 22:45:58 +0000 Received: from sgspiesaa002.seagate.com ([10.4.144.53]) by sgspzesaa002.seagate.com with ESMTP; 02 Jun 2022 15:48:34 -0700 X-IronPort-AV: E=Sophos;i="5.91,272,1647327600"; d="scan'208";a="62195114" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False STX-Internal-Mailhost: TRUE Received: from unknown (HELO tyler-ubuntu.colo.seagate.com) ([10.4.50.15]) by sgspiesaa002.seagate.com with ESMTP; 02 Jun 2022 15:33:29 -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, stable@vger.kernel.org Subject: [PATCH v2 1/3] libata: fix reading concurrent positioning ranges log Date: Thu, 2 Jun 2022 16:51:11 -0600 Message-Id: <20220602225113.10218-2-tyler.erickson@seagate.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220602225113.10218-1-tyler.erickson@seagate.com> References: <20220602225113.10218-1-tyler.erickson@seagate.com> X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: c1c1db09-a83a-4390-2ef3-08da44e9aa29 X-MS-TrafficTypeDiagnostic: BN6PR20MB1235: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: 4CsJHUIcfRmXZyYfTerS2g4CUdRsLlHllofcapETRq/d8ETsIJ1Ok0v72HrSgCNxn7TK50Ei9HIArx8kY9tp32o3syrB1y0tmhdF6bod9Xe/4ri8Tb1b4m3XKUXohltq1KDVufYvzm0AhpFVfhOuwGkXPPvXtTrTI28NoUvY4ayultCACrLz/IIESKXiDnXnggGNUgMRqoNLclw+lpI/TbsVgNvM519bX8qEf5WYw+s9uQJBMtb3TRF5YjX580wrlTLKWAHcEuCEyt5KNowz+d+9GQxMH14BaUiYCG67sXT/QUk+V+fSmOqQEYuoocJd6iuaazuOf7ghnM4l6yKhM+OCAduqMc0nq9W3ShBtnyaKGVcY1OtUIvDp2H7iZ+jvZJbre/cuyrkfmCFQAnFubNCSWIPcfhN26stFkAOlvUa68OoYJLpUrVulw4HDc8kE1RExzQq/5KF2Z9tuMPizvteM5iYcV1YcBTKRNHw0F+zkh30tvRfuP5D7sxzqH8pNsf/wLedOybch10IFGZrX0BdkPJOvwvNSxlRZfnM462idZvrsq5Y2aZZ1sqbUNeX421m7112/shQQgSu8PqZODbM3xOesi9EjVDxqDP4JAkF5Cd59sphszdNHlFuXT2/AgdRFUqdd9+/DPkj3Icns0Po4wwCP2T3UT/X/oX8k9x2qHndEsOTeusLtFb2X/GkGEE5OuxkKxyKCv5++vwYUEg== X-Forefront-Antispam-Report: CIP:192.55.16.51; CTRY:SG; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:sgspzesaa002.seagate.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230001)(40470700004)(36840700001)(46966006)(47076005)(82310400005)(1076003)(426003)(336012)(2616005)(40460700003)(356005)(316002)(26005)(70206006)(81166007)(36860700001)(2906002)(186003)(86362001)(7696005)(36756003)(83380400001)(6666004)(44832011)(508600001)(8936002)(8676002)(4326008)(450100002)(5660300002)(70586007)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: seagate.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jun 2022 22:45:58.7054 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c1c1db09-a83a-4390-2ef3-08da44e9aa29 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.51]; Helo=[sgspzesaa002.seagate.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM10FT031.eop-nam10.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR20MB1235 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org 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. This resolves this error from the dmesg output: ata6.00: Read log 0x47 page 0x00 failed, Emask 0x1 Cc: stable@vger.kernel.org Fixes: fe22e1c2f705 ("libata: support concurrent positioning ranges log") Signed-off-by: Tyler Erickson Reviewed-by: Muhammad Ahmad Tested-by: Michael English --- drivers/ata/libata-core.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 40e816419f48..3ea10f72cb70 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -2010,16 +2010,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) @@ -2455,15 +2455,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; From patchwork Thu Jun 2 22:51:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Erickson X-Patchwork-Id: 578632 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 3A1F5C43334 for ; Thu, 2 Jun 2022 22:46:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237753AbiFBWqO (ORCPT ); Thu, 2 Jun 2022 18:46:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51264 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239742AbiFBWqG (ORCPT ); Thu, 2 Jun 2022 18:46:06 -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 B973F37A82; Thu, 2 Jun 2022 15:46:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=seagate.com; i=@seagate.com; q=dns/txt; s=stxiport; t=1654209965; x=1685745965; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=eb7xTJtCIh8JPBdgQmEpvQXXnwnVATmYzvJbreqvvl4=; b=rLk4t/T3sm1Ne/d/DwIxCLQC/4VwyqzQhC0MpJiIxazImoFGLYYQ97Xf 45Jqa5FvZo1hfVOBwSFXLndOD8joRbg24kAIY1v4qg2bi82bI9bZzyv1Y y78+lwOPQuOH5oqninXmh9EzMrXR7eWAf5CZMRc4nsRi3KehLgr8ySRSM 4=; Received: from mail-dm6nam12lp2176.outbound.protection.outlook.com (HELO NAM12-DM6-obe.outbound.protection.outlook.com) ([104.47.59.176]) by ob1.hc4959-67.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2022 15:46:04 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=n4vyxH2FxCTpwToI3WXnPvo/PvXoV/22jDKuU64KrmidIoYvGigjzZoQVA/5uLKBvys8GYSxzRCMxdBvdm3vgf2K6mA4pI/Ax3YYvnwaJUdIm70OwoBi4bO/jsg02sCzLeuHg9m8OeJCjAEI1yMwLydeU5MxiDCfHOttXIZ+PaUfpS9QwGM+J3O9SIhbgbwmV9/j1hTFdhqjo5KJTXwOwML4yXWi/GdqfymeAeQEGp2fsTsz5bUVhEpeGaveMi/UwBgeB5rlOlwh5nlcD7cUXipFZQwkTwOevqoRuNXTSeGwRY3vVnKdEZwCyTF1S+S/5Xln4HAvjn1SWWewVR8aBw== 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=D9GUDTiACZXCvJ9iUr/A4XfNXj3+i2pVZVsHdx17j3U=; b=oClFm5xDkJfI9Rqk1hY6VfS144O6S5T+E8rllxk78D/MacZ2uSe9bzt02falgWroHitfpu4deR04KRTgp2i4gJdsVoqy21Lsu9PvryY1Cu+zjnjS0Zpg0VUDZRFnE9n1ahthXhSYuIatVSEhGo5rX68FNTRLYPnRVLGCNTHzwS4EzeKQUT+3t3cc0Qw/RuQ/wOu/RBOFy6xx6MkUbBWjnJm5JUw0QO/H8eCHHQjofY9rRgwsBCbz1eFVDohCDWO+PkyVtM+p1dgyxir6PKpPI1wrSzpHKr41ZdHUr5qhmvw0BDDoEO/qGoqc7sccG/0uga40sp0WjWqm7BN+3UnGRQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=softfail (sender ip is 192.55.16.51) 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=D9GUDTiACZXCvJ9iUr/A4XfNXj3+i2pVZVsHdx17j3U=; b=hKzGPlr6XMPRadk6E/Yd0Z8+Z4lUgW+ZGJWRkKt/3qDS8vbgePcf/qBvY4BarPouzWGUxkUDCjlj0pTVdIeXhBjkzFV+Qoi6Pw3Hb7jg9zTrWaPSQiMp7v6bCaVoGYwMjofjVPB8ZNAenDaZcdrWQnsVs5NtpihrRs5c795KgWc= Received: from DM3PR12CA0104.namprd12.prod.outlook.com (2603:10b6:0:55::24) by BN0PR20MB4087.namprd20.prod.outlook.com (2603:10b6:408:12d::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.13; Thu, 2 Jun 2022 22:46:01 +0000 Received: from DM6NAM10FT049.eop-nam10.prod.protection.outlook.com (2603:10b6:0:55:cafe::18) by DM3PR12CA0104.outlook.office365.com (2603:10b6:0:55::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.12 via Frontend Transport; Thu, 2 Jun 2022 22:46:01 +0000 X-MS-Exchange-Authentication-Results: spf=softfail (sender IP is 192.55.16.51) smtp.mailfrom=seagate.com; dkim=none (message not signed) header.d=none;dmarc=fail action=oreject header.from=seagate.com; Received: from sgspzesaa002.seagate.com (192.55.16.51) by DM6NAM10FT049.mail.protection.outlook.com (10.13.153.121) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.12 via Frontend Transport; Thu, 2 Jun 2022 22:46:00 +0000 Received: from sgspiesaa002.seagate.com ([10.4.144.53]) by sgspzesaa002.seagate.com with ESMTP; 02 Jun 2022 15:48:36 -0700 X-IronPort-AV: E=Sophos;i="5.91,272,1647327600"; d="scan'208";a="62195121" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False STX-Internal-Mailhost: TRUE Received: from unknown (HELO tyler-ubuntu.colo.seagate.com) ([10.4.50.15]) by sgspiesaa002.seagate.com with ESMTP; 02 Jun 2022 15:33:32 -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, stable@vger.kernel.org Subject: [PATCH v2 2/3] libata: fix translation of concurrent positioning ranges Date: Thu, 2 Jun 2022 16:51:12 -0600 Message-Id: <20220602225113.10218-3-tyler.erickson@seagate.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220602225113.10218-1-tyler.erickson@seagate.com> References: <20220602225113.10218-1-tyler.erickson@seagate.com> X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: c6e41293-1905-42cc-c9b9-08da44e9ab03 X-MS-TrafficTypeDiagnostic: BN0PR20MB4087: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: lonApMpQL2yGrPXhLGs/UjX5F+Q66kWsN3a2oG5idNbBfStzkdYKZ2Sim4xY3WBqTCfK/xmi8nz+VTQXqLi7MJ3mJSFCvJqUPlKtwoNuP6gOrb0pN4nvtPTGvgI49AjS5oGCsvAMRVe+RPUdwWwWzNdVCTFOMMQ5hTydJoWJ3S2mrL6t9mJHcdL9i0ZWrEFUzHHoqapC4cIpxvy41Ex910TjffcGNuBvps8jdQoz4MvCr/rUwblZ2i46Cr/OSSHV4IDfEuvnWp7QHZQITiE8932iLZXgkL5moG8aigosWmAm9OU/a1Glxs1p74CFUVIKdKMcyjpEqdH1Al8aQ34xSt70Z5jyJOgXhG/eB0udtJw+ykXZdFWlgpVKIPswLDqDO+MR+ECKSpxApVne08S1ywPjmrZt8NJ/DsPZDnjpPlRz2E0y9qH5O0A/wKZ4KppoDuV3sSLD//SYpWF0GPYBInuIHjU9NglmKitjdB1m+H+1Q1Z0C8Kyn6C/2yC+U9iJUHB2njfEV/KBn28PuzpM1zF8hGeGlAF3W+g4ZLj3U6HeqVSbTDXlQ9rLnPM5Wf/FHO4upexL4ishuCe9lKUNNulTv1LdKCQ0a1RPfWEdVUHZyDk0cYjkN6AQdtmen6t8Q45W3jv2/wY8HYrF+/qq/RIomFC2JT1awEvBHCqBdWOFXZkRg8ZYop54SJlZLUred3lF99Ih0h+siGh2ZWevMg== X-Forefront-Antispam-Report: CIP:192.55.16.51; CTRY:SG; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:sgspzesaa002.seagate.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230001)(36840700001)(46966006)(40470700004)(70206006)(83380400001)(44832011)(186003)(1076003)(2616005)(2906002)(47076005)(8676002)(36860700001)(82310400005)(336012)(426003)(8936002)(7696005)(26005)(5660300002)(36756003)(6666004)(508600001)(356005)(40460700003)(81166007)(86362001)(450100002)(316002)(4326008)(70586007)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: seagate.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jun 2022 22:46:00.1380 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c6e41293-1905-42cc-c9b9-08da44e9ab03 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.51]; Helo=[sgspzesaa002.seagate.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM10FT049.eop-nam10.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN0PR20MB4087 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Fixing the page length in the SCSI translation for the concurrent positioning ranges VPD page. It was writing starting in offset 3 rather than offset 2 where the MSB is supposed to start for the VPD page length. Cc: stable@vger.kernel.org Fixes: fe22e1c2f705 ("libata: support concurrent positioning ranges log") Signed-off-by: Tyler Erickson Reviewed-by: Muhammad Ahmad Tested-by: Michael English --- drivers/ata/libata-scsi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index 42cecf95a4e5..86dbb1cdfabd 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c @@ -2125,7 +2125,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 Thu Jun 2 22:51:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tyler Erickson X-Patchwork-Id: 578418 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 0F55FC43334 for ; Thu, 2 Jun 2022 22:46:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239749AbiFBWqR (ORCPT ); Thu, 2 Jun 2022 18:46:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239745AbiFBWqL (ORCPT ); Thu, 2 Jun 2022 18:46:11 -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 9E09037A8A; Thu, 2 Jun 2022 15:46:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=seagate.com; i=@seagate.com; q=dns/txt; s=stxiport; t=1654209968; x=1685745968; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=fESTwgSp9C8M5iY9KkxqZ4tyQHRpyxysp1kFdG542fU=; b=hyIIdXEDNHWtuYWf4uL/KYRfB0s3qvzqnx3nvRDzi8ua3Y8Py1RDvlsv E0OJ3fHU33FBbSxZf/JolD1OsBsiHuvcfi/Dfy06Ir61VcTN97FY5u477 gqf6ODI1KSUXq5uhvg72HdSElD86MrvCMvMGqopU6yPPGZQn0Ev07e1y7 U=; Received: from mail-bn7nam10lp2105.outbound.protection.outlook.com (HELO NAM10-BN7-obe.outbound.protection.outlook.com) ([104.47.70.105]) by ob1.hc4959-67.iphmx.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 02 Jun 2022 15:46:07 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ct4g74Ce+P4O1xgA0fLMkk2xM6qFKg9HtCD0P9LbpnaLQKyS6vdM+kRtyYegjEs02WE1DDNguOq1+LLgoBjHN7qdDaK10+dgPd0iG9RWqIcda4oVch7f67Ovocs3LtR0LBzKPtEo4onusM9InnSLbfwYGW9LP/GbXtRFDWpWXGAsJL5kPzQPaG/wkH7orM/nE6AACx2A+7X3uPhdmdgZ1dH/QFKNnhpUkIcatV9X1f05mYvBOi3hpTbnxYNTRSzcu7ZY9IlzvCuXdZ3T3iwS2+G2b0DGkRt9bB3vx6c5dF2J9eVrUcO5k/mZ+9Cfvzg2cIwWUrJZA0LEADihBz2mfg== 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=6uYAp+BBT4Z/mQY35yc+yn8WHaPxzZeF158FLYfZdas=; b=F+MGbbWAUeDcU8gmTT2CtB6zz4BKOIQVEcrQIHSzMkog9OEy/PzyB9FjTB9JesoBz/0IahXKPtabaq6V9JHkPhnyeQcjdIqkFE9tmReUfbsWX2fvoPiEoDcjzSV+1hfRclQb3/bqI66MiwCvNpKnobTJbRgsYpXBRB+de8GU6TyFRZHyMzw3mHNgdm7O6gGBf37WUwiWKlh3UVqKCV8eH2c0jbbWlqOZM2HND0MzKbgnGHQAueswfg6IRFtvvfDl8iHHPSSc3TMlW6zOni4bYGSXAz47OGgY359xkNIl5pvdWP/RGk9zgMBO4QoosJql/Zg1tzAKC1yJIvVyaMlA+g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=softfail (sender ip is 192.55.16.51) 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=6uYAp+BBT4Z/mQY35yc+yn8WHaPxzZeF158FLYfZdas=; b=D5aiGwSEUWvP6f5na+/cNU7P298ntis1x/Y71YnwMGoUuYHqJ3/YlLsoRuQMMz25D+QmcSoxMlR20AZj4LrhwvvzKL1YMrqFLMc1YKR4+K66GUSkLqYDIcvzhmqsLxgzKHWhL0Y5uS9Rg2vsTaetDPx3LnwoqqXikgQKl8hcW0k= Received: from DM5PR05CA0007.namprd05.prod.outlook.com (2603:10b6:3:d4::17) by PH7PR20MB5081.namprd20.prod.outlook.com (2603:10b6:510:1f2::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.13; Thu, 2 Jun 2022 22:46:05 +0000 Received: from DM6NAM10FT060.eop-nam10.prod.protection.outlook.com (2603:10b6:3:d4:cafe::31) by DM5PR05CA0007.outlook.office365.com (2603:10b6:3:d4::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.14 via Frontend Transport; Thu, 2 Jun 2022 22:46:05 +0000 X-MS-Exchange-Authentication-Results: spf=softfail (sender IP is 192.55.16.51) smtp.mailfrom=seagate.com; dkim=none (message not signed) header.d=none;dmarc=fail action=oreject header.from=seagate.com; Received: from sgspzesaa002.seagate.com (192.55.16.51) by DM6NAM10FT060.mail.protection.outlook.com (10.13.152.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.12 via Frontend Transport; Thu, 2 Jun 2022 22:46:04 +0000 Received: from sgspiesaa002.seagate.com ([10.4.144.53]) by sgspzesaa002.seagate.com with ESMTP; 02 Jun 2022 15:48:39 -0700 X-IronPort-AV: E=Sophos;i="5.91,272,1647327600"; d="scan'208";a="62195127" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False STX-Internal-Mailhost: TRUE Received: from unknown (HELO tyler-ubuntu.colo.seagate.com) ([10.4.50.15]) by sgspiesaa002.seagate.com with ESMTP; 02 Jun 2022 15:33:34 -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, stable@vger.kernel.org Subject: [PATCH v2 3/3] scsi: sd: Fix interpretation of VPD B9h length Date: Thu, 2 Jun 2022 16:51:13 -0600 Message-Id: <20220602225113.10218-4-tyler.erickson@seagate.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220602225113.10218-1-tyler.erickson@seagate.com> References: <20220602225113.10218-1-tyler.erickson@seagate.com> X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: e58074f4-1008-4b38-35b0-08da44e9ad68 X-MS-TrafficTypeDiagnostic: PH7PR20MB5081: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: Z/jmal5t0Anu063zPd3IPiWoTrOT4f0NBj7/Uq2REDa9ktQEMy3c3ICby9Y0Zr8VJOdiQ/mnvN++t88zXhmiHEUWvktMuJT/UZwx6isuC04VR4B4bq/kllQfMVFh0ayZoVWOA7iY/sSJGNp79EktZJO7XzEQW/cV2BL1XGN0g5P1kMuuhtb4MhThPGTpq71Nl0sHBPdBDMAvo6bDBqito/upDlHYHglFzLci1jFurOZS+fKatZRCBD8sd6SDx5xfZ2cdzgrOxgj0JLR9ucKFCnREo1IyIG1xk35FcE44g/yehHREZ0lbeThprvuIeye6e6BOrFWzJl0DI8XgRmlzb9bA6ZTiGOBo671dQbRcHSKdv6jWgkvMi9V6SNbSsWr7Vi4DydcKDQH1DBkwgI6TsvMtsdz609kGOz+Wg+G/SoFDHkPWKD0spcMNTwe1vd4q7DA+DtfA3rzTYMWzInFYATFvMNkTHTABvXFGpwLrxLsHD3RM/TbA1GFbCoy/sgJAgrh5N8gY28gl2m4lPgfUDOLj5o2scMYQVxEVxt1+bsbnTJz2i0CJGETqMJH3aknsm8UQ7TY8P5tEAR8NzMKtN2tJsp8ZcORSjecJI6fVXb8T58XnHvc9ArqqC7NSqtQWqSS13fQF+mhHJeYfhCWohw+TRTYceqZT93fXsAN7qqtN5Mt6P5S6Iz/fY7zluz7p1WwEl+Lctf4oaQ5kMBFr+Q== X-Forefront-Antispam-Report: CIP:192.55.16.51; CTRY:SG; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:sgspzesaa002.seagate.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230001)(46966006)(40470700004)(36840700001)(86362001)(47076005)(336012)(1076003)(186003)(426003)(508600001)(83380400001)(81166007)(356005)(36860700001)(316002)(2616005)(82310400005)(5660300002)(450100002)(8936002)(40460700003)(4326008)(70586007)(8676002)(70206006)(6666004)(2906002)(26005)(7696005)(44832011)(36756003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: seagate.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Jun 2022 22:46:04.1672 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e58074f4-1008-4b38-35b0-08da44e9ad68 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.51]; Helo=[sgspzesaa002.seagate.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM10FT060.eop-nam10.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR20MB5081 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 Cc: stable@vger.kernel.org Fixes: e815d36548f0 ("scsi: sd: add concurrent positioning ranges support") Signed-off-by: Tyler Erickson Reviewed-by: Muhammad Ahmad Tested-by: Michael English Reviewed-by: Damien Le Moal Reviewed-by: Hannes Reinecke --- drivers/scsi/sd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 749316462075..f25b0cc5dd21 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -3072,7 +3072,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");