Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp317884imm; Mon, 2 Jul 2018 12:04:05 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeXnf27poST+uWvhKzCSQYjUMz7afbFv1SIQ6qPrh5VFE8t/yzWHoWPSrHqmyUqoBgT5IzC X-Received: by 2002:a62:864a:: with SMTP id x71-v6mr6937328pfd.252.1530558245372; Mon, 02 Jul 2018 12:04:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530558245; cv=none; d=google.com; s=arc-20160816; b=wE0mNSM+w07lNqMq6WKGiXm3OaHmnuxFr79paH7FKwcTq5FujNHODv1iW9+AshXhKJ /pwxfT9uJjqTQBZD3J4zBxrX0N4eL2GWY0EqIpe5P8HObQnSF9/4WW9eI/8CSHgJkbge lptpsSbwLFCy8db5Wp/TLDRl6SakEDzTC652doJiqWfZh/qLuCi0LCueVmMdKn5h7dLA WbTmP4L3M30UISxaWMDBC7+U5A1OWFQ48VWJo0vdtWSWz6RlzH0Qm5ibDgYqs+4F5xe/ ZOJS2zRlkzRmaXR1rYrSzU7CO6yNATXxIKFYQ4is9kFvt7OR/mV/OX40T43H7QxLc2q3 lhCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=3o3kDJUg12FN3/7mTUg5VyUJepys5/5edGqI7hQHaU0=; b=gyhhbZomjZ88WktEX7mWEjZo/jMjCwxXUXDwYMmqZhWn82dgdJC8AKoaL0t3o1FwFu zWg0u6TPKekKMFwd/S5IQ+bHr7JyFhvYtmWqMzlWj3zYuBT9ixA/qvD86BaqsIS6swSF yCMLMPXZ4437UndtZlBV3kLVMv0IXFPnECamGZjtQQ7fFix/BBtBLb/JxXqHC5H4+hQW O2P9/cnPuxOA2D1KUjUH6nKh2TgRPzOfjqtKX3BgC3GQ/2O1CTn6oEjQ96qJqP5Boyrm 0K63h6CWKkICSJUAK+zQll1b3w9lcDQPC1B9osGlBhRt2NIs2TaMsiK4mW6rhBc5G2f7 EqQA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 6-v6si5796431pgw.680.2018.07.02.12.03.50; Mon, 02 Jul 2018 12:04: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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932198AbeGBTCa (ORCPT + 99 others); Mon, 2 Jul 2018 15:02:30 -0400 Received: from mga07.intel.com ([134.134.136.100]:50141 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753497AbeGBTCG (ORCPT ); Mon, 2 Jul 2018 15:02:06 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga105.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Jul 2018 12:02:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,299,1526367600"; d="scan'208";a="54584845" Received: from spandruv-desk.jf.intel.com ([10.54.75.31]) by orsmga006.jf.intel.com with ESMTP; 02 Jul 2018 12:02:05 -0700 From: Srinivas Pandruvada To: tj@kernel.org, hdegoede@redhat.com Cc: rjw@rjwysocki.net, alan.cox@intel.com, linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org, Srinivas Pandruvada Subject: [PATCH 2/2] ata: libahci: Allow reconfigure of DEVSLP register Date: Mon, 2 Jul 2018 12:01:54 -0700 Message-Id: <20180702190154.6864-3-srinivas.pandruvada@linux.intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180702190154.6864-1-srinivas.pandruvada@linux.intel.com> References: <20180702190154.6864-1-srinivas.pandruvada@linux.intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 f6795d261869..432ac2f5de34 100644 --- a/drivers/ata/libahci.c +++ b/drivers/ata/libahci.c @@ -2104,7 +2104,7 @@ static void ahci_set_aggressive_devslp(struct ata_port *ap, bool sleep) 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; @@ -2128,8 +2128,15 @@ static void ahci_set_aggressive_devslp(struct ata_port *ap, bool sleep) 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 */ @@ -2137,11 +2144,6 @@ static void ahci_set_aggressive_devslp(struct ata_port *ap, bool sleep) 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. */ -- 2.17.1