From patchwork Mon Oct 24 11:30:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 9535 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp483957wru; Mon, 24 Oct 2022 07:28:38 -0700 (PDT) X-Google-Smtp-Source: AMsMyM62aoFKWPOSk0EULliEwI/gqgsqdKI6YL/a22Skl+CWB5anF/vLgHXbI7zvUbazIS0xOLpb X-Received: by 2002:a63:c104:0:b0:459:c6a1:15c0 with SMTP id w4-20020a63c104000000b00459c6a115c0mr27505716pgf.588.1666621717760; Mon, 24 Oct 2022 07:28:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666621717; cv=none; d=google.com; s=arc-20160816; b=XV97hfqeuPimzehKiTfziTUrbrSkUeoDKyxgHwCzKizOeyDvAbghmVHSGJhTE3pVhD jV09LUHVFzt4JKOBfpzoG7RkBZacg8tVH9vkSc20NkHqn7tmuqrKQY8HrO35Q8Rm6ugG jqSPQEYbgzG0F2rvFpcCGoNSCaEh/ad/sxr48luOhgo72PfbxI3hUPUoZePrNynxZj0Q 78JPMVp3exUWEcsvxWz5IdDMoZ/PZaExsaxT1L1X0UbYe40cwlFkrJMSJy3a4awaHFxB FXAyjAoy3/+rlQhh2efokkBM3nO5bHJRQKNtFC5HxVO/kF2oISZ0/4JcCQm6avuN4BPU fzDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Yg7qgomtPNUs2l1XMWWR7N5K/NC/KFNvLNS/0w0ztDQ=; b=Idhy8qr9kp+Lf14bDbI22cjDHkaZxZIdZW8GspZN9KSuQtEY28HYLDfYLz5Yjqam1C bTYCuvypfA6cugtvZhq81q5ZEmOAMJMVytbsZFJcRLf4j34GhglZcAPlAIF7Cd1wJf+v b3YjDNghS7+qpnEyowi/XWfUFNxecHNqVKTgDlZ30BLPuRLN5jq1LPsN9vzleOFv/oOs TC6y/5eAv6Rc6HQJ6tZWG7XqezHYC+wUXU/2Kd9NxjN9z8Y6BNCzdxbCmQ4G+XJQReHn c7Drpz3cJAIIEMhRgn/hOm+i02JiHLwkRcGLe+rRlMCWx5WflSXUBUBcema3ix22eB1e CMFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=q0oNlDpB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p17-20020a631e51000000b00422c003b4c9si35459313pgm.46.2022.10.24.07.28.24; Mon, 24 Oct 2022 07:28:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=q0oNlDpB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236978AbiJXO0a (ORCPT + 99 others); Mon, 24 Oct 2022 10:26:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237302AbiJXOZO (ORCPT ); Mon, 24 Oct 2022 10:25:14 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14CF557E32; Mon, 24 Oct 2022 06:00:06 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 25D9A612B3; Mon, 24 Oct 2022 12:46:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3BD74C433D6; Mon, 24 Oct 2022 12:46:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666615607; bh=/s4q7R/+QRfYxpXntGdWRSfHWp+7TLzsCVi7sl9z1d4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q0oNlDpBG04DsTqc5MSQD3ADYns160QPFgr/cFxDHiSEOQAn01fEbXvS0+0/E5+MX HBImb9gySXbEi8W/ah1RSLGQ7v7lvHbfQcsYPdIJEquU1D6AELxwuwSAUhPfGZKY5a FERVY37pvJVuhl+byix5ffRJ3QrYWQC9QcaquHVs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Niklas Cassel , Damien Le Moal , Sasha Levin Subject: [PATCH 5.15 315/530] ata: fix ata_id_has_dipm() Date: Mon, 24 Oct 2022 13:30:59 +0200 Message-Id: <20221024113059.284242959@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113044.976326639@linuxfoundation.org> References: <20221024113044.976326639@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747579534053795849?= X-GMAIL-MSGID: =?utf-8?q?1747579534053795849?= From: Niklas Cassel [ Upstream commit 630624cb1b5826d753ac8e01a0e42de43d66dedf ] ACS-5 section 7.13.6.36 Word 78: Serial ATA features supported states that: If word 76 is not 0000h or FFFFh, word 78 reports the features supported by the device. If this word is not supported, the word shall be cleared to zero. (This text also exists in really old ACS standards, e.g. ACS-3.) The problem with ata_id_has_dipm() is that the while it performs a check against 0 and 0xffff, it performs the check against ATA_ID_FEATURE_SUPP (word 78), the same word where the feature bit is stored. Fix this by performing the check against ATA_ID_SATA_CAPABILITY (word 76), like required by the spec. The feature bit check itself is of course still performed against ATA_ID_FEATURE_SUPP (word 78). Additionally, move the macro to the other ATA_ID_FEATURE_SUPP macros (which already have this check), thus making it more likely that the next ATA_ID_FEATURE_SUPP macro that is added will include this check. Fixes: ca77329fb713 ("[libata] Link power management infrastructure") Signed-off-by: Niklas Cassel Signed-off-by: Damien Le Moal Signed-off-by: Sasha Levin --- include/linux/ata.h | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/include/linux/ata.h b/include/linux/ata.h index 295a6c6b506d..3b1ad57d0e01 100644 --- a/include/linux/ata.h +++ b/include/linux/ata.h @@ -573,6 +573,10 @@ struct ata_bmdma_prd { ((((id)[ATA_ID_SATA_CAPABILITY] != 0x0000) && \ ((id)[ATA_ID_SATA_CAPABILITY] != 0xffff)) && \ ((id)[ATA_ID_FEATURE_SUPP] & (1 << 7))) +#define ata_id_has_dipm(id) \ + ((((id)[ATA_ID_SATA_CAPABILITY] != 0x0000) && \ + ((id)[ATA_ID_SATA_CAPABILITY] != 0xffff)) && \ + ((id)[ATA_ID_FEATURE_SUPP] & (1 << 3))) #define ata_id_iordy_disable(id) ((id)[ATA_ID_CAPABILITY] & (1 << 10)) #define ata_id_has_iordy(id) ((id)[ATA_ID_CAPABILITY] & (1 << 11)) #define ata_id_u32(id,n) \ @@ -596,17 +600,6 @@ static inline bool ata_id_has_hipm(const u16 *id) return val & (1 << 9); } -static inline bool ata_id_has_dipm(const u16 *id) -{ - u16 val = id[ATA_ID_FEATURE_SUPP]; - - if (val == 0 || val == 0xffff) - return false; - - return val & (1 << 3); -} - - static inline bool ata_id_has_fua(const u16 *id) { if ((id[ATA_ID_CFSSE] & 0xC000) != 0x4000)