Received: by 2002:a05:7412:251c:b0:e2:908c:2ebd with SMTP id w28csp2543083rda; Wed, 25 Oct 2023 06:02:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGGJIKExfD/icVSlWtgDcnSQwBwbi7jPLn5J6lYZUuQOLAgnQNzt0KgkBzPFH7s2LLuCTRF X-Received: by 2002:a05:6830:3101:b0:6bc:f328:696e with SMTP id b1-20020a056830310100b006bcf328696emr15543355ots.0.1698238931458; Wed, 25 Oct 2023 06:02:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698238931; cv=none; d=google.com; s=arc-20160816; b=MXYpUNipnaK8Ign5nrLYoE8ODTT4DsuhaMR1uDsEacYQR8NGP6Nfdlq2Oy6p0AwJSM g9ANWdm4GTDDXGgGvhkVvskY9WTgp5AakAAYBz0QtluOiuxkdbEYok3JAlENvaB38a3V Mlm085hs906mzMuj71IrSblUJD0doM9PIsnsjFRSsVBYguK8PQWGZwFy3OfCAZBcVeSu lcTtaM1W0Kc3kAezdtyozStKUV1dDUhIECcG1JLKlQfVeuyTN/vuN/n3lPH1Nma7wjRt vRwUu8I4/jgBV8i/6INqFdGft+oS3w53jHXvJ0tG2cAyhHhBunPboGijEzi5vhD+gek0 7nqw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=qBEwFvY7A0Gjt/uGwV7Ad9RZEpWO878DTXchrP8q7sQ=; fh=O8oQQpdQNV847NBabkRVefeOBWmO5sh1F+kuTj75mO0=; b=LWvyscwDEEFjz2r+xRSPWARBQHYS821m6EUBXa5mo4SFFzivePxk02Lr+2qUD2E4I1 S+OD/A4j3yPOaedNULlhtVd6cJa74V67dZdsmzNfNbzARvhwo7/QmJYEpZhj9C6V1SWg DXDan0ekDlX/1O2xPbYSCe+qfagZBf/KPC172NjuKzqkUz7Ag+f/ULVgdmytlE+n3cSR +Y8VWNIjOBycVTPQWGy/klXVZO7T/0q1IqVqe7g2ghfRt5UFg7OgqUB95BAd7DiGY9vr Ac39wljQwLYKmPx9x7bKUtJjxFH1jIKDRMQ1j6er8T98z1nYa2pfUVYuWNR3PWKpg8P1 A8GQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EEhz0UMD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id t14-20020a67ad0e000000b004525202b950si1173683vsl.559.2023.10.25.06.02.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 06:02:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EEhz0UMD; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 4D6F5809C3BB; Wed, 25 Oct 2023 06:01:08 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344338AbjJYNAo (ORCPT + 99 others); Wed, 25 Oct 2023 09:00:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344307AbjJYNAm (ORCPT ); Wed, 25 Oct 2023 09:00:42 -0400 Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 713D1C1 for ; Wed, 25 Oct 2023 06:00:40 -0700 (PDT) Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-6b89ab5ddb7so5651742b3a.0 for ; Wed, 25 Oct 2023 06:00:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698238840; x=1698843640; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=qBEwFvY7A0Gjt/uGwV7Ad9RZEpWO878DTXchrP8q7sQ=; b=EEhz0UMDkhZ2eOmZeQjckv8P5v377syHwE/1UgnQjaLQoEtkhbafzWUYT5wiYeVlD8 eHbD3yFHe7Zao93woWsrQ7LycLi+Koq6DHIHRSoUenSWy83uS4eykUphw0A+vxKkafgm GDUL3A3DQq/vvtN/T/Kido7s8G88GMhKueCCvlAAWiZFTnyaWdYAZJ2tjlgl/hBLMAmc PioDvAzsxScPRLJjbwYx2NqgJS3uqYxJmVFTfUQiuQRg4TqEol6KUvy5cCxhgqUIY916 spFzLiX+lVoMBLHAdetuSeyE+GT0XonoXybsvao+cWQUroA7hxj477VQfG8dAUNJ939h xTJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698238840; x=1698843640; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qBEwFvY7A0Gjt/uGwV7Ad9RZEpWO878DTXchrP8q7sQ=; b=jhn2SCrDmqPH72pZ8XUGKWDAfAA+/78hpb7uuBvQ+ZxoD+uKcWcacAXT0CZ9heKPw2 E65OB9fO7rnMls5QRgDzQscVuykt8N+ik4U7VaCHIuOxrBgMAzmq2VLo3cpSVmKHrbmc cow0NgVQu9vSgzMzNF5kQvAVU1g357tLQXuy0fwpk0+R798rKfsRcFe2xfAivrKrPtW0 ebTVJPVhIo3ljttUU/RzW9BgzlaoTaozb30LmUFDRMs/BOmSjKyffqcXUO5k1WVcm0aC aIS/RpUgM38ODfLm7vtiyM4fx/21KGglBGI0EtG+jhcRXpfPFxZzbQBUiSiu+TZYs0VJ yuXQ== X-Gm-Message-State: AOJu0Yw4A64pqbHJDpG/flgNizQm3SOShm3BRnmCCA2FHoRDzCd0ecvL si2JWTPrsxW2yQ9qS45LVWoF X-Received: by 2002:a05:6a21:778d:b0:16b:8498:d9bc with SMTP id bd13-20020a056a21778d00b0016b8498d9bcmr5327839pzc.62.1698238839655; Wed, 25 Oct 2023 06:00:39 -0700 (PDT) Received: from localhost.localdomain ([103.28.246.120]) by smtp.gmail.com with ESMTPSA id n11-20020aa7984b000000b00690d4464b95sm9616304pfq.16.2023.10.25.06.00.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Oct 2023 06:00:39 -0700 (PDT) From: Manivannan Sadhasivam To: jingoohan1@gmail.com, gustavo.pimentel@synopsys.com, lpieralisi@kernel.org, robh@kernel.org, kw@linux.com, bhelgaas@google.com Cc: linux-pci@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, quic_bjorande@quicinc.com, fancer.lancer@gmail.com, Manivannan Sadhasivam , stable@vger.kernel.org Subject: [PATCH v2 1/1] PCI: qcom-ep: Implement write_dbi2() callback for writing DBI2 registers properly Date: Wed, 25 Oct 2023 18:30:29 +0530 Message-Id: <20231025130029.74693-2-manivannan.sadhasivam@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231025130029.74693-1-manivannan.sadhasivam@linaro.org> References: <20231025130029.74693-1-manivannan.sadhasivam@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=1.7 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_SBL,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Wed, 25 Oct 2023 06:01:08 -0700 (PDT) X-Spam-Level: * DWC core driver exposes the write_dbi2() callback for writing to the DBI2 registers in a vendor specific way. On the Qcom EP plaforms, DBI_CS2 bit in the ELBI region needs to be asserted before writing to any DBI2 registers and deasserted once done. So let's implement the callback for the Qcom PCIe EP driver so that the DBI2 writes are handled properly in the hardware. Without this callback, DBI2 register writes like BAR size won't go through and as a result, the default BAR size is set for all BARs. Cc: stable@vger.kernel.org # 5.16+ Fixes: f55fee56a631 ("PCI: qcom-ep: Add Qualcomm PCIe Endpoint controller driver") Suggested-by: Serge Semin Signed-off-by: Manivannan Sadhasivam --- drivers/pci/controller/dwc/pcie-qcom-ep.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/pci/controller/dwc/pcie-qcom-ep.c b/drivers/pci/controller/dwc/pcie-qcom-ep.c index 32c8d9e37876..7da0599f70e7 100644 --- a/drivers/pci/controller/dwc/pcie-qcom-ep.c +++ b/drivers/pci/controller/dwc/pcie-qcom-ep.c @@ -124,6 +124,7 @@ /* ELBI registers */ #define ELBI_SYS_STTS 0x08 +#define ELBI_CS2_ENABLE 0xa4 /* DBI registers */ #define DBI_CON_STATUS 0x44 @@ -262,6 +263,21 @@ static void qcom_pcie_dw_stop_link(struct dw_pcie *pci) disable_irq(pcie_ep->perst_irq); } +static void qcom_pcie_write_dbi2(struct dw_pcie *pci, void __iomem *base, + u32 reg, size_t size, u32 val) +{ + struct qcom_pcie_ep *pcie_ep = to_pcie_ep(pci); + int ret; + + writel(1, pcie_ep->elbi + ELBI_CS2_ENABLE); + + ret = dw_pcie_write(pci->dbi_base2 + reg, size, val); + if (ret) + dev_err(pci->dev, "Failed to write DBI2 register (0x%x): %d\n", reg, ret); + + writel(0, pcie_ep->elbi + ELBI_CS2_ENABLE); +} + static void qcom_pcie_ep_icc_update(struct qcom_pcie_ep *pcie_ep) { struct dw_pcie *pci = &pcie_ep->pci; @@ -500,6 +516,7 @@ static const struct dw_pcie_ops pci_ops = { .link_up = qcom_pcie_dw_link_up, .start_link = qcom_pcie_dw_start_link, .stop_link = qcom_pcie_dw_stop_link, + .write_dbi2 = qcom_pcie_write_dbi2, }; static int qcom_pcie_ep_get_io_resources(struct platform_device *pdev, -- 2.25.1