Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp6224473pxv; Thu, 29 Jul 2021 09:14:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyHTFEtsUvjOZcZHzzFrR00LpVYGIdzng8BmcVhLm45xgLIyy6P2j9MOxy+MueU44mwPwr6 X-Received: by 2002:a05:6402:184b:: with SMTP id v11mr6992451edy.267.1627575249079; Thu, 29 Jul 2021 09:14:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627575249; cv=none; d=google.com; s=arc-20160816; b=xgL/s+LZ3ZMfAryg/jBUQVL+RI6Eppwh26ZSfpmrI0vvvB4OeiZpCP1/McV0QLEzz/ lCg4wyIkUe+yYullHtbgPMsWpu1/u3bO7A60Q9dobUu6rI5EMildCcI6EAonqW2oda1b 96JTX3def3FgSUhQobVtZB5NYSAVYfANoFvNlPbndK+16kHrrH8lg8lkSlTlfO2d3pKP s+IQdiM0iqJMyEzNQY8yFEjymYzTr+3AQ9N89aeBSdoJIhPpiqm0E5mHkEquLF3TuFHG /7pWzzB4tfX6WcIa1MZzVvKbSGiyGfGhsDsywQR6doj1z1UyixhkLScwPQfYsyK7ArS5 sHXA== 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; bh=0eM2Z646gUFi3du/q9sn/HaLyZ2ndDCXv0adQp8OJVA=; b=OtWpVozztKVn9PvhK6qb75LPAxuuhzETd9tAXc48UL2wXzdrUi+Olac2VAU8GMZZMR +44cD+WdXtq+XVw25BmORPkM7wdOtdi0gNqeAkKYEfRWkBAI2v88iJ06E73gmGvaSqSv xTIJKBhdw+aQ+AX7DMLfr/SYU1ZObd94r99EdiWWt7IQ5FhpRViCy6dHeIiC0En5K48i BOB2mXOCRMAwTiUFvXLHHVagVRC8k3zohwea1/MJms6/90QLF358lXFILAydez/bP5sx 16AmOgvqzsnQxkZjHKgl/fKjDXh2QQggAQmHgHuaZBo4DErVEuQObOmUCwnsX+aMX5VO mWDg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x13si3029591ejc.602.2021.07.29.09.13.44; Thu, 29 Jul 2021 09:14:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229800AbhG2QLO (ORCPT + 99 others); Thu, 29 Jul 2021 12:11:14 -0400 Received: from gloria.sntech.de ([185.11.138.130]:58922 "EHLO gloria.sntech.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234234AbhG2QJw (ORCPT ); Thu, 29 Jul 2021 12:09:52 -0400 Received: from ip5f5aa64a.dynamic.kabel-deutschland.de ([95.90.166.74] helo=diego.localnet) by gloria.sntech.de with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m98aN-0004AD-4y; Thu, 29 Jul 2021 18:08:39 +0200 From: Heiko =?ISO-8859-1?Q?St=FCbner?= To: Benjamin Gaignard , joro@8bytes.org, will@kernel.org, robh+dt@kernel.org, xxm@rock-chips.com, robin.murphy@arm.com, Ezequiel Garcia , Dafna Hirschfeld Cc: iommu@lists.linux-foundation.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org, kernel@collabora.com Subject: Re: [PATCH v7 3/4] iommu: rockchip: Add internal ops to handle variants Date: Thu, 29 Jul 2021 18:08:38 +0200 Message-ID: <3544194.oiGErgHkdL@diego> In-Reply-To: References: <20210525121551.606240-1-benjamin.gaignard@collabora.com> <20210525121551.606240-4-benjamin.gaignard@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Dafna, Am Donnerstag, 29. Juli 2021, 17:59:26 CEST schrieb Dafna Hirschfeld: > On 25.05.21 14:15, Benjamin Gaignard wrote: > > @@ -879,7 +895,7 @@ static int rk_iommu_enable(struct rk_iommu *iommu) > > > > for (i = 0; i < iommu->num_mmu; i++) { > > rk_iommu_write(iommu->bases[i], RK_MMU_DTE_ADDR, > > - rk_domain->dt_dma); > > + rk_ops->dma_addr_dte(rk_domain->dt_dma)); > > Hi, > This is not related to that patch, I was wondring why are all mmu devices initialized > with the same dt_dma? > I see for example that the isp0_mmu in rk3399.dtsi has two resources. Can't each resource > be initialized with different dt_dma and this way there are two dt tables instead of the two mmus pointing > to the same dt table. maybe git log -1 cd6438c5f8446691afa4829fe1a9d7b656204f11 "iommu/rockchip: Reconstruct to support multi slaves There are some IPs, such as video encoder/decoder, contains 2 slave iommus, one for reading and the other for writing. They share the same irq and clock with master. This patch reconstructs to support this case by making them share the same Page Directory, Page Tables and even the register operations. That means every instruction to the reading MMU registers would be duplicated to the writing MMU and vice versa." Heiko > > Thanks, > Dafna > > > rk_iommu_base_command(iommu->bases[i], RK_MMU_CMD_ZAP_CACHE); > > rk_iommu_write(iommu->bases[i], RK_MMU_INT_MASK, RK_MMU_IRQ_MASK); > > } > > @@ -1037,7 +1053,7 @@ static void rk_iommu_domain_free(struct iommu_domain *domain) > > for (i = 0; i < NUM_DT_ENTRIES; i++) { > > u32 dte = rk_domain->dt[i]; > > if (rk_dte_is_pt_valid(dte)) { > > - phys_addr_t pt_phys = rk_dte_pt_address(dte); > > + phys_addr_t pt_phys = rk_ops->pt_address(dte); > > u32 *page_table = phys_to_virt(pt_phys); > > dma_unmap_single(dma_dev, pt_phys, > > SPAGE_SIZE, DMA_TO_DEVICE); > > @@ -1127,6 +1143,7 @@ static int rk_iommu_probe(struct platform_device *pdev) > > struct device *dev = &pdev->dev; > > struct rk_iommu *iommu; > > struct resource *res; > > + const struct rk_iommu_ops *ops; > > int num_res = pdev->num_resources; > > int err, i; > > > > @@ -1138,6 +1155,17 @@ static int rk_iommu_probe(struct platform_device *pdev) > > iommu->dev = dev; > > iommu->num_mmu = 0; > > > > + ops = of_device_get_match_data(dev); > > + if (!rk_ops) > > + rk_ops = ops; > > + > > + /* > > + * That should not happen unless different versions of the > > + * hardware block are embedded the same SoC > > + */ > > + if (WARN_ON(rk_ops != ops)) > > + return -EINVAL; > > + > > iommu->bases = devm_kcalloc(dev, num_res, sizeof(*iommu->bases), > > GFP_KERNEL); > > if (!iommu->bases) > > @@ -1226,6 +1254,8 @@ static int rk_iommu_probe(struct platform_device *pdev) > > } > > } > > > > + dma_set_mask_and_coherent(dev, rk_ops->dma_bit_mask); > > + > > return 0; > > err_remove_sysfs: > > iommu_device_sysfs_remove(&iommu->iommu); > > @@ -1277,8 +1307,20 @@ static const struct dev_pm_ops rk_iommu_pm_ops = { > > pm_runtime_force_resume) > > }; > > > > +static struct rk_iommu_ops iommu_data_ops_v1 = { > > + .pt_address = &rk_dte_pt_address, > > + .mk_dtentries = &rk_mk_dte, > > + .mk_ptentries = &rk_mk_pte, > > + .dte_addr_phys = &rk_dte_addr_phys, > > + .dma_addr_dte = &rk_dma_addr_dte, > > + .dma_bit_mask = DMA_BIT_MASK(32), > > +}; > > + > > + > > static const struct of_device_id rk_iommu_dt_ids[] = { > > - { .compatible = "rockchip,iommu" }, > > + { .compatible = "rockchip,iommu", > > + .data = &iommu_data_ops_v1, > > + }, > > { /* sentinel */ } > > }; > > > > >