Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp12052144rwl; Tue, 3 Jan 2023 08:21:51 -0800 (PST) X-Google-Smtp-Source: AMrXdXsunpIYM8bCmv3WhpM9/wb41GcnO2l4Adx7oSnpGWHbtt/IEm/KYVcNxdHX/yFRf1qxmiHG X-Received: by 2002:a17:90a:a594:b0:225:fa96:c744 with SMTP id b20-20020a17090aa59400b00225fa96c744mr32581691pjq.37.1672762911008; Tue, 03 Jan 2023 08:21:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672762910; cv=none; d=google.com; s=arc-20160816; b=N0nKxkxtybBUKpJpMEkcN67nrvered3d1JJl/MzQVjUIfXSTi0mv7NXKaGRY3W8tpx 9EZe4jzakNx92V81IqC1Vo02KKTJsxSZPIMttSCzNZVvvLD/e9JdAKqPyEjKBvmVgKnF GJBm3srbeh+uR1GU9mjfkrnZexCH9n7ozMbJ5iI9Om6XArsckTnbgIJ10m4/rQHMDR8M cIdIvPAUECqvQKSujPJrmjsaelVRikTFoEQki7Fi8ynZTOmrSyBsHLHTyZb5CerFGp4n xo/MygynDKOCHyt3eCbJqBkB02P3jlCfSywIpverWAVMsqbW+QPx0pDH5Qdn4FFQzQ0P xxuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id:dkim-signature; bh=KPIltgXLcHbMrQ52Lpe9AnY3EOsSgDqPWtgU38MSmuA=; b=vJO5Gq2BPQPKbPha27bYxJ9CjmFeXbsaAB+2PDudctgvSG59ZfxPVDgZMhP0IiGNV/ YBHay0yL3eiNs3deordlNqdV/UA/Xyq7Uj7Ciu3Vqsz/JsJOOFRU8VAbwJV/Q12mB3xN 0k0zj4Y+IkCOt04JiuRDCnFW2iprbRL/uD0kEECiEewj8zHDxo8d2tosmf9LPF4eBcX6 4Ff4dDeTLIVKhWHisk1X/4CBmHAg+lW3FXvVS2ldOUdExUcRqzW20UdqSrjUQIUQIDaX NlFeYq9Fv4bvjHRstl2SIrplf5KGBFCb2nGkxoYZT9mIgQwp1afMOH6am9uua0Qc41vV PYLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=Wvje720B; 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=REJECT sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k133-20020a636f8b000000b00478add2c2a6si27890525pgc.653.2023.01.03.08.21.43; Tue, 03 Jan 2023 08:21:50 -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=@ibm.com header.s=pp1 header.b=Wvje720B; 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=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237660AbjACQEM (ORCPT + 60 others); Tue, 3 Jan 2023 11:04:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237845AbjACQEE (ORCPT ); Tue, 3 Jan 2023 11:04:04 -0500 Received: from mx0a-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14CB112628; Tue, 3 Jan 2023 08:04:03 -0800 (PST) Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 303F6dY7007140; Tue, 3 Jan 2023 16:03:31 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : subject : from : to : cc : date : in-reply-to : references : content-type : content-transfer-encoding : mime-version; s=pp1; bh=KPIltgXLcHbMrQ52Lpe9AnY3EOsSgDqPWtgU38MSmuA=; b=Wvje720BtmDRxaBaFTG4WI2s7O8GUwyEAllmpNHFRat0EtXvcTMs/HmDclcIxfSD4low qR4Zpu9wEa4/za4wgVv+gLsmGaBGvVptWxjOzJ9GnQ8xq8WAzW7bF5R3hO5STbETkmL4 YTgqEJ/Shh7K4Ko/tm+kEbxFQdhN9dfL6Yvv5Oh4fBWT8bMEMp+p6gEKDWnZ0I9jWlll fLMGSK016qyVW68O7fMzzAEvxj0t9Bp3h7qbgjIgJ7jHbRHdh5omVEtLdKIarCVKBAR7 mmP01DupO5JONdbk+9aGGNNywS0VNGAzEytFTO9G5Ub9DeITM/E8FAMhQIm591HfWpbn TQ== Received: from ppma04fra.de.ibm.com (6a.4a.5195.ip4.static.sl-reverse.com [149.81.74.106]) by mx0b-001b2d01.pphosted.com (PPS) with ESMTPS id 3mvmb7n9v8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 03 Jan 2023 16:03:31 +0000 Received: from pps.filterd (ppma04fra.de.ibm.com [127.0.0.1]) by ppma04fra.de.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 302N0mkG006506; Tue, 3 Jan 2023 16:03:29 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma04fra.de.ibm.com (PPS) with ESMTPS id 3mtcq6ay3n-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 03 Jan 2023 16:03:29 +0000 Received: from smtpav04.fra02v.mail.ibm.com (smtpav04.fra02v.mail.ibm.com [10.20.54.103]) by smtprelay02.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 303G3PPh41157076 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 3 Jan 2023 16:03:25 GMT Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B473720040; Tue, 3 Jan 2023 16:03:25 +0000 (GMT) Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B25A420049; Tue, 3 Jan 2023 16:03:24 +0000 (GMT) Received: from [9.179.26.205] (unknown [9.179.26.205]) by smtpav04.fra02v.mail.ibm.com (Postfix) with ESMTP; Tue, 3 Jan 2023 16:03:24 +0000 (GMT) Message-ID: <310913b0a92bd06b93ede9e01e3f99cb5bce4e7a.camel@linux.ibm.com> Subject: Re: [PATCH v3 2/7] iommu: Allow .iotlb_sync_map to fail and handle s390's -ENOMEM return From: Niklas Schnelle To: Joerg Roedel , Will Deacon , Robin Murphy , Jason Gunthorpe , Wenjia Zhang Cc: Matthew Rosato , Gerd Bayer , Pierre Morel , iommu@lists.linux.dev, linux-s390@vger.kernel.org, borntraeger@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com, gerald.schaefer@linux.ibm.com, agordeev@linux.ibm.com, svens@linux.ibm.com, linux-kernel@vger.kernel.org, Julian Ruess Date: Tue, 03 Jan 2023 17:03:23 +0100 In-Reply-To: <20230102115619.2088685-3-schnelle@linux.ibm.com> References: <20230102115619.2088685-1-schnelle@linux.ibm.com> <20230102115619.2088685-3-schnelle@linux.ibm.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.46.2 (3.46.2-1.fc37) MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: c3genIMIgTmUDXTYXgiTkNQddLTb2SxI X-Proofpoint-GUID: c3genIMIgTmUDXTYXgiTkNQddLTb2SxI X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.923,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2023-01-03_05,2023-01-03_02,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 phishscore=0 mlxlogscore=754 malwarescore=0 bulkscore=0 lowpriorityscore=0 priorityscore=1501 clxscore=1015 mlxscore=0 spamscore=0 adultscore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2212070000 definitions=main-2301030136 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,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, 2023-01-02 at 12:56 +0100, Niklas Schnelle wrote: > On s390 .iotlb_sync_map is used to sync mappings to an underlying > hypervisor by letting the hypervisor inspect the synced IOVA range and > updating its shadow table. This however means that it can fail as the > hypervisor may run out of resources. This can be due to the hypervisor > being unable to pin guest pages, due to a limit on concurrently mapped > addresses such as vfio_iommu_type1.dma_entry_limit or other resources. > Either way such a failure to sync a mapping should result in > a DMA_MAPPING_EROR. >=20 > Now especially when running with batched IOTLB flushes for unmap it may > be that some IOVAs have already been invalidated but not yet synced via > .iotlb_sync_map. Thus if the hypervisor indicates running out of > resources, first do a global flush allowing the hypervisor to free > resources associated with these mappings and only if that also fails > report this error to callers. >=20 > Signed-off-by: Niklas Schnelle > --- > drivers/iommu/amd/iommu.c | 5 +++-- > drivers/iommu/apple-dart.c | 5 +++-- > drivers/iommu/intel/iommu.c | 5 +++-- > drivers/iommu/iommu.c | 20 ++++++++++++++++---- > drivers/iommu/msm_iommu.c | 5 +++-- > drivers/iommu/mtk_iommu.c | 5 +++-- > drivers/iommu/s390-iommu.c | 29 ++++++++++++++++++++++++----- > drivers/iommu/sprd-iommu.c | 5 +++-- > drivers/iommu/tegra-gart.c | 5 +++-- > include/linux/iommu.h | 4 ++-- > 10 files changed, 63 insertions(+), 25 deletions(-) Ok kernel test robot reported that I missed an implementation of .iotlb_sync_map in drivers/iommu/sun50i-iommu.c during rebase as that was only added in v6.2-rc1 by commit e563cc0c787c85 ("iommu/sun50i: Implement .iotlb_sync_map"). Will add and send a v4 including the proposed commit message rewording too. >=20 > diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c > index cbeaab55c0db..3df7d20e0e52 100644 > --- a/drivers/iommu/amd/iommu.c > +++ b/drivers/iommu/amd/iommu.c > @@ -2180,14 +2180,15 @@ static int amd_iommu_attach_device(struct iommu_d= omain *dom, > return ret; > } > =20 > -static void amd_iommu_iotlb_sync_map(struct iommu_domain *dom, > - unsigned long iova, size_t size) ---8<---