Received: by 2002:a05:622a:251a:b0:39a:b4a2:e86 with SMTP id cm26csp525867qtb; Wed, 19 Oct 2022 08:07:09 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4GOiCUQSDyS9eYnbEZHp/jYwIwrPQ3NZF5YGERERnXJBb7P00H/ZQyVxHuSYLBvmKCYMwM X-Received: by 2002:a17:907:7635:b0:78d:74c2:a986 with SMTP id jy21-20020a170907763500b0078d74c2a986mr7307542ejc.442.1666192029632; Wed, 19 Oct 2022 08:07:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666192029; cv=none; d=google.com; s=arc-20160816; b=F2DXPuv7g9clfEqnAkfCPHQ1OKuhKpzqHbRHmjCFuhUs+OfvPTqCCkhY5AHHDbo2IE 5oA4rL+CcX9U6Wff4cUoPnVIYtoYeA/KbATPa6R7HV4KS2ndpHp6V4jceYXpIE0eoLHI +pgAl3Z62HC/+rRrYMFPjwzEqMgdL5T/K3wHrPdmm2sJeVDsVTgY6fD+Ppqd3GaxMtwv BLMs0QXgBsPrQIEzme+HK+UaNX6CFfQD2mSPLSYA3JSjbU7GjkHxwWFwBsR16FPqxXtW wgRJEyAVw6C5xWyNcOJwJ5deYayp+M4OxDEMkacWHFAFFL8/3U8gfvON+XZdhCR9tWvH CU3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=hP0kCovPbWmZTSy7tSN9XNIJQRipnc5HWdbuDbVN2YU=; b=XSl/3YJF0cHLhxMStdV+rr5l0W8dcT7M1ZSUathbJ67VPYTistqNtAUW2BY3R9audv /i9k2bU6Mtm4FGltOMvPPewg0T6VWxzakCW3p6Ar6cGpjlCLatVX59Hlt+/Yq2jMeOh1 44zZkpfgE8i7UaEUV2Skua241t8H+yZBNTjujl8ozzMjnwg76S4kJWuhUsUYsKF3Vzo0 AfoNzWrUwt+ZxfwlvDszhM66/dPIVPhmR4VIohFDIKRxDWxxfMO2zrcjwvq/Jo79E7yf B62PCLecxywjZtkE04TNg+woIwAu2duzAGl5xernFk/kzYHLcRt3x5Xnts0dxV4Mo2Oa 7rlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=qEl5bfgq; 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=ibm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id eg47-20020a05640228af00b0045cc6aa0429si12147729edb.250.2022.10.19.08.06.35; Wed, 19 Oct 2022 08:07:09 -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=@ibm.com header.s=pp1 header.b=qEl5bfgq; 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=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230168AbiJSOyN (ORCPT + 99 others); Wed, 19 Oct 2022 10:54:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231225AbiJSOxJ (ORCPT ); Wed, 19 Oct 2022 10:53:09 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFC38EC506; Wed, 19 Oct 2022 07:44:58 -0700 (PDT) Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 29JEgkJH001278; Wed, 19 Oct 2022 14:44:44 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=hP0kCovPbWmZTSy7tSN9XNIJQRipnc5HWdbuDbVN2YU=; b=qEl5bfgqGf28ihyh/cPPxyh1sNZPPGwwXDfVfhlOhuUlTwcmeqwquncH52O1W6+wu3YV gfytbKnEeZrecOWM/+sF6nzlPwRF9KafpnGnHD/LOmT23x2P7z7/cLg/rF7Sy5KbrwEu OIPSmTDcr1KZcndz31bxfy+nHx+x/pz4OsMM1MXyHeVghLYznhcAlK8jrtMVZgyH2qPj y96oDJU+En0cIAJ51N3tA9+0B8d5Jy2Pqj+zFtdZZsfDkRI3braVCV+IRlbiribq6G3+ 40dJevJnvkYDuSnSQK1yOBnxtKoapSSYZT4NpqaWQbh99g+msMJkhUMPLInvNNnCWwsI 9w== Received: from ppma03ams.nl.ibm.com (62.31.33a9.ip4.static.sl-reverse.com [169.51.49.98]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3kak7yg1ww-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 19 Oct 2022 14:44:43 +0000 Received: from pps.filterd (ppma03ams.nl.ibm.com [127.0.0.1]) by ppma03ams.nl.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 29JEZDkB017393; Wed, 19 Oct 2022 14:44:40 GMT Received: from b06avi18878370.portsmouth.uk.ibm.com (b06avi18878370.portsmouth.uk.ibm.com [9.149.26.194]) by ppma03ams.nl.ibm.com with ESMTP id 3k7mg97bt2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 19 Oct 2022 14:44:40 +0000 Received: from d06av22.portsmouth.uk.ibm.com (d06av22.portsmouth.uk.ibm.com [9.149.105.58]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 29JEjALF44368136 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 19 Oct 2022 14:45:10 GMT Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 900474C044; Wed, 19 Oct 2022 14:44:37 +0000 (GMT) Received: from d06av22.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1E0374C040; Wed, 19 Oct 2022 14:44:37 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by d06av22.portsmouth.uk.ibm.com (Postfix) with ESMTP; Wed, 19 Oct 2022 14:44:37 +0000 (GMT) From: Niklas Schnelle To: Matthew Rosato , iommu@lists.linux.dev, Joerg Roedel , Will Deacon , Robin Murphy , Jason Gunthorpe Cc: Gerd Bayer , Pierre Morel , 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, Wenjia Zhang , Julian Ruess Subject: [RFC 2/6] s390/pci: prepare is_passed_through() for dma-iommu Date: Wed, 19 Oct 2022 16:44:31 +0200 Message-Id: <20221019144435.369902-3-schnelle@linux.ibm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221019144435.369902-1-schnelle@linux.ibm.com> References: <20221019144435.369902-1-schnelle@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: aWZLz9Xyy5inkK2T3tn0v2aIwu2T7b0O X-Proofpoint-ORIG-GUID: aWZLz9Xyy5inkK2T3tn0v2aIwu2T7b0O X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-10-19_08,2022-10-19_03,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 mlxscore=0 malwarescore=0 impostorscore=0 spamscore=0 priorityscore=1501 lowpriorityscore=0 suspectscore=0 adultscore=0 mlxlogscore=941 bulkscore=0 clxscore=1015 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2209130000 definitions=main-2210190081 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 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 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) -- 2.34.1