From nobody Fri Dec 27 10:33:51 2024 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5509A198851; Mon, 9 Dec 2024 19:24:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733772262; cv=none; b=AbSekurv1hblQESuLPoBlNc7C9y1J+prSnTtXrgg0CymRRxPaAbb/+H4WNh640ujJoUCeoWl6sLavzTJbxm9yVA+3pNd+t6N+a3F1XiBxsBbl3b/Q5BRyvau3c3jDgtg+2BHfWc/WCeg0qLH+Hi7DiUF0B3xRKrlA6p0IZeQr3s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733772262; c=relaxed/simple; bh=ivzM0Fn+SYmmRrt31w8ZZD2rWtkfeOYME2IS420Zv28=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=goL4IBTPK94QIDCVP6BAmk5uZ8kHcYOMa470dcDArGJ83YxVlUF1zlZ3XbJJqZcGt/OYsb9+3MNY6rgzPyLkCYDCsiMcHvAg0W4O987ja6xIXo+EOJO/CyeXqCXp6cFDJPp9fv3hJJkfyzUzlpo0tWUH3qaaQhe9RwG/5D6Dxrg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=KHgcLg2S; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="KHgcLg2S" Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4B9Crbk5018529; Mon, 9 Dec 2024 19:24:10 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=y2cCHdWh3L5oPNUkh XBi+lBVCm0QqWlTx3Vs/0PeLPo=; b=KHgcLg2Svg6YKNBgrOhzsguu9ZNluZ3bH 9HRZBQkHqAHW/5NpJI6blQhmk+CxRfjCL0GARd43QkQaS/lH7SFJfVjF3C8TZ+gf SqJPiFn7f4Ovjx7hflPoyqEBbDMerfOSrmMz1XgLMsL5dTy3M/NYVqKMBhxYUOu3 XNGSoSfHP+4FS2K2JNUgTboGaYBlLAQPcSa9psEt31z6WDPy/+bGj5fIQvXKXO3j YSKZ8oIo+tbVJdN91c0nkxec6xRXOWRlHLR2kN21dEGyBE/O+xCRCGEpOWYGD234 W8NUeyO0AUx8FNA+qlgHZ1PsCzjdoWRjq4N2gp3syg0GHwe23+EFg== Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 43ce38k5g3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 Dec 2024 19:24:10 +0000 (GMT) Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 4B9FILRI023023; Mon, 9 Dec 2024 19:24:09 GMT Received: from smtprelay04.dal12v.mail.ibm.com ([172.16.1.6]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 43d2wjqt1a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 Dec 2024 19:24:09 +0000 Received: from smtpav01.wdc07v.mail.ibm.com (smtpav01.wdc07v.mail.ibm.com [10.39.53.228]) by smtprelay04.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 4B9JO8TC18285154 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 9 Dec 2024 19:24:08 GMT Received: from smtpav01.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2F52F58063; Mon, 9 Dec 2024 19:24:08 +0000 (GMT) Received: from smtpav01.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6A4665804B; Mon, 9 Dec 2024 19:24:06 +0000 (GMT) Received: from li-2311da4c-2e09-11b2-a85c-c003041e9174.ibm.com.com (unknown [9.61.107.222]) by smtpav01.wdc07v.mail.ibm.com (Postfix) with ESMTP; Mon, 9 Dec 2024 19:24:06 +0000 (GMT) From: Matthew Rosato To: joro@8bytes.org, will@kernel.org, robin.murphy@arm.com, gerald.schaefer@linux.ibm.com, schnelle@linux.ibm.com Cc: hca@linux.ibm.com, gor@linux.ibm.com, agordeev@linux.ibm.com, svens@linux.ibm.com, borntraeger@linux.ibm.com, farman@linux.ibm.com, clegoate@redhat.com, iommu@lists.linux.dev, linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org Subject: [PATCH 1/6] s390/pci: check for relaxed translation capability Date: Mon, 9 Dec 2024 14:23:58 -0500 Message-ID: <20241209192403.107090-2-mjrosato@linux.ibm.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241209192403.107090-1-mjrosato@linux.ibm.com> References: <20241209192403.107090-1-mjrosato@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: rT4Ll5fkLXqtZ0D5Qv0a8oI27eEA8j06 X-Proofpoint-ORIG-GUID: rT4Ll5fkLXqtZ0D5Qv0a8oI27eEA8j06 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-15_01,2024-10-11_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 suspectscore=0 spamscore=0 clxscore=1015 priorityscore=1501 lowpriorityscore=0 impostorscore=0 bulkscore=0 mlxscore=0 malwarescore=0 mlxlogscore=796 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2411120000 definitions=main-2412090147 Content-Type: text/plain; charset="utf-8" For each zdev, record whether or not CLP indicates relaxed translation capability for the associated device group. Signed-off-by: Matthew Rosato --- arch/s390/include/asm/pci.h | 2 +- arch/s390/include/asm/pci_clp.h | 4 +++- arch/s390/pci/pci_clp.c | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/arch/s390/include/asm/pci.h b/arch/s390/include/asm/pci.h index 474e1f8d1d3c..8fe4c7a72c0b 100644 --- a/arch/s390/include/asm/pci.h +++ b/arch/s390/include/asm/pci.h @@ -144,7 +144,7 @@ struct zpci_dev { u8 util_str_avail : 1; u8 irqs_registered : 1; u8 tid_avail : 1; - u8 reserved : 1; + u8 rtr_avail : 1; /* Relaxed translation allowed */ unsigned int devfn; /* DEVFN part of the RID*/ =20 u8 pfip[CLP_PFIP_NR_SEGMENTS]; /* pci function internal path */ diff --git a/arch/s390/include/asm/pci_clp.h b/arch/s390/include/asm/pci_cl= p.h index 3fff2f7095c8..7ebff39c84b3 100644 --- a/arch/s390/include/asm/pci_clp.h +++ b/arch/s390/include/asm/pci_clp.h @@ -156,7 +156,9 @@ struct clp_rsp_query_pci_grp { u16 : 4; u16 noi : 12; /* number of interrupts */ u8 version; - u8 : 6; + u8 : 2; + u8 rtr : 1; /* Relaxed translation requirement */ + u8 : 3; u8 frame : 1; u8 refresh : 1; /* TLB refresh mode */ u16 : 3; diff --git a/arch/s390/pci/pci_clp.c b/arch/s390/pci/pci_clp.c index 14bf7e8d06b7..27248686e588 100644 --- a/arch/s390/pci/pci_clp.c +++ b/arch/s390/pci/pci_clp.c @@ -112,6 +112,7 @@ static void clp_store_query_pci_fngrp(struct zpci_dev *= zdev, zdev->version =3D response->version; zdev->maxstbl =3D response->maxstbl; zdev->dtsm =3D response->dtsm; + zdev->rtr_avail =3D response->rtr; =20 switch (response->version) { case 1: --=20 2.47.0 From nobody Fri Dec 27 10:33:51 2024 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 17CDF198A3F; Mon, 9 Dec 2024 19:24:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733772263; cv=none; b=G01KoRSBd6weA5NuegVdIc7XFPZY+3YDWWkAvuSGJcgIVj5+SvMqHO8BXd5AyXsReBLJcOu/mu8/90ELaN9VAgk3hKFR9en2/PdAzlpeBwxaX4zNEFWpHxRxSNninB+os9Yx5/DtaikW/n2dqgHZ7LPx3RA71a647HbnVwCNoJ4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733772263; c=relaxed/simple; bh=rI19rioQDI2uPP2Y1PY/87017aOIDwnrfqz5fN6Fhcg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OCBsBr6FnND4rlzhW36n3jnIVlooJ4EXRCCU8Gv32bnYjDbEBvRLfpPgVZr/lBLV6U4Cnia62u4oR7D1C4WU+47IjaUvk7SxXaoKDpe4lnEkRuBkJg+vkSCi2JTnQR6YN7CZ4jddckFmjto89PFfcp7ZeE8vWNqE+0fUpDaBjRw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=AjkTeFbu; arc=none smtp.client-ip=148.163.158.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="AjkTeFbu" Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4B9FDwKF006740; Mon, 9 Dec 2024 19:24:12 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=UT318P9SnxrIM7wfd hTP+u/ekosxLEiioyvgQ5vHIzg=; b=AjkTeFbuntFblQ2IEPfQ1/GqPVK03knpP 7PeMzVVuO4RyinQhmw33gZYbh4MId4l9Une+a0zYGD62M4yd0fidyrCNQHr02cYP cJ7g5VZNtIKxWDzdPbl3p3IuQfATNYQ40OV7CUYfao/ntwnmNHmSh23KNKHKKS3d 6oG29F1tbz/OxZWyjj3Ki1ymCQNyfVW3PY1UYf8lo0rmKkwZjV4CpBFwgbEzh5WG Pd740oPwwjcOTP7vX/lVlpanvFX4kYU9Z1N1QE86HgcH9srgCx46pQheRufhwVNr eYTGKmZZo8qTHc6WP4zLGfSQXSiaC9iH+yXc0y65kb2kbSTY2w5IQ== Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 43cbsq2hgd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 Dec 2024 19:24:11 +0000 (GMT) Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 4B9FXggw023169; Mon, 9 Dec 2024 19:24:11 GMT Received: from smtprelay06.dal12v.mail.ibm.com ([172.16.1.8]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 43d2wjqt1b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 Dec 2024 19:24:11 +0000 Received: from smtpav01.wdc07v.mail.ibm.com (smtpav01.wdc07v.mail.ibm.com [10.39.53.228]) by smtprelay06.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 4B9JOAgs27394578 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 9 Dec 2024 19:24:10 GMT Received: from smtpav01.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 18DBA58067; Mon, 9 Dec 2024 19:24:10 +0000 (GMT) Received: from smtpav01.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5DF3458055; Mon, 9 Dec 2024 19:24:08 +0000 (GMT) Received: from li-2311da4c-2e09-11b2-a85c-c003041e9174.ibm.com.com (unknown [9.61.107.222]) by smtpav01.wdc07v.mail.ibm.com (Postfix) with ESMTP; Mon, 9 Dec 2024 19:24:08 +0000 (GMT) From: Matthew Rosato To: joro@8bytes.org, will@kernel.org, robin.murphy@arm.com, gerald.schaefer@linux.ibm.com, schnelle@linux.ibm.com Cc: hca@linux.ibm.com, gor@linux.ibm.com, agordeev@linux.ibm.com, svens@linux.ibm.com, borntraeger@linux.ibm.com, farman@linux.ibm.com, clegoate@redhat.com, iommu@lists.linux.dev, linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org Subject: [PATCH 2/6] s390: enable ARCH_HAS_PHYS_TO_DMA Date: Mon, 9 Dec 2024 14:23:59 -0500 Message-ID: <20241209192403.107090-3-mjrosato@linux.ibm.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241209192403.107090-1-mjrosato@linux.ibm.com> References: <20241209192403.107090-1-mjrosato@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: c6AMFGMkxU0zIwQi9TvZ6RgBiksb9nyf X-Proofpoint-GUID: c6AMFGMkxU0zIwQi9TvZ6RgBiksb9nyf X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-15_01,2024-10-11_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=769 adultscore=0 lowpriorityscore=0 clxscore=1015 phishscore=0 impostorscore=0 suspectscore=0 spamscore=0 mlxscore=0 priorityscore=1501 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2411120000 definitions=main-2412090147 Content-Type: text/plain; charset="utf-8" PCI devices on s390 have a DMA offset that is reported via CLP. In preparation for allowing identity domains, enable ARCH_HAS_PHYS_TO_DMA for s390 and get the dma offset for all PCI devices from the reported CLP value. Reviewed-by: Niklas Schnelle Signed-off-by: Matthew Rosato --- arch/s390/Kconfig | 1 + arch/s390/include/asm/device.h | 12 ++++++++++++ arch/s390/include/asm/dma-direct.h | 14 ++++++++++++++ arch/s390/pci/pci_bus.c | 2 ++ 4 files changed, 29 insertions(+) create mode 100644 arch/s390/include/asm/device.h create mode 100644 arch/s390/include/asm/dma-direct.h diff --git a/arch/s390/Kconfig b/arch/s390/Kconfig index 0077969170e8..5746d8abc8a7 100644 --- a/arch/s390/Kconfig +++ b/arch/s390/Kconfig @@ -83,6 +83,7 @@ config S390 select ARCH_HAS_FORTIFY_SOURCE select ARCH_HAS_GCOV_PROFILE_ALL select ARCH_HAS_GIGANTIC_PAGE + select ARCH_HAS_PHYS_TO_DMA select ARCH_HAS_KCOV select ARCH_HAS_MEMBARRIER_SYNC_CORE select ARCH_HAS_MEM_ENCRYPT diff --git a/arch/s390/include/asm/device.h b/arch/s390/include/asm/device.h new file mode 100644 index 000000000000..a6bf5e137a17 --- /dev/null +++ b/arch/s390/include/asm/device.h @@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_S390_DEVICE_H +#define _ASM_S390_DEVICE_H + +struct dev_archdata { + dma_addr_t dma_offset; +}; + +struct pdev_archdata { +}; + +#endif /* _ASM_S390_DEVICE_H */ diff --git a/arch/s390/include/asm/dma-direct.h b/arch/s390/include/asm/dma= -direct.h new file mode 100644 index 000000000000..9391820fca2c --- /dev/null +++ b/arch/s390/include/asm/dma-direct.h @@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef ASM_S390_DMA_DIRECT_H +#define ASM_S390_DMA_DIRECT_H 1 + +static inline dma_addr_t phys_to_dma(struct device *dev, phys_addr_t paddr) +{ + return paddr + dev->archdata.dma_offset; +} + +static inline phys_addr_t dma_to_phys(struct device *dev, dma_addr_t daddr) +{ + return daddr - dev->archdata.dma_offset; +} +#endif /* ASM_S390_DMA_DIRECT_H */ diff --git a/arch/s390/pci/pci_bus.c b/arch/s390/pci/pci_bus.c index d5ace00d10f0..ec874ba858c6 100644 --- a/arch/s390/pci/pci_bus.c +++ b/arch/s390/pci/pci_bus.c @@ -288,6 +288,8 @@ void pcibios_bus_add_device(struct pci_dev *pdev) { struct zpci_dev *zdev =3D to_zpci(pdev); =20 + pdev->dev.archdata.dma_offset =3D zdev->start_dma; + /* * With pdev->no_vf_scan the common PCI probing code does not * perform PF/VF linking. --=20 2.47.0 From nobody Fri Dec 27 10:33:51 2024 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 08A981990C1; Mon, 9 Dec 2024 19:24:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733772265; cv=none; b=lX+Yz9E7llsDr4J91+6EsSOJtfkGQW4HLfi0nnv1GJvffO+w+hxgoocGhC/cEtbBToFbBx/A5z+9glq4M6I9HEzwDgQlZYPd4hBi7da2NXJ5isDeSUtL5VRTiM7HsBI2vCmQeHSoCa+KYZsobcDF81SUXBv7NyjBpLRsyCsl4tI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733772265; c=relaxed/simple; bh=pSw1N4FI61HybzwNZ+a7Qr2Vhm9SDMTeFa0yrrrgChI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FSMH7B7ugnK1gS7Dd97a0dboj6WumBYZpFhLASQ3T57H2YBXd9BfVlr0oEPor9zMZhRWr4LYpt5D9eGILcsuNU6TwbjLgB/izJdZbT6SRsuHBRBpY6DPRI1+qMvG03iiFPPC+um4LounwJH1z+dUp9n1CyxBj5vhDUUoiR3ZHCc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=VQK4lFmE; arc=none smtp.client-ip=148.163.158.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="VQK4lFmE" Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4B9DnR24018963; Mon, 9 Dec 2024 19:24:14 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=i3l7CNlENhH1dNAsP NCHDAa46sjVE3KXrPJEIhT2E30=; b=VQK4lFmEw0q0+h1YEXnzvUBdYn+UDl/f3 7boaI3cJ8H1SjVvD+Ujbk/ZKuPrcJQi75450br4IXoTJt+O1MF1K7YY0/8tIen+Y /yMXRa4uHhfR5BAKc/YMZTzZGkYclWk79bSsyagS1hKSL1kzbPyJYLv44iaCG/vJ Lcu/yGWKOVTO42HtNwztuoY3vmciDUvyBLnldLvwoiPnxOtH9ZrCBTBu/cSISdve NiY4N7AveVMKL/FgAhBgnWyzQ/kUIHzRq9Kg55zq2OH48eQyKOwkaJ6xydDO/Ojp Rkkg0+nTHsZ0FwYt5UKLTzk06mOMjUYx+8D6xaOcvmVad5GFeFF8A== Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 43ce0xa6bg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 Dec 2024 19:24:14 +0000 (GMT) Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 4B9FILRK023023; Mon, 9 Dec 2024 19:24:13 GMT Received: from smtprelay01.wdc07v.mail.ibm.com ([172.16.1.68]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 43d2wjqt1g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 Dec 2024 19:24:13 +0000 Received: from smtpav01.wdc07v.mail.ibm.com (smtpav01.wdc07v.mail.ibm.com [10.39.53.228]) by smtprelay01.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 4B9JOCcN47317622 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 9 Dec 2024 19:24:12 GMT Received: from smtpav01.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2ED295804B; Mon, 9 Dec 2024 19:24:12 +0000 (GMT) Received: from smtpav01.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 468F45805B; Mon, 9 Dec 2024 19:24:10 +0000 (GMT) Received: from li-2311da4c-2e09-11b2-a85c-c003041e9174.ibm.com.com (unknown [9.61.107.222]) by smtpav01.wdc07v.mail.ibm.com (Postfix) with ESMTP; Mon, 9 Dec 2024 19:24:10 +0000 (GMT) From: Matthew Rosato To: joro@8bytes.org, will@kernel.org, robin.murphy@arm.com, gerald.schaefer@linux.ibm.com, schnelle@linux.ibm.com Cc: hca@linux.ibm.com, gor@linux.ibm.com, agordeev@linux.ibm.com, svens@linux.ibm.com, borntraeger@linux.ibm.com, farman@linux.ibm.com, clegoate@redhat.com, iommu@lists.linux.dev, linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org Subject: [PATCH 3/6] iommu/s390: implement iommu passthrough via identity domain Date: Mon, 9 Dec 2024 14:24:00 -0500 Message-ID: <20241209192403.107090-4-mjrosato@linux.ibm.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241209192403.107090-1-mjrosato@linux.ibm.com> References: <20241209192403.107090-1-mjrosato@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: gj3kztyv_sivNZ_rE3P1UZfEBhVXKUh8 X-Proofpoint-ORIG-GUID: gj3kztyv_sivNZ_rE3P1UZfEBhVXKUh8 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-15_01,2024-10-11_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 spamscore=0 clxscore=1015 impostorscore=0 mlxscore=0 mlxlogscore=964 priorityscore=1501 malwarescore=0 adultscore=0 bulkscore=0 phishscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2411120000 definitions=main-2412090147 Content-Type: text/plain; charset="utf-8" Enabled via the kernel command-line 'iommu.passthrough=3D1' option. Introduce the concept of identity domains to s390-iommu, which relies on phys_to_dma and dma_to_phys to offset identity mappings to the start of the DMA aperture advertized by CLP. Signed-off-by: Matthew Rosato --- arch/s390/pci/pci.c | 6 ++++-- drivers/iommu/s390-iommu.c | 42 +++++++++++++++++++++++++++++++++++--- 2 files changed, 43 insertions(+), 5 deletions(-) diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c index 88f72745fa59..758b23331754 100644 --- a/arch/s390/pci/pci.c +++ b/arch/s390/pci/pci.c @@ -124,14 +124,16 @@ int zpci_register_ioat(struct zpci_dev *zdev, u8 dmaa= s, struct zpci_fib fib =3D {0}; u8 cc; =20 - WARN_ON_ONCE(iota & 0x3fff); fib.pba =3D base; /* Work around off by one in ISM virt device */ if (zdev->pft =3D=3D PCI_FUNC_TYPE_ISM && limit > base) fib.pal =3D limit + (1 << 12); else fib.pal =3D limit; - fib.iota =3D iota | ZPCI_IOTA_RTTO_FLAG; + if (iota =3D=3D 0) + fib.iota =3D iota; + else + fib.iota =3D iota | ZPCI_IOTA_RTTO_FLAG; fib.gd =3D zdev->gisa; cc =3D zpci_mod_fc(req, &fib, status); if (cc) diff --git a/drivers/iommu/s390-iommu.c b/drivers/iommu/s390-iommu.c index fbdeded3d48b..18979d8109b2 100644 --- a/drivers/iommu/s390-iommu.c +++ b/drivers/iommu/s390-iommu.c @@ -392,9 +392,11 @@ static int blocking_domain_attach_device(struct iommu_= domain *domain, return 0; =20 s390_domain =3D to_s390_domain(zdev->s390_domain); - spin_lock_irqsave(&s390_domain->list_lock, flags); - list_del_rcu(&zdev->iommu_list); - spin_unlock_irqrestore(&s390_domain->list_lock, flags); + if (zdev->dma_table) { + spin_lock_irqsave(&s390_domain->list_lock, flags); + list_del_rcu(&zdev->iommu_list); + spin_unlock_irqrestore(&s390_domain->list_lock, flags); + } =20 zpci_unregister_ioat(zdev, 0); zdev->dma_table =3D NULL; @@ -787,6 +789,39 @@ static int __init s390_iommu_init(void) } subsys_initcall(s390_iommu_init); =20 +static int s390_attach_dev_identity(struct iommu_domain *domain, + struct device *dev) +{ + struct zpci_dev *zdev =3D to_zpci_dev(dev); + u8 status; + int cc; + + blocking_domain_attach_device(&blocking_domain, dev); + + /* If we fail now DMA remains blocked via blocking domain */ + cc =3D zpci_register_ioat(zdev, 0, zdev->start_dma, zdev->end_dma, + 0, &status); + /* + * If the device is undergoing error recovery the reset code + * will re-establish the new domain. + */ + if (cc && status !=3D ZPCI_PCI_ST_FUNC_NOT_AVAIL) + return -EIO; + + zdev_s390_domain_update(zdev, domain); + + return 0; +} + +static const struct iommu_domain_ops s390_identity_ops =3D { + .attach_dev =3D s390_attach_dev_identity, +}; + +static struct iommu_domain s390_identity_domain =3D { + .type =3D IOMMU_DOMAIN_IDENTITY, + .ops =3D &s390_identity_ops, +}; + static struct iommu_domain blocking_domain =3D { .type =3D IOMMU_DOMAIN_BLOCKED, .ops =3D &(const struct iommu_domain_ops) { @@ -797,6 +832,7 @@ static struct iommu_domain blocking_domain =3D { static const struct iommu_ops s390_iommu_ops =3D { .blocked_domain =3D &blocking_domain, .release_domain =3D &blocking_domain, + .identity_domain =3D &s390_identity_domain, .capable =3D s390_iommu_capable, .domain_alloc_paging =3D s390_domain_alloc_paging, .probe_device =3D s390_iommu_probe_device, --=20 2.47.0 From nobody Fri Dec 27 10:33:51 2024 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D95FE1993BD; Mon, 9 Dec 2024 19:24:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733772268; cv=none; b=H9g/vYoM/TZl5gfokrovxqB37ZQug5HrJhP+UiB2yTJ2TfMoVUx1t7GPWoXAy/WToRegB4pOJ4YbVAWAqzIdvXysVr7VvmYfuT16rhYMglSybUZjlNY8xuRBqBgnrFUQNuiMUJr+CUSniSWXkJ8ziytYPZ3ErUSlXcE1LK9VBk0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733772268; c=relaxed/simple; bh=4t3M/LFI8xQI2dP8zyuDM11laDXF1cxWj0wZiCzvzGc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CbANvosR7qhXAlQ8HcrQ4MExCNUIR15yfPTStu9uDmz3hz7uUn3O1HS71F3xHsX3weJY7ZR8uRwAn5UxTQbtnKx7N+Z8HCgJKtOxvgCmKVfi5xvo+LYuoHP9dgFLdCCtjshBGx6+pABi0Jc4Ng/VcE+G8mEf3L1cg+6zGuEI8M4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=aPy2CTKi; arc=none smtp.client-ip=148.163.158.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="aPy2CTKi" Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4B9BHnnf016108; Mon, 9 Dec 2024 19:24:16 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=T7jhz1GBlueszh6LA n0GVJ4QQO/fPk9U2VxnhKMtZQw=; b=aPy2CTKiKtiHSY4FD4yFGtsmVSD4+buwc JOpnQ93XbYTyCSiAaJwWAUJK42d2e3/sdQ7XmdKNwWyS9bRWqU+e9KbYxFK8YCYe VOPrSTkyO+U6bsKiSoqGuG1QKHuba+R40OPv3S7dkGaQgI0pGmA+iZm+gNAGaOKO VUvEFEAzoXWCCHFNc12RMG5a2R1XenY7gNmuRHCHxs87N8a0xdwBnwnQl2rOs8VZ SjRY3TOIy+yK2XT8YvuQanNZqp7oc+1baTzplVCnXVjKh6g6TPTRJoMknQwsnx+e WTDDAmExouhvrT7kh1BRVlMSfGyDM1z1OH+58TASgDOuLn8+iCyXA== Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 43cbsq2hgh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 Dec 2024 19:24:16 +0000 (GMT) Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 4B9HvNI8016919; Mon, 9 Dec 2024 19:24:15 GMT Received: from smtprelay03.wdc07v.mail.ibm.com ([172.16.1.70]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 43d12y086d-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 Dec 2024 19:24:15 +0000 Received: from smtpav01.wdc07v.mail.ibm.com (smtpav01.wdc07v.mail.ibm.com [10.39.53.228]) by smtprelay03.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 4B9JOEor54264272 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 9 Dec 2024 19:24:14 GMT Received: from smtpav01.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2704658068; Mon, 9 Dec 2024 19:24:14 +0000 (GMT) Received: from smtpav01.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5C7905805B; Mon, 9 Dec 2024 19:24:12 +0000 (GMT) Received: from li-2311da4c-2e09-11b2-a85c-c003041e9174.ibm.com.com (unknown [9.61.107.222]) by smtpav01.wdc07v.mail.ibm.com (Postfix) with ESMTP; Mon, 9 Dec 2024 19:24:12 +0000 (GMT) From: Matthew Rosato To: joro@8bytes.org, will@kernel.org, robin.murphy@arm.com, gerald.schaefer@linux.ibm.com, schnelle@linux.ibm.com Cc: hca@linux.ibm.com, gor@linux.ibm.com, agordeev@linux.ibm.com, svens@linux.ibm.com, borntraeger@linux.ibm.com, farman@linux.ibm.com, clegoate@redhat.com, iommu@lists.linux.dev, linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org Subject: [PATCH 4/6] iommu: add routine to check strict setting Date: Mon, 9 Dec 2024 14:24:01 -0500 Message-ID: <20241209192403.107090-5-mjrosato@linux.ibm.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241209192403.107090-1-mjrosato@linux.ibm.com> References: <20241209192403.107090-1-mjrosato@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: qSPmcwGyrn5nKXB390gbqvLHelXddQ9R X-Proofpoint-GUID: qSPmcwGyrn5nKXB390gbqvLHelXddQ9R X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-15_01,2024-10-11_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=632 adultscore=0 lowpriorityscore=0 clxscore=1015 phishscore=0 impostorscore=0 suspectscore=0 spamscore=0 mlxscore=0 priorityscore=1501 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2411120000 definitions=main-2412090147 Content-Type: text/plain; charset="utf-8" Add a simple routine to return whether or not strict TLB invalidation is in effect for the iommu. For drivers that implement the def_domain_type op, this can be used to determine whether or not flush queueing is allowed. Reviewed-by: Niklas Schnelle Signed-off-by: Matthew Rosato --- drivers/iommu/iommu.c | 5 +++++ include/linux/iommu.h | 1 + 2 files changed, 6 insertions(+) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 599030e1e890..6bdede4177ff 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -715,6 +715,11 @@ void iommu_set_dma_strict(void) iommu_def_domain_type =3D IOMMU_DOMAIN_DMA; } =20 +bool iommu_dma_is_strict(void) +{ + return iommu_dma_strict; +} + static ssize_t iommu_group_attr_show(struct kobject *kobj, struct attribute *__attr, char *buf) { diff --git a/include/linux/iommu.h b/include/linux/iommu.h index 318d27841130..05279109c732 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -911,6 +911,7 @@ int iommu_set_pgtable_quirks(struct iommu_domain *domai= n, unsigned long quirks); =20 void iommu_set_dma_strict(void); +extern bool iommu_dma_is_strict(void); =20 extern int report_iommu_fault(struct iommu_domain *domain, struct device *= dev, unsigned long iova, int flags); --=20 2.47.0 From nobody Fri Dec 27 10:33:51 2024 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3FDE7199E8B; Mon, 9 Dec 2024 19:24:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733772269; cv=none; b=cc1MfwCixfwaU8Y+Ng4RJoGdkAVCo5YyOfTwp+YxDuztnYMAWGOy7u/1AMsmo/0VcAL9n1yGxgGj94JarZKJLgVbAA9Ny6xk+0I36rdfOj9Z5x+iss4fbKF82CKeBJ0P12EE4IyPcyIn3ago1wgEJLfDr0dPkr0TSPKUxOZexLw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733772269; c=relaxed/simple; bh=uM0sCFBR5OENaGUrRCRnB92RfG/TWV67sfsbyX7n2HM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jITWwuVHDIn0ZaFhp+r02x7Gx+MhUrzB2oCsfQaIzZM1mDKusGp4q80dGsU+/k43ZmVPRdYOFSH/B7QL5kUbAyhyR6RV7b+RdkKcRomlroPNGzKZeNt1yEir7RVAZjs9Y6ePdcruj68fvJLhhaOLhd1wCXeQ/ik2thIXiMib/gM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=eO7esuaL; arc=none smtp.client-ip=148.163.156.1 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="eO7esuaL" Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4B9GAl3e030748; Mon, 9 Dec 2024 19:24:18 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=KvORLKxHLutvvvXor H0FcfeQztw8VpV355F34zVZGGE=; b=eO7esuaL3eIZtlKmOE9Ac+u74BeIGWa1S Z5Bz/LZpEDpnKlbirw5n+i6E8cN9ciR8ijhWGEzdPKtLsFaVW4+NHqOpiZrsqYuZ zwvMVB33PV8B/MmPsYUoGfsKFHratyQOh7fyvIdIkonJg1FhQ8YsXeP1GvlOrBXF UhqC9QTdUjMLNG00ByaPhSncdHVNtJ1aRkdLODTk3yOSf2+5xyi0lY0LgnLnvHr9 /zPowVyd8z+WPrkWV9uNX52g7J1hAR9b/KHUVSAmvpBidWBbcR7g166+dJUBYHSH Ohe7OIMZSYyRH2++otyDd9u6jIWT5jh5HIXYz62PJznjBPn9tXtwQ== Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 43ce1vk69a-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 Dec 2024 19:24:18 +0000 (GMT) Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 4B9HUnS5032734; Mon, 9 Dec 2024 19:24:17 GMT Received: from smtprelay03.dal12v.mail.ibm.com ([172.16.1.5]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 43d0ps89jq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 Dec 2024 19:24:17 +0000 Received: from smtpav01.wdc07v.mail.ibm.com (smtpav01.wdc07v.mail.ibm.com [10.39.53.228]) by smtprelay03.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 4B9JOGG931654554 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 9 Dec 2024 19:24:16 GMT Received: from smtpav01.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2F55658055; Mon, 9 Dec 2024 19:24:16 +0000 (GMT) Received: from smtpav01.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 54EF45805B; Mon, 9 Dec 2024 19:24:14 +0000 (GMT) Received: from li-2311da4c-2e09-11b2-a85c-c003041e9174.ibm.com.com (unknown [9.61.107.222]) by smtpav01.wdc07v.mail.ibm.com (Postfix) with ESMTP; Mon, 9 Dec 2024 19:24:14 +0000 (GMT) From: Matthew Rosato To: joro@8bytes.org, will@kernel.org, robin.murphy@arm.com, gerald.schaefer@linux.ibm.com, schnelle@linux.ibm.com Cc: hca@linux.ibm.com, gor@linux.ibm.com, agordeev@linux.ibm.com, svens@linux.ibm.com, borntraeger@linux.ibm.com, farman@linux.ibm.com, clegoate@redhat.com, iommu@lists.linux.dev, linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org Subject: [PATCH 5/6] iommu: document missing def_domain_type return Date: Mon, 9 Dec 2024 14:24:02 -0500 Message-ID: <20241209192403.107090-6-mjrosato@linux.ibm.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241209192403.107090-1-mjrosato@linux.ibm.com> References: <20241209192403.107090-1-mjrosato@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-GUID: iIs3Vd7cp6Am8rsLkjzNgnJng_mDJOM3 X-Proofpoint-ORIG-GUID: iIs3Vd7cp6Am8rsLkjzNgnJng_mDJOM3 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-15_01,2024-10-11_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 priorityscore=1501 clxscore=1015 phishscore=0 bulkscore=0 mlxlogscore=999 impostorscore=0 spamscore=0 malwarescore=0 suspectscore=0 adultscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2411120000 definitions=main-2412090147 Content-Type: text/plain; charset="utf-8" In addition to IOMMU_DOMAIN_DMA, def_domain_type can also return IOMMU_DOMAIN_DMA_FQ when applicable, else flush queues will never be used. Signed-off-by: Matthew Rosato --- include/linux/iommu.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/linux/iommu.h b/include/linux/iommu.h index 05279109c732..d0da1918d2de 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -585,6 +585,7 @@ iommu_copy_struct_from_full_user_array(void *kdst, size= _t kdst_entry_size, * @def_domain_type: device default domain type, return value: * - IOMMU_DOMAIN_IDENTITY: must use an identity domain * - IOMMU_DOMAIN_DMA: must use a dma domain + * - IOMMU_DOMAIN_DMA_FQ: dma domain with batch invalidation * - 0: use the default setting * @default_domain_ops: the default ops for domains * @remove_dev_pasid: Remove any translation configurations of a specific --=20 2.47.0 From nobody Fri Dec 27 10:33:51 2024 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 16151198A1A; Mon, 9 Dec 2024 19:24:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733772270; cv=none; b=L/SoQt1vn0HfZzxVK/BXnD1J3vUl69eYoOatxH2Rn2HREM9rUQy/Aw8C2t6Jsq1yCO0ps6RtgWG9tX71As5LwQDkFIp/bOYACHULVj8Pioln0B7i4Q9mtBGAGM0qH3B02L9h7BHhi2emTHwnK3VYueibZ5dVbVqXmTkeTG7SYUM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733772270; c=relaxed/simple; bh=2H3v0Kp6QuT9dBBdMh1p8eIlnPIw5OTegPTKTEO7qxM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qh3ptyXVKfnpW0zAm2Z9bD4rbUkDDhA1SYb+ivXUeMalhhNAaB+sQWFF3GpyX6FAIFox5IF2AMNiObXT724DpiRhkfDkSoDdNpr4rrF1MbcIEX14MqPo70M1u4ftX70GKQeh3LNXZNzd+xa7raXlcHK+CQi9ctsNAb/9c+OUjfc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=SW6ZFWaW; arc=none smtp.client-ip=148.163.158.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="SW6ZFWaW" Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4B9CblDB020924; Mon, 9 Dec 2024 19:24:20 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=1PzxnFKgbpd0suK57 mb6gHLfcFYBJuxvqlMUjse2nn8=; b=SW6ZFWaWBv2UvhmuCWhr5DYRRMuvrN2zV UUmQ0GIGeWPqWsX8l0imWDSx9/cr44xWU96ry5ALnt2YcoDdz1VHFg2eVm7Wxs1U 8XulaYijE9Voh8rjlapHm3RQJnpoS6Pq4+EpHWWC1EF4fpGVcVtk3hM7/y6g0N3T ArEk/a5gQXUiZAtgXlzj0Cnn+VJq1SY9ntUnHSCM+sybhFUMbroBHrCJcco1pMza 2Qeffxmgf67HgrbAP+CwHtehbqOkJfq3i2Uqb7HKf31JkZyysvTMaaaPDx+NW8rq q4BnCmYXmwKABGyGjtjounGKCZs2XjzGOPvcAlQJZPuyj6mM+RvgA== Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 43cbsq2hgr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 Dec 2024 19:24:20 +0000 (GMT) Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.18.1.2/8.18.1.2) with ESMTP id 4B9FILRL023023; Mon, 9 Dec 2024 19:24:19 GMT Received: from smtprelay05.wdc07v.mail.ibm.com ([172.16.1.72]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 43d2wjqt1q-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 09 Dec 2024 19:24:19 +0000 Received: from smtpav01.wdc07v.mail.ibm.com (smtpav01.wdc07v.mail.ibm.com [10.39.53.228]) by smtprelay05.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 4B9JOIgO18285112 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 9 Dec 2024 19:24:18 GMT Received: from smtpav01.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0D0FB5804B; Mon, 9 Dec 2024 19:24:18 +0000 (GMT) Received: from smtpav01.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5CF0C58065; Mon, 9 Dec 2024 19:24:16 +0000 (GMT) Received: from li-2311da4c-2e09-11b2-a85c-c003041e9174.ibm.com.com (unknown [9.61.107.222]) by smtpav01.wdc07v.mail.ibm.com (Postfix) with ESMTP; Mon, 9 Dec 2024 19:24:16 +0000 (GMT) From: Matthew Rosato To: joro@8bytes.org, will@kernel.org, robin.murphy@arm.com, gerald.schaefer@linux.ibm.com, schnelle@linux.ibm.com Cc: hca@linux.ibm.com, gor@linux.ibm.com, agordeev@linux.ibm.com, svens@linux.ibm.com, borntraeger@linux.ibm.com, farman@linux.ibm.com, clegoate@redhat.com, iommu@lists.linux.dev, linux-kernel@vger.kernel.org, linux-s390@vger.kernel.org Subject: [PATCH 6/6] iommu/s390: implement def_domain_type Date: Mon, 9 Dec 2024 14:24:03 -0500 Message-ID: <20241209192403.107090-7-mjrosato@linux.ibm.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20241209192403.107090-1-mjrosato@linux.ibm.com> References: <20241209192403.107090-1-mjrosato@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: Pq_rI4anfqEDA3VrbremRz1I_1tf1mpV X-Proofpoint-GUID: Pq_rI4anfqEDA3VrbremRz1I_1tf1mpV X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1051,Hydra:6.0.680,FMLib:17.12.62.30 definitions=2024-10-15_01,2024-10-11_01,2024-09-30_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 adultscore=0 lowpriorityscore=0 clxscore=1015 phishscore=0 impostorscore=0 suspectscore=0 spamscore=0 mlxscore=0 priorityscore=1501 malwarescore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2411120000 definitions=main-2412090147 Content-Type: text/plain; charset="utf-8" On s390, identity domains are only supported under certain virtualization scenarios. If iommu passthrough is requested but unavailable for a device, ignore the request and instead fall back to dma-iommu with a message. Signed-off-by: Matthew Rosato --- drivers/iommu/s390-iommu.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/iommu/s390-iommu.c b/drivers/iommu/s390-iommu.c index 18979d8109b2..6906e1b5b1b0 100644 --- a/drivers/iommu/s390-iommu.c +++ b/drivers/iommu/s390-iommu.c @@ -462,6 +462,28 @@ static void s390_iommu_get_resv_regions(struct device = *dev, } } =20 +static int s390_iommu_def_domain_type(struct device *dev) +{ + struct zpci_dev *zdev =3D to_zpci_dev(dev); + + /* If strict DMA is requested this takes priority */ + if (iommu_dma_is_strict()) + return IOMMU_DOMAIN_DMA; + + /* DMA_FQ is the default unless passthrough is specified */ + if (!iommu_default_passthrough()) + return IOMMU_DOMAIN_DMA_FQ; + + /* If passthrough specified, CLP must indicate it is allowed. */ + if (zdev->rtr_avail) + return IOMMU_DOMAIN_IDENTITY; + + /* If not allowed, fall back to using translation via DMA_FQ */ + pr_info("Passthrough ignored, translation required for %s.\n", + pci_name(to_pci_dev(dev))); + return IOMMU_DOMAIN_DMA_FQ; +} + static struct iommu_device *s390_iommu_probe_device(struct device *dev) { struct zpci_dev *zdev; @@ -839,6 +861,7 @@ static const struct iommu_ops s390_iommu_ops =3D { .device_group =3D generic_device_group, .pgsize_bitmap =3D SZ_4K, .get_resv_regions =3D s390_iommu_get_resv_regions, + .def_domain_type =3D s390_iommu_def_domain_type, .default_domain_ops =3D &(const struct iommu_domain_ops) { .attach_dev =3D s390_iommu_attach_device, .map_pages =3D s390_iommu_map_pages, --=20 2.47.0