From patchwork Fri Oct 6 16:40:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Reinette Chatre X-Patchwork-Id: 13411737 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 C6ACEE81E19 for ; Fri, 6 Oct 2023 16:41:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232946AbjJFQl1 (ORCPT ); Fri, 6 Oct 2023 12:41:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49640 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232900AbjJFQl0 (ORCPT ); Fri, 6 Oct 2023 12:41:26 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52B21C5; Fri, 6 Oct 2023 09:41:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1696610485; x=1728146485; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=E7b6MxJENrxyYMmSRzlDsTMhK6exMtnF17Bw1TQ8Ogs=; b=eNZv36ncxzKZfN+hEcDe/NAY1vEDO0bZ651UVhrLEE25e3bva41BZZkG NajGL+HBuOHCAR2TNouK3HbX1O/OTCwNLDWdz57GM0J0gOYZ21luGvCC7 2wwpjqLD65BIOewy/J5C406MbJj1tYGaUDyoWa4aKJb59yGqcKcjVI45U Xhf8pV/x/E/PTcYvWw6GklKR7bVOlG54prVn8Y3iSHGyGR3v+DuBRQ5jh LbrqBeXIFJnE6TC7w1TbBVnsngNaT/sUXvMXDkSH+EFJvwQ92iuQoAC0e cPgkhq8Fqmj4ONAUXiMUOana7IrtWdAxSvmk6wDcRKm6KbnZpB4MMf3Ao A==; X-IronPort-AV: E=McAfee;i="6600,9927,10855"; a="364063156" X-IronPort-AV: E=Sophos;i="6.03,204,1694761200"; d="scan'208";a="364063156" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Oct 2023 09:41:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10855"; a="842892842" X-IronPort-AV: E=Sophos;i="6.03,204,1694761200"; d="scan'208";a="842892842" Received: from rchatre-ws.ostc.intel.com ([10.54.69.144]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Oct 2023 09:41:23 -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 V2 02/18] vfio/pci: Move PCI specific check from wrapper to PCI function Date: Fri, 6 Oct 2023 09:40:57 -0700 Message-Id: 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 --- 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;