From: Alex Williamson <alex.williamson@redhat.com>
To: maarten.lankhorst@linux.intel.com, mripard@kernel.org,
tzimmermann@suse.de, airlied@linux.ie, daniel@ffwll.ch
Cc: Laszlo Ersek <lersek@redhat.com>,
Laszlo Ersek <lersek@redhat.com>,
Gerd Hoffmann <kraxel@redhat.com>,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
kvm@vger.kernel.org
Subject: [PATCH 1/2] drm/aperture: Split conflicting platform driver removal
Date: Mon, 06 Jun 2022 11:53:22 -0600 [thread overview]
Message-ID: <165453800256.3592816.10844562232615146019.stgit@omen> (raw)
In-Reply-To: <165453797543.3592816.6381793341352595461.stgit@omen>
Split the removal of platform drivers conflicting with PCI resources from
drm_aperture_remove_conflicting_pci_framebuffers() to support both non-DRM
callers and better modularity. This is intended to support the vfio-pci
driver, which can acquire ownership of PCI graphics devices, but is not
itself a DRM or FB driver, and therefore has no Kconfig dependencies. The
remaining actions of drm_aperture_remove_conflicting_pci_framebuffers() are
already exported from their respective subsystems, therefore this allows
vfio-pci to separate each set of conflicts independently based on the
configured features.
Reported-by: Laszlo Ersek <lersek@redhat.com>
Tested-by: Laszlo Ersek <lersek@redhat.com>
Suggested-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
---
drivers/gpu/drm/drm_aperture.c | 33 ++++++++++++++++++++++++---------
include/drm/drm_aperture.h | 2 ++
2 files changed, 26 insertions(+), 9 deletions(-)
diff --git a/drivers/gpu/drm/drm_aperture.c b/drivers/gpu/drm/drm_aperture.c
index 74bd4a76b253..5b2500f7fb8b 100644
--- a/drivers/gpu/drm/drm_aperture.c
+++ b/drivers/gpu/drm/drm_aperture.c
@@ -313,6 +313,28 @@ int drm_aperture_remove_conflicting_framebuffers(resource_size_t base, resource_
}
EXPORT_SYMBOL(drm_aperture_remove_conflicting_framebuffers);
+/**
+ * drm_aperture_detach_platform_drivers - detach platform drivers conflicting with PCI device
+ * @pdev: PCI device
+ *
+ * This function detaches platform drivers with resource conflicts to the memory
+ * bars of the provided @pdev.
+ */
+void drm_aperture_detach_platform_drivers(struct pci_dev *pdev)
+{
+ resource_size_t base, size;
+ int bar;
+
+ for (bar = 0; bar < PCI_STD_NUM_BARS; ++bar) {
+ if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM))
+ continue;
+ base = pci_resource_start(pdev, bar);
+ size = pci_resource_len(pdev, bar);
+ drm_aperture_detach_drivers(base, size);
+ }
+}
+EXPORT_SYMBOL(drm_aperture_detach_platform_drivers);
+
/**
* drm_aperture_remove_conflicting_pci_framebuffers - remove existing framebuffers for PCI devices
* @pdev: PCI device
@@ -328,16 +350,9 @@ EXPORT_SYMBOL(drm_aperture_remove_conflicting_framebuffers);
int drm_aperture_remove_conflicting_pci_framebuffers(struct pci_dev *pdev,
const struct drm_driver *req_driver)
{
- resource_size_t base, size;
- int bar, ret = 0;
+ int ret = 0;
- for (bar = 0; bar < PCI_STD_NUM_BARS; ++bar) {
- if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM))
- continue;
- base = pci_resource_start(pdev, bar);
- size = pci_resource_len(pdev, bar);
- drm_aperture_detach_drivers(base, size);
- }
+ drm_aperture_detach_platform_drivers(pdev);
/*
* WARNING: Apparently we must kick fbdev drivers before vgacon,
diff --git a/include/drm/drm_aperture.h b/include/drm/drm_aperture.h
index 7096703c3949..53fd36fa258e 100644
--- a/include/drm/drm_aperture.h
+++ b/include/drm/drm_aperture.h
@@ -15,6 +15,8 @@ int devm_aperture_acquire_from_firmware(struct drm_device *dev, resource_size_t
int drm_aperture_remove_conflicting_framebuffers(resource_size_t base, resource_size_t size,
bool primary, const struct drm_driver *req_driver);
+void drm_aperture_detach_platform_drivers(struct pci_dev *pdev);
+
int drm_aperture_remove_conflicting_pci_framebuffers(struct pci_dev *pdev,
const struct drm_driver *req_driver);
next prev parent reply other threads:[~2022-06-06 17:53 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-06 17:53 [PATCH 0/2] Improve vfio-pci primary GPU assignment behavior Alex Williamson
2022-06-06 17:53 ` Alex Williamson [this message]
2022-06-06 17:53 ` [PATCH 2/2] vfio/pci: Remove console drivers Alex Williamson
2022-06-08 11:11 ` Thomas Zimmermann
2022-06-08 14:04 ` Alex Williamson
2022-06-09 9:13 ` Thomas Zimmermann
2022-06-09 21:41 ` Alex Williamson
2022-06-09 21:44 ` Alex Williamson
2022-06-10 7:03 ` Thomas Zimmermann
2022-06-10 14:30 ` Alex Williamson
2022-06-08 15:37 ` Gerd Hoffmann
2022-06-07 17:40 ` [PATCH 0/2] Improve vfio-pci primary GPU assignment behavior Javier Martinez Canillas
2022-06-07 21:01 ` Alex Williamson
2022-06-08 7:43 ` Gerd Hoffmann
2022-06-08 8:51 ` Javier Martinez Canillas
2022-06-08 9:11 ` Gerd Hoffmann
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=165453800256.3592816.10844562232615146019.stgit@omen \
--to=alex.williamson@redhat.com \
--cc=airlied@linux.ie \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=kraxel@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=lersek@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=tzimmermann@suse.de \
/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
all inboxes | Powered by JetHome®