From patchwork Fri Nov 10 21:58:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 10053847 X-Patchwork-Delegate: bhelgaas@google.com 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 000186032D for ; Fri, 10 Nov 2017 21:59:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E8FA62929B for ; Fri, 10 Nov 2017 21:59:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DD9042B11C; Fri, 10 Nov 2017 21:59:06 +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=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI autolearn=unavailable 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 E9E1B2ACE8 for ; Fri, 10 Nov 2017 21:59:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751206AbdKJV7D (ORCPT ); Fri, 10 Nov 2017 16:59:03 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:32787 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751186AbdKJV7C (ORCPT ); Fri, 10 Nov 2017 16:59:02 -0500 Received: by mail-wm0-f66.google.com with SMTP id r68so7277934wmr.0; Fri, 10 Nov 2017 13:59:01 -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:in-reply-to:references; bh=FAwD9irxVM1nnqNDpU+wde3i4owX2fPmdQXUlQsDTWA=; b=J/8m/USqtderkrWEY5JRiEiZU7K34wQwsaRj1Kur+6Uw5tHmyf8GnG7MzK07MXXupR jxhNe4yMbFtn/lVFjVsUk0gUGc711H8ruZpyEqt3o0q1oG8D9iNPgFBZ2XnEr21oWBHO H375gRvfMXcJ2V6A6L/CU5lN+QI8Sc/YyvfSXzTD0Nhq+uOfXkxgqdmAMJjaIA7VAZww naFhOaPwj04fE6T1Pwal3C9f8Jqg1tuwXwhteXbbDza9A8sW4A6tgGFNnSdtzvFXOkEB 63NTiWAq4lL+eJgygkEeLnLDGulSNEu2fRHa0J/66hJDsC9vQ5o9lG6T3FbmJwQ9S+/D c/CQ== 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:in-reply-to :references; bh=FAwD9irxVM1nnqNDpU+wde3i4owX2fPmdQXUlQsDTWA=; b=gH0ax8W1DJvxvxcOs4ePCOFbck0Lo9wHpQ2kBOAL4JVFLtL1hQOKJBUM80uxCZqCTu Epb21VeOh7ZcTE5PVaoFwUaydeKjZRAdS+atM/YWLMZN3oe+7YyZJgd2Qdgp9jG7Y6dg zuxqxRMxKA+JxhrOJRXia26+NM3uuI5Svh/Zl2w3R4W6OLsGiY6aV0j0jx2JQAuMaC/M BEg0Ljx7kfuZbTtuoyFOLa3Q9o+PSsUmIvBd9hIlDCN233Ijjgz1oIzyzvifG2U1VmTC g9g/1lcKR6nhaKP/PB5/FL/HoC9O8B453GxQUjso8todPuP8fKwHeINELJ39Js8E7oSE DAIw== X-Gm-Message-State: AJaThX788wA2exJcKWTxfVHIeBwl3++qFCHMYH7NiH7OpnR5VCbxrmQd iUMHtBTP1/Opne4nngp5KS1k+2Xd X-Google-Smtp-Source: AGs4zMZlnfv5FDW4VgDcM5ziLTMpbcgCBZVYOdSSovfa7ha4ctNWEePtqFocYGjtYdXq9v8+oz5vHw== X-Received: by 10.28.222.70 with SMTP id v67mr1128253wmg.99.1510351140870; Fri, 10 Nov 2017 13:59:00 -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 c3sm4560784wrd.44.2017.11.10.13.58.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 10 Nov 2017 13:59:00 -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 , Phil Edworthy , Simon Horman , Wolfram Sang , linux-renesas-soc@vger.kernel.org Subject: [PATCH V2 3/5] PCI: rcar: Add the initialization of PCIe link in resume_noirq Date: Fri, 10 Nov 2017 22:58:41 +0100 Message-Id: <20171110215843.432-4-marek.vasut+renesas@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171110215843.432-1-marek.vasut+renesas@gmail.com> References: <20171110215843.432-1-marek.vasut+renesas@gmail.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@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: Phil Edworthy Cc: Simon Horman Cc: Wolfram Sang Cc: linux-renesas-soc@vger.kernel.org Acked-by: Simon Horman --- V2: - Use BIT() macro for (1 << n) - Since polling in rcar_pcie_wait_for_dl() uses udelay(), do not add extra changes to this function anymore - Make resume_noirq return early and clean up parenthesis therein --- drivers/pci/host/pcie-rcar.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/drivers/pci/host/pcie-rcar.c b/drivers/pci/host/pcie-rcar.c index 811e8194ef74..ab61829db389 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 BIT(3) #define CFINIT 1 #define PCIETSTR 0x02004 #define DATA_LINK_ACTIVE 1 @@ -1107,6 +1108,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); @@ -1167,10 +1169,28 @@ 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); + + if (rcar_pci_read_reg(pcie, PMSR) && + !(rcar_pci_read_reg(pcie, PCIETCTLR) & DL_DOWN)) + return 0; + + /* Re-establish the PCIe link */ + rcar_pci_write_reg(pcie, CFINIT, PCIETCTLR); + return rcar_pcie_wait_for_dl(pcie); +} + +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,