Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp4535087imm; Mon, 17 Sep 2018 16:03:05 -0700 (PDT) X-Google-Smtp-Source: ANB0VdaDyt6KI4DYIKwlG9VgFpOk8JWm6+3PSwEcx3WDm93OyVuwFIiZeeBnjRNffAIesmsA0fXM X-Received: by 2002:a62:1f11:: with SMTP id f17-v6mr27884203pff.168.1537225385144; Mon, 17 Sep 2018 16:03:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537225385; cv=none; d=google.com; s=arc-20160816; b=gcwJEnUpV/XBGYHnuJ+myyIxiTklLApQmaXKed2cgpFvxztehW1MTumxtAr22thwhk B2Jpltvjk1AaqLZAjYoU9eofZB0CaHL94fKlUO3RIltvgPiOHxOBbzm8sqgkvEVq9/Er 1JgINjQdrllgR4gq3Z+G9cyE8GjWukbXyQ84UrEx39mo7Eme8IaX0opQoYJNuoHjQJ5O LfKFzwfAQn0gPonxPvJIFEUFKdKEdxEpsHBgAHu170JBu9AbkkI8cGeWjQr25yhZo112 gLLk3SpToempyzu/qXRVbjvi6lWuSgbYray4BlDuCUfG0gFdFvM4lAAhxEhNVd78FEVP jKVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from; bh=BTCfCI9sieoxFxIsIrOmqPnwAQZubsSx6SsR80TU6O4=; b=GRb1NByT/nyq9EARTOKS3ZRDdIyAhveATxxJOqcwET62cfqmmZhAcZGnIY+2lT/zQ3 k6Bd35T4Ben86+MDf/vFpYrsTqdEYQEn3LbJSmm7+ytWO+dzOvRTzdxJ9olaHQfySRc/ +qFmhER0gBF5qMy8fp2rqAFE8EUMDLNkpUrwiKGudmVNDHxVxTBX2dX1WXbL/TZOGuzz IzFA4xFo5cT6vgSI4Ns3hm0xZoN/Azyq9CMeMZHZB1iqRKBPEw9Sdw85ivDnlSpI+fKH uYUul05WxOUMepRUr6jH0hfnKIKgPEdxqImDqWtvWl1Nbhd4x48urH81Xr6+W9cyKhbS e6YA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p15-v6si15888299pgh.281.2018.09.17.16.02.49; Mon, 17 Sep 2018 16:03:05 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730438AbeIREcE (ORCPT + 99 others); Tue, 18 Sep 2018 00:32:04 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:48514 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727088AbeIREcD (ORCPT ); Tue, 18 Sep 2018 00:32:03 -0400 Received: from localhost (li1825-44.members.linode.com [172.104.248.44]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 5E879C49; Mon, 17 Sep 2018 23:02:35 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Srinivas Pandruvada , Hans de Goede , Tejun Heo , Sasha Levin Subject: [PATCH 4.14 057/126] ata: libahci: Allow reconfigure of DEVSLP register Date: Tue, 18 Sep 2018 00:41:45 +0200 Message-Id: <20180917211708.207983842@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180917211703.481236999@linuxfoundation.org> References: <20180917211703.481236999@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ 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 Signed-off-by: Greg Kroah-Hartman --- drivers/ata/libahci.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) --- a/drivers/ata/libahci.c +++ b/drivers/ata/libahci.c @@ -2096,7 +2096,7 @@ static void ahci_set_aggressive_devslp(s struct ahci_host_priv *hpriv = ap->host->private_data; void __iomem *port_mmio = ahci_port_base(ap); struct ata_device *dev = ap->link.device; - u32 devslp, dm, dito, mdat, deto; + u32 devslp, dm, dito, mdat, deto, dito_conf; int rc; unsigned int err_mask; @@ -2120,8 +2120,15 @@ static void ahci_set_aggressive_devslp(s return; } - /* device sleep was already enabled */ - if (devslp & PORT_DEVSLP_ADSE) + dm = (devslp & PORT_DEVSLP_DM_MASK) >> PORT_DEVSLP_DM_OFFSET; + dito = devslp_idle_timeout / (dm + 1); + if (dito > 0x3ff) + dito = 0x3ff; + + dito_conf = (devslp >> PORT_DEVSLP_DITO_OFFSET) & 0x3FF; + + /* device sleep was already enabled and same dito */ + if ((devslp & PORT_DEVSLP_ADSE) && (dito_conf == dito)) return; /* set DITO, MDAT, DETO and enable DevSlp, need to stop engine first */ @@ -2129,11 +2136,6 @@ static void ahci_set_aggressive_devslp(s if (rc) return; - dm = (devslp & PORT_DEVSLP_DM_MASK) >> PORT_DEVSLP_DM_OFFSET; - dito = devslp_idle_timeout / (dm + 1); - if (dito > 0x3ff) - dito = 0x3ff; - /* Use the nominal value 10 ms if the read MDAT is zero, * the nominal value of DETO is 20 ms. */