From: Liu Yi L <yi.l.liu@intel.com>
To: alex.williamson@redhat.com, kwankhede@nvidia.com
Cc: kevin.tian@intel.com, baolu.lu@linux.intel.com,
yi.l.liu@intel.com, yi.y.sun@intel.com, joro@8bytes.org,
linux-kernel@vger.kernel.org, kvm@vger.kernel.org
Subject: [PATCH v1 2/9] vfio_pci: refine user config reference in vfio-pci module
Date: Sat, 8 Jun 2019 21:21:04 +0800 [thread overview]
Message-ID: <1560000071-3543-3-git-send-email-yi.l.liu@intel.com> (raw)
In-Reply-To: <1560000071-3543-1-git-send-email-yi.l.liu@intel.com>
This patch adds three fields in struct vfio_pci_device to pass the user
configs of vfio-pci module to some functions which could be common in
future usage.
Cc: Kevin Tian <kevin.tian@intel.com>
Cc: Lu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: Liu Yi L <yi.l.liu@intel.com>
---
drivers/vfio/pci/vfio_pci.c | 24 +++++++++++++++---------
drivers/vfio/pci/vfio_pci_private.h | 9 +++++++--
2 files changed, 22 insertions(+), 11 deletions(-)
diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c
index 3841460..2aa8a84 100644
--- a/drivers/vfio/pci/vfio_pci.c
+++ b/drivers/vfio/pci/vfio_pci.c
@@ -72,7 +72,8 @@ static unsigned int vfio_pci_set_vga_decode(void *opaque, bool single_vga)
unsigned char max_busnr;
unsigned int decodes;
- if (single_vga || !vfio_vga_disabled() || pci_is_root_bus(pdev->bus))
+ if (single_vga || !vfio_vga_disabled(vdev) ||
+ pci_is_root_bus(pdev->bus))
return VGA_RSRC_NORMAL_IO | VGA_RSRC_NORMAL_MEM |
VGA_RSRC_LEGACY_IO | VGA_RSRC_LEGACY_MEM;
@@ -276,7 +277,7 @@ static int vfio_pci_enable(struct vfio_pci_device *vdev)
if (!vdev->pci_saved_state)
pci_dbg(pdev, "%s: Couldn't store saved state\n", __func__);
- if (likely(!nointxmask)) {
+ if (likely(!vdev->nointxmask)) {
if (vfio_pci_nointx(pdev)) {
pci_info(pdev, "Masking broken INTx support\n");
vdev->nointx = true;
@@ -313,7 +314,7 @@ static int vfio_pci_enable(struct vfio_pci_device *vdev)
} else
vdev->msix_bar = 0xFF;
- if (!vfio_vga_disabled() && vfio_pci_is_vga(pdev))
+ if (!vfio_vga_disabled(vdev) && vfio_pci_is_vga(pdev))
vdev->has_vga = true;
@@ -439,7 +440,7 @@ static void vfio_pci_disable(struct vfio_pci_device *vdev)
vfio_pci_try_bus_reset(vdev);
- if (!disable_idle_d3)
+ if (!vdev->disable_idle_d3)
vfio_pci_set_power_state(vdev, PCI_D3hot);
}
@@ -1307,6 +1308,11 @@ static int vfio_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
spin_lock_init(&vdev->irqlock);
mutex_init(&vdev->ioeventfds_lock);
INIT_LIST_HEAD(&vdev->ioeventfds_list);
+ vdev->nointxmask = nointxmask;
+#ifdef CONFIG_VFIO_PCI_VGA
+ vdev->disable_vga = disable_vga;
+#endif
+ vdev->disable_idle_d3 = disable_idle_d3;
ret = vfio_add_group_dev(&pdev->dev, &vfio_pci_ops, vdev);
if (ret) {
@@ -1331,7 +1337,7 @@ static int vfio_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
vfio_pci_probe_power_state(vdev);
- if (!disable_idle_d3) {
+ if (!vdev->disable_idle_d3) {
/*
* pci-core sets the device power state to an unknown value at
* bootup and after being removed from a driver. The only
@@ -1362,7 +1368,7 @@ static void vfio_pci_remove(struct pci_dev *pdev)
kfree(vdev->region);
mutex_destroy(&vdev->ioeventfds_lock);
- if (!disable_idle_d3)
+ if (!vdev->disable_idle_d3)
vfio_pci_set_power_state(vdev, PCI_D0);
kfree(vdev->pm_save);
@@ -1597,7 +1603,7 @@ static void vfio_pci_try_bus_reset(struct vfio_pci_device *vdev)
if (!ret) {
tmp->needs_reset = false;
- if (tmp != vdev && !disable_idle_d3)
+ if (tmp != vdev && !tmp->disable_idle_d3)
vfio_pci_set_power_state(tmp, PCI_D3hot);
}
@@ -1613,7 +1619,7 @@ static void __exit vfio_pci_cleanup(void)
vfio_pci_uninit_perm_bits();
}
-static void __init vfio_pci_fill_ids(void)
+static void __init vfio_pci_fill_ids(char *ids)
{
char *p, *id;
int rc;
@@ -1668,7 +1674,7 @@ static int __init vfio_pci_init(void)
if (ret)
goto out_driver;
- vfio_pci_fill_ids();
+ vfio_pci_fill_ids(&ids[0]);
return 0;
diff --git a/drivers/vfio/pci/vfio_pci_private.h b/drivers/vfio/pci/vfio_pci_private.h
index 60c03e6..b53fe34 100644
--- a/drivers/vfio/pci/vfio_pci_private.h
+++ b/drivers/vfio/pci/vfio_pci_private.h
@@ -125,6 +125,11 @@ struct vfio_pci_device {
struct list_head dummy_resources_list;
struct mutex ioeventfds_lock;
struct list_head ioeventfds_list;
+ bool nointxmask;
+#ifdef CONFIG_VFIO_PCI_VGA
+ bool disable_vga;
+#endif
+ bool disable_idle_d3;
};
#define is_intx(vdev) (vdev->irq_type == VFIO_PCI_INTX_IRQ_INDEX)
@@ -138,10 +143,10 @@ static inline bool vfio_pci_is_vga(struct pci_dev *pdev)
return (pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA;
}
-static inline bool vfio_vga_disabled(void)
+static inline bool vfio_vga_disabled(struct vfio_pci_device *vdev)
{
#ifdef CONFIG_VFIO_PCI_VGA
- return disable_vga;
+ return vdev->disable_vga;
#else
return true;
#endif
--
2.7.4
next prev parent reply other threads:[~2019-06-09 13:38 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-08 13:21 [PATCH v1 0/9] vfio_pci: wrap pci device as a mediated device Liu Yi L
2019-06-08 13:21 ` [PATCH v1 1/9] vfio_pci: move vfio_pci_is_vga/vfio_vga_disabled to header Liu Yi L
2019-06-08 13:21 ` Liu Yi L [this message]
2019-06-08 13:21 ` [PATCH v1 3/9] vfio_pci: refine vfio_pci_driver reference in vfio_pci.c Liu Yi L
2019-06-08 13:21 ` [PATCH v1 4/9] vfio_pci: make common functions be extern Liu Yi L
2019-06-08 13:21 ` [PATCH v1 5/9] vfio_pci: duplicate vfio_pci.c Liu Yi L
2019-06-08 13:21 ` [PATCH v1 6/9] vfio_pci: shrink vfio_pci_common.c Liu Yi L
2019-06-08 13:21 ` [PATCH v1 7/9] vfio_pci: shrink vfio_pci.c Liu Yi L
2019-06-08 13:21 ` [PATCH v1 8/9] vfio/pci: protect cap/ecap_perm bits alloc/free with atomic op Liu Yi L
2019-06-08 13:21 ` [PATCH v1 9/9] smaples: add vfio-mdev-pci driver Liu Yi L
2019-06-20 4:26 ` Alex Williamson
2019-06-20 13:00 ` Liu, Yi L
2019-06-20 21:07 ` Alex Williamson
2019-06-21 10:23 ` Liu, Yi L
2019-06-21 15:57 ` Alex Williamson
2019-06-24 8:20 ` Liu, Yi L
2019-06-28 15:07 ` Alex Williamson
2019-07-03 8:25 ` Liu, Yi L
2019-07-03 17:22 ` Alex Williamson
2019-07-04 9:11 ` Liu, Yi L
2019-07-05 15:55 ` Alex Williamson
2019-07-11 12:27 ` Liu, Yi L
2019-07-11 19:08 ` Alex Williamson
2019-07-12 12:55 ` Liu, Yi L
2019-07-19 20:57 ` Alex Williamson
2019-07-26 9:04 ` Liu, Yi L
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1560000071-3543-3-git-send-email-yi.l.liu@intel.com \
--to=yi.l.liu@intel.com \
--cc=alex.williamson@redhat.com \
--cc=baolu.lu@linux.intel.com \
--cc=joro@8bytes.org \
--cc=kevin.tian@intel.com \
--cc=kvm@vger.kernel.org \
--cc=kwankhede@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=yi.y.sun@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).