Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2000594rwb; Mon, 7 Nov 2022 08:05:06 -0800 (PST) X-Google-Smtp-Source: AMsMyM643+NjUUxVgNzXbr6zjtOyiWkpQ3TxMbGAuHyJIrLpwGTakQ80KebPBh6f92CDwroNqwdR X-Received: by 2002:a05:6402:2994:b0:453:4c5c:d31c with SMTP id eq20-20020a056402299400b004534c5cd31cmr51053824edb.412.1667837106755; Mon, 07 Nov 2022 08:05:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667837106; cv=none; d=google.com; s=arc-20160816; b=c9qT4LmQmsHTrnXzS8KZsTQydcZx9C2gVkEeXTPDEtGreWtVy5+wugSTeaT7fknHnC KqMFg9B5cUB/d7acOTcuIjPDo3K6q1q6yVA0r3MaYMis56Rc4IK8buTtKWH2J1h+NdTE ai6L639sPFVI6rw2nrgFPQQwApokZL2o2qZ4vhy5i44vZtidOEwIZ4Gz11o59yImiMmu 26cAMP8Y5wEfegW7Pg5qDSoOEdF34/QdX/Iea3s+uwdIvd3vSdbq2g6Gz3dEP6EfZy/j 3MxHnJmThD+oVs99oqlTWtjCL1XlqEpstmTlXFPqYJ/TaOibARZPAm4rqx/mdA9ZkDFZ OAHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=XKsZ1pUPn3K5pRE/Dp7ngoFgBEjp8MGy+3G1/3kBp9o=; b=DnPWlo8ae24+EsMhCuN6ldPwoxIIoftMPTrbrPz6SyupzOo7cSI+3xwaXVgJRTIHpZ e3m+jKmVIZ1QV3BMenM59sdyiOTS2/1INEvYVHq0lv034iyyWJo2HNKV11bEVnrSYHqy 8WLpVKgUCK+gcgqATFDFw5U4amkG9g91RXaK4Uj91MAA1YSSDmRpaTH0VCmIKG4Fa8lU UwGDAKuuA1JIF/GjU+Ih0wdbRxr+Cm+Q53McA/4IaCKdyO34Q0T7egkIVRuswV4winSW rRtInrFsC6lR3iZsTFCfMmehclSt48uWjHhybYs46qNE/uOREDgoa7N9/4FxPRBiAdhk ohaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CtQqMj5p; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id rv14-20020a17090710ce00b007a087ccd275si7086180ejb.384.2022.11.07.08.04.27; Mon, 07 Nov 2022 08:05:06 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=CtQqMj5p; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232020AbiKGP1B (ORCPT + 92 others); Mon, 7 Nov 2022 10:27:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33936 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232879AbiKGP04 (ORCPT ); Mon, 7 Nov 2022 10:26:56 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFB2EBC93; Mon, 7 Nov 2022 07:26:55 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 57D2D6113D; Mon, 7 Nov 2022 15:26:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 45829C433C1; Mon, 7 Nov 2022 15:26:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1667834814; bh=W675gqNAfxBDemkU93uk7keZsNkIbPSTt12Mk3qnGOg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=CtQqMj5pvofsT6RL6c73nOHyJPNzYHtWR26lgwhR5lL+mFr3DLmnfXNOyM2ctk2EB DXSnyVmwBDVWCuh6t/jOYy4sGDpVuaah8fWod0gReT/fuEvZjRhpL+WKjRyfD3KxA5 StyJ8iTVWr2AYevyJncv9jcjUdKTGN08CG+c4sb5sthZwvKGwtnyE5ke3jg/Iw5YSO IG58eDQv1Bu1n7fbiBR5ddQtysHqTwy/hn4mRBxbfYaLnb08KeHt4dh1qmmSMB2QnU Rbls6y5O+krcPIpTHylZ9sv6MHtZf+7JOJAm12EOSyHvBewer8sDqrAkrqaWflTupW qNvv+jC8xzkbQ== Date: Mon, 7 Nov 2022 15:26:45 +0000 From: Will Deacon To: Nicolin Chen Cc: joro@8bytes.org, robin.murphy@arm.com, jgg@nvidia.com, kevin.tian@intel.com, quic_jjohnson@quicinc.com, suravee.suthikulpanit@amd.com, robdclark@gmail.com, dwmw2@infradead.org, baolu.lu@linux.intel.com, yong.wu@mediatek.com, matthias.bgg@gmail.com, orsonzhai@gmail.com, baolin.wang@linux.alibaba.com, zhang.lyra@gmail.com, thierry.reding@gmail.com, vdumpa@nvidia.com, jonathanh@nvidia.com, jean-philippe@linaro.org, tglx@linutronix.de, shameerali.kolothum.thodi@huawei.com, christophe.jaillet@wanadoo.fr, yangyicong@hisilicon.com, yangyingliang@huawei.com, quic_saipraka@quicinc.com, jon@solid-run.com, iommu@lists.linux.dev, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-tegra@vger.kernel.org, virtualization@lists.linux-foundation.org Subject: Re: [PATCH v7 4/5] iommu: Use EINVAL for incompatible device/domain in ->attach_dev Message-ID: <20221107152645.GD21002@willie-the-truck> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 Mon, Oct 17, 2022 at 04:02:21PM -0700, Nicolin Chen wrote: > Following the new rules in include/linux/iommu.h kdocs, update all drivers > ->attach_dev callback functions to return EINVAL in the failure paths that > are related to domain incompatibility. > > Also, drop adjacent error prints to prevent a kernel log spam. > > Reviewed-by: Jean-Philippe Brucker > Reviewed-by: Lu Baolu > Reviewed-by: Kevin Tian > Reviewed-by: Jason Gunthorpe > Signed-off-by: Nicolin Chen > --- > drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 11 +---------- > drivers/iommu/arm/arm-smmu/arm-smmu.c | 3 --- > drivers/iommu/arm/arm-smmu/qcom_iommu.c | 7 +------ > drivers/iommu/intel/iommu.c | 10 +++------- > drivers/iommu/ipmmu-vmsa.c | 2 -- > drivers/iommu/omap-iommu.c | 2 +- > drivers/iommu/sprd-iommu.c | 4 +--- > drivers/iommu/tegra-gart.c | 2 +- > drivers/iommu/virtio-iommu.c | 3 +-- > 9 files changed, 9 insertions(+), 35 deletions(-) > > diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c > index ba47c73f5b8c..01fd7df16cb9 100644 > --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c > +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c > @@ -2430,23 +2430,14 @@ static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev) > goto out_unlock; > } > } else if (smmu_domain->smmu != smmu) { > - dev_err(dev, > - "cannot attach to SMMU %s (upstream of %s)\n", > - dev_name(smmu_domain->smmu->dev), > - dev_name(smmu->dev)); > - ret = -ENXIO; > + ret = -EINVAL; > goto out_unlock; > } else if (smmu_domain->stage == ARM_SMMU_DOMAIN_S1 && > master->ssid_bits != smmu_domain->s1_cfg.s1cdmax) { > - dev_err(dev, > - "cannot attach to incompatible domain (%u SSID bits != %u)\n", > - smmu_domain->s1_cfg.s1cdmax, master->ssid_bits); > ret = -EINVAL; > goto out_unlock; > } else if (smmu_domain->stage == ARM_SMMU_DOMAIN_S1 && > smmu_domain->stall_enabled != master->stall_enabled) { > - dev_err(dev, "cannot attach to stall-%s domain\n", > - smmu_domain->stall_enabled ? "enabled" : "disabled"); > ret = -EINVAL; > goto out_unlock; > } I think it would be helpful to preserve these messages using dev_err_ratelimited() so that attach failure can be diagnosed without having to hack the messages back into the driver. With that: Acked-by: Will Deacon Will