From patchwork Thu Sep 28 14:31:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Schnelle X-Patchwork-Id: 146227 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:cae8:0:b0:403:3b70:6f57 with SMTP id r8csp3475177vqu; Thu, 28 Sep 2023 10:21:37 -0700 (PDT) X-Google-Smtp-Source: AGHT+IELcL3H55OQe9ibE1he8OAiZAFlzFZzUvKyG/FLx25zLvENFkrF12Oj6DfNlYFRRAD3p/8o X-Received: by 2002:a05:6a20:5611:b0:14c:f16a:2b78 with SMTP id ir17-20020a056a20561100b0014cf16a2b78mr1742963pzc.45.1695921697453; Thu, 28 Sep 2023 10:21:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695921697; cv=none; d=google.com; s=arc-20160816; b=Mzi0dAE7TE/8mcDp1uFKBRx0FLAfJoK6GLjfCm49ooEvFNRhTvXluYE6FbJju10dI/ OZRNB0b67hWzMwXQgZ93nvSXetGPhoeA83gx59kZ8Ae5BRIGJZogOZFoMud+gJ5TLGbv ralBQcOw79EA5KVH8iTqUKFh8n9KnvvTMcgoihebvsdu6itbYHmJtraN0F6BuiKu33RM EBWVqBIh1bIjikBuqA5nan1JN2L4d0nYgDPYIDnNKLGoC5ncVHeAe6PtdTrxJrd9cxLY NotPej3QMuaNijdYZEWaV2Oc+zSCza2d84Dw7ykDXjr3lQgRgjqQ0Q4v3i6mA7WX9E5d 06VQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from :dkim-signature; bh=rodPNwLfHsIuiQQiFeOVrCe92jgLqk9u0QoV1c2yRD8=; fh=r4hvbVDumYlzVi2p/bmDHTejJvSdOCjfHvh+MZAy288=; b=ODA17DceNU5Vrap18fyDdPiVhOG5YqO4B/Db6ewKpd7e5FMrLGthsqoDack9WLtSl2 OGwGifxhsANoXZ5Zup/4ltqSjyEdim/jLVI3FjhHgqwAKLyy31sqy6vXC6vsOpOvMzsn gICVUaTwkLaXk1lIL1+PPj7MTrR7PhP5AYPv/W262I3tj99CAsWUcTeLriVowSTDhBM1 gbTi1DqGcGhvtX2QmkLf4tQl75LK0y87c5fgB6MES9avPshVWIPs4/CdAocwZbXC4M3v TwyAuP+VYOPJvOutTiUwjVlHG+aRowWxc8PY2ZyaQu4/08fmrAVnck7qR5ICtWcdm6/v EEBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=M9e8fdPu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id bx20-20020a056a00429400b00687427c1ac1si19188521pfb.25.2023.09.28.10.21.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 10:21:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=M9e8fdPu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 1C83181E3E05; Thu, 28 Sep 2023 07:34:50 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232606AbjI1OeW (ORCPT + 21 others); Thu, 28 Sep 2023 10:34:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232683AbjI1OeN (ORCPT ); Thu, 28 Sep 2023 10:34:13 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E2441B2; Thu, 28 Sep 2023 07:34:08 -0700 (PDT) Received: from pps.filterd (m0353726.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 38SEK77V015574; Thu, 28 Sep 2023 14:33:36 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : date : subject : mime-version : content-type : content-transfer-encoding : message-id : references : in-reply-to : to : cc; s=pp1; bh=rodPNwLfHsIuiQQiFeOVrCe92jgLqk9u0QoV1c2yRD8=; b=M9e8fdPuBnAQzV8p+a5BOrKjS995DeHuRMfXmdnyaIgHx1ITc080ejbXclGMoY53MbGR iysJAHqug83kzUKvAUYukXMw90MgbIVqiRLMG8uHTIhZZBdeLb+5qTVeUJ09LZRHsbGD myIQFvz9JYPcd9lFppFscx2Q7x1y7OPp6ecRYIC39AVL0YScREABS3dc9Kc2PMFK6KTh PDvdnKGuQ5/CcAfe0XR/Qe3U4I9gK909CIToncApHtoY+u/xXyDLJzIHoEVwWlmHfuu8 nL7S3uMgtzj3TDBl8LUAJCVFLjOOcsxy5dXZ/ZzcYN2r5QJK+n0ywExBHMNcRGMVSy0N 2A== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3tdb5mrb7k-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 Sep 2023 14:33:35 +0000 Received: from m0353726.ppops.net (m0353726.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 38SENBnP024057; Thu, 28 Sep 2023 14:33:32 GMT Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3tdb5mrb20-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 Sep 2023 14:33:32 +0000 Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 38SDfF9t008250; Thu, 28 Sep 2023 14:32:37 GMT Received: from smtprelay02.fra02v.mail.ibm.com ([9.218.2.226]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3tabbnn36g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 Sep 2023 14:32:37 +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 38SEWYwR24314500 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 28 Sep 2023 14:32:34 GMT Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1BEF020040; Thu, 28 Sep 2023 14:32:34 +0000 (GMT) Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4107B20063; Thu, 28 Sep 2023 14:32:33 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav04.fra02v.mail.ibm.com (Postfix) with ESMTP; Thu, 28 Sep 2023 14:32:33 +0000 (GMT) From: Niklas Schnelle Date: Thu, 28 Sep 2023 16:31:36 +0200 Subject: [PATCH v13 2/6] s390/pci: prepare is_passed_through() for dma-iommu MIME-Version: 1.0 Message-Id: <20230928-dma_iommu-v13-2-9e5fc4dacc36@linux.ibm.com> References: <20230928-dma_iommu-v13-0-9e5fc4dacc36@linux.ibm.com> In-Reply-To: <20230928-dma_iommu-v13-0-9e5fc4dacc36@linux.ibm.com> To: Joerg Roedel , Matthew Rosato , Will Deacon , Wenjia Zhang , Robin Murphy , Jason Gunthorpe Cc: Gerd Bayer , Julian Ruess , Pierre Morel , Alexandra Winter , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Suravee Suthikulpanit , Hector Martin , Sven Peter , Alyssa Rosenzweig , David Woodhouse , Lu Baolu , Andy Gross , Bjorn Andersson , Konrad Dybcio , Yong Wu , Matthias Brugger , AngeloGioacchino Del Regno , Gerald Schaefer , Orson Zhai , Baolin Wang , Chunyan Zhang , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Thierry Reding , Krishna Reddy , Jonathan Hunter , Niklas Schnelle , Jonathan Corbet , linux-s390@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, iommu@lists.linux.dev, asahi@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, linux-doc@vger.kernel.org X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=1902; i=schnelle@linux.ibm.com; h=from:subject:message-id; bh=JnpBPtIA02SvkModRZiVKujLXSYwAXU0tTNoKrRKqJY=; b=owGbwMvMwCH2Wz534YHOJ2GMp9WSGFJF+8Lkp2uwJZvdOfXxXrKRddVldcXFK2f6l2jPyX7/v qmx3o+jo5SFQYyDQVZMkWVRl7PfuoIppnuC+jtg5rAygQxh4OIUgIm8Xsfwz8b125Un76345GZM /xmfvG3nrgfJ6tkX37/lnKS5mn9r42eGf1ZsHl+P3fGbs+2j7KlV/Lbtd/sa+XXVV/y996CTLUh bmxsA X-Developer-Key: i=schnelle@linux.ibm.com; a=openpgp; fpr=9DB000B2D2752030A5F72DDCAFE43F15E8C26090 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: qc5dno9irCoxT06syVYDsWp3Q-x0o4LZ X-Proofpoint-GUID: eZRNd7FLzoKg_WOfMzaz1kzLaCIEyU1l X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.980,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-09-28_13,2023-09-28_02,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 suspectscore=0 impostorscore=0 mlxlogscore=940 bulkscore=0 malwarescore=0 phishscore=0 mlxscore=0 spamscore=0 priorityscore=1501 clxscore=1015 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2309180000 definitions=main-2309280126 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Thu, 28 Sep 2023 07:34:50 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778302790016217694 X-GMAIL-MSGID: 1778302790016217694 With the IOMMU always controlled through the IOMMU driver testing for zdev->s390_domain is not a valid indication of the device being passed-through. Instead test if zdev->kzdev is set. Reviewed-by: Pierre Morel Reviewed-by: Matthew Rosato Signed-off-by: Niklas Schnelle --- arch/s390/pci/pci_event.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/arch/s390/pci/pci_event.c b/arch/s390/pci/pci_event.c index b9324ca2eb94..4ef5a6a1d618 100644 --- a/arch/s390/pci/pci_event.c +++ b/arch/s390/pci/pci_event.c @@ -59,9 +59,16 @@ static inline bool ers_result_indicates_abort(pci_ers_result_t ers_res) } } -static bool is_passed_through(struct zpci_dev *zdev) +static bool is_passed_through(struct pci_dev *pdev) { - return zdev->s390_domain; + struct zpci_dev *zdev = to_zpci(pdev); + bool ret; + + mutex_lock(&zdev->kzdev_lock); + ret = !!zdev->kzdev; + mutex_unlock(&zdev->kzdev_lock); + + return ret; } static bool is_driver_supported(struct pci_driver *driver) @@ -176,7 +183,7 @@ static pci_ers_result_t zpci_event_attempt_error_recovery(struct pci_dev *pdev) } pdev->error_state = pci_channel_io_frozen; - if (is_passed_through(to_zpci(pdev))) { + if (is_passed_through(pdev)) { pr_info("%s: Cannot be recovered in the host because it is a pass-through device\n", pci_name(pdev)); goto out_unlock; @@ -239,7 +246,7 @@ static void zpci_event_io_failure(struct pci_dev *pdev, pci_channel_state_t es) * we will inject the error event and let the guest recover the device * itself. */ - if (is_passed_through(to_zpci(pdev))) + if (is_passed_through(pdev)) goto out; driver = to_pci_driver(pdev->dev.driver); if (driver && driver->err_handler && driver->err_handler->error_detected)