From patchwork Fri Feb 2 04:56:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Reinette Chatre X-Patchwork-Id: 195565 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:9bc1:b0:106:209c:c626 with SMTP id op1csp212000dyc; Thu, 1 Feb 2024 20:59:52 -0800 (PST) X-Google-Smtp-Source: AGHT+IHkYjsolO+IgsQog2aOgNqTt3ivexWUUr54mpAJtADVCDQrdXYTvpVd5ga9/PyxTCnSE8// X-Received: by 2002:a05:622a:34a:b0:42a:3195:e8be with SMTP id r10-20020a05622a034a00b0042a3195e8bemr4868061qtw.51.1706849992549; Thu, 01 Feb 2024 20:59:52 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706849992; cv=pass; d=google.com; s=arc-20160816; b=hvdobVy2QtJ7BqbID77YhJq2xDD4x29Y+Cna+UX7dFmXCzlksdQc0sAIgwhEwsnLq1 CNV7Pdkk4VOzfYE3LYIvRzbQsXwwQu2H5hOhQvuIfSmcvGLuzmd7CdOgdUxwHMRxLpIb OBnctPWPs0l3hvqfu1i3Q+kBnaUFwU8l8Ydq01pby1QkQvR23kYks4rherYGKsXqUJXB 0b2WMWKS+yEAorNkiFazmEiLA0pRLWwI2A0RhLEM7Blbq//YQfsD6AN7vHueuMSarA30 7hu85OvykL7kqp20YcBCjCTD4ibO/O5cJ0fnhH3HI3PxU27LjkWyOWrDvroVcLIkjAqQ w10w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=bX6PujnvYzVWvXvG1VP4BCFUIjqKZt+tDJb+USnp6aA=; fh=ORhuBRDL5kyCNilIT7kKOjTR6ie6WlesRBPi260/j0I=; b=JFaH4UN+W4AJNskvgfJO232Dv2Ky+9E8TVv3mcns+fVG6iihkLHvFD5NDH5Wa/6zXj Vhq8vBh8fRmP90mTx7BtZYhirOHRppb6Y7eg6nRxzOtyl6+eNO9NP02HyRzqNjvneamG QqLDPJG/WS41ykAEh7xwdP0yUc0HJDAttf3/9pjKrzCPN149YncCi1ok8xZtssCZtCSt Hda651h1SPZIcW2VxGdyuZzLHmHD9aPV+e6w1HaBhfO6faj4IwhvzAOa+WQNJDTpdpyd ThJb6j4WvQqnJUybyTlCgtkFRe84cbbqxYA8k8j1R93nFs02Z7c772WiLMcEtXj8yUA5 ukQA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=hWDHKiky; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-49208-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49208-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com X-Forwarded-Encrypted: i=1; AJvYcCWu4QQ/2IdL4qDaQt0j1TQ/lFfEZsZZrKfJFPfW39FAWX2UfHkBBa7UsmjC3TXBsnKGlV04zBKfUyNWv1sZLG0zxR07zA== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id f32-20020a05622a1a2000b0042bff27388asi1206376qtb.151.2024.02.01.20.59.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 20:59:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-49208-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=hWDHKiky; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-49208-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-49208-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 591AF1C24CE3 for ; Fri, 2 Feb 2024 04:59:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6DEBA18027; Fri, 2 Feb 2024 04:57:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="hWDHKiky" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) (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 2DC91101EC; Fri, 2 Feb 2024 04:57:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.8 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706849851; cv=none; b=frFarHnJmAT9RLRerrCWX/GYRDf611wcwST3EnGFPZjUJrIqc33/100eXSks3mof5qX56M1cYpjZxKSMlSP+JVWovtADfyasKmb9no5YX9LmJT6Uj6actaOGngsAUm3qP7M5Fy4eVNET3XnMnuMWH+z5gogeVsNPrXMz21TVN9A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706849851; c=relaxed/simple; bh=wjShxdkTqGwADOgBt3EJHJs5FYJXIg/tseoEaV8uAgM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=h+LiooV3yfqwWDWfXPczHc26MoycSQt5xqEigxgDQQZE/fdWD0WPa7xWrDOwfCgEzplFDh1vnC0svFqHLAM/DkElpeJV1j0hFg8mduk0CICx46MyhU/2/Liwp7eCUaOQCqQtD89uZmHTzIft/fB+L9P0GT/B1i17nbPe41NzHBc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=hWDHKiky; arc=none smtp.client-ip=192.198.163.8 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1706849850; x=1738385850; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=wjShxdkTqGwADOgBt3EJHJs5FYJXIg/tseoEaV8uAgM=; b=hWDHKikybu6AUycg4O0oPYwBVNvSHN0JWa0LTlEpkXFJFC2UwlIWk7B4 4CJYR0u7q4+d4dN8UITwRaahaSVNtbEDldb9m44QCv/9miCWlwiAtlI6Y lPPaqACjaFOGPavV4f4X3XU0DjGY8W0KxwJFm70kWiE5a5vcAnZM3vRDh I0rLwf/Qf6DpPUJ/Lbb8NocBUS3DvgCUhDg2OJeoZm+3l0YyY5033mZbR 4/6izxhOJGiJ4JR+V7znizMzu/+y5K11OuJMufKsJuZ2tlnyaGsiwyZZi 5YIDviDDO0EOTgwlFTaUf3o5kDBkc+Pc3qiQyglmNeztWiF4qG4jpivTs g==; X-IronPort-AV: E=McAfee;i="6600,9927,10971"; a="17615813" X-IronPort-AV: E=Sophos;i="6.05,237,1701158400"; d="scan'208";a="17615813" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Feb 2024 20:57:26 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10971"; a="912339771" X-IronPort-AV: E=Sophos;i="6.05,237,1701158400"; d="scan'208";a="912339771" Received: from rchatre-ws.ostc.intel.com ([10.54.69.144]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Feb 2024 20:57:24 -0800 From: Reinette Chatre To: jgg@nvidia.com, yishaih@nvidia.com, shameerali.kolothum.thodi@huawei.com, kevin.tian@intel.com, alex.williamson@redhat.com Cc: kvm@vger.kernel.org, dave.jiang@intel.com, ashok.raj@intel.com, reinette.chatre@intel.com, linux-kernel@vger.kernel.org, patches@lists.linux.dev Subject: [PATCH 05/17] vfio/pci: Limit eventfd signaling to interrupt management code Date: Thu, 1 Feb 2024 20:56:59 -0800 Message-Id: <54ba34d884de30f479bbe3844c4a342980760d79.1706849424.git.reinette.chatre@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789761937693636768 X-GMAIL-MSGID: 1789761937693636768 VFIO PCI interrupt management has full support for configuring, signaling, and clearing the eventfds associated with device request notification and error interrupts. Core VFIO PCI duplicates eventfd signaling while also accessing data that should be contained within the interrupt management code. Remove the duplicate eventfd signaling from core VFIO PCI and rely on VFIO PCI interrupt management for eventfd signaling. Signed-off-by: Reinette Chatre --- drivers/vfio/pci/vfio_pci_core.c | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/drivers/vfio/pci/vfio_pci_core.c b/drivers/vfio/pci/vfio_pci_core.c index de097174e455..a8235b9c1a81 100644 --- a/drivers/vfio/pci/vfio_pci_core.c +++ b/drivers/vfio/pci/vfio_pci_core.c @@ -1868,21 +1868,20 @@ void vfio_pci_core_request(struct vfio_device *core_vdev, unsigned int count) struct vfio_pci_core_device *vdev = container_of(core_vdev, struct vfio_pci_core_device, vdev); struct pci_dev *pdev = vdev->pdev; + int ret; - mutex_lock(&vdev->igate); + ret = vfio_pci_set_irqs_ioctl(vdev, VFIO_IRQ_SET_DATA_NONE | + VFIO_IRQ_SET_ACTION_TRIGGER, + VFIO_PCI_REQ_IRQ_INDEX, 0, 1, NULL); - if (vdev->req_trigger) { - if (!(count % 10)) - pci_notice_ratelimited(pdev, - "Relaying device request to user (#%u)\n", - count); - eventfd_signal(vdev->req_trigger); - } else if (count == 0) { + if (!ret && !(count % 10)) { + pci_notice_ratelimited(pdev, + "Relaying device request to user (#%u)\n", + count); + } else if (ret && count == 0) { pci_warn(pdev, - "No device request channel registered, blocked until released by user\n"); + "No device request channel registered, blocked until released by user\n"); } - - mutex_unlock(&vdev->igate); } EXPORT_SYMBOL_GPL(vfio_pci_core_request); @@ -2292,12 +2291,9 @@ pci_ers_result_t vfio_pci_core_aer_err_detected(struct pci_dev *pdev, { struct vfio_pci_core_device *vdev = dev_get_drvdata(&pdev->dev); - mutex_lock(&vdev->igate); - - if (vdev->err_trigger) - eventfd_signal(vdev->err_trigger); - - mutex_unlock(&vdev->igate); + vfio_pci_set_irqs_ioctl(vdev, VFIO_IRQ_SET_DATA_NONE | + VFIO_IRQ_SET_ACTION_TRIGGER, + VFIO_PCI_ERR_IRQ_INDEX, 0, 1, NULL); return PCI_ERS_RESULT_CAN_RECOVER; }