From patchwork Wed Nov 28 09:19:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AceLan Kao X-Patchwork-Id: 1004287 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="LwN/uoYV"; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 434ZqT20xyz9s4s; Wed, 28 Nov 2018 20:19:49 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1gRw0W-0000aL-Ps; Wed, 28 Nov 2018 09:19:44 +0000 Received: from mail-pf1-f194.google.com ([209.85.210.194]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1gRw0V-0000Z3-Kk for kernel-team@lists.ubuntu.com; Wed, 28 Nov 2018 09:19:43 +0000 Received: by mail-pf1-f194.google.com with SMTP id i12so9878211pfo.7 for ; Wed, 28 Nov 2018 01:19:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=gVyqM0gTw4BCfnJZZEvMH5/EJlh4Pr4rFS/VOPrPoZ4=; b=LwN/uoYV4E+wEHUqz0zUSQOuFXjpqrABE0KH/FwiofSYTVv3RUsyRuK4/g3olsLNi5 QrGE7bcb4Xo6HWZ8/j0lH9+9k9gm+qfIl49f4QpxcRuxL3TLKARBiWjO7AWOlwd7Sbsa 4ZXth+83BE2E0/Z4ouC4KKbkZycbMjZ73XzWNllPI4V6XDAQl3kZQkvA89nMaHaRh/Fy kSoUWu860SbrrCAGpfQCi/BfkvWr9BOpBnCUPzKL2TYsuiMDuMtEfW1jLuZebDkCimhY ae5ThgmHTqlUOrF2Pzll1HyWiEpwjxyUCNa94Qa8TkDp93llaWjoOK3LTbA5DsAOStDY hAow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=gVyqM0gTw4BCfnJZZEvMH5/EJlh4Pr4rFS/VOPrPoZ4=; b=UZjCV8d54zUyppfSSnwa/+aezZ6lQfcrsgQVGxuBo/CNiLVcEa0atHrditjvjPR7ct iqVj7kkO8LdGiM5o9fHvMukxRDtZuyvxtASmebFX6fY73zXFfPCiWrFUQVsUDmPxkqqp oYD+guHwjTBlCkInRIT8sZaVJM3BU+8ze5uUpSd16JDnaoMkTBCsQDRjxyp+Ny7pj+Ld Gr6b6mTu5BxEvca2G/Cc3Hjbhe0EJ164UZh1pC8r32ian8/3upy6e1pAPRtdQZYyHeMY PAGZ9wT1UVtm83Y95jG/Us4TuanC6OeBqTGn8DgY7+nzTc8bZP5442V5zvjo+H83XqoU MWpw== X-Gm-Message-State: AA+aEWZ8OxiXH9+DU56IpDuOfSf8ipjzu/8RDjz8wRgL0NUfB25KXRoA PComDSJjfqcybJU4+OPpn4eZ/rPK X-Google-Smtp-Source: AFSGD/V71utPLypyj70jtMNSTMGaUXLLkG/8EIt9jnj9G360XP5HdBEJ2YfUDUiHU8G0FOR1HqFe5w== X-Received: by 2002:a63:2744:: with SMTP id n65mr32245550pgn.65.1543396781546; Wed, 28 Nov 2018 01:19:41 -0800 (PST) Received: from localhost (114-32-69-186.HINET-IP.hinet.net. [114.32.69.186]) by smtp.gmail.com with ESMTPSA id g136sm8037650pfb.154.2018.11.28.01.19.40 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 28 Nov 2018 01:19:40 -0800 (PST) From: AceLan Kao To: kernel-team@lists.ubuntu.com Subject: [PATCH 2/4][SRU][OEM-B] ata: libahci: Allow reconfigure of DEVSLP register Date: Wed, 28 Nov 2018 17:19:23 +0800 Message-Id: <20181128091932.18316-3-acelan.kao@canonical.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181128091932.18316-1-acelan.kao@canonical.com> References: <20181128091932.18316-1-acelan.kao@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Srinivas Pandruvada BugLink: https://bugs.launchpad.net/bugs/1781533 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 (cherry picked from commit 11c291461b6ea8d1195a96d6bba6673a94aacebc) Signed-off-by: AceLan Kao --- 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 0a2938e4c834..a1342fa12859 100644 --- a/drivers/ata/libahci.c +++ b/drivers/ata/libahci.c @@ -2094,7 +2094,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; @@ -2118,8 +2118,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 */ @@ -2127,11 +2134,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. */