Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp5630101rwb; Wed, 7 Sep 2022 05:57:32 -0700 (PDT) X-Google-Smtp-Source: AA6agR6YiPh4iT2hMnbwT18F8zjDsS+Fx3ECna4yo+0qjVxq2It2q3XO5JAJQ5cgI2ykHe46KNJ1 X-Received: by 2002:aa7:dcd2:0:b0:44e:69f3:edd1 with SMTP id w18-20020aa7dcd2000000b0044e69f3edd1mr2996783edu.244.1662555452498; Wed, 07 Sep 2022 05:57:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662555452; cv=none; d=google.com; s=arc-20160816; b=RK2sbdOjSNUNJMLRclfcL7rSrssC/2mDAYJiz9fZuAtbii9nwbo9DvUrS8DQk6UueE wj5EQI0aA3E/RK68EFlzSoPex8bFCgnEHz4Tm2qWmGN75Q8yhH6UnB6Z5CSW36cbLu0b scT1kA789Hg6xNDshXwFKIhUVTMYJtf6OLHySUTcl/oo6mqJYsdMQidVd8ZQHYM9JOex YPLtN+TgMt+50zAfCZgpv9OaKqmeYvUKYpdBbPhm2YTuvS8ma6bXeoa6JCbFfJlU4mNl 02hn9gTOHbKAp8i9KQ+Q3vB7PnnQIP6ct/uYhiAdlr3zakv37pIGK+3VA/jmNZkLuU5R cLmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=XIxdREi3Ti2by2J5mIgSoJYnvifDR2X/nVcpSg7T7jQ=; b=MulNdblqafcv5xEHcP3CSUEyCXc6X2STR/7pmhlXEyFTNkMJWLkDbjHHZy0xAGh1s8 tVOaBFcKyEvOikNokJt72fNzGRGr2RfFh+5E+nemN5d890EsNgvBUcz9KSN/MsvT4zKb EOESH7q24eh0athC0dhe2zHDE71WBA7N+SA6OUjvzoiTQPPuG6nm69OQ3zkzQINZr26F YoNhPjnBu42dF++H7+TAosB7uISioJBSAgpaRC0+OEwA/j7H3ABWBfLgAxj3it5ZkTB8 h1QAQ+xeVGC7EmzBXdq3Ll/PXKf87SXXG/I0NYMQfcIVD59XuOigeqWivi39ZMKhnlFz cthQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@8bytes.org header.s=default header.b=60gm7iJb; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cw14-20020a056402228e00b0044ebc68596dsi4419845edb.538.2022.09.07.05.57.07; Wed, 07 Sep 2022 05:57:32 -0700 (PDT) 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=@8bytes.org header.s=default header.b=60gm7iJb; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229908AbiIGMvA (ORCPT + 99 others); Wed, 7 Sep 2022 08:51:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229609AbiIGMut (ORCPT ); Wed, 7 Sep 2022 08:50:49 -0400 Received: from mail.8bytes.org (mail.8bytes.org [85.214.250.239]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id EFF0975CF8; Wed, 7 Sep 2022 05:50:46 -0700 (PDT) Received: from 8bytes.org (p4ff2bb62.dip0.t-ipconnect.de [79.242.187.98]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.8bytes.org (Postfix) with ESMTPSA id 6FAA4240857; Wed, 7 Sep 2022 14:41:55 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=8bytes.org; s=default; t=1662554516; bh=JzhvE6AKnt05k9hUcUfcBmLyd7x5XDIZ52BK23fxpSg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=60gm7iJb3a9EHDRBPPmkRhjnPxPdo8Gl8tCIOOIov74tc9nJYqxwRN3f9BaD/uBTh ZoV5WBylA/H+HpQRYy6dC/0WalBc7Xg2gQ/EGr7HOKkp3DB6I7K2VtL5rWe+yHaFHo 3GC6YDahBrvwp1lTMhPP0vwiUslxcaImFmKevknjuQ++PrHb+32Kb+SwW1OGoiSniC j5WIwf2zsHXP7Dwv+Ps3tJybqv0ASdmzh/SRgK2OM7/c76yEAtXi01DBWO3CrfKkfR V7IV9Z/HY1tQSVYITH64oKsBfN+UYoyf/xQA2uGwpPthodTETsq7ja03Rs0zm47WBI eNx1oHFYz53Og== Date: Wed, 7 Sep 2022 14:41:54 +0200 From: Joerg Roedel To: Nicolin Chen Cc: will@kernel.org, robin.murphy@arm.com, alex.williamson@redhat.com, suravee.suthikulpanit@amd.com, marcan@marcan.st, sven@svenpeter.dev, alyssa@rosenzweig.io, robdclark@gmail.com, dwmw2@infradead.org, baolu.lu@linux.intel.com, mjrosato@linux.ibm.com, gerald.schaefer@linux.ibm.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, cohuck@redhat.com, jgg@nvidia.com, tglx@linutronix.de, shameerali.kolothum.thodi@huawei.com, thunder.leizhen@huawei.com, christophe.jaillet@wanadoo.fr, yangyingliang@huawei.com, jon@solid-run.com, iommu@lists.linux.dev, linux-kernel@vger.kernel.org, asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-s390@vger.kernel.org, linux-tegra@vger.kernel.org, virtualization@lists.linux-foundation.org, kvm@vger.kernel.org, kevin.tian@intel.com Subject: Re: [PATCH v6 1/5] iommu: Return -EMEDIUMTYPE for incompatible domain and device/group Message-ID: References: <20220815181437.28127-1-nicolinc@nvidia.com> <20220815181437.28127-2-nicolinc@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220815181437.28127-2-nicolinc@nvidia.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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, Aug 15, 2022 at 11:14:33AM -0700, Nicolin Chen wrote: > Provide a dedicated errno from the IOMMU driver during attach that the > reason attached failed is because of domain incompatability. EMEDIUMTYPE > is chosen because it is never used within the iommu subsystem today and > evokes a sense that the 'medium' aka the domain is incompatible. I am not a fan of re-using EMEDIUMTYPE or any other special value. What is needed here in EINVAL, but with a way to tell the caller which of the function parameters is actually invalid. For that I prefer adding an additional pointer parameter to the attach functions in which the reason for the failure can be communicated up the chain. For the top-level iommu_attach_device() function I am okay with having a special version which has this additional paremter. Regards, Joerg