Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp3633846rwb; Tue, 8 Nov 2022 06:48:42 -0800 (PST) X-Google-Smtp-Source: AMsMyM6RSXwRB4cL1qRY+sqTVWrsr/drxPGsPVAbMP+ajDWJHsetgmYtXL7SBItk4mz5iEgWmOEt X-Received: by 2002:a17:907:2cf1:b0:7ad:f558:e148 with SMTP id hz17-20020a1709072cf100b007adf558e148mr37459544ejc.274.1667918922244; Tue, 08 Nov 2022 06:48:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667918922; cv=none; d=google.com; s=arc-20160816; b=k2EiElnE/xuhcBoTxPtEuA07e2zRavykRyfppPWHA2sHw90LA9GEuZT9wov2dGr2X7 AMZA5M3DIf4BURL48GhgZtwd9MwbdO0ZgXOOjPox04Z3QCDTNF2dRkog/Y6tbKaWEB9e 91iBMRwTIvy8LmsV0RdxPStMvCbiGLOTt7Ew1/2VqZMfwQI4etxhKNKpiKuKWsmjTN0v fjnTRvrpSY6Dw2BIMTzcK/dGuk8VkoADZsDqSuehQxquHEbkTrxtQeCKjW39Dx3b131g 6BOx0sO6Pq/0UkbBQbowPiLQiZ7512RNI0Ux+iSoqkYmOMVL9fn45k0xeQ0VxFXKGLMZ IREA== 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=972S+snkfIEyptDGN/uXs5rf4BUjW/YZmuV568v603E=; b=ZVniLRMadlzxUrQsIaD0IJDDrxkyeoAxFAxy17gNHIWx4DM1ZG2AwYkVhzCEg9kegb QritJrOW5W/LYvvkRv3ydNYrDrZWC/hwEagcEkC4PhUzI4RQGIAm9aiD3P/j0Dsy4vFE YISJHazt26NEgFi+OJT+a+MTTtj7SpfoiV8lo/Ld/3M4M5DYW/GY+YgeE23pzQTwwiJB 8X11VCU3lHZkEkxUIXgr5OQvAuey2XP0nYfM07pu+2vcCY/A6AFmst1ECz7Nvss5tT+u DEvRio2BhP/8qzbSTZO9U85Wsi9pjUdVJSjs/j6leeEoufsjOab3RgENJQyrL1Fch5Y3 dr0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LZaBgX2V; 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 mp41-20020a1709071b2900b0078d9b5792a0si14263596ejc.319.2022.11.08.06.48.21; Tue, 08 Nov 2022 06:48:42 -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=LZaBgX2V; 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 S234388AbiKHNUy (ORCPT + 90 others); Tue, 8 Nov 2022 08:20:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233751AbiKHNUx (ORCPT ); Tue, 8 Nov 2022 08:20:53 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6ECF831F8D; Tue, 8 Nov 2022 05:20:52 -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 121EE61557; Tue, 8 Nov 2022 13:20:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D7360C433D6; Tue, 8 Nov 2022 13:20:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1667913651; bh=F1MrMjvh/L1F4zxWBX7r8xXYoMUO4ZXMTGWde/+UFd8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=LZaBgX2VaqGZgOh/2C0l++qPRlM8ueDrM9SLeSVBvUQEQ0+CNdo356p2qirP1dEgJ p/H4iy/1oAwn0ait0PvZKuBfPMAnQDFDkXJtKbJiot6gOdqiqVGf0/w7jk8vpPsbFI n39iYmDpzjVLSA1MXWr/cDCfrGf3A/+OHru3RiE4kPX3W97ALdEM6/h3yPQ0zjGCJZ q1ivEC4oeiOD9WI4AegBBhj03IgPbMrHzOGR+4pXQwzPuGiX7waZ0und1RxcXF1J+j MXeA9iQvAXVNy8WS4w2xu8rFWvjxhzh0obhV1OFgD6jSVycIiG4hb8lh5dBxyqba2D JHeBEQ2z21fvg== Date: Tue, 8 Nov 2022 13:20:42 +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: <20221108132041.GB22816@willie-the-truck> References: <20221107152645.GD21002@willie-the-truck> 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, Nov 07, 2022 at 04:14:32PM -0800, Nicolin Chen wrote: > On Mon, Nov 07, 2022 at 03:26:45PM +0000, Will Deacon wrote: > > > > 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. > > Thank you for the review. > > The change is already picked up last week. Yet, I can add prints > back with a followup patch, if no one has a problem with that. Sorry, I fell behind with upstream so I got to this late. A patch on top would be fantastic! > Also, I am not quite sure what the use case would be to have an > error print. Perhaps dev_dbg() would be more fitting if it is > just for diagnosis? Sure, that works for me. I think the messages are useful for folks triggering this path e.g. via sysfs but if they're limited to debug I think that's better than removing them altogether. Cheers, Will