From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E74D2C3A5A0 for ; Mon, 20 Apr 2020 15:26:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D0B422074F for ; Mon, 20 Apr 2020 15:26:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726123AbgDTP02 (ORCPT ); Mon, 20 Apr 2020 11:26:28 -0400 Received: from foss.arm.com ([217.140.110.172]:51002 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726050AbgDTP02 (ORCPT ); Mon, 20 Apr 2020 11:26:28 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 99BAD31B; Mon, 20 Apr 2020 08:26:27 -0700 (PDT) Received: from [10.57.33.63] (unknown [10.57.33.63]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3F9483F73D; Mon, 20 Apr 2020 08:26:25 -0700 (PDT) Subject: Re: [PATCHv2 3/6] iommu/arm-smmu: Implement iommu_ops->def_domain_type call-back To: Sai Prakash Ranjan , Will Deacon , Joerg Roedel , Sibi Sankar , Bjorn Andersson , Jordan Crouse , Rob Clark Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Evan Green , Stephen Boyd , iommu@lists.linux-foundation.org, Matthias Kaehlcke , linux-arm-kernel@lists.infradead.org References: <558b1aee4c699a0a5b14b325178d22a79958488f.1587392905.git.saiprakash.ranjan@codeaurora.org> From: Robin Murphy Message-ID: <6dd26176-448a-985c-90fc-7c47088015ff@arm.com> Date: Mon, 20 Apr 2020 16:26:22 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <558b1aee4c699a0a5b14b325178d22a79958488f.1587392905.git.saiprakash.ranjan@codeaurora.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org On 2020-04-20 3:37 pm, Sai Prakash Ranjan wrote: > Implement the new def_domain_type call-back for the ARM > SMMU driver. We need this to support requesting the domain > type by the client devices. > > Signed-off-by: Sai Prakash Ranjan > --- > drivers/iommu/arm-smmu.c | 20 ++++++++++++++++++++ > 1 file changed, 20 insertions(+) > > diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c > index e622f4e33379..b5d1d52dfbb8 100644 > --- a/drivers/iommu/arm-smmu.c > +++ b/drivers/iommu/arm-smmu.c > @@ -1609,6 +1609,25 @@ static void arm_smmu_get_resv_regions(struct device *dev, > iommu_dma_get_resv_regions(dev, head); > } > > +static int arm_smmu_def_domain_type(struct device *dev) > +{ > + struct iommu_fwspec *fwspec; > + struct arm_smmu_device *smmu; > + > + fwspec = dev_iommu_fwspec_get(dev); > + if (!fwspec || fwspec->ops != &arm_smmu_ops) > + return -ENODEV; > + > + smmu = arm_smmu_get_by_fwnode(fwspec->iommu_fwnode); > + if (!smmu) > + return -ENODEV; > + AFAICS this should only ever be called for a device in a group, which means an initial ->probe_device has succeeded and rather than defensively going the long way round, we can safely assume this: struct arm_smmu_master_cfg = dev_iommu_priv_get(dev); struct arm_smmu_impl *impl = cfg->smmu->impl; if (impl && impl->req_domain) return impl->req_domain(dev); Or have I misunderstood the flow? Robin. > + if (smmu->impl && smmu->impl->req_domain) > + return smmu->impl->req_domain(dev); > + > + return 0; > +} > + > static struct iommu_ops arm_smmu_ops = { > .capable = arm_smmu_capable, > .domain_alloc = arm_smmu_domain_alloc, > @@ -1627,6 +1646,7 @@ static struct iommu_ops arm_smmu_ops = { > .of_xlate = arm_smmu_of_xlate, > .get_resv_regions = arm_smmu_get_resv_regions, > .put_resv_regions = generic_iommu_put_resv_regions, > + .def_domain_type = arm_smmu_def_domain_type, > .pgsize_bitmap = -1UL, /* Restricted during device attach */ > }; > > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C73B8C3815B for ; Mon, 20 Apr 2020 15:26:31 +0000 (UTC) Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 94C662074F for ; Mon, 20 Apr 2020 15:26:31 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 94C662074F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=iommu-bounces@lists.linux-foundation.org Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 7088687009; Mon, 20 Apr 2020 15:26:31 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id wyeyyIsuoy0F; Mon, 20 Apr 2020 15:26:30 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by hemlock.osuosl.org (Postfix) with ESMTP id BFFDF86758; Mon, 20 Apr 2020 15:26:30 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id A506AC07FF; Mon, 20 Apr 2020 15:26:30 +0000 (UTC) Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 2D358C0177 for ; Mon, 20 Apr 2020 15:26:29 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id 168EE86CAC for ; Mon, 20 Apr 2020 15:26:29 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id lvtPDIkmjLVD for ; Mon, 20 Apr 2020 15:26:28 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by hemlock.osuosl.org (Postfix) with ESMTP id 433C786758 for ; Mon, 20 Apr 2020 15:26:28 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 99BAD31B; Mon, 20 Apr 2020 08:26:27 -0700 (PDT) Received: from [10.57.33.63] (unknown [10.57.33.63]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3F9483F73D; Mon, 20 Apr 2020 08:26:25 -0700 (PDT) Subject: Re: [PATCHv2 3/6] iommu/arm-smmu: Implement iommu_ops->def_domain_type call-back To: Sai Prakash Ranjan , Will Deacon , Joerg Roedel , Sibi Sankar , Bjorn Andersson , Jordan Crouse , Rob Clark References: <558b1aee4c699a0a5b14b325178d22a79958488f.1587392905.git.saiprakash.ranjan@codeaurora.org> From: Robin Murphy Message-ID: <6dd26176-448a-985c-90fc-7c47088015ff@arm.com> Date: Mon, 20 Apr 2020 16:26:22 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <558b1aee4c699a0a5b14b325178d22a79958488f.1587392905.git.saiprakash.ranjan@codeaurora.org> Content-Language: en-GB Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Evan Green , Stephen Boyd , iommu@lists.linux-foundation.org, Matthias Kaehlcke , linux-arm-kernel@lists.infradead.org X-BeenThere: iommu@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Development issues for Linux IOMMU support List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: iommu-bounces@lists.linux-foundation.org Sender: "iommu" On 2020-04-20 3:37 pm, Sai Prakash Ranjan wrote: > Implement the new def_domain_type call-back for the ARM > SMMU driver. We need this to support requesting the domain > type by the client devices. > > Signed-off-by: Sai Prakash Ranjan > --- > drivers/iommu/arm-smmu.c | 20 ++++++++++++++++++++ > 1 file changed, 20 insertions(+) > > diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c > index e622f4e33379..b5d1d52dfbb8 100644 > --- a/drivers/iommu/arm-smmu.c > +++ b/drivers/iommu/arm-smmu.c > @@ -1609,6 +1609,25 @@ static void arm_smmu_get_resv_regions(struct device *dev, > iommu_dma_get_resv_regions(dev, head); > } > > +static int arm_smmu_def_domain_type(struct device *dev) > +{ > + struct iommu_fwspec *fwspec; > + struct arm_smmu_device *smmu; > + > + fwspec = dev_iommu_fwspec_get(dev); > + if (!fwspec || fwspec->ops != &arm_smmu_ops) > + return -ENODEV; > + > + smmu = arm_smmu_get_by_fwnode(fwspec->iommu_fwnode); > + if (!smmu) > + return -ENODEV; > + AFAICS this should only ever be called for a device in a group, which means an initial ->probe_device has succeeded and rather than defensively going the long way round, we can safely assume this: struct arm_smmu_master_cfg = dev_iommu_priv_get(dev); struct arm_smmu_impl *impl = cfg->smmu->impl; if (impl && impl->req_domain) return impl->req_domain(dev); Or have I misunderstood the flow? Robin. > + if (smmu->impl && smmu->impl->req_domain) > + return smmu->impl->req_domain(dev); > + > + return 0; > +} > + > static struct iommu_ops arm_smmu_ops = { > .capable = arm_smmu_capable, > .domain_alloc = arm_smmu_domain_alloc, > @@ -1627,6 +1646,7 @@ static struct iommu_ops arm_smmu_ops = { > .of_xlate = arm_smmu_of_xlate, > .get_resv_regions = arm_smmu_get_resv_regions, > .put_resv_regions = generic_iommu_put_resv_regions, > + .def_domain_type = arm_smmu_def_domain_type, > .pgsize_bitmap = -1UL, /* Restricted during device attach */ > }; > > _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.3 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4E487C3815B for ; Mon, 20 Apr 2020 15:26:46 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1A2382074F for ; Mon, 20 Apr 2020 15:26:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="ECUy5hgS" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1A2382074F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender:Content-Type: Content-Transfer-Encoding:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=p6URrvNyeMTse4lm9HpANTWuPYOEfQtjuUhGARBzcV8=; b=ECUy5hgSPXxUY5f+K1MDEKZxI IyU0AfM/U9wPMStLXIefsNew1iUklZvLXv1LMw33qw7V5O1E+AH1ZSv6Qxhjl1UM6FLLVZrfEspzU DA6/2i4QYP3S2CPWtyVqw2IVb1N2q8fCV0NrbLE9V3HHGcqXg4DMzcLEYCfixMipDlDahL4BuQlKv v4u8KbO7waDsZsjRqfZE94YqshkB9dvgwRbglBKTFlz1Mk7Czg2PO2LNtIjBD/l+y/NWwKkf599Rl kIIeJL+ztJnuWptUXtgRmmlHLYOvrcOqX7I7eGIi6Q1hmpOuZE0TJIIvWiFV9wBjUVI7q5ucajp4p E87j4pQ8g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jQYJn-0003of-0J; Mon, 20 Apr 2020 15:26:43 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jQYJY-0003bt-5x for linux-arm-kernel@lists.infradead.org; Mon, 20 Apr 2020 15:26:29 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 99BAD31B; Mon, 20 Apr 2020 08:26:27 -0700 (PDT) Received: from [10.57.33.63] (unknown [10.57.33.63]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3F9483F73D; Mon, 20 Apr 2020 08:26:25 -0700 (PDT) Subject: Re: [PATCHv2 3/6] iommu/arm-smmu: Implement iommu_ops->def_domain_type call-back To: Sai Prakash Ranjan , Will Deacon , Joerg Roedel , Sibi Sankar , Bjorn Andersson , Jordan Crouse , Rob Clark References: <558b1aee4c699a0a5b14b325178d22a79958488f.1587392905.git.saiprakash.ranjan@codeaurora.org> From: Robin Murphy Message-ID: <6dd26176-448a-985c-90fc-7c47088015ff@arm.com> Date: Mon, 20 Apr 2020 16:26:22 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <558b1aee4c699a0a5b14b325178d22a79958488f.1587392905.git.saiprakash.ranjan@codeaurora.org> Content-Language: en-GB X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200420_082628_331791_29ED264D X-CRM114-Status: GOOD ( 18.14 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Evan Green , Stephen Boyd , iommu@lists.linux-foundation.org, Matthias Kaehlcke , linux-arm-kernel@lists.infradead.org Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 2020-04-20 3:37 pm, Sai Prakash Ranjan wrote: > Implement the new def_domain_type call-back for the ARM > SMMU driver. We need this to support requesting the domain > type by the client devices. > > Signed-off-by: Sai Prakash Ranjan > --- > drivers/iommu/arm-smmu.c | 20 ++++++++++++++++++++ > 1 file changed, 20 insertions(+) > > diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c > index e622f4e33379..b5d1d52dfbb8 100644 > --- a/drivers/iommu/arm-smmu.c > +++ b/drivers/iommu/arm-smmu.c > @@ -1609,6 +1609,25 @@ static void arm_smmu_get_resv_regions(struct device *dev, > iommu_dma_get_resv_regions(dev, head); > } > > +static int arm_smmu_def_domain_type(struct device *dev) > +{ > + struct iommu_fwspec *fwspec; > + struct arm_smmu_device *smmu; > + > + fwspec = dev_iommu_fwspec_get(dev); > + if (!fwspec || fwspec->ops != &arm_smmu_ops) > + return -ENODEV; > + > + smmu = arm_smmu_get_by_fwnode(fwspec->iommu_fwnode); > + if (!smmu) > + return -ENODEV; > + AFAICS this should only ever be called for a device in a group, which means an initial ->probe_device has succeeded and rather than defensively going the long way round, we can safely assume this: struct arm_smmu_master_cfg = dev_iommu_priv_get(dev); struct arm_smmu_impl *impl = cfg->smmu->impl; if (impl && impl->req_domain) return impl->req_domain(dev); Or have I misunderstood the flow? Robin. > + if (smmu->impl && smmu->impl->req_domain) > + return smmu->impl->req_domain(dev); > + > + return 0; > +} > + > static struct iommu_ops arm_smmu_ops = { > .capable = arm_smmu_capable, > .domain_alloc = arm_smmu_domain_alloc, > @@ -1627,6 +1646,7 @@ static struct iommu_ops arm_smmu_ops = { > .of_xlate = arm_smmu_of_xlate, > .get_resv_regions = arm_smmu_get_resv_regions, > .put_resv_regions = generic_iommu_put_resv_regions, > + .def_domain_type = arm_smmu_def_domain_type, > .pgsize_bitmap = -1UL, /* Restricted during device attach */ > }; > > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel