From patchwork Tue Apr 13 14:22:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Baryshkov X-Patchwork-Id: 420218 Delivered-To: patch@linaro.org Received: by 2002:a17:906:6d12:0:0:0:0 with SMTP id m18csp2557558ejr; Tue, 13 Apr 2021 07:22:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxJvC1sziyOhg9C1olpVcNMdZLH6SOP5CyvPuspLXbFnczPgQ735EveZaVnc6eno0/aABtr X-Received: by 2002:a17:906:28c9:: with SMTP id p9mr13857386ejd.111.1618323757123; Tue, 13 Apr 2021 07:22:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618323757; cv=none; d=google.com; s=arc-20160816; b=KUJjOtVPc33hOu5q0jhOOTpWrkB4qXdGhGYQim+Msnakxwn3ODjfovZgmJq741LVRG kT16DzkAaNez41r7X2aXAUBHuGYpIP/vfYmSgc4RJ4v0eeKjHv9CZ5I4692WY967dHR1 0RX65dMKWiCyyvYqxGQvKgbl8wyiLLdqiH5VuKuW2qqm6YAnnzESmuEMUsk0fMR/Du75 It7zsN6W0ceTR/1TB6lB+ZsKlZqbgJvqAoRH1Pjlp+EZHkt5INcboAuqRyT1RIjzuICT wCNDbJyEebD150FI7IBdsjfQeSeKv/2id/ARqk6JiQT0ztN6KKF0HN6DdbMncN+FvuoN QD1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=sSdkvcoRP/DLD226a2zcjxaqs8CSLLa63pnFVOEgkYc=; b=lG3LvTGXb8EPyYxam4UkytKq1pOUuQGuq1TT61rMDWkj/lFXCg2RkPM+kSXIvGchEM ngkBlgQ8kWdy4Ui2dOdxAVGgpvc4ppmmX5tLfpzCd2FO1vNB9gq3aCuMvuSdKp5Vfojq JkPC96HMmBGTren4BZ6FEYA1Jrsph1KreTeN+N29PnFO2kZKChDmL0bt18VjevkC0kX2 mMHLSKoXWzBsOzPH76mpAYNHM5UXiGXvWUnamZ5mncUPJ4pq6LD2+peDlONB9C69c76a WZYFVTG10gkkt5VZ8QoaSp292+vZTodYn7tq9ucABEvY1DKswn2kGx8uEjFdL12U8uWE 33rw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CCZYPUCh; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 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. [23.128.96.18]) by mx.google.com with ESMTP id w20si10780071edt.357.2021.04.13.07.22.36; Tue, 13 Apr 2021 07:22:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CCZYPUCh; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 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 S237911AbhDMOWv (ORCPT + 16 others); Tue, 13 Apr 2021 10:22:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231477AbhDMOWo (ORCPT ); Tue, 13 Apr 2021 10:22:44 -0400 Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7AE9C06175F for ; Tue, 13 Apr 2021 07:22:23 -0700 (PDT) Received: by mail-lf1-x12c.google.com with SMTP id 12so27523232lfq.13 for ; Tue, 13 Apr 2021 07:22:23 -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:mime-version :content-transfer-encoding; bh=sSdkvcoRP/DLD226a2zcjxaqs8CSLLa63pnFVOEgkYc=; b=CCZYPUChjpWx+NonKRNO2t2uLvncd+6QV5OYgzIv0mW7RUb2PXRzCrp9YvNG7NavmT Hv4Q4buek8R1ReXrHv5tWDpVzDs9A9XkdPFSzNwSnAW63VqafrqUh4nt2lf+CSIVTzfJ 8RSlYD/yJc7ScBTWdXj6DTyAjBE+Sg7H2vwdAqxk/PGKVyTE6ZbyjnMaSoKx+dCerr8h ZZphWWEVF29QQYmM9dNL7tOK3yTMcYe9Irwit5fIWJbzQOIwY1ATZ/bb4kodsEm8mXk5 riY/0u9CD9MUgnbtrR/xxiNeOto3j8fvNRvZ5BmEobzxNr2nJLv5w1VLD0tUqDqiaXsN TMrg== 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:mime-version :content-transfer-encoding; bh=sSdkvcoRP/DLD226a2zcjxaqs8CSLLa63pnFVOEgkYc=; b=PMb0sr7/iTj+FwlQ2yVluruWhe9H2o3TixaAPptMEB+Y6GAHuJ3GdsGNQPoe5PozR/ 1zPue07u159eE5ULmlmNcPUpsGnpSUoCpdqzh0kMNjM4EWVtbezuyisE8cNtZ+zZ9EpL T6fWpfM0j34IAe+IyNV9ECxCU5qcsaoUfzm5AHyaPNFXz9fUuW0c3acRZE1tlyMy21xZ eSdsqOLas77766VO8kor6rOGdzoBpNmWnqxb9KaMqW+HrH2mHTwE6vfzyZ45tTsB4Lct WyzNSmcLIt2MnOJd3LhoRI8/ciLXXI0eOxo/cMoQHbWFAP/CypBw28dIqYTcn5Pltib7 zrDQ== X-Gm-Message-State: AOAM530r4dg0kBa3U40e0aNmq0f/B+UU5ZQBXKHfn1tpzuTAURm2GqEh QokdhkuAvILAhoTJPtKc4CSvgie9LVCsWA== X-Received: by 2002:a19:c187:: with SMTP id r129mr7608474lff.457.1618323741124; Tue, 13 Apr 2021 07:22:21 -0700 (PDT) Received: from eriador.lan ([37.153.55.125]) by smtp.gmail.com with ESMTPSA id n7sm3397814lft.65.2021.04.13.07.22.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Apr 2021 07:22:20 -0700 (PDT) From: Dmitry Baryshkov To: Andy Gross , Bjorn Andersson , Rob Herring , Lorenzo Pieralisi Cc: linux-arm-msm@vger.kernel.org, Manivannan Sadhasivam , linux-pci@vger.kernel.org, Hou Zhiqiang , Kunihiko Hayashi , Bjorn Helgaas , Rob Herring , stable@vger.kernel.org, Marek Szyprowski Subject: [PATCH v2] PCI: dwc: Move iATU detection earlier Date: Tue, 13 Apr 2021 17:22:19 +0300 Message-Id: <20210413142219.2301430-1-dmitry.baryshkov@linaro.org> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org From: Hou Zhiqiang dw_pcie_ep_init() depends on the detected iATU region numbers to allocate the in/outbound window management bitmap. It fails after 281f1f99cf3a ("PCI: dwc: Detect number of iATU windows"). Move the iATU region detection into a new function, move the detection to the very beginning of dw_pcie_host_init() and dw_pcie_ep_init(). Also remove it from the dw_pcie_setup(), since it's more like a software initialization step than hardware setup. Fixes: 281f1f99cf3a ("PCI: dwc: Detect number of iATU windows") Link: https://lore.kernel.org/r/20210125044803.4310-1-Zhiqiang.Hou@nxp.com Tested-by: Kunihiko Hayashi Signed-off-by: Hou Zhiqiang Signed-off-by: Bjorn Helgaas Reviewed-by: Rob Herring Cc: stable@vger.kernel.org # v5.11+ [DB: moved dw_pcie_iatu_detect to happen after host_init callback] Link: https://lore.kernel.org/linux-pci/20210407131255.702054-1-dmitry.baryshkov@linaro.org Cc: Marek Szyprowski Signed-off-by: Dmitry Baryshkov --- drivers/pci/controller/dwc/pcie-designware-ep.c | 2 ++ drivers/pci/controller/dwc/pcie-designware-host.c | 1 + drivers/pci/controller/dwc/pcie-designware.c | 11 ++++++++--- drivers/pci/controller/dwc/pcie-designware.h | 1 + 4 files changed, 12 insertions(+), 3 deletions(-) -- 2.30.2 Tested-by: Manivannan Sadhasivam Tested-by: Marek Szyprowski diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c b/drivers/pci/controller/dwc/pcie-designware-ep.c index 1c25d8337151..8d028a88b375 100644 --- a/drivers/pci/controller/dwc/pcie-designware-ep.c +++ b/drivers/pci/controller/dwc/pcie-designware-ep.c @@ -705,6 +705,8 @@ int dw_pcie_ep_init(struct dw_pcie_ep *ep) } } + dw_pcie_iatu_detect(pci); + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "addr_space"); if (!res) return -EINVAL; diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c index 7e55b2b66182..24192b40e3a2 100644 --- a/drivers/pci/controller/dwc/pcie-designware-host.c +++ b/drivers/pci/controller/dwc/pcie-designware-host.c @@ -398,6 +398,7 @@ int dw_pcie_host_init(struct pcie_port *pp) if (ret) goto err_free_msi; } + dw_pcie_iatu_detect(pci); dw_pcie_setup_rc(pp); dw_pcie_msi_init(pp); diff --git a/drivers/pci/controller/dwc/pcie-designware.c b/drivers/pci/controller/dwc/pcie-designware.c index 004cb860e266..a945f0c0e73d 100644 --- a/drivers/pci/controller/dwc/pcie-designware.c +++ b/drivers/pci/controller/dwc/pcie-designware.c @@ -660,11 +660,9 @@ static void dw_pcie_iatu_detect_regions(struct dw_pcie *pci) pci->num_ob_windows = ob; } -void dw_pcie_setup(struct dw_pcie *pci) +void dw_pcie_iatu_detect(struct dw_pcie *pci) { - u32 val; struct device *dev = pci->dev; - struct device_node *np = dev->of_node; struct platform_device *pdev = to_platform_device(dev); if (pci->version >= 0x480A || (!pci->version && @@ -693,6 +691,13 @@ void dw_pcie_setup(struct dw_pcie *pci) dev_info(pci->dev, "Detected iATU regions: %u outbound, %u inbound", pci->num_ob_windows, pci->num_ib_windows); +} + +void dw_pcie_setup(struct dw_pcie *pci) +{ + u32 val; + struct device *dev = pci->dev; + struct device_node *np = dev->of_node; if (pci->link_gen > 0) dw_pcie_link_set_max_speed(pci, pci->link_gen); diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h index 7247c8b01f04..7d6e9b7576be 100644 --- a/drivers/pci/controller/dwc/pcie-designware.h +++ b/drivers/pci/controller/dwc/pcie-designware.h @@ -306,6 +306,7 @@ int dw_pcie_prog_inbound_atu(struct dw_pcie *pci, u8 func_no, int index, void dw_pcie_disable_atu(struct dw_pcie *pci, int index, enum dw_pcie_region_type type); void dw_pcie_setup(struct dw_pcie *pci); +void dw_pcie_iatu_detect(struct dw_pcie *pci); static inline void dw_pcie_writel_dbi(struct dw_pcie *pci, u32 reg, u32 val) {