Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp7021142rwn; Tue, 13 Sep 2022 12:29:33 -0700 (PDT) X-Google-Smtp-Source: AA6agR6uXwieptred1tUKDjLmUneyVwiQo1PQQK6/fj7gcZqhL1symXiVSDxiGBE2Nq1kBLecs9a X-Received: by 2002:a17:907:60c9:b0:77f:be6d:d870 with SMTP id hv9-20020a17090760c900b0077fbe6dd870mr4463470ejc.348.1663097373541; Tue, 13 Sep 2022 12:29:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663097373; cv=none; d=google.com; s=arc-20160816; b=pE14G+TVDemaT65aLqfghmOwHsEhOBQQyobBXCk8oDTKcReM7yC7iaF+9BxWpKu9Oy biHp0OcChrH9LA9DZXFEmqVBOhHVhk7fRT0vt8eJwACPMzmLobGseXCodUN91QLLiXR1 P047ZUXVQflEhrh++pdIe83xBFTTF5uZflxsy8U143Y5mdqSOQ9GgRs2WNZqRN2DZ9uD k3nZGB/v4ra70Azz1IiEAs9yMiZHT6aa4nMwQPYCkO4ZkkdogAnNyVA6cVQBhgdnqhhJ jAeK2xFTI2d+z3EhhUCQ/pdh2+vWJzK++sML1HycHfWzwj0B5ouFmDg053cVhj1lACUK 3ugw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=vQhLlxqmzjKr9NsrPdkmOXYQsiz9/Tdn5+aZavAWXnA=; b=Ire1miJyh/9P9Mn6E+s8v37RPaTKqT2z0jjCXnc6q78HmsDhVebwmcusWj1JsEdTG+ Hbd7wpLFOI9/wBy0EzBQg88IIdxtzBoprL538fnEURAsuCfA09KyZQNOb66CPETC339l mNv+fYBq8+v9uYcMpUrfM6zZUNvBfUAtmNFlA0SJcc5MXR318QXLzexw7rzMu1G2/m2v z7Oj4T251nGzm6DSkV5bSnq/szYsnTzLO2lEKTdKOsTnS7hIv/iGNMN9pazv+2gCwWUY nGEIyS4YILoUALfwFsiOoB0mq1W5TySAuKXz+Y61zf+pvSyHc6/gjIEGslV93W6ZM/F9 qQ5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcppdkim1 header.b=Jgp305mz; 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=quicinc.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cr16-20020a170906d55000b0077fc6cbccb1si3457539ejc.963.2022.09.13.12.29.07; Tue, 13 Sep 2022 12:29:33 -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=@quicinc.com header.s=qcppdkim1 header.b=Jgp305mz; 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=quicinc.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233054AbiIMS4C (ORCPT + 99 others); Tue, 13 Sep 2022 14:56:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233019AbiIMSzb (ORCPT ); Tue, 13 Sep 2022 14:55:31 -0400 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EBF70CFA; Tue, 13 Sep 2022 11:43:24 -0700 (PDT) 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 , , , , , , , , , , , , , , , , , , , CC: , , , , , , , , , , , , , , , , 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> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit 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-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_LOW, 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 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