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=-15.3 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,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 A9C43C433C1 for ; Thu, 25 Mar 2021 14:28:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 819CD61A25 for ; Thu, 25 Mar 2021 14:28:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230113AbhCYO2F (ORCPT ); Thu, 25 Mar 2021 10:28:05 -0400 Received: from foss.arm.com ([217.140.110.172]:50798 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231400AbhCYO1n (ORCPT ); Thu, 25 Mar 2021 10:27:43 -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 4BD9A143D; Thu, 25 Mar 2021 07:27:43 -0700 (PDT) Received: from [10.57.50.37] (unknown [10.57.50.37]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A88173F792; Thu, 25 Mar 2021 07:27:41 -0700 (PDT) Subject: Re: [PATCH 4/9] iommu/arm-smmu: Implement ->probe_finalize() To: Thierry Reding , Will Deacon , Joerg Roedel , Krzysztof Kozlowski Cc: Jon Hunter , Nicolin Chen , Krishna Reddy , linux-tegra@vger.kernel.org, iommu@lists.linux-foundation.org, linux-arm-kernel@lists.infradead.org References: <20210325130332.778208-1-thierry.reding@gmail.com> <20210325130332.778208-5-thierry.reding@gmail.com> From: Robin Murphy Message-ID: <57ffa62b-76da-c643-fa68-aed92b1e92e0@arm.com> Date: Thu, 25 Mar 2021 14:27:34 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: <20210325130332.778208-5-thierry.reding@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-tegra@vger.kernel.org On 2021-03-25 13:03, Thierry Reding wrote: > From: Thierry Reding > > Implement a ->probe_finalize() callback that can be used by vendor > implementations to perform extra programming necessary after devices > have been attached to the SMMU. > > Signed-off-by: Thierry Reding > --- > drivers/iommu/arm/arm-smmu/arm-smmu.c | 17 +++++++++++++++++ > drivers/iommu/arm/arm-smmu/arm-smmu.h | 1 + > 2 files changed, 18 insertions(+) > > diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-smmu/arm-smmu.c > index d8c6bfde6a61..4589e76543a8 100644 > --- a/drivers/iommu/arm/arm-smmu/arm-smmu.c > +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c > @@ -1447,6 +1447,22 @@ static void arm_smmu_release_device(struct device *dev) > iommu_fwspec_free(dev); > } > > +static void arm_smmu_probe_finalize(struct device *dev) > +{ > + struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev); > + struct arm_smmu_master_cfg *cfg; > + struct arm_smmu_device *smmu; > + > + if (!fwspec || fwspec->ops != &arm_smmu_ops) > + return; I think we can trust the IOMMU core not to call things in the wrong order, and if the fwspec has changed since it was validated in .probe_device then the world is probably on fire anyway. Robin. > + > + cfg = dev_iommu_priv_get(dev); > + smmu = cfg->smmu; > + > + if (smmu->impl->probe_finalize) > + smmu->impl->probe_finalize(smmu, dev); > +} > + > static struct iommu_group *arm_smmu_device_group(struct device *dev) > { > struct arm_smmu_master_cfg *cfg = dev_iommu_priv_get(dev); > @@ -1630,6 +1646,7 @@ static struct iommu_ops arm_smmu_ops = { > .iova_to_phys = arm_smmu_iova_to_phys, > .probe_device = arm_smmu_probe_device, > .release_device = arm_smmu_release_device, > + .probe_finalize = arm_smmu_probe_finalize, > .device_group = arm_smmu_device_group, > .domain_get_attr = arm_smmu_domain_get_attr, > .domain_set_attr = arm_smmu_domain_set_attr, > diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.h b/drivers/iommu/arm/arm-smmu/arm-smmu.h > index d2a2d1bc58ba..6779db30cebb 100644 > --- a/drivers/iommu/arm/arm-smmu/arm-smmu.h > +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.h > @@ -439,6 +439,7 @@ struct arm_smmu_impl { > struct device *dev, int start); > void (*write_s2cr)(struct arm_smmu_device *smmu, int idx); > void (*write_sctlr)(struct arm_smmu_device *smmu, int idx, u32 reg); > + void (*probe_finalize)(struct arm_smmu_device *smmu, struct device *dev); > }; > > #define INVALID_SMENDX -1 > 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=-15.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, URIBL_RED,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 C39FCC433C1 for ; Thu, 25 Mar 2021 14:27:48 +0000 (UTC) Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (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 50F2C61A25 for ; Thu, 25 Mar 2021 14:27:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 50F2C61A25 Authentication-Results: mail.kernel.org; dmarc=fail (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 smtp1.osuosl.org (Postfix) with ESMTP id 1E93C84A10; Thu, 25 Mar 2021 14:27:48 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id IouIbyxZ9ZdQ; Thu, 25 Mar 2021 14:27:47 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp1.osuosl.org (Postfix) with ESMTP id 01DF684A0A; Thu, 25 Mar 2021 14:27:47 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id D546FC000E; Thu, 25 Mar 2021 14:27:46 +0000 (UTC) Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by lists.linuxfoundation.org (Postfix) with ESMTP id 43D99C000A for ; Thu, 25 Mar 2021 14:27:46 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 229574058B for ; Thu, 25 Mar 2021 14:27:46 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id xls-cTCZof9Z for ; Thu, 25 Mar 2021 14:27:45 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp4.osuosl.org (Postfix) with ESMTP id F40CE4056B for ; Thu, 25 Mar 2021 14:27:44 +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 4BD9A143D; Thu, 25 Mar 2021 07:27:43 -0700 (PDT) Received: from [10.57.50.37] (unknown [10.57.50.37]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A88173F792; Thu, 25 Mar 2021 07:27:41 -0700 (PDT) Subject: Re: [PATCH 4/9] iommu/arm-smmu: Implement ->probe_finalize() To: Thierry Reding , Will Deacon , Joerg Roedel , Krzysztof Kozlowski References: <20210325130332.778208-1-thierry.reding@gmail.com> <20210325130332.778208-5-thierry.reding@gmail.com> From: Robin Murphy Message-ID: <57ffa62b-76da-c643-fa68-aed92b1e92e0@arm.com> Date: Thu, 25 Mar 2021 14:27:34 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: <20210325130332.778208-5-thierry.reding@gmail.com> Content-Language: en-GB Cc: iommu@lists.linux-foundation.org, Jon Hunter , Nicolin Chen , linux-tegra@vger.kernel.org, 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 2021-03-25 13:03, Thierry Reding wrote: > From: Thierry Reding > > Implement a ->probe_finalize() callback that can be used by vendor > implementations to perform extra programming necessary after devices > have been attached to the SMMU. > > Signed-off-by: Thierry Reding > --- > drivers/iommu/arm/arm-smmu/arm-smmu.c | 17 +++++++++++++++++ > drivers/iommu/arm/arm-smmu/arm-smmu.h | 1 + > 2 files changed, 18 insertions(+) > > diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-smmu/arm-smmu.c > index d8c6bfde6a61..4589e76543a8 100644 > --- a/drivers/iommu/arm/arm-smmu/arm-smmu.c > +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c > @@ -1447,6 +1447,22 @@ static void arm_smmu_release_device(struct device *dev) > iommu_fwspec_free(dev); > } > > +static void arm_smmu_probe_finalize(struct device *dev) > +{ > + struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev); > + struct arm_smmu_master_cfg *cfg; > + struct arm_smmu_device *smmu; > + > + if (!fwspec || fwspec->ops != &arm_smmu_ops) > + return; I think we can trust the IOMMU core not to call things in the wrong order, and if the fwspec has changed since it was validated in .probe_device then the world is probably on fire anyway. Robin. > + > + cfg = dev_iommu_priv_get(dev); > + smmu = cfg->smmu; > + > + if (smmu->impl->probe_finalize) > + smmu->impl->probe_finalize(smmu, dev); > +} > + > static struct iommu_group *arm_smmu_device_group(struct device *dev) > { > struct arm_smmu_master_cfg *cfg = dev_iommu_priv_get(dev); > @@ -1630,6 +1646,7 @@ static struct iommu_ops arm_smmu_ops = { > .iova_to_phys = arm_smmu_iova_to_phys, > .probe_device = arm_smmu_probe_device, > .release_device = arm_smmu_release_device, > + .probe_finalize = arm_smmu_probe_finalize, > .device_group = arm_smmu_device_group, > .domain_get_attr = arm_smmu_domain_get_attr, > .domain_set_attr = arm_smmu_domain_set_attr, > diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.h b/drivers/iommu/arm/arm-smmu/arm-smmu.h > index d2a2d1bc58ba..6779db30cebb 100644 > --- a/drivers/iommu/arm/arm-smmu/arm-smmu.h > +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.h > @@ -439,6 +439,7 @@ struct arm_smmu_impl { > struct device *dev, int start); > void (*write_s2cr)(struct arm_smmu_device *smmu, int idx); > void (*write_sctlr)(struct arm_smmu_device *smmu, int idx, u32 reg); > + void (*probe_finalize)(struct arm_smmu_device *smmu, struct device *dev); > }; > > #define INVALID_SMENDX -1 > _______________________________________________ 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=-15.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,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 B9D18C433DB for ; Thu, 25 Mar 2021 14:29:56 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 5A698619CB for ; Thu, 25 Mar 2021 14:29:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5A698619CB Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+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=desiato.20200630; 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=/h6nrzFNWlM8EnSHQ0DAZohdiEBIIkB2pjliYEbiGlg=; b=VsFHaVPoOcb7VHgYITUwKkkag TfDyffVzff8mfwxXyrYQmBs0Xt97p10K/rhgwl0LqvB06ZRaR0TP3hXBvOzEx9atCS60Nl+nmfn2B HlD0LbVBD0GufRliZu64ODoY+oRIKGT9F4ZGR6uXLsyMrs32dEGjdiawmzLq7G41D4Zp9a4CY7tM+ I+103qNnDa8bPy+uPLguh8Vf7traDJfLCIMqNrhZWD9dTogy6fl4GQGzkOs3025VeSyuHX2HVViAD zTTimBAMF3bZcP7sNMNWbBUZ0ISX6BO2SvbKQEiMwsO7wGtbVsLJOzukVBTDmEJ7qxUCViXQc/h0v hdMwejW8Q==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lPQxj-001bji-3A; Thu, 25 Mar 2021 14:27:51 +0000 Received: from foss.arm.com ([217.140.110.172]) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lPQxc-001bj6-9J for linux-arm-kernel@lists.infradead.org; Thu, 25 Mar 2021 14:27:46 +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 4BD9A143D; Thu, 25 Mar 2021 07:27:43 -0700 (PDT) Received: from [10.57.50.37] (unknown [10.57.50.37]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A88173F792; Thu, 25 Mar 2021 07:27:41 -0700 (PDT) Subject: Re: [PATCH 4/9] iommu/arm-smmu: Implement ->probe_finalize() To: Thierry Reding , Will Deacon , Joerg Roedel , Krzysztof Kozlowski References: <20210325130332.778208-1-thierry.reding@gmail.com> <20210325130332.778208-5-thierry.reding@gmail.com> From: Robin Murphy Message-ID: <57ffa62b-76da-c643-fa68-aed92b1e92e0@arm.com> Date: Thu, 25 Mar 2021 14:27:34 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: <20210325130332.778208-5-thierry.reding@gmail.com> Content-Language: en-GB X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210325_142744_547951_CC4012DA X-CRM114-Status: GOOD ( 19.63 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: iommu@lists.linux-foundation.org, Jon Hunter , Nicolin Chen , linux-tegra@vger.kernel.org, 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+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 2021-03-25 13:03, Thierry Reding wrote: > From: Thierry Reding > > Implement a ->probe_finalize() callback that can be used by vendor > implementations to perform extra programming necessary after devices > have been attached to the SMMU. > > Signed-off-by: Thierry Reding > --- > drivers/iommu/arm/arm-smmu/arm-smmu.c | 17 +++++++++++++++++ > drivers/iommu/arm/arm-smmu/arm-smmu.h | 1 + > 2 files changed, 18 insertions(+) > > diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-smmu/arm-smmu.c > index d8c6bfde6a61..4589e76543a8 100644 > --- a/drivers/iommu/arm/arm-smmu/arm-smmu.c > +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c > @@ -1447,6 +1447,22 @@ static void arm_smmu_release_device(struct device *dev) > iommu_fwspec_free(dev); > } > > +static void arm_smmu_probe_finalize(struct device *dev) > +{ > + struct iommu_fwspec *fwspec = dev_iommu_fwspec_get(dev); > + struct arm_smmu_master_cfg *cfg; > + struct arm_smmu_device *smmu; > + > + if (!fwspec || fwspec->ops != &arm_smmu_ops) > + return; I think we can trust the IOMMU core not to call things in the wrong order, and if the fwspec has changed since it was validated in .probe_device then the world is probably on fire anyway. Robin. > + > + cfg = dev_iommu_priv_get(dev); > + smmu = cfg->smmu; > + > + if (smmu->impl->probe_finalize) > + smmu->impl->probe_finalize(smmu, dev); > +} > + > static struct iommu_group *arm_smmu_device_group(struct device *dev) > { > struct arm_smmu_master_cfg *cfg = dev_iommu_priv_get(dev); > @@ -1630,6 +1646,7 @@ static struct iommu_ops arm_smmu_ops = { > .iova_to_phys = arm_smmu_iova_to_phys, > .probe_device = arm_smmu_probe_device, > .release_device = arm_smmu_release_device, > + .probe_finalize = arm_smmu_probe_finalize, > .device_group = arm_smmu_device_group, > .domain_get_attr = arm_smmu_domain_get_attr, > .domain_set_attr = arm_smmu_domain_set_attr, > diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.h b/drivers/iommu/arm/arm-smmu/arm-smmu.h > index d2a2d1bc58ba..6779db30cebb 100644 > --- a/drivers/iommu/arm/arm-smmu/arm-smmu.h > +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.h > @@ -439,6 +439,7 @@ struct arm_smmu_impl { > struct device *dev, int start); > void (*write_s2cr)(struct arm_smmu_device *smmu, int idx); > void (*write_sctlr)(struct arm_smmu_device *smmu, int idx, u32 reg); > + void (*probe_finalize)(struct arm_smmu_device *smmu, struct device *dev); > }; > > #define INVALID_SMENDX -1 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel