From mboxrd@z Thu Jan 1 00:00:00 1970 From: chenfeng Subject: Re: [PATCH 2/3] iommu/hisilicon: Add hi6220 iommu driver Date: Mon, 19 Oct 2015 09:49:43 +0800 Message-ID: <56244C37.9030407@hisilicon.com> References: <1444290348-66509-1-git-send-email-puck.chen@hisilicon.com> <1444290348-66509-2-git-send-email-puck.chen@hisilicon.com> <20151014121843.GN27420@8bytes.org> Mime-Version: 1.0 Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20151014121843.GN27420-zLv9SwRftAIdnm+yROfE0A@public.gmane.org> Sender: devicetree-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Joerg Roedel Cc: iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org, linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org, pawel.moll-5wv7dgnIgG8@public.gmane.org, haojian.zhuang-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org, devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, xuwei5-C8/M+/jPZTeaMJb+Lgu22Q@public.gmane.org, xuyiping-C8/M+/jPZTeaMJb+Lgu22Q@public.gmane.org, w.f-hv44wF8Li93QT0dZR+AlfA@public.gmane.org, kong.kongxinwei-C8/M+/jPZTeaMJb+Lgu22Q@public.gmane.org, z.liuxinliang-C8/M+/jPZTeaMJb+Lgu22Q@public.gmane.org, yudongbin-C8/M+/jPZTeaMJb+Lgu22Q@public.gmane.org, weidong2-C8/M+/jPZTeaMJb+Lgu22Q@public.gmane.org, saberlily.xia-C8/M+/jPZTeaMJb+Lgu22Q@public.gmane.org, linuxarm-hv44wF8Li93QT0dZR+AlfA@public.gmane.org, dan.zhao-C8/M+/jPZTeaMJb+Lgu22Q@public.gmane.org, peter.panshilin-C8/M+/jPZTeaMJb+Lgu22Q@public.gmane.org, qijiwen-C8/M+/jPZTeaMJb+Lgu22Q@public.gmane.org List-Id: iommu@lists.linux-foundation.org On 2015/10/14 20:18, Joerg Roedel wrote: > On Thu, Oct 08, 2015 at 03:45:47PM +0800, Chen Feng wrote: >> +static int hi6220_smmu_attach_dev(struct iommu_domain *domain, >> + struct device *dev) >> +{ >> + struct hi6220_domain *m_domain = to_hi6220_domain(domain); >> + >> + smmu_domain_prepare(m_domain); >> + dev->archdata.iommu = &m_domain->smmu_dev->iova_allocator; >> + >> + return 0; >> +} > > What happens when you attach devices behind different smmus to one > domain? Will that overwrite the smmu_dev pointer in the domain? > Since the smmu master use the same pagetable, the master can use the iova_allocator in smmu driver to allocate iova address. In this way, the different master can get the different io address. >> +static size_t hi6220_smmu_unmap(struct iommu_domain *domain, unsigned long iova, >> + size_t size) >> +{ >> + struct hi6220_domain *m_domain = to_hi6220_domain(domain); >> + size_t page_size = m_domain->smmu_dev->page_size; >> + struct hi6220_smmu *smmu_dev = m_domain->smmu_dev; >> + int *page_table = (unsigned int *)smmu_dev->pgtable_virt; >> + >> + if (size != page_size) { >> + pr_err("unmap size error, only support %zd\n", page_size); >> + return 0; >> + } >> + >> + __clear_smmu_pte(page_table + IOVA_PFN(iova)); >> + >> + return page_size; >> +} > > Don't you need a call to __invalid_smmu_tlb here too? Thanks, I will fix this next version. > > > > Joerg > > > . > -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752576AbbJSBuR (ORCPT ); Sun, 18 Oct 2015 21:50:17 -0400 Received: from szxga03-in.huawei.com ([119.145.14.66]:34725 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752035AbbJSBuP (ORCPT ); Sun, 18 Oct 2015 21:50:15 -0400 Subject: Re: [PATCH 2/3] iommu/hisilicon: Add hi6220 iommu driver To: Joerg Roedel References: <1444290348-66509-1-git-send-email-puck.chen@hisilicon.com> <1444290348-66509-2-git-send-email-puck.chen@hisilicon.com> <20151014121843.GN27420@8bytes.org> CC: , , , , , , , , , , , , , , , , , From: chenfeng Message-ID: <56244C37.9030407@hisilicon.com> Date: Mon, 19 Oct 2015 09:49:43 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <20151014121843.GN27420@8bytes.org> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.142.192.172] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090202.56244C4D.0009,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 8c9b0ec3d9dba2ebe283df73594f7ce0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2015/10/14 20:18, Joerg Roedel wrote: > On Thu, Oct 08, 2015 at 03:45:47PM +0800, Chen Feng wrote: >> +static int hi6220_smmu_attach_dev(struct iommu_domain *domain, >> + struct device *dev) >> +{ >> + struct hi6220_domain *m_domain = to_hi6220_domain(domain); >> + >> + smmu_domain_prepare(m_domain); >> + dev->archdata.iommu = &m_domain->smmu_dev->iova_allocator; >> + >> + return 0; >> +} > > What happens when you attach devices behind different smmus to one > domain? Will that overwrite the smmu_dev pointer in the domain? > Since the smmu master use the same pagetable, the master can use the iova_allocator in smmu driver to allocate iova address. In this way, the different master can get the different io address. >> +static size_t hi6220_smmu_unmap(struct iommu_domain *domain, unsigned long iova, >> + size_t size) >> +{ >> + struct hi6220_domain *m_domain = to_hi6220_domain(domain); >> + size_t page_size = m_domain->smmu_dev->page_size; >> + struct hi6220_smmu *smmu_dev = m_domain->smmu_dev; >> + int *page_table = (unsigned int *)smmu_dev->pgtable_virt; >> + >> + if (size != page_size) { >> + pr_err("unmap size error, only support %zd\n", page_size); >> + return 0; >> + } >> + >> + __clear_smmu_pte(page_table + IOVA_PFN(iova)); >> + >> + return page_size; >> +} > > Don't you need a call to __invalid_smmu_tlb here too? Thanks, I will fix this next version. > > > > Joerg > > > . >