Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3829009rdg; Wed, 18 Oct 2023 07:16:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFUUg8bdzAIsckArwbXRx77qSiIl9wYh+nqM7j2l+wFl6+MZmaieQZkbB7WYV8PnHnYEOn2 X-Received: by 2002:a05:6870:7998:b0:1bf:b863:b6d with SMTP id he24-20020a056870799800b001bfb8630b6dmr5132149oab.1.1697638598201; Wed, 18 Oct 2023 07:16:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697638598; cv=none; d=google.com; s=arc-20160816; b=DM+JbnLtF6iJWBmLpEVzrYoURDLGL5/AGK6o6YcuoRQjx6Ys0OHwCVeoluM6yde8Jl 5D6w/pGX3qyR3w8ES8DU3SSI/oIoi/BjL6San+IT3g4HMr2++12mbVdtfW28fVaRkNh6 dbo4Efi3GBBj8y1Rodgof80mnvnyQH8htEFwH9J+IRoiBPveOV+AOGa3Au+AiAzvOnhi kLYhayyYER22dXpF6l849sXQFcVJWjsey6IUa0fSFcnOL4h2rokBxBI6Rsorx3WgzVhS tmQtzqVbSR44oBg2eyBzVzSmvjC9ePK4AzO0xedWhFGPg9qmisdN/UsvGR+Cv2lyv2as HxYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=PhyxmUtG7ajyW2SjJyU5m+NzLdFKfkutpPsZw1ffkps=; fh=yUtYuvChrQjgtEDmau75vNz5y6+IPGsuXpR3gIGSqS4=; b=OfLuONFDyUZdmoLZRRV9HnnbShjTYk7Yhi+uNB0oTgd2SZxrY0IqB5VRqO3hzGeSpv wa2VSM7Y/iTSidP44LxFcRj5lJmrDJUwoN35BnriKMC1nYgoBvFk8AlYeFZb15pvQYsI Jq9iUi9JF0GVplSwstZx2CnwK7Yf6WOo7+9pmEJgp8iqTzwHkcRWy05mCyo/dvAtEfPO N6hf6gYyGbaQ1GK/HJOuBmCgDluQFmg2cj8LpcT7mWHXOGHuBe6krOQZZ2AF5/wSI5V5 Bg+KhLp8vwvM6G3WZ6HuNIiZcAinrOzPkP4zXRAg4RLNgBC44ZA+veAK47NVQ8bXGyW2 j41Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=eHO5mQcH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id bx32-20020a056a02052000b00585a5433e55si2699463pgb.143.2023.10.18.07.16.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 07:16:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=eHO5mQcH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 4489780E0A5A; Wed, 18 Oct 2023 07:16:34 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344961AbjJROQT (ORCPT + 99 others); Wed, 18 Oct 2023 10:16:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345102AbjJROPb (ORCPT ); Wed, 18 Oct 2023 10:15:31 -0400 Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com [IPv6:2a00:1450:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33390D61; Wed, 18 Oct 2023 07:13:48 -0700 (PDT) Received: by mail-lf1-x131.google.com with SMTP id 2adb3069b0e04-5079f9675c6so7255130e87.2; Wed, 18 Oct 2023 07:13:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697638426; x=1698243226; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=PhyxmUtG7ajyW2SjJyU5m+NzLdFKfkutpPsZw1ffkps=; b=eHO5mQcHxbbVmVyUsdm3qfVjWzY+w9bQtxkJI0c35p3h7lQuNTeztpOG0cCewLmQuG iyppswWFa3ckyNVz0D8+6kc0j8xcKXiTQQbMURHfXFsDOwHYfaE7BpgLwPlNYk9+tPw8 cNaKtQLzF297Fz9NAEOSXHPETpsOBD0gY71efeG7QWATTM8vdNEfn1pmlpRpSKevgBTJ WWmzeGmKu2bGtHxDAGw2A+eJBzqTfT06YOI/qf+kexkieSvNvJl58D/a+ArLKW1H7J+2 zyQWK3zyMhZg8GjkI//OR4U+hFyzBezK2KBL8iCMH9A+IHvLayLasYc4PBA7G+eQIR7r kVvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697638426; x=1698243226; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=PhyxmUtG7ajyW2SjJyU5m+NzLdFKfkutpPsZw1ffkps=; b=VeY2PyfFfoU8cpkNx+Gr+tOKc40DRQ7Zp2cI45eMqkoFLHzDhGwmosRzx9cb1D71Ri v6ZN4gf2S4SNYBFjPujRv5WTkxabvnpK6B9CurGZIjsgaX4raoBepcbgYYHAEDkhYi61 14CTVkFZD1SNcof0XIhSZ9M2K3tZFO5EKBtOgf2sSPMNlXLiN4MSyYJ0REPBOW+476cf jkOJAaDCDX+3zxUK2/5Si0r2WNIinLimPc7iPvYjheuzpMIJK8mO7Ik7WGSor2zB5C0Q Sq+obrz93GdkL+tnCH1agg5RHde/aqfcpl4X+bK+dIqqmHdSegYCfBExA6k/DNgKvLQa qIkQ== X-Gm-Message-State: AOJu0Yzhm967Z1byeowY5wuOn3VIg7CHIPeWbOCr6b7cRLzan+cx1fsy QeKkmVCVbQrIEN3yJpGxOGs= X-Received: by 2002:ac2:548e:0:b0:507:9fa0:e244 with SMTP id t14-20020ac2548e000000b005079fa0e244mr3912595lfk.65.1697638425660; Wed, 18 Oct 2023 07:13:45 -0700 (PDT) Received: from mobilestation ([178.176.56.174]) by smtp.gmail.com with ESMTPSA id k10-20020ac257ca000000b00500a4679148sm714150lfo.20.2023.10.18.07.13.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 07:13:45 -0700 (PDT) Date: Wed, 18 Oct 2023 17:13:41 +0300 From: Serge Semin To: Manivannan Sadhasivam Cc: Jingoo Han , Gustavo Pimentel , Manivannan Sadhasivam , Lorenzo Pieralisi , Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= , Rob Herring , Bjorn Helgaas , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org Subject: Re: [PATCH 1/2] PCI: dwc: Add new accessors to enable/disable DBI CS2 while setting the BAR size Message-ID: References: <20231017-pcie-qcom-bar-v1-0-3e26de07bec0@linaro.org> <20231017-pcie-qcom-bar-v1-1-3e26de07bec0@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231017-pcie-qcom-bar-v1-1-3e26de07bec0@linaro.org> X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.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 (agentk.vger.email [0.0.0.0]); Wed, 18 Oct 2023 07:16:34 -0700 (PDT) On Tue, Oct 17, 2023 at 11:47:54AM +0530, Manivannan Sadhasivam wrote: > From: Manivannan Sadhasivam > > As per the DWC databook v4.21a, section M.4.1, in order to write some read > only and shadow registers through application DBI, the device driver should > assert DBI Chip Select 2 (CS2) in addition to DBI Chip Select (CS). > > This is a requirement at least on the Qcom platforms while programming the > BAR size, as the BAR mask registers are marked RO. So let's add two new > accessors dw_pcie_dbi_cs2_{en/dis} to enable/disable CS2 access in a vendor > specific way while programming the BAR size. Emm, it's a known thing for all IP-core versions: dbi_cs2 must be asserted to access the shadow DW PCIe CSRs space for both RC and EP including the BARs mask and their enabling/disabling flag (there are many more shadow CSRs available on DW PCIe EPs, and a few in DW PCIe RCs). That's why the dw_pcie_ops->writel_dbi2 pointer has been defined in the first place (dbi2 suffix means dbi_cs2). You should use it to create the platform-specific dbi_cs2 write accessors like it's done in pci-keystone.c and pcie-bt1.c. For instance like this: static void qcom_pcie_write_dbi2(struct dw_pcie *pci, 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, "write DBI address failed\n"); writel(0, pcie_ep->elbi + ELBI_CS2_ENABLE); } /* Common DWC controller ops */ 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, }; For that reason there is absolutely no need in adding the new callbacks. -Serge(y) > > Signed-off-by: Manivannan Sadhasivam > --- > drivers/pci/controller/dwc/pcie-designware-ep.c | 6 ++++++ > drivers/pci/controller/dwc/pcie-designware.h | 13 +++++++++++++ > 2 files changed, 19 insertions(+) > > diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c b/drivers/pci/controller/dwc/pcie-designware-ep.c > index d34a5e87ad18..1874fb3d8df4 100644 > --- a/drivers/pci/controller/dwc/pcie-designware-ep.c > +++ b/drivers/pci/controller/dwc/pcie-designware-ep.c > @@ -269,11 +269,17 @@ static int dw_pcie_ep_set_bar(struct pci_epc *epc, u8 func_no, u8 vfunc_no, > > dw_pcie_dbi_ro_wr_en(pci); > > + dw_pcie_dbi_cs2_en(pci); > dw_pcie_writel_dbi2(pci, reg_dbi2, lower_32_bits(size - 1)); > + dw_pcie_dbi_cs2_dis(pci); > + > dw_pcie_writel_dbi(pci, reg, flags); > > if (flags & PCI_BASE_ADDRESS_MEM_TYPE_64) { > + dw_pcie_dbi_cs2_en(pci); > dw_pcie_writel_dbi2(pci, reg_dbi2 + 4, upper_32_bits(size - 1)); > + dw_pcie_dbi_cs2_dis(pci); > + > dw_pcie_writel_dbi(pci, reg + 4, 0); > } > > diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h > index 55ff76e3d384..3cba27b5bbe5 100644 > --- a/drivers/pci/controller/dwc/pcie-designware.h > +++ b/drivers/pci/controller/dwc/pcie-designware.h > @@ -379,6 +379,7 @@ struct dw_pcie_ops { > size_t size, u32 val); > void (*write_dbi2)(struct dw_pcie *pcie, void __iomem *base, u32 reg, > size_t size, u32 val); > + void (*dbi_cs2_access)(struct dw_pcie *pcie, bool enable); > int (*link_up)(struct dw_pcie *pcie); > enum dw_pcie_ltssm (*get_ltssm)(struct dw_pcie *pcie); > int (*start_link)(struct dw_pcie *pcie); > @@ -508,6 +509,18 @@ static inline void dw_pcie_dbi_ro_wr_dis(struct dw_pcie *pci) > dw_pcie_writel_dbi(pci, reg, val); > } > > +static inline void dw_pcie_dbi_cs2_en(struct dw_pcie *pci) > +{ > + if (pci->ops && pci->ops->dbi_cs2_access) > + pci->ops->dbi_cs2_access(pci, true); > +} > + > +static inline void dw_pcie_dbi_cs2_dis(struct dw_pcie *pci) > +{ > + if (pci->ops && pci->ops->dbi_cs2_access) > + pci->ops->dbi_cs2_access(pci, false); > +} > + > static inline int dw_pcie_start_link(struct dw_pcie *pci) > { > if (pci->ops && pci->ops->start_link) > > -- > 2.25.1 >