From patchwork Tue Jun 4 23:24:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Andersson X-Patchwork-Id: 165854 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp6475571ili; Tue, 4 Jun 2019 16:24:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqzBTVlA5pWqrtv80U0/phLFj6DYsK7owEpI2bmlZeU3KHviFb7PRVXZxDxwE2DzG5r05eAn X-Received: by 2002:a63:5443:: with SMTP id e3mr341868pgm.265.1559690689905; Tue, 04 Jun 2019 16:24:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559690689; cv=none; d=google.com; s=arc-20160816; b=hDnVXo/j871W/OrBNtCn0x1/h+s70X2i22WjWBkJ33n91kR9UnKEiTFdgXzzDuZc7x 8OvgaOXIXHI6jYFz6U7Kenw75hhP63althNomNexiob0axgqmlthLmoBkfWtLNTaavyH ntTyTV+E2C/nlwX29vPADAdEG2BmzG1gSmWfya0pQ87VvryWHEt3ogPgChzhcmORnL/1 z9zvCJn8tcpa0KnaUfyL80he6Gd4UfaGA4rWgrf1aADAjkiIxAX3RY16LFxPgYH5i91z qvX66GlHtRA6daXy34DI8Lfd7dG0Y7J9xZ8v6Ot0tFM/Vd/Ts2XyQ1SfIa4k3+tUrbKH wTag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=obi0eC193ooLcTgT4aYZ/LPXcwma3pGIiVwdm+ZLW/M=; b=Jh01HK39TuO7hbdlMM2WpwBy0mXugfQ4vevqsPuahT2Xu2VS+ZU7ixzXHWdUIL9XZR gB653onIQ5b8WYhtpzrXeMqeKAC9fLpmB6zbWbe8A9TbD1zjLXD7o9t6V34uuRE8zQkW RWlZ6NeBsJnFDMo8x3yLx0p3qm2taoCzsWQtnEMn1TP3cSAfBuEt6ZPQLYXJ47S+ZVwW 7HtkiJuei+YIeZhr7qfBYR1xtmgeMnUNKD5AsJzF4mQOTi1SAPx8UD0CflNojAw4xIOi ugrcuVo4Do36uFOLTH/SLwEtcQ/DJmG++XzDrtU0SvICs3NHzElFkOWoJFxBQXEhiQQe /7oQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AMsYJVyx; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ci12si22232990plb.45.2019.06.04.16.24.49; Tue, 04 Jun 2019 16:24:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-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=@linaro.org header.s=google header.b=AMsYJVyx; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727747AbfFDXYs (ORCPT + 15 others); Tue, 4 Jun 2019 19:24:48 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:44272 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727732AbfFDXYr (ORCPT ); Tue, 4 Jun 2019 19:24:47 -0400 Received: by mail-pg1-f193.google.com with SMTP id n2so11248923pgp.11 for ; Tue, 04 Jun 2019 16:24:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=obi0eC193ooLcTgT4aYZ/LPXcwma3pGIiVwdm+ZLW/M=; b=AMsYJVyx1E2PhELXukpwNv2QK5/j+6HSE907U0nWeM+7fJtL4qVUauTtrcKUP+BaC+ m2/USB/fiddVi/6q4IG+znP1gen+av+vkXXnsNxm8HJNIpni7r08iMzsp0FuiNV8R7l4 9ZoDiTfjoshVEVjPRbbCIy/iCssV/bDqKmHtiyNdGGOkzD0CW78bP3Fl/jKruoOSqRX0 CXNFL4NnIkhJcABp/CU32yr2Ry2TZrxwIp0JGDcF+kguGOTkgxLbT1csaoGpdA/WGQrV 9edE+Cp8TjvESqm45wBW7DaVmLH+Pnc0gCgp556wP1QNcJtF0VpcYt8e4+9oCRkhZyMj VUzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=obi0eC193ooLcTgT4aYZ/LPXcwma3pGIiVwdm+ZLW/M=; b=QuvBRm9FhmvwaUc8TNAsVgp/xQ317JNVNBdLSmQ+PgHKNrsC9sRqR7zmvXDzZxW9w/ rFZ4ywl5deXZ/nK0+2Rm8tfrMuSCXayO6nfDolCo5wrcHKvWOZFoT4lr5tRyWtZMj7Qr FJ03OkG72tFNk4OziERh21W7ohxd0n06Vr3Aml8lQHWCIzQ5XsQ9Vm/C3PV6umTmsd1k bxczBjT62qcCB6vGbnB9mXSL3Qjc00FqtWyR413y/zrar0XNrmtngRIQSAiRszw6dIFe nBM91jPZ1XUbPSORaszNVtiRBeTcwiNOGZWviceZvfe8zhrK2UEoKsdTg0xDD5kgyekQ 9t6w== X-Gm-Message-State: APjAAAVwVxY10bvLYVO+zFtWkEyCjdtcqe+zAJ1oZPKJb+Qlw4Usbick q1yywrCfhMeTdrEuKrpdpJEK/A== X-Received: by 2002:a63:de43:: with SMTP id y3mr361411pgi.271.1559690686503; Tue, 04 Jun 2019 16:24:46 -0700 (PDT) Received: from localhost.localdomain (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id a12sm19244474pgq.0.2019.06.04.16.24.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Jun 2019 16:24:45 -0700 (PDT) From: Bjorn Andersson To: Kishon Vijay Abraham I Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Evan Green , Marc Gonzalez , Vivek Gautam Subject: [PATCH] phy: qcom-qmp: Correct READY_STATUS poll break condition Date: Tue, 4 Jun 2019 16:24:43 -0700 Message-Id: <20190604232443.3417-1-bjorn.andersson@linaro.org> X-Mailer: git-send-email 2.18.0 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org After issuing a PHY_START request to the QMP, the hardware documentation states that the software should wait for the PCS_READY_STATUS to become 1. With the introduction of c9b589791fc1 ("phy: qcom: Utilize UFS reset controller") an additional 1ms delay was introduced between the start request and the check of the status bit. This greatly increases the chances for the hardware to actually becoming ready before the status bit is read. The result can be seen in that UFS PHY enabling is now reported as a failure in 10% of the boots on SDM845, which is a clear regression from the previous rare/occasional failure. This patch fixes the "break condition" of the poll to check for the correct state of the status bit. Unfortunately PCIe on 8996 and 8998 does not specify the mask_pcs_ready register, which means that the code checks a bit that's always 0. So the patch also fixes these, in order to not regress these targets. Cc: stable@vger.kernel.org Cc: Evan Green Cc: Marc Gonzalez Cc: Vivek Gautam Fixes: 73d7ec899bd8 ("phy: qcom-qmp: Add msm8998 PCIe QMP PHY support") Fixes: e78f3d15e115 ("phy: qcom-qmp: new qmp phy driver for qcom-chipsets") Signed-off-by: Bjorn Andersson --- @Kishon, this is a regression spotted in v5.2-rc1, so please consider applying this towards v5.2. drivers/phy/qualcomm/phy-qcom-qmp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) -- 2.18.0 Reviewed-by: Evan Green diff --git a/drivers/phy/qualcomm/phy-qcom-qmp.c b/drivers/phy/qualcomm/phy-qcom-qmp.c index cd91b4179b10..43abdfd0deed 100644 --- a/drivers/phy/qualcomm/phy-qcom-qmp.c +++ b/drivers/phy/qualcomm/phy-qcom-qmp.c @@ -1074,6 +1074,7 @@ static const struct qmp_phy_cfg msm8996_pciephy_cfg = { .start_ctrl = PCS_START | PLL_READY_GATE_EN, .pwrdn_ctrl = SW_PWRDN | REFCLK_DRV_DSBL, + .mask_pcs_ready = PHYSTATUS, .mask_com_pcs_ready = PCS_READY, .has_phy_com_ctrl = true, @@ -1253,6 +1254,7 @@ static const struct qmp_phy_cfg msm8998_pciephy_cfg = { .start_ctrl = SERDES_START | PCS_START, .pwrdn_ctrl = SW_PWRDN | REFCLK_DRV_DSBL, + .mask_pcs_ready = PHYSTATUS, .mask_com_pcs_ready = PCS_READY, }; @@ -1547,7 +1549,7 @@ static int qcom_qmp_phy_enable(struct phy *phy) status = pcs + cfg->regs[QPHY_PCS_READY_STATUS]; mask = cfg->mask_pcs_ready; - ret = readl_poll_timeout(status, val, !(val & mask), 1, + ret = readl_poll_timeout(status, val, val & mask, 1, PHY_INIT_COMPLETE_TIMEOUT); if (ret) { dev_err(qmp->dev, "phy initialization timed-out\n");