Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp885293rwb; Tue, 27 Sep 2022 06:01:32 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5FgiqFKLyd82hQF2J8H4DECWjhoyoVzDQGpUCQDPFp8L/yC3ZnwMwlts5r02CdTmL6/0+L X-Received: by 2002:a17:907:2c75:b0:77c:2b6a:6b63 with SMTP id ib21-20020a1709072c7500b0077c2b6a6b63mr23340485ejc.702.1664283691660; Tue, 27 Sep 2022 06:01:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664283691; cv=none; d=google.com; s=arc-20160816; b=QGwC7Gr89TrBgFWyPXfqb/tAkqxvCH9s80TLJooT4QBKBaJI7ARXlAftV0a6u7Zayt dDluVqobSPinptouSC/VvtGHGa2d/3MdrOsvSiG3CixyUBXUoe54k5mP01wSagM24oLF a8EjUR/E1BO9obVg7FHWLV5E8TqiEc7X6rwCiS7Q7z3h8VMNdMfVzqPg+95LqnR36kYM fL+FjO+RiBz4OQeznXBBoIIR9q1wjU9zP8MU8gW17OG+c8z842qzl4q4ZhngyM5BOWOW 43BZj+jpkfv18ag1dkxS6HwxGT+56oVdmLZps9HUv8LUHfkWxUbyCl1KoffaZDR9nPzg suPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :organization:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:dkim-signature; bh=pfj6983/EAoZm2rbtwJSO226VmQstgNVOVTasXVB7lo=; b=CJJFPgSbDva6ACYQkkMM1yQUatVfNK9o2SV+0ZiI7E04rkeZ5GfXiGMRNlDk5Ue0jz sIx03PuXDg9XvKKlNXnWauv5PJ26OQjgMQ7OibsL5uc7pi2AO7wOnlzFIjb99ruyWIJR CXEgwFN/O9YBzDld+GVIAAikXawC2SIyX//OnAopX6U+WJyZKi2X2sbWuNYlJe8J0h4t aYBZ+uEFSbBp+AjK/4HxE+OHk15kE0PUE7fACkS0p+0ZWCSv3dzeODvrkS6qe33vXmMC rW01QbibH8vvqRUbHe1LT4iGsADQPq60/WPD48ZT8fopj6ElMDGc8wrgxEIUrEIKaQDK 2Lcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=I7yjHeho; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lo23-20020a170906fa1700b007708400bee5si994182ejb.1003.2022.09.27.06.01.00; Tue, 27 Sep 2022 06:01:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=I7yjHeho; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231640AbiI0Mp4 (ORCPT + 99 others); Tue, 27 Sep 2022 08:45:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230055AbiI0Mpy (ORCPT ); Tue, 27 Sep 2022 08:45:54 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 254B51406F7; Tue, 27 Sep 2022 05:45:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1664282753; x=1695818753; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=4sq1AHyWFyOqVpjRETvsq1ss7KGQ2KV4EhyDYN3JmJg=; b=I7yjHeho+za68gzOwraRmsxbgUx2YpejdX8V+q8S2tYNMVCmqWhO+LMp XRHbpru5G+uQV1WlnrhWjqABEqDNdh83KwfghtlBJrJCaL6rPTFG7vb54 TtTzsykrzPnA5FObh8SVPcryoOAtI0S8ytxVV9Y6o1+MUpSuh67k5pDve oE2nsGat0d2HgDnVbqDq9XAFfKOnbsDcRpRRwvwJxdpHj+hBTOMYcn98r bLN6xYAwfwszE1VdjbCiEieGXI7YkNPoslMGRAdgnAxx2Kqbw7PaO4w16 N343ydjGmDdwKHdfXTRieo/8feyegJ/BsrpTjpRK4JITqGw5b9U54zEAT Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10483"; a="363143665" X-IronPort-AV: E=Sophos;i="5.93,349,1654585200"; d="scan'208";a="363143665" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Sep 2022 05:45:52 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10483"; a="763863509" X-IronPort-AV: E=Sophos;i="5.93,349,1654585200"; d="scan'208";a="763863509" Received: from ahunter6-mobl1.ger.corp.intel.com (HELO [10.0.2.15]) ([10.252.35.200]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Sep 2022 05:45:49 -0700 Message-ID: Date: Tue, 27 Sep 2022 15:45:44 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Firefox/91.0 Thunderbird/91.11.0 Subject: Re: [PATCH v5 2/3] mmc: sdhci-tegra: Add support to program MC stream ID Content-Language: en-US To: Prathamesh Shete , ulf.hansson@linaro.org, thierry.reding@gmail.com, jonathanh@nvidia.com, p.zabel@pengutronix.de, linux-mmc@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Cc: anrao@nvidia.com, smangipudi@nvidia.com, kyarlagadda@nvidia.com References: <20220927111314.32229-1-pshete@nvidia.com> <20220927111314.32229-2-pshete@nvidia.com> From: Adrian Hunter Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki In-Reply-To: <20220927111314.32229-2-pshete@nvidia.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 27/09/22 14:13, Prathamesh Shete wrote: > SMMU clients are supposed to program stream ID from > their respective address spaces instead of MC override. > Define NVQUIRK_PROGRAM_STREAMID and use it to program > SMMU stream ID from the SDMMC client address space. > > Signed-off-by: Aniruddha TVS Rao > Signed-off-by: Prathamesh Shete > --- > drivers/mmc/host/sdhci-tegra.c | 47 ++++++++++++++++++++++++++++++++++ > 1 file changed, 47 insertions(+) > > diff --git a/drivers/mmc/host/sdhci-tegra.c b/drivers/mmc/host/sdhci-tegra.c > index a6c5bbae77b4..46f37cc26dbb 100644 > --- a/drivers/mmc/host/sdhci-tegra.c > +++ b/drivers/mmc/host/sdhci-tegra.c > @@ -25,6 +25,9 @@ > #include > #include > #include > +#ifdef CONFIG_IOMMU_API > +#include > +#endif > > #include > > @@ -94,6 +97,8 @@ > #define SDHCI_TEGRA_AUTO_CAL_STATUS 0x1ec > #define SDHCI_TEGRA_AUTO_CAL_ACTIVE BIT(31) > > +#define SDHCI_TEGRA_CIF2AXI_CTRL_0 0x1fc > + > #define NVQUIRK_FORCE_SDHCI_SPEC_200 BIT(0) > #define NVQUIRK_ENABLE_BLOCK_GAP_DET BIT(1) > #define NVQUIRK_ENABLE_SDHCI_SPEC_300 BIT(2) > @@ -121,6 +126,7 @@ > #define NVQUIRK_HAS_TMCLK BIT(10) > > #define NVQUIRK_HAS_ANDROID_GPT_SECTOR BIT(11) > +#define NVQUIRK_PROGRAM_STREAMID BIT(12) > > /* SDMMC CQE Base Address for Tegra Host Ver 4.1 and Higher */ > #define SDHCI_TEGRA_CQE_BASE_ADDR 0xF000 > @@ -128,6 +134,8 @@ > #define SDHCI_TEGRA_CQE_TRNS_MODE (SDHCI_TRNS_MULTI | \ > SDHCI_TRNS_BLK_CNT_EN | \ > SDHCI_TRNS_DMA) > +#define SDHCI_TEGRA_STREAMID_MASK 0xff > +#define SDHCI_TEGRA_WRITE_STREAMID_SHIFT 0x8 > > struct sdhci_tegra_soc_data { > const struct sdhci_pltfm_data *pdata; > @@ -177,6 +185,9 @@ struct sdhci_tegra { > bool enable_hwcq; > unsigned long curr_clk_rate; > u8 tuned_tap_delay; > +#ifdef CONFIG_IOMMU_API > + u32 streamid; > +#endif > }; > > static u16 tegra_sdhci_readw(struct sdhci_host *host, int reg) > @@ -1564,6 +1575,7 @@ static const struct sdhci_tegra_soc_data soc_data_tegra234 = { > NVQUIRK_DIS_CARD_CLK_CONFIG_TAP | > NVQUIRK_ENABLE_SDR50 | > NVQUIRK_ENABLE_SDR104 | > + NVQUIRK_PROGRAM_STREAMID | > NVQUIRK_HAS_TMCLK, > .min_tap_delay = 95, > .max_tap_delay = 111, > @@ -1636,6 +1648,9 @@ static int sdhci_tegra_probe(struct platform_device *pdev) > struct sdhci_host *host; > struct sdhci_pltfm_host *pltfm_host; > struct sdhci_tegra *tegra_host; > +#ifdef CONFIG_IOMMU_API > + struct iommu_fwspec *fwspec; > +#endif Move this below > struct clk *clk; > int rc; > > @@ -1775,6 +1790,25 @@ static int sdhci_tegra_probe(struct platform_device *pdev) > if (rc) > goto err_add_host; > > + /* Program MC streamID for DMA transfers */ > +#ifdef CONFIG_IOMMU_API > + if (soc_data->nvquirks & NVQUIRK_PROGRAM_STREAMID) { Can put it here struct iommu_fwspec *fwspec; > + fwspec = dev_iommu_fwspec_get(&pdev->dev); > + if (fwspec == NULL) { > + dev_warn(mmc_dev(host->mmc), > + "iommu fwspec is NULL, continue without stream ID\n"); > + } else { > + tegra_host->streamid = fwspec->ids[0] & 0xffff; > + tegra_sdhci_writel(host, (tegra_host->streamid & > + SDHCI_TEGRA_STREAMID_MASK) | > + ((tegra_host->streamid << > + SDHCI_TEGRA_WRITE_STREAMID_SHIFT) > + & SDHCI_TEGRA_STREAMID_MASK), > + SDHCI_TEGRA_CIF2AXI_CTRL_0); This is hard to read. Maybe use GENMASK and FIELD_PREP, or if the bytes need swapping, one of the byte swapping macros. Also, isn't this always zero ? ((tegra_host->streamid << SDHCI_TEGRA_WRITE_STREAMID_SHIFT) & SDHCI_TEGRA_STREAMID_MASK), > + } > + } > +#endif > + > return 0; > > err_add_host: > @@ -1861,6 +1895,10 @@ static int sdhci_tegra_suspend(struct device *dev) > static int sdhci_tegra_resume(struct device *dev) > { > struct sdhci_host *host = dev_get_drvdata(dev); > +#ifdef CONFIG_IOMMU_API > + struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); > + struct sdhci_tegra *tegra_host = sdhci_pltfm_priv(pltfm_host); > +#endif > int ret; > > ret = mmc_gpio_set_cd_wake(host->mmc, false); > @@ -1871,6 +1909,15 @@ static int sdhci_tegra_resume(struct device *dev) > if (ret) > return ret; > > + /* Re-program MC streamID for DMA transfers */ > +#ifdef CONFIG_IOMMU_API > + if (tegra_host->soc_data->nvquirks & NVQUIRK_PROGRAM_STREAMID) { > + tegra_sdhci_writel(host, tegra_host->streamid | > + (tegra_host->streamid << 8), This looks like it ought to be the same calculation as above ? > + SDHCI_TEGRA_CIF2AXI_CTRL_0); > + } > +#endif > + > ret = sdhci_resume_host(host); > if (ret) > goto disable_clk;