From patchwork Thu Aug 24 05:04:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oza Pawandeep X-Patchwork-Id: 9919041 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 1AA2360353 for ; Thu, 24 Aug 2017 05:06:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0C83D28B38 for ; Thu, 24 Aug 2017 05:06:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0123C28B40; Thu, 24 Aug 2017 05:06:18 +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=-2.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7707728B38 for ; Thu, 24 Aug 2017 05:06:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=0IVal8d8AUMnEq2GZKtKppvOUkxFg5b9HaGshO0N498=; b=Oi5USshydDYLSE 8rPsOBu7e1eNAVoKHMCZNkVqAsYrCYhb6Hy0OiqW7jLWXSvpjEscpWEQQV9j9f3roTFZekSeTi2Zd dKoRSV4XSzTgZiOHnETqemCfYQqlT1y6BoR44F0ydLkoctK/NmN++wzOxDG839ho1ICMTXukLMpGt GI4bI68Gh/6gNlRELxeNQfEBF1Bf49GSnOd1DXbnxoKv1Lo2slRKnxbkip1zNThq+utxWW5d405nb p9DVQfoYWW1HZoOEuD21ma2BBmPehajquFcSkStyJ0e2TowamODSsXlmdG0FX7POzEo4zz+JYIACr X5MVe2mgR8i91hZ5WU7Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dkkLL-0002Ou-Tp; Thu, 24 Aug 2017 05:06:11 +0000 Received: from mail-wm0-x231.google.com ([2a00:1450:400c:c09::231]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dkkKM-0000LE-Vi for linux-arm-kernel@lists.infradead.org; Thu, 24 Aug 2017 05:05:17 +0000 Received: by mail-wm0-x231.google.com with SMTP id r134so12325645wmf.0 for ; Wed, 23 Aug 2017 22:04:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=Kb/QryCzir9/u0J0kFUj7eT/cpvKVGubZ7lzISsPyYA=; b=aLpZSUNfedNab5i9yV8cJYSsZSR7n+jGVCazMQaWa1HxY5ti2l2Ft1umhbX7sj+Qba 8U4tV6NGuNuTf02Ml0Np0yo/FI1/77wkELPQ6t91ZBxP83w4/fD1nvpCkDdo//Vj5rYI /X3ATN+7Y/+xVFDROvjGGUUt6eZjh2Nju5qH8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=Kb/QryCzir9/u0J0kFUj7eT/cpvKVGubZ7lzISsPyYA=; b=mpIH2aUu6ylNy0z26fp2F5zorgi/0wqjfd6ufpPWWwzZD27vkul/3dY/mKcPrLBu2w 35WoAN9OXdtGKEPHla/SoCgcDWgbnVPQPmX0a4Rgb1fYNz9OekfXN3Vqn6pApidGd/by m7ZrEYrPN/w8s6O9CITE8RT5XSzkW+Gi5ypnuPiEr4j3bzis8gvxsx8xHkhCrkcxkP1N PsTN4hiIXfWvJKSZIbOAPm9t860vKOc7UFRhiw+tQiYuzn1F7tIYyEDNG7RYttTOgTZk X4ujTnLzguUS9K1x9UIVc7n+21oqdBfwrwD3Xv4grbyocqSFws1f/nJEfUPyNXCx8A5O F6vg== X-Gm-Message-State: AHYfb5iqlRl9azCfcHISTmXGtYcjho0QJxt+bIrEodDvbqhUQl+0XVgE XOWpnSI43i20jr5L X-Received: by 10.28.23.79 with SMTP id 76mr2668501wmx.149.1503551091857; Wed, 23 Aug 2017 22:04:51 -0700 (PDT) Received: from anjanavk-OptiPlex-7010.dhcp.avagotech.net ([192.19.237.250]) by smtp.gmail.com with ESMTPSA id n67sm3602691wmi.43.2017.08.23.22.04.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 23 Aug 2017 22:04:51 -0700 (PDT) From: Oza Pawandeep To: Bjorn Helgaas , , Rob Herring , Mark Rutland , Ray Jui , Scott Branden , Jon Mason , bcm-kernel-feedback-list@broadcom.com, Oza Pawandeep , Andy Gospodarek , linux-pci@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Oza Pawandeep Subject: [PATCH v8 3/3] PCI: iproc: add device shutdown for PCI RC Date: Thu, 24 Aug 2017 10:34:26 +0530 Message-Id: <1503551066-23212-4-git-send-email-oza.oza@broadcom.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1503551066-23212-1-git-send-email-oza.oza@broadcom.com> References: <1503551066-23212-1-git-send-email-oza.oza@broadcom.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170823_220511_573092_11034404 X-CRM114-Status: GOOD ( 15.36 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP PERST must be asserted around ~500ms before the reboot is applied. During soft reset (e.g., "reboot" from Linux) on some iproc based SOCs LCPLL clock and PERST both goes off simultaneously. This will cause certain Endpoints Intel NVMe not get detected, upon next boot sequence. This is specifically happening with Intel P3700 400GB series. Endpoint is expecting the clock for some amount of time after PERST is asserted, which is not happening in Stingray (iproc based SOC). This causes NVMe to behave in undefined way. On the contrary, Intel x86 boards will have ref clock running, so we do not see this behavior there. Besides, PCI spec does not stipulate about such timings. In-fact it does not tell us, whether PCIe device should consider refclk to be available or not to be. It is completely up to vendor to design their EP the way they want with respect to ref clock availability. 500ms is just based on the observation and taken as safe margin. This patch adds platform shutdown where it should be called in device_shutdown while reboot command is issued. So in sequence first Endpoint Shutdown (e.g. nvme_shutdown) followed by RC shutdown, which issues safe PERST assertion. Signed-off-by: Oza Pawandeep Reviewed-by: Ray Jui Reviewed-by: Scott Branden diff --git a/drivers/pci/host/pcie-iproc-platform.c b/drivers/pci/host/pcie-iproc-platform.c index 2253119..a5073a9 100644 --- a/drivers/pci/host/pcie-iproc-platform.c +++ b/drivers/pci/host/pcie-iproc-platform.c @@ -134,6 +134,13 @@ static int iproc_pcie_pltfm_remove(struct platform_device *pdev) return iproc_pcie_remove(pcie); } +static void iproc_pcie_pltfm_shutdown(struct platform_device *pdev) +{ + struct iproc_pcie *pcie = platform_get_drvdata(pdev); + + iproc_pcie_shutdown(pcie); +} + static struct platform_driver iproc_pcie_pltfm_driver = { .driver = { .name = "iproc-pcie", @@ -141,6 +148,7 @@ static int iproc_pcie_pltfm_remove(struct platform_device *pdev) }, .probe = iproc_pcie_pltfm_probe, .remove = iproc_pcie_pltfm_remove, + .shutdown = iproc_pcie_pltfm_shutdown, }; module_platform_driver(iproc_pcie_pltfm_driver); diff --git a/drivers/pci/host/pcie-iproc.c b/drivers/pci/host/pcie-iproc.c index 37f4adf..cbdabe8 100644 --- a/drivers/pci/host/pcie-iproc.c +++ b/drivers/pci/host/pcie-iproc.c @@ -659,7 +659,7 @@ static int iproc_pcie_config_write32(struct pci_bus *bus, unsigned int devfn, .write = iproc_pcie_config_write32, }; -static void iproc_pcie_reset(struct iproc_pcie *pcie) +static void iproc_pcie_perst_ctrl(struct iproc_pcie *pcie, bool assert) { u32 val; @@ -671,19 +671,26 @@ static void iproc_pcie_reset(struct iproc_pcie *pcie) if (pcie->ep_is_internal) return; - /* - * Select perst_b signal as reset source. Put the device into reset, - * and then bring it out of reset - */ - val = iproc_pcie_read_reg(pcie, IPROC_PCIE_CLK_CTRL); - val &= ~EP_PERST_SOURCE_SELECT & ~EP_MODE_SURVIVE_PERST & - ~RC_PCIE_RST_OUTPUT; - iproc_pcie_write_reg(pcie, IPROC_PCIE_CLK_CTRL, val); - udelay(250); - - val |= RC_PCIE_RST_OUTPUT; - iproc_pcie_write_reg(pcie, IPROC_PCIE_CLK_CTRL, val); - msleep(100); + if (assert) { + val = iproc_pcie_read_reg(pcie, IPROC_PCIE_CLK_CTRL); + val &= ~EP_PERST_SOURCE_SELECT & ~EP_MODE_SURVIVE_PERST & + ~RC_PCIE_RST_OUTPUT; + iproc_pcie_write_reg(pcie, IPROC_PCIE_CLK_CTRL, val); + udelay(250); + } else { + val = iproc_pcie_read_reg(pcie, IPROC_PCIE_CLK_CTRL); + val |= RC_PCIE_RST_OUTPUT; + iproc_pcie_write_reg(pcie, IPROC_PCIE_CLK_CTRL, val); + msleep(100); + } +} + +int iproc_pcie_shutdown(struct iproc_pcie *pcie) +{ + iproc_pcie_perst_ctrl(pcie, true); + msleep(500); + + return 0; } static int iproc_pcie_check_link(struct iproc_pcie *pcie) @@ -1365,7 +1372,8 @@ int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res) goto err_exit_phy; } - iproc_pcie_reset(pcie); + iproc_pcie_perst_ctrl(pcie, true); + iproc_pcie_perst_ctrl(pcie, false); if (pcie->need_ob_cfg) { ret = iproc_pcie_map_ranges(pcie, res); diff --git a/drivers/pci/host/pcie-iproc.h b/drivers/pci/host/pcie-iproc.h index 0bbe2ea..a6b55ce 100644 --- a/drivers/pci/host/pcie-iproc.h +++ b/drivers/pci/host/pcie-iproc.h @@ -110,6 +110,7 @@ struct iproc_pcie { int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res); int iproc_pcie_remove(struct iproc_pcie *pcie); +int iproc_pcie_shutdown(struct iproc_pcie *pcie); #ifdef CONFIG_PCIE_IPROC_MSI int iproc_msi_init(struct iproc_pcie *pcie, struct device_node *node);