From patchwork Wed Nov 8 09:28:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 10048091 X-Patchwork-Delegate: horms@verge.net.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 1034A6032D for ; Wed, 8 Nov 2017 09:30:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0B4F82A4AD for ; Wed, 8 Nov 2017 09:30:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F423E2A4ED; Wed, 8 Nov 2017 09:30:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 70C782A4AD for ; Wed, 8 Nov 2017 09:30:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751623AbdKHJal (ORCPT ); Wed, 8 Nov 2017 04:30:41 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:55287 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751650AbdKHJ2V (ORCPT ); Wed, 8 Nov 2017 04:28:21 -0500 Received: by mail-wm0-f66.google.com with SMTP id r68so9285921wmr.3; Wed, 08 Nov 2017 01:28:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=Pkf+Ayq302cLAsRMHEEOUYg4kIxD67V/XBh4y0lDRJc=; b=UeSxHRDSPf4HbNZkHAhnxzMBgGSKM5ueM3qY6ooWn5WTGEKbyFk22CodkwVhBz6JCn eIYAbhMcHFsoFibjDhuEU/bkpQjQNLYEUzjrAqbvIWggwfqCP1ryNEU6Mu0sV0n1/62U v2HNWg5PGRXtioUm96HoDT1+oSnoqXb+em4ac/VDrKM53wr9dWIuFcO+tF8shtUiNPtd Bbb+O+vc2eZEO5ePUy5MUsi3s5XTwzdBG1eagdY/gNOUe8uuHq5YzgkpMQnwFtzn+YzL 5lXcCdlYVDSSAfkO5zFU16tYE3BtrcXszCy+ww/zBRpUc58xilQ4yiuKmCKo4F99V/W5 4k8Q== 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=Pkf+Ayq302cLAsRMHEEOUYg4kIxD67V/XBh4y0lDRJc=; b=QhcR9O3FGEd47DUVbao4VlGSRLsGpU48WiRBdEnSjutUDk82VGX/YbjaM17VZTDLm4 Y+j4ebVb5tKdv7A/EMiWw4IA0X/yBgq6Ok/oaz5jkXFIUeQGJeuJ6iirsuxfkr4w0npY CIG7r2MZmyZKr2sq5KNQHqxf4T8xPC7unwhy5FulDEKXU9b5KVgCeOCwLh8SZ+bMjgmi VpKn2Wij0E8YXWKJH72YgACbWKH89RpUze4L1fjhl8SyJJyRgMEVP5FxOfUJCCg73BJ3 aAx6fEDQBPkQnYJqk9fi5xND2t7lLTRkH/PfE4burVW9VLg9bC+gP664alBjAd3sWMU1 F6WQ== X-Gm-Message-State: AJaThX6Y+iQ2yBV+pFMAotn4uH0FBdjgxptzUy+zM4aZNFR8Z4YrpVGp lGjjUcH3pkVtwKZr2g4a7OELjcI3 X-Google-Smtp-Source: ABhQp+Susm3cGiKx3GgTfK5/OKMla0NfG8jyu/cczaiY36G/K8eLEqu9pBqdPF7ZbvbzNSzbd311HQ== X-Received: by 10.28.31.76 with SMTP id f73mr1586188wmf.139.1510133299582; Wed, 08 Nov 2017 01:28:19 -0800 (PST) Received: from kurokawa.lan (ip-86-49-107-50.net.upcbroadband.cz. [86.49.107.50]) by smtp.gmail.com with ESMTPSA id o135sm4489691wmg.1.2017.11.08.01.28.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 Nov 2017 01:28:18 -0800 (PST) From: Marek Vasut X-Google-Original-From: Marek Vasut To: linux-pci@vger.kernel.org Cc: Kazufumi Ikeda , Gaku Inami , Marek Vasut , Geert Uytterhoeven , Simon Horman , Wolfram Sang , linux-renesas-soc@vger.kernel.org Subject: [PATCH 1/3] PCI: rcar: Add the initialization of PCIe link in resume_noirq Date: Wed, 8 Nov 2017 10:28:04 +0100 Message-Id: <20171108092806.10335-1-marek.vasut+renesas@gmail.com> X-Mailer: git-send-email 2.11.0 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Kazufumi Ikeda Reestablish the PCIe link very early in the resume process in case it went down to prevent PCI accesses from hanging the bus. Such accesses can happen early in the PCI resume process, in the resume_noirq, thus the link must be reestablished in the resume_noirq callback of the driver. Signed-off-by: Kazufumi Ikeda Signed-off-by: Gaku Inami Signed-off-by: Marek Vasut Cc: Geert Uytterhoeven Cc: Simon Horman Cc: Wolfram Sang Cc: linux-renesas-soc@vger.kernel.org --- drivers/pci/host/pcie-rcar.c | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/drivers/pci/host/pcie-rcar.c b/drivers/pci/host/pcie-rcar.c index 889603783f01..aa588a7d4811 100644 --- a/drivers/pci/host/pcie-rcar.c +++ b/drivers/pci/host/pcie-rcar.c @@ -43,6 +43,7 @@ /* Transfer control */ #define PCIETCTLR 0x02000 +#define DL_DOWN (1 << 3) #define CFINIT 1 #define PCIETSTR 0x02004 #define DATA_LINK_ACTIVE 1 @@ -529,7 +530,7 @@ static void phy_write_reg(struct rcar_pcie *pcie, phy_wait_for_ack(pcie); } -static int rcar_pcie_wait_for_dl(struct rcar_pcie *pcie) +static int rcar_pcie_wait_for_dl(struct rcar_pcie *pcie, int atomic) { unsigned int timeout = 10; @@ -537,7 +538,10 @@ static int rcar_pcie_wait_for_dl(struct rcar_pcie *pcie) if ((rcar_pci_read_reg(pcie, PCIETSTR) & DATA_LINK_ACTIVE)) return 0; - msleep(5); + if (atomic) + mdelay(5); + else + msleep(5); } return -ETIMEDOUT; @@ -595,7 +599,7 @@ static int rcar_pcie_hw_init(struct rcar_pcie *pcie) rcar_pci_write_reg(pcie, CFINIT, PCIETCTLR); /* This will timeout if we don't have a link. */ - err = rcar_pcie_wait_for_dl(pcie); + err = rcar_pcie_wait_for_dl(pcie, 0); if (err) return err; @@ -1110,6 +1114,7 @@ static int rcar_pcie_probe(struct platform_device *pdev) pcie = pci_host_bridge_priv(bridge); pcie->dev = dev; + platform_set_drvdata(pdev, pcie); INIT_LIST_HEAD(&pcie->resources); @@ -1173,10 +1178,30 @@ static int rcar_pcie_probe(struct platform_device *pdev) return err; } +static int rcar_pcie_resume_noirq(struct device *dev) +{ + struct rcar_pcie *pcie = dev_get_drvdata(dev); + u32 val = rcar_pci_read_reg(pcie, PMSR); + int ret = 0; + + if ((val == 0) || (rcar_pci_read_reg(pcie, PCIETCTLR) & DL_DOWN)) { + /* Re-establish the PCIe link */ + rcar_pci_write_reg(pcie, CFINIT, PCIETCTLR); + ret = rcar_pcie_wait_for_dl(pcie, 1); + } + + return ret; +} + +static const struct dev_pm_ops rcar_pcie_pm_ops = { + .resume_noirq = rcar_pcie_resume_noirq, +}; + static struct platform_driver rcar_pcie_driver = { .driver = { .name = "rcar-pcie", .of_match_table = rcar_pcie_of_match, + .pm = &rcar_pcie_pm_ops, .suppress_bind_attrs = true, }, .probe = rcar_pcie_probe,