From patchwork Thu May 24 07:23:18 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 919692 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=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="cAiC78LT"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40s1880Snbz9rvt for ; Thu, 24 May 2018 17:23:36 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935623AbeEXHXe (ORCPT ); Thu, 24 May 2018 03:23:34 -0400 Received: from mail-wr0-f193.google.com ([209.85.128.193]:45293 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935346AbeEXHXd (ORCPT ); Thu, 24 May 2018 03:23:33 -0400 Received: by mail-wr0-f193.google.com with SMTP id w3-v6so1097764wrl.12; Thu, 24 May 2018 00:23:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=5w2rncQUNsIVomWo4NCjLjYtYLWyjkAUQbw2ovQf6sM=; b=cAiC78LTOx6HLdztpxJB4sUdwvMiNoI/AABLoTBfjQ35Tc9pCvCi1yfHQQcYnT9CBy GpFZpZWHcpO1O8EEnSXE+BHYEW1d6dDLP7vtEX81xN+leg7LhxpMe8orNEnGnupM4W1j QziCxHE2ZhNcsq0q6onWYY4Tnb7L7FshbUQE/uMPelVL/uzaZKeVGm4j5+dUpdhVVcv2 lvyh1aSTy5Y3vax7Y3wUlRMIPdrUg+4eXdW0upuvh2xtwdkNHqPMxf3TRQ+QpXVsv8HF kfZnGhbPgnsEx1Q37I3M7J+vWxWMncqdqRcECmqyscJNmFauZklWJ2titmxjovQ5IhU/ Y/ZQ== 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=5w2rncQUNsIVomWo4NCjLjYtYLWyjkAUQbw2ovQf6sM=; b=WyAbcJcFPhQ0f/9i2jTon2L+XL/UekO8sihGEFO1kASn8oIYMZVkVBjVDrAHkwrOf5 Z3E/GXFuaHHedCUvVDWf5rqc6lrqnxcuDxR5+ugj3mqCqcdXnRGSG6S5vfhuyrTzRehE b/i2HufoZucOtIE5aslqW2w1dfWjRrH4LE5g8xR3ah++XsihzHGnjuj+trjHZimSgskW QQInKMtzmM/1sCFc11D1tnRzVmJ6sjN+fIMgG1LIctTshF9ODrSs6toBF1OxCon50L/r KxLPH7FcnWRpPB7j0BFWY1Gs14TkxYKoVl0i/aKoPuT2l8gI/7tGStOzwm/AxRN+UjJ3 Tqcg== X-Gm-Message-State: ALKqPweeUiXaMDx0kpjEytobiQc3TaVQtrfN48t/dvSBZn6NIwK5nU40 5timdtveOCrd4T/cKyWTL3B4x7P1 X-Google-Smtp-Source: AB8JxZrhmX5+ZOquD6xtMjff7iWNsskxMjJgk5lq8pokC/nsBa0mkCEavxtRFvaIJggnnDK9J5PpnA== X-Received: by 2002:adf:99f4:: with SMTP id y107-v6mr3734948wrb.277.1527146611537; Thu, 24 May 2018 00:23:31 -0700 (PDT) Received: from kurokawa.lan (ip-86-49-107-50.net.upcbroadband.cz. [86.49.107.50]) by smtp.gmail.com with ESMTPSA id j13-v6sm10997919wre.38.2018.05.24.00.23.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 May 2018 00:23:30 -0700 (PDT) From: Marek Vasut X-Google-Original-From: Marek Vasut To: linux-pci@vger.kernel.org Cc: Marek Vasut , Geert Uytterhoeven , Phil Edworthy , Simon Horman , Wolfram Sang , linux-renesas-soc@vger.kernel.org Subject: [PATCH 1/6] PCI: rcar: Pull bus clock enable/disable from rcar_pcie_get_resources() Date: Thu, 24 May 2018 09:23:18 +0200 Message-Id: <20180524072323.22115-1-marek.vasut+renesas@gmail.com> X-Mailer: git-send-email 2.16.2 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org The rcar_pcie_get_resources() is another misnomer with a side effect. The function does not only get resources, but also enables/disables bus clock. This is forgotten in the probe() function though and if anything in probe() fails after rcar_pcie_get_resources() is called, the bus clock are never disabled. This patch pulls the clock handling out of the rcar_pcie_get_resources() and enables clock after all the resources were requested. Moreover, this patch also always disables the clock in case of failure. Signed-off-by: Marek Vasut Cc: Geert Uytterhoeven Cc: Phil Edworthy Cc: Simon Horman Cc: Wolfram Sang Cc: linux-renesas-soc@vger.kernel.org --- drivers/pci/host/pcie-rcar.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/drivers/pci/host/pcie-rcar.c b/drivers/pci/host/pcie-rcar.c index 8d161563bce8..0879880f7975 100644 --- a/drivers/pci/host/pcie-rcar.c +++ b/drivers/pci/host/pcie-rcar.c @@ -946,32 +946,22 @@ static int rcar_pcie_get_resources(struct rcar_pcie *pcie) dev_err(dev, "cannot get pcie bus clock\n"); return PTR_ERR(pcie->bus_clk); } - err = clk_prepare_enable(pcie->bus_clk); - if (err) - return err; i = irq_of_parse_and_map(dev->of_node, 0); if (!i) { dev_err(dev, "cannot get platform resources for msi interrupt\n"); - err = -ENOENT; - goto err_map_reg; + return -ENOENT; } pcie->msi.irq1 = i; i = irq_of_parse_and_map(dev->of_node, 1); if (!i) { dev_err(dev, "cannot get platform resources for msi interrupt\n"); - err = -ENOENT; - goto err_map_reg; + return -ENOENT; } pcie->msi.irq2 = i; return 0; - -err_map_reg: - clk_disable_unprepare(pcie->bus_clk); - - return err; } static int rcar_pcie_inbound_ranges(struct rcar_pcie *pcie, @@ -1115,22 +1105,28 @@ static int rcar_pcie_probe(struct platform_device *pdev) goto err_pm_put; } + err = clk_prepare_enable(pcie->bus_clk); + if (err) { + dev_err(dev, "failed to enable bus clock: %d\n", err); + goto err_pm_put; + } + err = rcar_pcie_parse_map_dma_ranges(pcie, dev->of_node); if (err) - goto err_pm_put; + goto err_clk_disable; phy_init_fn = of_device_get_match_data(dev); err = phy_init_fn(pcie); if (err) { dev_err(dev, "failed to init PCIe PHY\n"); - goto err_pm_put; + goto err_clk_disable; } /* Failure to get a link might just be that no cards are inserted */ if (rcar_pcie_hw_init(pcie)) { dev_info(dev, "PCIe link down\n"); err = -ENODEV; - goto err_pm_put; + goto err_clk_disable; } data = rcar_pci_read_reg(pcie, MACSR); @@ -1142,16 +1138,19 @@ static int rcar_pcie_probe(struct platform_device *pdev) dev_err(dev, "failed to enable MSI support: %d\n", err); - goto err_pm_put; + goto err_clk_disable; } } err = rcar_pcie_enable(pcie); if (err) - goto err_pm_put; + goto err_clk_disable; return 0; +err_clk_disable: + clk_disable_unprepare(pcie->bus_clk); + err_pm_put: pm_runtime_put(dev); From patchwork Thu May 24 07:23:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 919693 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=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="A49FFWZV"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40s1896Jp6z9rvt for ; Thu, 24 May 2018 17:23:37 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935632AbeEXHXg (ORCPT ); Thu, 24 May 2018 03:23:36 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:50504 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935616AbeEXHXe (ORCPT ); Thu, 24 May 2018 03:23:34 -0400 Received: by mail-wm0-f68.google.com with SMTP id t11-v6so2179695wmt.0; Thu, 24 May 2018 00:23:34 -0700 (PDT) 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=VM4Gw8GuTm9uNYh47GTYF6azng1E6OQKiSD9QDLyFQY=; b=A49FFWZVDEMIQu4Q3SdvId+cZpmWXzQYcnrFa3xbPC8SoH9XOKd6yXHnhJuqgkZSXX v0YMeg/wetRKONyEhQxBlxLZdPHMf2EVDrCEkCC8ddpgBoZOnJuPEkyRCOIM/7qzyfyx MO3u5CH6Vxxw5UMjjdz6d/Lwzez6+quCmpSriUSsqfGOX5xgYT45NjYvcqXLlYcAvwev SxYga6JlccV806YXNU0XHJsVEd06LmlQca50CdUGz+b8bpLrb427qpi6Cdza6qIdLFEg tLEEWeMBWNgFx6ON9vM5/ftbthEIGkgGcpCmMnd5nR1EeLHnA516g++wI0/Tt0K/ExSt zpYg== 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=VM4Gw8GuTm9uNYh47GTYF6azng1E6OQKiSD9QDLyFQY=; b=FTy57YOWffKt+1x/r/3r3GaOdPvHgSdgMK9Cfyn1E/s5y7VcyZL658/Zu7FqaiK0qU do6EvQXVMPzbN6CHi4RZfiGqpRmSmW0Otj3gMuK1cC2qJoUDnpNzVdMxaH4MefH1mHER ByvKkaccI4QjDpstW/hcCfwm2e81GGZX8vQz0kJ329jxsr74ZU9TrqWvU140wfj3gmUt KsMcla3fCDgecq+yYUTzNvMc/CpRjh4jcpWmjEo2vPuGe/Wu6nscCSQlLlprxOyCsgRW mykhzs07uB7MmeZfx7cs5sFeo1vwdm/X4EZg2qWsmSQK4mhJ7PIcrZYJ4aByoGk9VieW X4KQ== X-Gm-Message-State: ALKqPwes+OnzcoyOZWNY8X7ndYO68ajepJjkzhdT+ooHCL6+OPUjWB8M 9jvK8bKVmXlfrihXnSI9AD01664H X-Google-Smtp-Source: AB8JxZpwHFNxRRmHzmjgyJexRHDfg9SxQX6XPP5ciaBSEGAX5FOMDGeDcf/SYJp/IR3ADsbdSYVe5Q== X-Received: by 2002:a7b:c011:: with SMTP id c17-v6mr7010861wmb.78.1527146613239; Thu, 24 May 2018 00:23:33 -0700 (PDT) Received: from kurokawa.lan (ip-86-49-107-50.net.upcbroadband.cz. [86.49.107.50]) by smtp.gmail.com with ESMTPSA id j13-v6sm10997919wre.38.2018.05.24.00.23.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 May 2018 00:23:31 -0700 (PDT) From: Marek Vasut X-Google-Original-From: Marek Vasut To: linux-pci@vger.kernel.org Cc: Marek Vasut , Geert Uytterhoeven , Phil Edworthy , Simon Horman , Wolfram Sang , linux-renesas-soc@vger.kernel.org Subject: [PATCH 2/6] PCI: rcar: Add missing irq_dispose_mapping() into failpath Date: Thu, 24 May 2018 09:23:19 +0200 Message-Id: <20180524072323.22115-2-marek.vasut+renesas@gmail.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180524072323.22115-1-marek.vasut+renesas@gmail.com> References: <20180524072323.22115-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 The rcar_pcie_get_resources() is another misnomer with a side effect. The function does not only get resources, but also maps MSI IRQs via irq_of_parse_and_map(). In case anything fails afterward, the IRQ mapping must be disposed through irq_dispose_mapping() which is not done. This patch handles irq_of_parse_and_map() failures in by disposing of the mapping in rcar_pcie_get_resources() as well as in probe. Signed-off-by: Marek Vasut Cc: Geert Uytterhoeven Cc: Phil Edworthy Cc: Simon Horman Cc: Wolfram Sang Cc: linux-renesas-soc@vger.kernel.org --- drivers/pci/host/pcie-rcar.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/drivers/pci/host/pcie-rcar.c b/drivers/pci/host/pcie-rcar.c index 0879880f7975..6bb1cdec26be 100644 --- a/drivers/pci/host/pcie-rcar.c +++ b/drivers/pci/host/pcie-rcar.c @@ -950,18 +950,25 @@ static int rcar_pcie_get_resources(struct rcar_pcie *pcie) i = irq_of_parse_and_map(dev->of_node, 0); if (!i) { dev_err(dev, "cannot get platform resources for msi interrupt\n"); - return -ENOENT; + err = -ENOENT; + goto err_irq1; } pcie->msi.irq1 = i; i = irq_of_parse_and_map(dev->of_node, 1); if (!i) { dev_err(dev, "cannot get platform resources for msi interrupt\n"); - return -ENOENT; + err = -ENOENT; + goto err_irq2; } pcie->msi.irq2 = i; return 0; + +err_irq2: + irq_dispose_mapping(pcie->msi.irq1); +err_irq1: + return err; } static int rcar_pcie_inbound_ranges(struct rcar_pcie *pcie, @@ -1108,7 +1115,7 @@ static int rcar_pcie_probe(struct platform_device *pdev) err = clk_prepare_enable(pcie->bus_clk); if (err) { dev_err(dev, "failed to enable bus clock: %d\n", err); - goto err_pm_put; + goto err_unmap_msi_irqs; } err = rcar_pcie_parse_map_dma_ranges(pcie, dev->of_node); @@ -1151,6 +1158,10 @@ static int rcar_pcie_probe(struct platform_device *pdev) err_clk_disable: clk_disable_unprepare(pcie->bus_clk); +err_unmap_msi_irqs: + irq_dispose_mapping(pcie->msi.irq2); + irq_dispose_mapping(pcie->msi.irq1); + err_pm_put: pm_runtime_put(dev); From patchwork Thu May 24 07:23:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 919694 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=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="V43coJlw"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40s18C2D4Pz9rvt for ; Thu, 24 May 2018 17:23:39 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935616AbeEXHXh (ORCPT ); Thu, 24 May 2018 03:23:37 -0400 Received: from mail-wm0-f66.google.com ([74.125.82.66]:54347 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935346AbeEXHXg (ORCPT ); Thu, 24 May 2018 03:23:36 -0400 Received: by mail-wm0-f66.google.com with SMTP id f6-v6so2140687wmc.4; Thu, 24 May 2018 00:23:35 -0700 (PDT) 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=LgeIoUfyMRkdTDZMoSqA4TGg42OfM4ptSwPRNMJ/454=; b=V43coJlwnSl1ajr7iwXvrqscxtbj1lDg6fSrVc+H//sC5RttoC80dMbxDe6gkCZhCX jc80oHFlcYv9Wr6GoKueDoFoDMyi8+Ci1Lgm4qBT62gtNMT4SO7L6N1BCr69mCfpHXjO IjfQkxep8fagYxMt9PsDwefNjH2ruNeP7jVcmWC6tYkgDkeIS8nOZHueUQYduI7N4Wje 0tuU0tL/vzvu9KmkCuKG9s4JNsSrBdgZDOhnGnBFeAEWQajHpeSCWTRRTmyD9prn3Ukm Jk3BcOmtVhTEC/KxEPRRVh+r9V7Q++62B0ktQ50Sc0wCtCYb6NXTU5Llq9z19yXRdqq1 ZWDA== 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=LgeIoUfyMRkdTDZMoSqA4TGg42OfM4ptSwPRNMJ/454=; b=glLxmtxMdMP+jZnMXIcXyDCWJ2Y5zfq1P15/42kzGM+hyp1ePqBGzKZtvLzv+NXpKq el1e3TljspZL2px7d4UEllNjDjniXNmMxwtrol3fCMgfoGFAz5VrWa6h5c0Il80VJ5tb Fz7fDwvp41R0Nv52ObMBPmpDK1STQBCRjBUERESJ5ZfhDO+iA9dFdN3eMvO02/YYksY7 bU+BSkK9ovyIEyW3LNZFmAzA6bmxOJAL0Bm9jYBKMs5hdVrnjHja9ilFJ5Z69n5SV64/ q986PGpcxDtdSpRNxb4//MWtXWadOLjQimYDjmRTV5n4x82x39tlO82uz0webh2GDwwu 0y/w== X-Gm-Message-State: ALKqPwccCDON8SssLxbohztmQOkY4IO/jP8Bj6mSFgkeDwpw7T3UMkcf alwsST/4AGPWMISNCN9pEeAX7K2j X-Google-Smtp-Source: AB8JxZpa+d5bUaLeZTbAXXKq7UKDVzKNSCg1MDIJPih6G0ML6jsRQKrYpBMCevqY1/npCfwu76RdZg== X-Received: by 2002:a1c:ec82:: with SMTP id h2-v6mr5960748wmi.137.1527146614572; Thu, 24 May 2018 00:23:34 -0700 (PDT) Received: from kurokawa.lan (ip-86-49-107-50.net.upcbroadband.cz. [86.49.107.50]) by smtp.gmail.com with ESMTPSA id j13-v6sm10997919wre.38.2018.05.24.00.23.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 May 2018 00:23:33 -0700 (PDT) From: Marek Vasut X-Google-Original-From: Marek Vasut To: linux-pci@vger.kernel.org Cc: Marek Vasut , Geert Uytterhoeven , Phil Edworthy , Simon Horman , Wolfram Sang , linux-renesas-soc@vger.kernel.org Subject: [PATCH 3/6] PCI: rcar: Teardown MSI setup if rcar_pcie_enable() fails Date: Thu, 24 May 2018 09:23:20 +0200 Message-Id: <20180524072323.22115-3-marek.vasut+renesas@gmail.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180524072323.22115-1-marek.vasut+renesas@gmail.com> References: <20180524072323.22115-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 If the rcar_pcie_enable() fails and MSIs are enabled, the setup done in rcar_pcie_enable_msi() is never undone. Add a function to tear down the MSI setup by disabling the MSI handling in the PCIe block, deallocating the pages requested for the MSIs and zapping the IRQ mapping. Signed-off-by: Marek Vasut Cc: Geert Uytterhoeven Cc: Phil Edworthy Cc: Simon Horman Cc: Wolfram Sang Cc: linux-renesas-soc@vger.kernel.org --- drivers/pci/host/pcie-rcar.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/drivers/pci/host/pcie-rcar.c b/drivers/pci/host/pcie-rcar.c index 6bb1cdec26be..d6a7e8482dcf 100644 --- a/drivers/pci/host/pcie-rcar.c +++ b/drivers/pci/host/pcie-rcar.c @@ -923,6 +923,28 @@ static int rcar_pcie_enable_msi(struct rcar_pcie *pcie) return err; } +static void rcar_pcie_teardown_msi(struct rcar_pcie *pcie) +{ + struct rcar_msi *msi = &pcie->msi; + int irq, i; + + /* Disable all MSI interrupts */ + rcar_pci_write_reg(pcie, 0, PCIEMSIIER); + + /* Disable address decoding of the MSI interrupt, MSIFE */ + rcar_pci_write_reg(pcie, 0, PCIEMSIALR); + + free_pages(msi->pages, 0); + + for (i = 0; i < INT_PCI_MSI_NR; i++) { + irq = irq_find_mapping(msi->domain, i); + if (irq > 0) + irq_dispose_mapping(irq); + } + + irq_domain_remove(msi->domain); +} + static int rcar_pcie_get_resources(struct rcar_pcie *pcie) { struct device *dev = pcie->dev; @@ -1151,10 +1173,14 @@ static int rcar_pcie_probe(struct platform_device *pdev) err = rcar_pcie_enable(pcie); if (err) - goto err_clk_disable; + goto err_msi_teardown; return 0; +err_msi_teardown: + if (IS_ENABLED(CONFIG_PCI_MSI)) + rcar_pcie_teardown_msi(pcie); + err_clk_disable: clk_disable_unprepare(pcie->bus_clk); From patchwork Thu May 24 07:23:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 919695 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=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="j1BmcNyd"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40s18F5lg9z9rvt for ; Thu, 24 May 2018 17:23:41 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935643AbeEXHXi (ORCPT ); Thu, 24 May 2018 03:23:38 -0400 Received: from mail-wr0-f196.google.com ([209.85.128.196]:35662 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935605AbeEXHXh (ORCPT ); Thu, 24 May 2018 03:23:37 -0400 Received: by mail-wr0-f196.google.com with SMTP id i14-v6so1130495wre.2; Thu, 24 May 2018 00:23:36 -0700 (PDT) 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=zuNeicoflWk0j4S2kF/eI7Kjk1dDDKbWxZYtHokpiTA=; b=j1BmcNydIt3/SJmMb1d50FjZyZ2WLGq1YJUkST7C0RWfEzU9TzL5lvtUOBA0W48fu4 9wWok/ZkeAVuXOcpzrGMbIF55fB/m37lFvhio0WL65K+bju7yUo5X2cTaYAZL/FabXz9 +4d2v9i5ETrFpBmZvvoxggjwAiNbpr4iIpwFHk7SFR0tOWupJf0COWFcnFBPLi5CqlLc y4sR5FfXahTAoWVYYKQOE4d27K2fdLtAMFxhFhNeJeUYXj8YfDvimFU/lHZSetrNCfJc 9Kq7t9Ozf+qfNhobnbC6W/MOYZBZjfwZb7pOTGcFE9HcOiYpQSs6zScFD65eqO8ijVSk 3ukA== 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=zuNeicoflWk0j4S2kF/eI7Kjk1dDDKbWxZYtHokpiTA=; b=JWpDbAwMvjP0YraKX9lqafQvFc2bleD+R2KmNQDLx1WaJTC2FjKLz6lmW/ROjL8+hB k+EuUq0pb4jKB+lIErMcmJolZOx3tSy4YZ6+2Gqwn1ou/j9mYR5ius3T16TB2mT9HbOH ctUL8R4Srk0RvXzOSC8PruF7km+Op53YzKmrWXxGo+tUAt5gB70rBc0+1nQR3ZfXs20e gBZiyZQy4zx74zPKgTO1YpNSbiYnUSzvLdpaKVWnC8rEdnB9h9MPCPQit+/YRynnMxoc +tXLTVMj46NbPKFm0XDE5tCWNFgp5taQgjoMnFQYOAIEt7kZ++vz2yS+sofjkRL8rCwS TtXA== X-Gm-Message-State: ALKqPwd8j2oGfqQ0Ch1uKzt7g7nppCe2gOShRDxUKfAaEFvHbhdlcHSC YhHgf5s96QCICL0cuuRNMMIg677u X-Google-Smtp-Source: AB8JxZqoYxnnUyQ2wYFUXWTPlow0Zdm+V/Ca6mMdk+IeMGSg8q5fkGnwxVKKfYinW9kAneMq3wUfpw== X-Received: by 2002:adf:c3c2:: with SMTP id d2-v6mr349017wrg.68.1527146615880; Thu, 24 May 2018 00:23:35 -0700 (PDT) Received: from kurokawa.lan (ip-86-49-107-50.net.upcbroadband.cz. [86.49.107.50]) by smtp.gmail.com with ESMTPSA id j13-v6sm10997919wre.38.2018.05.24.00.23.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 May 2018 00:23:34 -0700 (PDT) From: Marek Vasut X-Google-Original-From: Marek Vasut To: linux-pci@vger.kernel.org Cc: Marek Vasut , Geert Uytterhoeven , Phil Edworthy , Simon Horman , Wolfram Sang , linux-renesas-soc@vger.kernel.org Subject: [PATCH 4/6] PCI: rcar: Poll more often in rcar_pcie_wait_for_dl() Date: Thu, 24 May 2018 09:23:21 +0200 Message-Id: <20180524072323.22115-4-marek.vasut+renesas@gmail.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180524072323.22115-1-marek.vasut+renesas@gmail.com> References: <20180524072323.22115-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 The data link active signal usually takes ~20 uSec to be asserted, poll the bit more often to avoid useless delays in this function. Use udelay() instead of usleep() for such a small delay as suggested by the timer documentation and because this will be used in atomic context later on when the suspend/resume patches land. Signed-off-by: Marek Vasut Cc: Geert Uytterhoeven Cc: Phil Edworthy Cc: Simon Horman Cc: Wolfram Sang Cc: linux-renesas-soc@vger.kernel.org --- V2: s/content/context in commit message V3: Add cpu_relax() --- drivers/pci/host/pcie-rcar.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/pci/host/pcie-rcar.c b/drivers/pci/host/pcie-rcar.c index d6a7e8482dcf..4843a4dc6059 100644 --- a/drivers/pci/host/pcie-rcar.c +++ b/drivers/pci/host/pcie-rcar.c @@ -546,13 +546,14 @@ static int rcar_pcie_wait_for_phyrdy(struct rcar_pcie *pcie) static int rcar_pcie_wait_for_dl(struct rcar_pcie *pcie) { - unsigned int timeout = 10; + unsigned int timeout = 10000; while (timeout--) { if ((rcar_pci_read_reg(pcie, PCIETSTR) & DATA_LINK_ACTIVE)) return 0; - msleep(5); + udelay(5); + cpu_relax(); } return -ETIMEDOUT; From patchwork Thu May 24 07:23:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 919696 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=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="NQNT1EEy"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40s18G6X73z9s29 for ; Thu, 24 May 2018 17:23:42 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935646AbeEXHXk (ORCPT ); Thu, 24 May 2018 03:23:40 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:52530 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935346AbeEXHXi (ORCPT ); Thu, 24 May 2018 03:23:38 -0400 Received: by mail-wm0-f67.google.com with SMTP id w194-v6so2153642wmf.2; Thu, 24 May 2018 00:23:38 -0700 (PDT) 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=Q0Wt3E32Gn8ylN4OJO9c39DfjKkmP35lC/R4NVr2WmY=; b=NQNT1EEySWpOWtt2ieC7lgvM/v0p28r442Ze/m2KT0D4xsdGXN7mwtxSW4x4Cll4IZ Z6dkXw/RLPsdm6KALthuh4uYuk8nzlGiUt0oCGlx5h+F38Xr9zxEfU4hzPOWRU7ZoL6M NnXThrqWh2UtIzONrWOgZ4E29NrDl4GmO+J8hVfolTKoZKbjbWUMsfAq+yIKW8L9E06B qzAADYYuz8XoD7JaKQhramA5hOieqkt1p/AYj8jkiRmTBfr5kJ7KFiBqR3V2GAdkjz/r 0cFwsEWz5NTmoYf9QiW6jHjvKepSWCXyupNh3ad4EeMsX7KtxybmFQjXA28wtT8eFGZo Mh1Q== 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=Q0Wt3E32Gn8ylN4OJO9c39DfjKkmP35lC/R4NVr2WmY=; b=N5xChQkHH/K0e+HOH2AeqbYf2oV1Zbx8KKaOz4GdTmR3rB4TrptI5hE10SSsDSl1CG ns+L2TKrHLvSkX/Eli567WSAY69jgHSp3I9VEXNAI9feuNdJqBXwHJiakMKHKFWWfj0a FR7EBQ/bAA05Xa3Ss4QNxKisTe87W4Kxg7DjfcKwL6eUsA/8vuX1qv/hQhzCHg51lCDu +nXWnvVxk/XKN56Ieaw0TvIUIi+OUtWAfzqJe77XQQJRZUYWXPOI9TWGVhDpXAnjeV3B MINxc7zA+VjvHi0J9pBX3MmAakvjMft1eA+XsPHrYG3jcm3KulBJsjy0iDHaTxBxajkK qVwQ== X-Gm-Message-State: ALKqPwfIKgGi6AH+g8U666dj3t90tLdE1ETi6d6o8rB3XzKqRDCjByZs igGqpwApG3DES8VD5Tw20ebcNEQ2 X-Google-Smtp-Source: AB8JxZqU1x3fnxMN6FRKVk9c9ZPn4Efr76sGxbvMpo+s9mEsHY3yH7uXvoISEXoW19zWWkP5X47Ukw== X-Received: by 2002:a1c:b884:: with SMTP id i126-v6mr5835959wmf.30.1527146617125; Thu, 24 May 2018 00:23:37 -0700 (PDT) Received: from kurokawa.lan (ip-86-49-107-50.net.upcbroadband.cz. [86.49.107.50]) by smtp.gmail.com with ESMTPSA id j13-v6sm10997919wre.38.2018.05.24.00.23.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 May 2018 00:23:36 -0700 (PDT) From: Marek Vasut X-Google-Original-From: Marek Vasut To: linux-pci@vger.kernel.org Cc: Marek Vasut , Geert Uytterhoeven , Phil Edworthy , Simon Horman , Wolfram Sang , linux-renesas-soc@vger.kernel.org Subject: [PATCH 5/6] PCI: rcar: Remove IRQ mappings in rcar_pcie_enable_msi failpath Date: Thu, 24 May 2018 09:23:22 +0200 Message-Id: <20180524072323.22115-5-marek.vasut+renesas@gmail.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180524072323.22115-1-marek.vasut+renesas@gmail.com> References: <20180524072323.22115-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 The rcar_pcie_enable_msi() creates IRQ mappings using irq_create_mapping() before requesting the IRQs using devm_request_irq(). If devm_request_irq() fails for some reason, rcar_pcie_enable_msi() does not remove the mapping. Pull out the code for disposing IRQ mappings from rcar_pcie_teardown_msi() into a separate function and call it from both rcar_pcie_teardown_msi() and rcar_pcie_enable_msi() failpath to remove the mappings correctly. Signed-off-by: Marek Vasut Reported-by: Geert Uytterhoeven Cc: Geert Uytterhoeven Cc: Phil Edworthy Cc: Simon Horman Cc: Wolfram Sang Cc: linux-renesas-soc@vger.kernel.org --- drivers/pci/host/pcie-rcar.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/drivers/pci/host/pcie-rcar.c b/drivers/pci/host/pcie-rcar.c index 4843a4dc6059..636c3c5095d2 100644 --- a/drivers/pci/host/pcie-rcar.c +++ b/drivers/pci/host/pcie-rcar.c @@ -866,6 +866,20 @@ static const struct irq_domain_ops msi_domain_ops = { .map = rcar_msi_map, }; +static void rcar_pcie_unmap_msi(struct rcar_pcie *pcie) +{ + struct rcar_msi *msi = &pcie->msi; + int i, irq; + + for (i = 0; i < INT_PCI_MSI_NR; i++) { + irq = irq_find_mapping(msi->domain, i); + if (irq > 0) + irq_dispose_mapping(irq); + } + + irq_domain_remove(msi->domain); +} + static int rcar_pcie_enable_msi(struct rcar_pcie *pcie) { struct device *dev = pcie->dev; @@ -920,14 +934,13 @@ static int rcar_pcie_enable_msi(struct rcar_pcie *pcie) return 0; err: - irq_domain_remove(msi->domain); + rcar_pcie_unmap_msi(pcie); return err; } static void rcar_pcie_teardown_msi(struct rcar_pcie *pcie) { struct rcar_msi *msi = &pcie->msi; - int irq, i; /* Disable all MSI interrupts */ rcar_pci_write_reg(pcie, 0, PCIEMSIIER); @@ -937,13 +950,7 @@ static void rcar_pcie_teardown_msi(struct rcar_pcie *pcie) free_pages(msi->pages, 0); - for (i = 0; i < INT_PCI_MSI_NR; i++) { - irq = irq_find_mapping(msi->domain, i); - if (irq > 0) - irq_dispose_mapping(irq); - } - - irq_domain_remove(msi->domain); + rcar_pcie_unmap_msi(pcie); } static int rcar_pcie_get_resources(struct rcar_pcie *pcie) From patchwork Thu May 24 07:23:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Vasut X-Patchwork-Id: 919697 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=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-pci-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="uIN7kD1w"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40s18H45jRz9rvt for ; Thu, 24 May 2018 17:23:43 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935652AbeEXHXl (ORCPT ); Thu, 24 May 2018 03:23:41 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:50528 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935605AbeEXHXj (ORCPT ); Thu, 24 May 2018 03:23:39 -0400 Received: by mail-wm0-f65.google.com with SMTP id t11-v6so2180276wmt.0; Thu, 24 May 2018 00:23:39 -0700 (PDT) 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=DyPlIi4Ywkd/ObZcL9NeUKW1y8mnQUHBPSDvnJCTobQ=; b=uIN7kD1wWaj4dwQpUp9IMjxKpbnVPWzf9+vbKfY64A0ycF/ax8tkvVbEKNtmg3A6Ce MYP9apLS2ivARLxKgkyff7CAhj/bpwjcWnb/UfpAeGKuLf+gOh3vAEKI0j+ouwykrFHr kmF1wVrj/TX3bCRx2+MF32MNBtFtwk4rYRNUW+2q5oExryZJsIRmbx2HfMlVIPNxa/ys HKXFV/8Ee2SE/UHyVxiio5V7a2NahbE5sRxicEzfVVbLRbrlJ4B91xwtmFxI1gs4SLMw LX3RMGnXafelsmaWutyM/LnKszZhlB5r9M+Bxane/i5orho5Eu305n0uUsc9blB4LBNt +9WA== 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=DyPlIi4Ywkd/ObZcL9NeUKW1y8mnQUHBPSDvnJCTobQ=; b=hb+Pyx5baIEuQ7Aeqopa9HGQiTrmgDJIXYH51OB65ANJXA6pChaLZLci/L9vQiGlYw Rq9UZT3N579i/Gi7V6FPW20rbpgYph27fUx9MYNq2yelqqQUPDU07FBev7r1XjUR2hZ+ qpsVYaGCFt/17QaJZz9tOO6g+R2jhEE4xaW8ZLINJuMoaQO7HHuWOcKyF75qI+k0qqSj 8a41pjolfNb3RA31DcV3Ui2Y+pnJrNVIyKvNwnbIHKTGcem0B3DbPqfsLrWH7W5O2F7d ScQyx+vjHZRoxtxn0cLNRumPdVJoySZHaUm9kqQxdjT5pSG9ZrjUQClHD7rsSd5si/Or WvRg== X-Gm-Message-State: ALKqPwd6faLxB4xEPXzveQ6QNgxHKFGq3HFMSzHAf036GsnkPHOeMykg BrqtkmPCOymB8f0RP9pgk39R9TEF X-Google-Smtp-Source: AB8JxZoFhxyl/YEFU2WiBi5HjamG7rrZEKaTbb5t1rDuR86yDzzCbtathRLE1Y72NJ2AU3OQe8vqQw== X-Received: by 2002:a1c:c588:: with SMTP id v130-v6mr5750463wmf.135.1527146618287; Thu, 24 May 2018 00:23:38 -0700 (PDT) Received: from kurokawa.lan (ip-86-49-107-50.net.upcbroadband.cz. [86.49.107.50]) by smtp.gmail.com with ESMTPSA id j13-v6sm10997919wre.38.2018.05.24.00.23.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 May 2018 00:23:37 -0700 (PDT) From: Marek Vasut X-Google-Original-From: Marek Vasut To: linux-pci@vger.kernel.org Cc: Marek Vasut , Geert Uytterhoeven , Phil Edworthy , Simon Horman , Wolfram Sang , linux-renesas-soc@vger.kernel.org Subject: [PATCH 6/6] PCI: rcar: Shut the PHY down in failpath Date: Thu, 24 May 2018 09:23:23 +0200 Message-Id: <20180524072323.22115-6-marek.vasut+renesas@gmail.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180524072323.22115-1-marek.vasut+renesas@gmail.com> References: <20180524072323.22115-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 If anything fails past phy_init_fn() and the system is a Gen3 with a PHY, the PHY will be left on and inited. This is caused by the phy_init_fn, which is in fact a pointer to rcar_pcie_phy_init_gen3() function, which starts the PHY, yet has no counterpart in the failpath. Add that counterpart. Signed-off-by: Marek Vasut Cc: Geert Uytterhoeven Cc: Phil Edworthy Cc: Simon Horman Cc: Wolfram Sang Cc: linux-renesas-soc@vger.kernel.org Fixes: 517ca93a7159 ("PCI: rcar: Add R-Car gen3 PHY support") --- drivers/pci/host/pcie-rcar.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/pci/host/pcie-rcar.c b/drivers/pci/host/pcie-rcar.c index 636c3c5095d2..695781934f0a 100644 --- a/drivers/pci/host/pcie-rcar.c +++ b/drivers/pci/host/pcie-rcar.c @@ -1163,7 +1163,7 @@ static int rcar_pcie_probe(struct platform_device *pdev) if (rcar_pcie_hw_init(pcie)) { dev_info(dev, "PCIe link down\n"); err = -ENODEV; - goto err_clk_disable; + goto err_phy_shutdown; } data = rcar_pci_read_reg(pcie, MACSR); @@ -1175,7 +1175,7 @@ static int rcar_pcie_probe(struct platform_device *pdev) dev_err(dev, "failed to enable MSI support: %d\n", err); - goto err_clk_disable; + goto err_phy_shutdown; } } @@ -1189,6 +1189,12 @@ static int rcar_pcie_probe(struct platform_device *pdev) if (IS_ENABLED(CONFIG_PCI_MSI)) rcar_pcie_teardown_msi(pcie); +err_phy_shutdown: + if (pcie->phy) { + phy_power_off(pcie->phy); + phy_exit(pcie->phy); + } + err_clk_disable: clk_disable_unprepare(pcie->bus_clk);