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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id C38ADECAAD8 for ; Tue, 13 Sep 2022 18:44:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:To:Subject:MIME-Version: Date:Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=2y1IryBjvfm9ax/Q6SP0zgIjhsG3WlIFCIhCT6mpzyQ=; b=LhcujwlTSIH1o6VnFJAmzybYMZ osTdnptw/TeLWTLcqVJVqEDOu+dWh6J62XhF5ojELUpnemP1JMrkxOSm7EPB0Hzo3lJv1Yejm3WM9 ASib+BDa90IWB9fHE2TFCgm/ZpIUwAJ3AVSqqt3BZxUCVsHTT1k9dx3FZYLM/Pf6aFkMvDFzYswvJ 0H71XOUQBNzcSCoXV8rHTXtdPd9O9SnEp0DaCoKCvdgWbcCYznezVBuk/SluCqYEle7jMe1tV3ERg 9NmURQ/Q9mhXiFmovihsEEP6ZLswq7vKYGXsWSwuuzSa4myGKKmzNULkQkE8s454ZFWpN9KQR5Sir GMB28fiA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oYAsH-00ErkW-RN; Tue, 13 Sep 2022 18:43:10 +0000 Received: from mx0a-0031df01.pphosted.com ([205.220.168.131]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oYAsD-00Erii-JN; Tue, 13 Sep 2022 18:43:07 +0000 Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 28DIFLWZ027735; Tue, 13 Sep 2022 18:41:55 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h=message-id : date : mime-version : subject : to : cc : references : from : in-reply-to : content-type : content-transfer-encoding; s=qcppdkim1; bh=vQhLlxqmzjKr9NsrPdkmOXYQsiz9/Tdn5+aZavAWXnA=; b=Jgp305mzyzJvJ0BeuKTDDJ3sWYkNQUc+IG5+Qbm0Lhn+VfREvy71ozQjAbCCISf5WYX3 Jdjm2v29zaW1i+q/ml2mJd17Topem7OTL3cavf5oo7I85t8nN0G01JXd2m9K0tKvvuge Yg6LSLE2nr6lZJuWqgE5ccqRdcrfchGMOEQOeuLmDXhNiQnFYXpLWz99DrewgFdUFGCl jUxSbTJIcpjs+7tl8DlnHec8pVa9lbB6bsPoJE6vuV5TnZjFXE90nmfScNdXClz8RlT1 zdyxh9IIR6kAJQ4fDtoeS9tNnVC/tfCLlwNognt9UacUg3JY3POyqWsO8hIes+Fx4yCk nA== Received: from nalasppmta04.qualcomm.com (Global_NAT1.qualcomm.com [129.46.96.20]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 3jjxyvg26b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 13 Sep 2022 18:41:55 +0000 Received: from nalasex01a.na.qualcomm.com (nalasex01a.na.qualcomm.com [10.47.209.196]) by NALASPPMTA04.qualcomm.com (8.17.1.5/8.17.1.5) with ESMTPS id 28DIfen3023964 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 13 Sep 2022 18:41:40 GMT Received: from [10.110.52.115] (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Tue, 13 Sep 2022 11:41:37 -0700 Message-ID: Date: Tue, 13 Sep 2022 11:41:35 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.2.2 Subject: Re: [PATCH 3/5] iommu: Add return errno rules to ->attach_dev ops Content-Language: en-US To: Nicolin Chen , , , , , , , , , , , , , , , , , , , References: <20220913082448.31120-1-nicolinc@nvidia.com> <20220913082448.31120-4-nicolinc@nvidia.com> From: Jeff Johnson In-Reply-To: <20220913082448.31120-4-nicolinc@nvidia.com> X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01a.na.qualcomm.com (10.47.209.196) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: etmjmEmkeGNTWFk3eX68NHU9O18Ysroz X-Proofpoint-ORIG-GUID: etmjmEmkeGNTWFk3eX68NHU9O18Ysroz X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.528,FMLib:17.11.122.1 definitions=2022-09-13_09,2022-09-13_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 adultscore=0 lowpriorityscore=0 spamscore=0 phishscore=0 priorityscore=1501 suspectscore=0 mlxlogscore=999 clxscore=1011 bulkscore=0 impostorscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2208220000 definitions=main-2209130086 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220913_114305_655199_47898ACF X-CRM114-Status: GOOD ( 29.46 ) 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: linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, yangyingliang@huawei.com, jon@solid-run.com, iommu@lists.linux.dev, shameerali.kolothum.thodi@huawei.com, jonathanh@nvidia.com, linux-rockchip@lists.infradead.org, christophe.jaillet@wanadoo.fr, linux-arm-kernel@lists.infradead.org, thunder.leizhen@huawei.com, linux-tegra@vger.kernel.org, linux-mediatek@lists.infradead.org, tglx@linutronix.de, virtualization@lists.linux-foundation.org, yong.wu@mediatek.com 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 9/13/2022 1:24 AM, Nicolin Chen wrote: > Cases like VFIO wish to attach a device to an existing domain that was > not allocated specifically from the device. This raises a condition > where the IOMMU driver can fail the domain attach because the domain and > device are incompatible with each other. > > This is a soft failure that can be resolved by using a different domain. > > Provide a dedicated errno EINVAL from the IOMMU driver during attach that > the reason attached failed is because of domain incompatability. > > VFIO can use this to know attach is a soft failure and it should continue > searching. Otherwise the attach will be a hard failure and VFIO will > return the code to userspace. > > Update kdocs first to add rules of return errno to ->attach_dev ops. > > Suggested-by: Jason Gunthorpe > Signed-off-by: Nicolin Chen > --- > include/linux/iommu.h | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/include/linux/iommu.h b/include/linux/iommu.h > index ea30f00dc145..c5d7ec0187c7 100644 > --- a/include/linux/iommu.h > +++ b/include/linux/iommu.h > @@ -266,6 +266,17 @@ struct iommu_ops { > /** > * struct iommu_domain_ops - domain specific operations > * @attach_dev: attach an iommu domain to a device > + * Rules of its return errno: > + * EINVAL - Exclusively, device and domain are incompatible. Must > + * avoid kernel prints along with this errno. Any EINVAL > + * returned from kAPIs must be converted to ENODEV if it > + * is device-specific, or to some other reasonable errno > + * being listed below > + * ENOMEM - Out of memory > + * ENOSPC - No space left on device > + * EBUSY - Device is attached to a domain and cannot be changed > + * ENODEV - Device specific errors, not able to be attached > + * - Treated as ENODEV by the caller. Use is discouraged It is my understanding that kernel-doc won't preserve your formatting without extra directives. See the "Note" after > * @detach_dev: detach an iommu domain from a device > * @map: map a physically contiguous memory region to an iommu domain > * @map_pages: map a physically contiguous set of pages of the same size to _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel