Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp991032imm; Sun, 2 Sep 2018 06:10:47 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdbcsr0YzkQvp8dQ2x2qEVdUnUXKGp2ZEWJrmoRODNp5QdUm3xqFwA+qvga76g/AaRTStRj/ X-Received: by 2002:a17:902:b40c:: with SMTP id x12-v6mr23919516plr.163.1535893847794; Sun, 02 Sep 2018 06:10:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535893847; cv=none; d=google.com; s=arc-20160816; b=y12JrI1FmzzZ71Yoye+Z1tfisHRpgJlPuJQycSm3kbhFFGrkW0VUgj8EUE5GgFXsVC zbImshgzqtyIbI1pJNmqtUVwhqrm7dWezZbQPHGlOJmEJjHiA+jkyVIM6kEN8vDiyk3N yJrpFCAJGoh+Qjzvc2d5EpAIlOc8gn4ZYfw5xK9yz6Jd/FIOi8G1TQKkWvIwoy39U4ob wV3A0biw7kjgqdGNsH+xT4wvCD9Yh6ioh4b65UWukvSRHCKNVATyjMr0lue0pZlurU5R Qaqhl5G7VKU7rTT24oeiqFO3i0FNxWa87tmsFl8YlFdw4MCWkg/r+Dtsoczz+j2fXk1y J7rw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=g+QFCwXQemAs5KbBo8z3h9haFicmRs0ZqB2lICmyI8g=; b=aop40NWy36lobI42DnpzQ96OP78+/h/BcTlWAgV3t5TUX00DlSTMjriM0PCrPzDUz7 8SyEnIAnZhLN3AXjkFU3joQEBSUnTopWmC8ANkuxK0hvp26VCs1hRymLKIAouuwe4tSL D8gEbJgEUtYLEbQz3qTZeq2H9PitEkqdGpHUNifI27K/91QO5lHI0hmI9nJpT4jImQrc KdhbVdtuQtSHPUZSojUq97dvKZn1i7zpl40xoD+bRoorYjc/eZqiyGyH0S7lyW1xtH16 8qDUyy0Z0g58LhnMKNLbSLtrZg+ExE0QwMSK4GyR49xy6RCUJesgd4x3/RWsymuF8rHp nfLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=gsQumPAM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f15-v6si15501757pli.194.2018.09.02.06.10.33; Sun, 02 Sep 2018 06:10:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=gsQumPAM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729662AbeIBRYi (ORCPT + 99 others); Sun, 2 Sep 2018 13:24:38 -0400 Received: from mail-by2nam03on0099.outbound.protection.outlook.com ([104.47.42.99]:42688 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727876AbeIBRYh (ORCPT ); Sun, 2 Sep 2018 13:24:37 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=g+QFCwXQemAs5KbBo8z3h9haFicmRs0ZqB2lICmyI8g=; b=gsQumPAM5qCJONLx02Yhn2hD2FIGu2b5nhgnFCA8fi6asOqsdLETR7IfXE5R+pCjIhR8BC5QaoyRfo2wCgmqx87e9Ko14SlOU6uW//h9/nUv6211TM+bPzUwl2W4MzC5ZhgjCBMq+V8EBesO+g/8H3vV/vTCoOTqdlDf05rwY68= Received: from CY4PR21MB0776.namprd21.prod.outlook.com (10.173.192.22) by CY4PR21MB0503.namprd21.prod.outlook.com (10.172.122.13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1122.2; Sun, 2 Sep 2018 13:07:11 +0000 Received: from CY4PR21MB0776.namprd21.prod.outlook.com ([fe80::7c3a:eea8:1391:1611]) by CY4PR21MB0776.namprd21.prod.outlook.com ([fe80::7c3a:eea8:1391:1611%7]) with mapi id 15.20.1143.000; Sun, 2 Sep 2018 13:07:11 +0000 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Srinivas Pandruvada , Tejun Heo , Sasha Levin Subject: [PATCH AUTOSEL 4.14 41/89] ata: libahci: Allow reconfigure of DEVSLP register Thread-Topic: [PATCH AUTOSEL 4.14 41/89] ata: libahci: Allow reconfigure of DEVSLP register Thread-Index: AQHUQr3TxvcLg2XLGku74QihPFE/yA== Date: Sun, 2 Sep 2018 13:06:57 +0000 Message-ID: <20180902064918.183387-41-alexander.levin@microsoft.com> References: <20180902064918.183387-1-alexander.levin@microsoft.com> In-Reply-To: <20180902064918.183387-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;CY4PR21MB0503;6:FPmEizDEf7fm+93VSmTalHl3CntXbU8LqFc1Jt6PF4hf1Wn/shmm+r6c322PkIEKT3zbnbJs2RW5BcCGrb3Qul7IVp9jOgc0PPV4Y1UlhHTdJN6ie9xYFSt536cvxG/S0ZscH84MzXXMjtjWmLaXoieGRMXvGwsDlnzxz29o8jH4coVtbiuqU0jxJD2hXPS1ZVS71EB1hmWCvV186N8fRTjnwF3jIIcp3IfLMYEfmSksiFyGLvPZBV6KWtYcMk+/J6lQyoMrny5LYGEl+XUhdGS+SX6WA2IOS1SQ2waOGsmjJMLcl6JeDjX5IJqF7HTVI3G9mm2GQLJIR1XMpFVuOqwtj86SPUqIH3eOpb3AcBwHPRcmbtxI12vDUZA2YQ14mscFwzckAV+DpMIcvxEj4uNX46MeWYm9PRAxRRGvkkcnVPs+BNGzdW/Di+389VyQql9fwRHjagw32RRzsEGksw==;5:7AJMBJqvuw8IpvIbMmfeyQY9FXY1LVV3XWLrpiDDsgSEWniOZleZSDAHb8gORCvQLrs3n44QkzTNL1XZAWk+dRD5EWljaq8IUAKA2pg3L2+fRPIahjGzmOttKWDq4rk801lFdhiYWpmxHlMq8Ogp29wKKRxf639keUH5fkSWhuI=;7:/3+hLMX+Ag6i2X2wWWyJMuaSHfUzo+ZSJKISnWzDs43COj4Smjw6Y3O9oye/p8x6kbowo2TYA59Uo5H0pIMSm7kzoXlAvgm1tQBsZ+wan4uKTIOa9+oVs98gBLecN1Ss9+TNisXJ2qHisZaoVB7Ozy20AazxwrjsNF/Dwxinz6NC1Hau+cO5qHQlxi1ityTUkYenwaACeSgI3Gj09g0TCw6YlIa5uFH7hoYVzlmhaQ7ONckLNhDcVXlGEfpmZbbD x-ms-office365-filtering-correlation-id: b1f63877-6c3d-4e14-ef14-08d610d4fea7 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(4534165)(4627221)(201703031133081)(201702281549075)(5600074)(711020)(4618075)(2017052603328)(7193020);SRVR:CY4PR21MB0503; x-ms-traffictypediagnostic: CY4PR21MB0503: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(228905959029699); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(2017102700009)(2017102701064)(6040522)(2401047)(5005006)(8121501046)(2017102702064)(20171027021009)(20171027022009)(20171027023009)(20171027024009)(20171027025009)(20171027026009)(2017102703076)(93006095)(93001095)(10201501046)(3231340)(944501410)(52105095)(2018427008)(3002001)(6055026)(149027)(150027)(6041310)(20161123558120)(20161123562045)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699049)(76991033);SRVR:CY4PR21MB0503;BCL:0;PCL:0;RULEID:;SRVR:CY4PR21MB0503; x-forefront-prvs: 078310077C x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(396003)(39860400002)(136003)(376002)(346002)(366004)(189003)(199004)(105586002)(8936002)(102836004)(6346003)(68736007)(2900100001)(6116002)(217873002)(186003)(36756003)(81156014)(81166006)(1076002)(99286004)(26005)(5660300001)(66066001)(6666003)(8676002)(54906003)(256004)(316002)(305945005)(22452003)(3846002)(10090500001)(7736002)(110136005)(106356001)(2906002)(6506007)(10290500003)(2501003)(478600001)(2616005)(72206003)(6512007)(53936002)(575784001)(86362001)(86612001)(107886003)(6436002)(14454004)(76176011)(486006)(25786009)(476003)(97736004)(446003)(11346002)(6486002)(4326008)(5250100002);DIR:OUT;SFP:1102;SCL:1;SRVR:CY4PR21MB0503;H:CY4PR21MB0776.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-message-info: P1kmEdvbVlo7B+pX1d4NDgBUvJnCO3brQoWcgd8BhpWk+Cz6OFkW8og3L0TrJoIi+wEzZO3+40kfP9sUEJcqLVgoDDSqPBKAYoEELlyQ3/BQCozNo4quNTVK9rB2LO0ch/EFibAxtG9swhcFRXj03pItWKLRTzruXvvWVNFdZDJSol5NR0zGPaLPJTZ6+NmK3akqSOmXEYJU2/Yp81lR00AxhE8/lgT4Dwr6bEfDsE6Tv2bSgJ4GcO15lb049Yk7US8y602YY5RFm2P1Sf/a8E4vwnpLeAh2pit8ZEH2JTpCXgJwLVhSP/AQ6SPMaw1Q4c09rrp3FaJTIbu52W+yAUP1yqTODLNclP7Xw1pudIg= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: b1f63877-6c3d-4e14-ef14-08d610d4fea7 X-MS-Exchange-CrossTenant-originalarrivaltime: 02 Sep 2018 13:06:57.2638 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR21MB0503 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Srinivas Pandruvada [ Upstream commit 11c291461b6ea8d1195a96d6bba6673a94aacebc ] There are two modes in which DEVSLP can be entered. The OS initiated or hardware autonomous. In hardware autonomous mode, BIOS configures the AHCI controller and the device to enable DEVSLP. But they may not be ideal for all cases. So in this case, OS should be able to reconfigure DEVSLP register. Currently if the DEVSLP is already enabled, we can't set again as it will simply return. There are some systems where the firmware is setting high DITO by default, in this case we can't modify here to correct settings. With the default in several seconds, we are not able to transition to DEVSLP. This change will allow reconfiguration of devslp register if DITO is different. Signed-off-by: Srinivas Pandruvada Reviewed-by: Hans de Goede Signed-off-by: Tejun Heo Signed-off-by: Sasha Levin --- drivers/ata/libahci.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c index bc562fd2b0a0..25edaf8f9629 100644 --- a/drivers/ata/libahci.c +++ b/drivers/ata/libahci.c @@ -2096,7 +2096,7 @@ static void ahci_set_aggressive_devslp(struct ata_por= t *ap, bool sleep) struct ahci_host_priv *hpriv =3D ap->host->private_data; void __iomem *port_mmio =3D ahci_port_base(ap); struct ata_device *dev =3D ap->link.device; - u32 devslp, dm, dito, mdat, deto; + u32 devslp, dm, dito, mdat, deto, dito_conf; int rc; unsigned int err_mask; =20 @@ -2120,8 +2120,15 @@ static void ahci_set_aggressive_devslp(struct ata_po= rt *ap, bool sleep) return; } =20 - /* device sleep was already enabled */ - if (devslp & PORT_DEVSLP_ADSE) + dm =3D (devslp & PORT_DEVSLP_DM_MASK) >> PORT_DEVSLP_DM_OFFSET; + dito =3D devslp_idle_timeout / (dm + 1); + if (dito > 0x3ff) + dito =3D 0x3ff; + + dito_conf =3D (devslp >> PORT_DEVSLP_DITO_OFFSET) & 0x3FF; + + /* device sleep was already enabled and same dito */ + if ((devslp & PORT_DEVSLP_ADSE) && (dito_conf =3D=3D dito)) return; =20 /* set DITO, MDAT, DETO and enable DevSlp, need to stop engine first */ @@ -2129,11 +2136,6 @@ static void ahci_set_aggressive_devslp(struct ata_po= rt *ap, bool sleep) if (rc) return; =20 - dm =3D (devslp & PORT_DEVSLP_DM_MASK) >> PORT_DEVSLP_DM_OFFSET; - dito =3D devslp_idle_timeout / (dm + 1); - if (dito > 0x3ff) - dito =3D 0x3ff; - /* Use the nominal value 10 ms if the read MDAT is zero, * the nominal value of DETO is 20 ms. */ --=20 2.17.1