From patchwork Fri Oct 27 17:00:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Reinette Chatre X-Patchwork-Id: 13438636 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 64DC1C25B47 for ; Fri, 27 Oct 2023 17:01:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346061AbjJ0RBd (ORCPT ); Fri, 27 Oct 2023 13:01:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41280 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345948AbjJ0RBa (ORCPT ); Fri, 27 Oct 2023 13:01:30 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 400441A5; Fri, 27 Oct 2023 10:01:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1698426087; x=1729962087; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=RMArCxGqHD+3tMudRHMvYRNJuBVfq4KK4WYAG6z1Fl4=; b=lwSo3Zc4CW1vwbOiECbplUSh4UR6hshZD2a6f4LEUJCVoQmn1WTQNnm9 dcRE1H9Mse8/kfDvDhC039+mEDS3nhKV91dMUAfNYyT1Pcq+Mg8QsNogL bCnYmOTTZ/cEX3STlQks6HqhRczMD+x5jz9fR+1tNtYlOvZEUvm8F7Jxa lGM2zUS/BR8lotcKlTCDkxE62If/8ej494PhzXwS029Xmgh+x0657QOXG M6fey5F08vnkzBpmLbXU9G8Tl+ZKwNlJ2ZIG0vX02T5N2t2EuCIgJTuq5 88ozw69CxJRaTwOj8e/cWjEvctsEoew+VVh3KZXKP89ci9PqKHh0UiMHL g==; X-IronPort-AV: E=McAfee;i="6600,9927,10876"; a="611832" X-IronPort-AV: E=Sophos;i="6.03,256,1694761200"; d="scan'208";a="611832" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Oct 2023 10:01:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10876"; a="1090988146" X-IronPort-AV: E=Sophos;i="6.03,256,1694761200"; d="scan'208";a="1090988146" Received: from rchatre-ws.ostc.intel.com ([10.54.69.144]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Oct 2023 10:01:13 -0700 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, jing2.liu@intel.com, ashok.raj@intel.com, fenghua.yu@intel.com, tom.zanussi@linux.intel.com, reinette.chatre@intel.com, linux-kernel@vger.kernel.org, patches@lists.linux.dev Subject: [RFC PATCH V3 02/26] vfio/pci: Move PCI specific check from wrapper to PCI function Date: Fri, 27 Oct 2023 10:00:34 -0700 Message-Id: <53d90183704bf3bd633a70983ef9ca8c7c341777.1698422237.git.reinette.chatre@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org vfio_pci_set_irqs_ioctl() uses a PCI device specific check to determine if PCI specific vfio_pci_set_err_trigger() should be called. Move the PCI device specific check into PCI specific vfio_pci_set_err_trigger() to make it easier for vfio_pci_set_irqs_ioctl() to become a frontend for interrupt backends for PCI devices as well as virtual devices. Signed-off-by: Reinette Chatre --- No changes since RFC V2. drivers/vfio/pci/vfio_pci_intrs.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/vfio/pci/vfio_pci_intrs.c b/drivers/vfio/pci/vfio_pci_intrs.c index cbb4bcbfbf83..b5b1c09bef25 100644 --- a/drivers/vfio/pci/vfio_pci_intrs.c +++ b/drivers/vfio/pci/vfio_pci_intrs.c @@ -758,6 +758,9 @@ static int vfio_pci_set_err_trigger(struct vfio_pci_core_device *vdev, unsigned index, unsigned start, unsigned count, uint32_t flags, void *data) { + if (!pci_is_pcie(vdev->pdev)) + return -ENOTTY; + if (index != VFIO_PCI_ERR_IRQ_INDEX || start != 0 || count > 1) return -EINVAL; @@ -813,8 +816,7 @@ int vfio_pci_set_irqs_ioctl(struct vfio_pci_core_device *vdev, uint32_t flags, case VFIO_PCI_ERR_IRQ_INDEX: switch (flags & VFIO_IRQ_SET_ACTION_TYPE_MASK) { case VFIO_IRQ_SET_ACTION_TRIGGER: - if (pci_is_pcie(vdev->pdev)) - func = vfio_pci_set_err_trigger; + func = vfio_pci_set_err_trigger; break; } break;