* [Nouveau] [PATCH 1/7] vgaarb: remove VGA_DEFAULT_DEVICE
2021-07-16 6:16 [Nouveau] misc vgaarb cleanups Christoph Hellwig
@ 2021-07-16 6:16 ` Christoph Hellwig
2021-07-16 7:14 ` Christian König
2021-07-16 6:16 ` [Nouveau] [PATCH 2/7] vgaarb: remove vga_conflicts Christoph Hellwig
` (6 subsequent siblings)
7 siblings, 1 reply; 13+ messages in thread
From: Christoph Hellwig @ 2021-07-16 6:16 UTC (permalink / raw)
To: David Airlie, Daniel Vetter
Cc: Joonas Lahtinen, kvm, amd-gfx, nouveau, dri-devel, Pan, Xinhui,
Maarten Lankhorst, Maxime Ripard, Alex Williamson, Jani Nikula,
Rodrigo Vivi, Alex Deucher, intel-gfx, Christian König,
Ben Skeggs
The define is entirely unused.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
include/linux/vgaarb.h | 6 ------
1 file changed, 6 deletions(-)
diff --git a/include/linux/vgaarb.h b/include/linux/vgaarb.h
index dc6ddce92066..26ec8a057d2a 100644
--- a/include/linux/vgaarb.h
+++ b/include/linux/vgaarb.h
@@ -42,12 +42,6 @@
#define VGA_RSRC_NORMAL_IO 0x04
#define VGA_RSRC_NORMAL_MEM 0x08
-/* Passing that instead of a pci_dev to use the system "default"
- * device, that is the one used by vgacon. Archs will probably
- * have to provide their own vga_default_device();
- */
-#define VGA_DEFAULT_DEVICE (NULL)
-
struct pci_dev;
/* For use by clients */
--
2.30.2
_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [Nouveau] [PATCH 1/7] vgaarb: remove VGA_DEFAULT_DEVICE
2021-07-16 6:16 ` [Nouveau] [PATCH 1/7] vgaarb: remove VGA_DEFAULT_DEVICE Christoph Hellwig
@ 2021-07-16 7:14 ` Christian König
2021-07-20 13:50 ` Daniel Vetter
0 siblings, 1 reply; 13+ messages in thread
From: Christian König @ 2021-07-16 7:14 UTC (permalink / raw)
To: Christoph Hellwig, David Airlie, Daniel Vetter
Cc: Joonas Lahtinen, kvm, amd-gfx, nouveau, dri-devel, Pan, Xinhui,
Maarten Lankhorst, Jani Nikula, Alex Williamson, Maxime Ripard,
Rodrigo Vivi, Alex Deucher, intel-gfx, Ben Skeggs
Am 16.07.21 um 08:16 schrieb Christoph Hellwig:
> The define is entirely unused.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
I'm not an expert for this particular code, but at least of hand
everything you do here makes totally sense.
Whole series is Acked-by: Christian König <christian.koenig@amd.com>
Regards,
Christian.
> ---
> include/linux/vgaarb.h | 6 ------
> 1 file changed, 6 deletions(-)
>
> diff --git a/include/linux/vgaarb.h b/include/linux/vgaarb.h
> index dc6ddce92066..26ec8a057d2a 100644
> --- a/include/linux/vgaarb.h
> +++ b/include/linux/vgaarb.h
> @@ -42,12 +42,6 @@
> #define VGA_RSRC_NORMAL_IO 0x04
> #define VGA_RSRC_NORMAL_MEM 0x08
>
> -/* Passing that instead of a pci_dev to use the system "default"
> - * device, that is the one used by vgacon. Archs will probably
> - * have to provide their own vga_default_device();
> - */
> -#define VGA_DEFAULT_DEVICE (NULL)
> -
> struct pci_dev;
>
> /* For use by clients */
_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Nouveau] [PATCH 1/7] vgaarb: remove VGA_DEFAULT_DEVICE
2021-07-16 7:14 ` Christian König
@ 2021-07-20 13:50 ` Daniel Vetter
2021-07-20 14:12 ` Christian König
2021-07-21 8:30 ` Christian König
0 siblings, 2 replies; 13+ messages in thread
From: Daniel Vetter @ 2021-07-20 13:50 UTC (permalink / raw)
To: Christian König
Cc: Joonas Lahtinen, kvm, David Airlie, nouveau, dri-devel, Pan,
Xinhui, Maarten Lankhorst, Maxime Ripard, Alex Williamson,
Jani Nikula, Daniel Vetter, Rodrigo Vivi, Alex Deucher, amd-gfx,
intel-gfx, Christoph Hellwig, Ben Skeggs
On Fri, Jul 16, 2021 at 09:14:02AM +0200, Christian König wrote:
> Am 16.07.21 um 08:16 schrieb Christoph Hellwig:
> > The define is entirely unused.
> >
> > Signed-off-by: Christoph Hellwig <hch@lst.de>
>
> I'm not an expert for this particular code, but at least of hand everything
> you do here makes totally sense.
>
> Whole series is Acked-by: Christian König <christian.koenig@amd.com>
Care to also push this into drm-misc-next since you looked already?
-Daniel
>
> Regards,
> Christian.
>
> > ---
> > include/linux/vgaarb.h | 6 ------
> > 1 file changed, 6 deletions(-)
> >
> > diff --git a/include/linux/vgaarb.h b/include/linux/vgaarb.h
> > index dc6ddce92066..26ec8a057d2a 100644
> > --- a/include/linux/vgaarb.h
> > +++ b/include/linux/vgaarb.h
> > @@ -42,12 +42,6 @@
> > #define VGA_RSRC_NORMAL_IO 0x04
> > #define VGA_RSRC_NORMAL_MEM 0x08
> > -/* Passing that instead of a pci_dev to use the system "default"
> > - * device, that is the one used by vgacon. Archs will probably
> > - * have to provide their own vga_default_device();
> > - */
> > -#define VGA_DEFAULT_DEVICE (NULL)
> > -
> > struct pci_dev;
> > /* For use by clients */
>
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Nouveau] [PATCH 1/7] vgaarb: remove VGA_DEFAULT_DEVICE
2021-07-20 13:50 ` Daniel Vetter
@ 2021-07-20 14:12 ` Christian König
2021-07-21 8:30 ` Christian König
1 sibling, 0 replies; 13+ messages in thread
From: Christian König @ 2021-07-20 14:12 UTC (permalink / raw)
To: Daniel Vetter
Cc: Joonas Lahtinen, kvm, David Airlie, nouveau, dri-devel, Pan,
Xinhui, Maarten Lankhorst, Maxime Ripard, Alex Williamson,
Jani Nikula, Rodrigo Vivi, Alex Deucher, amd-gfx, intel-gfx,
Christoph Hellwig, Ben Skeggs
Am 20.07.21 um 15:50 schrieb Daniel Vetter:
> On Fri, Jul 16, 2021 at 09:14:02AM +0200, Christian König wrote:
>> Am 16.07.21 um 08:16 schrieb Christoph Hellwig:
>>> The define is entirely unused.
>>>
>>> Signed-off-by: Christoph Hellwig <hch@lst.de>
>> I'm not an expert for this particular code, but at least of hand everything
>> you do here makes totally sense.
>>
>> Whole series is Acked-by: Christian König <christian.koenig@amd.com>
> Care to also push this into drm-misc-next since you looked already?
Sure, but Christoph doesn't has push access himself?
Christian.
> -Daniel
>
>> Regards,
>> Christian.
>>
>>> ---
>>> include/linux/vgaarb.h | 6 ------
>>> 1 file changed, 6 deletions(-)
>>>
>>> diff --git a/include/linux/vgaarb.h b/include/linux/vgaarb.h
>>> index dc6ddce92066..26ec8a057d2a 100644
>>> --- a/include/linux/vgaarb.h
>>> +++ b/include/linux/vgaarb.h
>>> @@ -42,12 +42,6 @@
>>> #define VGA_RSRC_NORMAL_IO 0x04
>>> #define VGA_RSRC_NORMAL_MEM 0x08
>>> -/* Passing that instead of a pci_dev to use the system "default"
>>> - * device, that is the one used by vgacon. Archs will probably
>>> - * have to provide their own vga_default_device();
>>> - */
>>> -#define VGA_DEFAULT_DEVICE (NULL)
>>> -
>>> struct pci_dev;
>>> /* For use by clients */
_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [Nouveau] [PATCH 1/7] vgaarb: remove VGA_DEFAULT_DEVICE
2021-07-20 13:50 ` Daniel Vetter
2021-07-20 14:12 ` Christian König
@ 2021-07-21 8:30 ` Christian König
1 sibling, 0 replies; 13+ messages in thread
From: Christian König @ 2021-07-21 8:30 UTC (permalink / raw)
To: Daniel Vetter, Christian König
Cc: Jani Nikula, Pan, Xinhui, kvm, David Airlie, nouveau, intel-gfx,
Joonas Lahtinen, Maarten Lankhorst, dri-devel, Alex Williamson,
Maxime Ripard, Rodrigo Vivi, Alex Deucher, amd-gfx,
Christoph Hellwig, Ben Skeggs
Am 20.07.21 um 15:50 schrieb Daniel Vetter:
> On Fri, Jul 16, 2021 at 09:14:02AM +0200, Christian König wrote:
>> Am 16.07.21 um 08:16 schrieb Christoph Hellwig:
>>> The define is entirely unused.
>>>
>>> Signed-off-by: Christoph Hellwig <hch@lst.de>
>> I'm not an expert for this particular code, but at least of hand everything
>> you do here makes totally sense.
>>
>> Whole series is Acked-by: Christian König <christian.koenig@amd.com>
> Care to also push this into drm-misc-next since you looked already?
Done.
Christian.
> -Daniel
>
>> Regards,
>> Christian.
>>
>>> ---
>>> include/linux/vgaarb.h | 6 ------
>>> 1 file changed, 6 deletions(-)
>>>
>>> diff --git a/include/linux/vgaarb.h b/include/linux/vgaarb.h
>>> index dc6ddce92066..26ec8a057d2a 100644
>>> --- a/include/linux/vgaarb.h
>>> +++ b/include/linux/vgaarb.h
>>> @@ -42,12 +42,6 @@
>>> #define VGA_RSRC_NORMAL_IO 0x04
>>> #define VGA_RSRC_NORMAL_MEM 0x08
>>> -/* Passing that instead of a pci_dev to use the system "default"
>>> - * device, that is the one used by vgacon. Archs will probably
>>> - * have to provide their own vga_default_device();
>>> - */
>>> -#define VGA_DEFAULT_DEVICE (NULL)
>>> -
>>> struct pci_dev;
>>> /* For use by clients */
_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Nouveau] [PATCH 2/7] vgaarb: remove vga_conflicts
2021-07-16 6:16 [Nouveau] misc vgaarb cleanups Christoph Hellwig
2021-07-16 6:16 ` [Nouveau] [PATCH 1/7] vgaarb: remove VGA_DEFAULT_DEVICE Christoph Hellwig
@ 2021-07-16 6:16 ` Christoph Hellwig
2021-07-16 6:16 ` [Nouveau] [PATCH 3/7] vgaarb: move the kerneldoc for vga_set_legacy_decoding to vgaarb.c Christoph Hellwig
` (5 subsequent siblings)
7 siblings, 0 replies; 13+ messages in thread
From: Christoph Hellwig @ 2021-07-16 6:16 UTC (permalink / raw)
To: David Airlie, Daniel Vetter
Cc: Joonas Lahtinen, kvm, amd-gfx, nouveau, dri-devel, Pan, Xinhui,
Maarten Lankhorst, Maxime Ripard, Alex Williamson, Jani Nikula,
Rodrigo Vivi, Alex Deucher, intel-gfx, Christian König,
Ben Skeggs
vga_conflicts only has a single caller and none of the arch overrides
mentioned in the comment. Just remove it and the thus dead check in the
caller.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
drivers/gpu/vga/vgaarb.c | 6 ------
include/linux/vgaarb.h | 12 ------------
2 files changed, 18 deletions(-)
diff --git a/drivers/gpu/vga/vgaarb.c b/drivers/gpu/vga/vgaarb.c
index 949fde433ea2..fccc7ef5153a 100644
--- a/drivers/gpu/vga/vgaarb.c
+++ b/drivers/gpu/vga/vgaarb.c
@@ -284,12 +284,6 @@ static struct vga_device *__vga_tryget(struct vga_device *vgadev,
if (vgadev == conflict)
continue;
- /* Check if the architecture allows a conflict between those
- * 2 devices or if they are on separate domains
- */
- if (!vga_conflicts(vgadev->pdev, conflict->pdev))
- continue;
-
/* We have a possible conflict. before we go further, we must
* check if we sit on the same bus as the conflicting device.
* if we don't, then we must tie both IO and MEM resources
diff --git a/include/linux/vgaarb.h b/include/linux/vgaarb.h
index 26ec8a057d2a..ca5160218538 100644
--- a/include/linux/vgaarb.h
+++ b/include/linux/vgaarb.h
@@ -122,18 +122,6 @@ static inline void vga_set_default_device(struct pci_dev *pdev) { }
static inline int vga_remove_vgacon(struct pci_dev *pdev) { return 0; }
#endif
-/*
- * Architectures should define this if they have several
- * independent PCI domains that can afford concurrent VGA
- * decoding
- */
-#ifndef __ARCH_HAS_VGA_CONFLICT
-static inline int vga_conflicts(struct pci_dev *p1, struct pci_dev *p2)
-{
- return 1;
-}
-#endif
-
#if defined(CONFIG_VGA_ARB)
int vga_client_register(struct pci_dev *pdev, void *cookie,
void (*irq_set_state)(void *cookie, bool state),
--
2.30.2
_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [Nouveau] [PATCH 3/7] vgaarb: move the kerneldoc for vga_set_legacy_decoding to vgaarb.c
2021-07-16 6:16 [Nouveau] misc vgaarb cleanups Christoph Hellwig
2021-07-16 6:16 ` [Nouveau] [PATCH 1/7] vgaarb: remove VGA_DEFAULT_DEVICE Christoph Hellwig
2021-07-16 6:16 ` [Nouveau] [PATCH 2/7] vgaarb: remove vga_conflicts Christoph Hellwig
@ 2021-07-16 6:16 ` Christoph Hellwig
2021-07-16 6:16 ` [Nouveau] [PATCH 4/7] vgaarb: cleanup vgaarb.h Christoph Hellwig
` (4 subsequent siblings)
7 siblings, 0 replies; 13+ messages in thread
From: Christoph Hellwig @ 2021-07-16 6:16 UTC (permalink / raw)
To: David Airlie, Daniel Vetter
Cc: Joonas Lahtinen, kvm, amd-gfx, nouveau, dri-devel, Pan, Xinhui,
Maarten Lankhorst, Maxime Ripard, Alex Williamson, Jani Nikula,
Rodrigo Vivi, Alex Deucher, intel-gfx, Christian König,
Ben Skeggs
Kerneldoc comments should be at the implementation side, not in the
header just declaring the prototype.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
drivers/gpu/vga/vgaarb.c | 11 +++++++++++
include/linux/vgaarb.h | 13 -------------
2 files changed, 11 insertions(+), 13 deletions(-)
diff --git a/drivers/gpu/vga/vgaarb.c b/drivers/gpu/vga/vgaarb.c
index fccc7ef5153a..3ed3734f66d9 100644
--- a/drivers/gpu/vga/vgaarb.c
+++ b/drivers/gpu/vga/vgaarb.c
@@ -834,6 +834,17 @@ static void __vga_set_legacy_decoding(struct pci_dev *pdev,
spin_unlock_irqrestore(&vga_lock, flags);
}
+/**
+ * vga_set_legacy_decoding
+ * @pdev: pci device of the VGA card
+ * @decodes: bit mask of what legacy regions the card decodes
+ *
+ * Indicates to the arbiter if the card decodes legacy VGA IOs, legacy VGA
+ * Memory, both, or none. All cards default to both, the card driver (fbdev for
+ * example) should tell the arbiter if it has disabled legacy decoding, so the
+ * card can be left out of the arbitration process (and can be safe to take
+ * interrupts at any time.
+ */
void vga_set_legacy_decoding(struct pci_dev *pdev, unsigned int decodes)
{
__vga_set_legacy_decoding(pdev, decodes, false);
diff --git a/include/linux/vgaarb.h b/include/linux/vgaarb.h
index ca5160218538..fdce9007d57e 100644
--- a/include/linux/vgaarb.h
+++ b/include/linux/vgaarb.h
@@ -46,19 +46,6 @@ struct pci_dev;
/* For use by clients */
-/**
- * vga_set_legacy_decoding
- *
- * @pdev: pci device of the VGA card
- * @decodes: bit mask of what legacy regions the card decodes
- *
- * Indicates to the arbiter if the card decodes legacy VGA IOs,
- * legacy VGA Memory, both, or none. All cards default to both,
- * the card driver (fbdev for example) should tell the arbiter
- * if it has disabled legacy decoding, so the card can be left
- * out of the arbitration process (and can be safe to take
- * interrupts at any time.
- */
#if defined(CONFIG_VGA_ARB)
extern void vga_set_legacy_decoding(struct pci_dev *pdev,
unsigned int decodes);
--
2.30.2
_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [Nouveau] [PATCH 4/7] vgaarb: cleanup vgaarb.h
2021-07-16 6:16 [Nouveau] misc vgaarb cleanups Christoph Hellwig
` (2 preceding siblings ...)
2021-07-16 6:16 ` [Nouveau] [PATCH 3/7] vgaarb: move the kerneldoc for vga_set_legacy_decoding to vgaarb.c Christoph Hellwig
@ 2021-07-16 6:16 ` Christoph Hellwig
2021-07-16 6:16 ` [Nouveau] [PATCH 5/7] vgaarb: provide a vga_client_unregister wrapper Christoph Hellwig
` (3 subsequent siblings)
7 siblings, 0 replies; 13+ messages in thread
From: Christoph Hellwig @ 2021-07-16 6:16 UTC (permalink / raw)
To: David Airlie, Daniel Vetter
Cc: Joonas Lahtinen, kvm, amd-gfx, nouveau, dri-devel, Pan, Xinhui,
Maarten Lankhorst, Maxime Ripard, Alex Williamson, Jani Nikula,
Rodrigo Vivi, Alex Deucher, intel-gfx, Christian König,
Ben Skeggs
Merge the different CONFIG_VGA_ARB ifdef blocks, remove superflous
externs, and regularize the stubs for !CONFIG_VGA_ARB.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
include/linux/vgaarb.h | 90 ++++++++++++++++++++----------------------
1 file changed, 42 insertions(+), 48 deletions(-)
diff --git a/include/linux/vgaarb.h b/include/linux/vgaarb.h
index fdce9007d57e..05171fc7e26a 100644
--- a/include/linux/vgaarb.h
+++ b/include/linux/vgaarb.h
@@ -33,6 +33,8 @@
#include <video/vga.h>
+struct pci_dev;
+
/* Legacy VGA regions */
#define VGA_RSRC_NONE 0x00
#define VGA_RSRC_LEGACY_IO 0x01
@@ -42,23 +44,47 @@
#define VGA_RSRC_NORMAL_IO 0x04
#define VGA_RSRC_NORMAL_MEM 0x08
-struct pci_dev;
-
-/* For use by clients */
-
-#if defined(CONFIG_VGA_ARB)
-extern void vga_set_legacy_decoding(struct pci_dev *pdev,
- unsigned int decodes);
-#else
+#ifdef CONFIG_VGA_ARB
+void vga_set_legacy_decoding(struct pci_dev *pdev, unsigned int decodes);
+int vga_get(struct pci_dev *pdev, unsigned int rsrc, int interruptible);
+void vga_put(struct pci_dev *pdev, unsigned int rsrc);
+struct pci_dev *vga_default_device(void);
+void vga_set_default_device(struct pci_dev *pdev);
+int vga_remove_vgacon(struct pci_dev *pdev);
+int vga_client_register(struct pci_dev *pdev, void *cookie,
+ void (*irq_set_state)(void *cookie, bool state),
+ unsigned int (*set_vga_decode)(void *cookie, bool state));
+#else /* CONFIG_VGA_ARB */
static inline void vga_set_legacy_decoding(struct pci_dev *pdev,
- unsigned int decodes) { };
-#endif
-
-#if defined(CONFIG_VGA_ARB)
-extern int vga_get(struct pci_dev *pdev, unsigned int rsrc, int interruptible);
-#else
-static inline int vga_get(struct pci_dev *pdev, unsigned int rsrc, int interruptible) { return 0; }
-#endif
+ unsigned int decodes)
+{
+};
+static inline int vga_get(struct pci_dev *pdev, unsigned int rsrc,
+ int interruptible)
+{
+ return 0;
+}
+static inline void vga_put(struct pci_dev *pdev, unsigned int rsrc)
+{
+}
+static inline struct pci_dev *vga_default_device(void)
+{
+ return NULL;
+}
+static inline void vga_set_default_device(struct pci_dev *pdev)
+{
+}
+static inline int vga_remove_vgacon(struct pci_dev *pdev)
+{
+ return 0;
+}
+static inline int vga_client_register(struct pci_dev *pdev, void *cookie,
+ void (*irq_set_state)(void *cookie, bool state),
+ unsigned int (*set_vga_decode)(void *cookie, bool state))
+{
+ return 0;
+}
+#endif /* CONFIG_VGA_ARB */
/**
* vga_get_interruptible
@@ -90,36 +116,4 @@ static inline int vga_get_uninterruptible(struct pci_dev *pdev,
return vga_get(pdev, rsrc, 0);
}
-#if defined(CONFIG_VGA_ARB)
-extern void vga_put(struct pci_dev *pdev, unsigned int rsrc);
-#else
-static inline void vga_put(struct pci_dev *pdev, unsigned int rsrc)
-{
-}
-#endif
-
-
-#ifdef CONFIG_VGA_ARB
-extern struct pci_dev *vga_default_device(void);
-extern void vga_set_default_device(struct pci_dev *pdev);
-extern int vga_remove_vgacon(struct pci_dev *pdev);
-#else
-static inline struct pci_dev *vga_default_device(void) { return NULL; }
-static inline void vga_set_default_device(struct pci_dev *pdev) { }
-static inline int vga_remove_vgacon(struct pci_dev *pdev) { return 0; }
-#endif
-
-#if defined(CONFIG_VGA_ARB)
-int vga_client_register(struct pci_dev *pdev, void *cookie,
- void (*irq_set_state)(void *cookie, bool state),
- unsigned int (*set_vga_decode)(void *cookie, bool state));
-#else
-static inline int vga_client_register(struct pci_dev *pdev, void *cookie,
- void (*irq_set_state)(void *cookie, bool state),
- unsigned int (*set_vga_decode)(void *cookie, bool state))
-{
- return 0;
-}
-#endif
-
#endif /* LINUX_VGA_H */
--
2.30.2
_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [Nouveau] [PATCH 5/7] vgaarb: provide a vga_client_unregister wrapper
2021-07-16 6:16 [Nouveau] misc vgaarb cleanups Christoph Hellwig
` (3 preceding siblings ...)
2021-07-16 6:16 ` [Nouveau] [PATCH 4/7] vgaarb: cleanup vgaarb.h Christoph Hellwig
@ 2021-07-16 6:16 ` Christoph Hellwig
2021-07-16 6:16 ` [Nouveau] [PATCH 6/7] vgaarb: remove the unused irq_set_state argument to vga_client_register Christoph Hellwig
` (2 subsequent siblings)
7 siblings, 0 replies; 13+ messages in thread
From: Christoph Hellwig @ 2021-07-16 6:16 UTC (permalink / raw)
To: David Airlie, Daniel Vetter
Cc: Joonas Lahtinen, kvm, amd-gfx, nouveau, dri-devel, Pan, Xinhui,
Maarten Lankhorst, Maxime Ripard, Alex Williamson, Jani Nikula,
Rodrigo Vivi, Alex Deucher, intel-gfx, Christian König,
Ben Skeggs
Add a trivial wrapper for the unregister case that sets all fields to
NULL.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 +-
drivers/gpu/drm/drm_irq.c | 4 ++--
drivers/gpu/drm/i915/display/intel_vga.c | 2 +-
drivers/gpu/drm/nouveau/nouveau_vga.c | 2 +-
drivers/gpu/drm/radeon/radeon_device.c | 2 +-
drivers/gpu/vga/vgaarb.c | 3 +--
drivers/vfio/pci/vfio_pci.c | 2 +-
include/linux/vgaarb.h | 5 +++++
8 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index d303e88e3c23..53afe0198e52 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -3838,7 +3838,7 @@ void amdgpu_device_fini_sw(struct amdgpu_device *adev)
vga_switcheroo_fini_domain_pm_ops(adev->dev);
}
if ((adev->pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA)
- vga_client_register(adev->pdev, NULL, NULL, NULL);
+ vga_client_unregister(adev->pdev);
if (IS_ENABLED(CONFIG_PERF_EVENTS))
amdgpu_pmu_fini(adev);
diff --git a/drivers/gpu/drm/drm_irq.c b/drivers/gpu/drm/drm_irq.c
index c3bd664ea733..c87b0fb384e4 100644
--- a/drivers/gpu/drm/drm_irq.c
+++ b/drivers/gpu/drm/drm_irq.c
@@ -140,7 +140,7 @@ int drm_irq_install(struct drm_device *dev, int irq)
if (ret < 0) {
dev->irq_enabled = false;
if (drm_core_check_feature(dev, DRIVER_LEGACY))
- vga_client_register(to_pci_dev(dev->dev), NULL, NULL, NULL);
+ vga_client_unregister(to_pci_dev(dev->dev));
free_irq(irq, dev);
} else {
dev->irq = irq;
@@ -203,7 +203,7 @@ int drm_irq_uninstall(struct drm_device *dev)
DRM_DEBUG("irq=%d\n", dev->irq);
if (drm_core_check_feature(dev, DRIVER_LEGACY))
- vga_client_register(to_pci_dev(dev->dev), NULL, NULL, NULL);
+ vga_client_unregister(to_pci_dev(dev->dev));
if (dev->driver->irq_uninstall)
dev->driver->irq_uninstall(dev);
diff --git a/drivers/gpu/drm/i915/display/intel_vga.c b/drivers/gpu/drm/i915/display/intel_vga.c
index f002b82ba9c0..833f9ec14493 100644
--- a/drivers/gpu/drm/i915/display/intel_vga.c
+++ b/drivers/gpu/drm/i915/display/intel_vga.c
@@ -158,5 +158,5 @@ void intel_vga_unregister(struct drm_i915_private *i915)
{
struct pci_dev *pdev = to_pci_dev(i915->drm.dev);
- vga_client_register(pdev, NULL, NULL, NULL);
+ vga_client_unregister(pdev);
}
diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c b/drivers/gpu/drm/nouveau/nouveau_vga.c
index 7c4b374b3eca..de7a3a860139 100644
--- a/drivers/gpu/drm/nouveau/nouveau_vga.c
+++ b/drivers/gpu/drm/nouveau/nouveau_vga.c
@@ -118,7 +118,7 @@ nouveau_vga_fini(struct nouveau_drm *drm)
return;
pdev = to_pci_dev(dev->dev);
- vga_client_register(pdev, NULL, NULL, NULL);
+ vga_client_unregister(pdev);
if (pci_is_thunderbolt_attached(pdev))
return;
diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
index 46eea01950cb..d781914f8bcb 100644
--- a/drivers/gpu/drm/radeon/radeon_device.c
+++ b/drivers/gpu/drm/radeon/radeon_device.c
@@ -1530,7 +1530,7 @@ void radeon_device_fini(struct radeon_device *rdev)
vga_switcheroo_unregister_client(rdev->pdev);
if (rdev->flags & RADEON_IS_PX)
vga_switcheroo_fini_domain_pm_ops(rdev->dev);
- vga_client_register(rdev->pdev, NULL, NULL, NULL);
+ vga_client_unregister(rdev->pdev);
if (rdev->rio_mem)
pci_iounmap(rdev->pdev, rdev->rio_mem);
rdev->rio_mem = NULL;
diff --git a/drivers/gpu/vga/vgaarb.c b/drivers/gpu/vga/vgaarb.c
index 3ed3734f66d9..85b765b80abf 100644
--- a/drivers/gpu/vga/vgaarb.c
+++ b/drivers/gpu/vga/vgaarb.c
@@ -877,8 +877,7 @@ EXPORT_SYMBOL(vga_set_legacy_decoding);
* This function does not check whether a client for @pdev has been registered
* already.
*
- * To unregister just call this function with @irq_set_state and @set_vga_decode
- * both set to NULL for the same @pdev as originally used to register them.
+ * To unregister just call vga_client_unregister().
*
* Returns: 0 on success, -1 on failure
*/
diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c
index 318864d52837..47d13a1fb7fb 100644
--- a/drivers/vfio/pci/vfio_pci.c
+++ b/drivers/vfio/pci/vfio_pci.c
@@ -1967,7 +1967,7 @@ static void vfio_pci_vga_uninit(struct vfio_pci_device *vdev)
if (!vfio_pci_is_vga(pdev))
return;
- vga_client_register(pdev, NULL, NULL, NULL);
+ vga_client_unregister(pdev);
vga_set_legacy_decoding(pdev, VGA_RSRC_NORMAL_IO | VGA_RSRC_NORMAL_MEM |
VGA_RSRC_LEGACY_IO |
VGA_RSRC_LEGACY_MEM);
diff --git a/include/linux/vgaarb.h b/include/linux/vgaarb.h
index 05171fc7e26a..7bca61a08700 100644
--- a/include/linux/vgaarb.h
+++ b/include/linux/vgaarb.h
@@ -116,4 +116,9 @@ static inline int vga_get_uninterruptible(struct pci_dev *pdev,
return vga_get(pdev, rsrc, 0);
}
+static inline void vga_client_unregister(struct pci_dev *pdev)
+{
+ vga_client_register(pdev, NULL, NULL, NULL);
+}
+
#endif /* LINUX_VGA_H */
--
2.30.2
_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [Nouveau] [PATCH 6/7] vgaarb: remove the unused irq_set_state argument to vga_client_register
2021-07-16 6:16 [Nouveau] misc vgaarb cleanups Christoph Hellwig
` (4 preceding siblings ...)
2021-07-16 6:16 ` [Nouveau] [PATCH 5/7] vgaarb: provide a vga_client_unregister wrapper Christoph Hellwig
@ 2021-07-16 6:16 ` Christoph Hellwig
2021-07-16 6:16 ` [Nouveau] [PATCH 7/7] vgaarb: don't pass a cookie " Christoph Hellwig
2021-07-16 11:40 ` [Nouveau] misc vgaarb cleanups Rodrigo Vivi
7 siblings, 0 replies; 13+ messages in thread
From: Christoph Hellwig @ 2021-07-16 6:16 UTC (permalink / raw)
To: David Airlie, Daniel Vetter
Cc: Joonas Lahtinen, kvm, amd-gfx, nouveau, dri-devel, Pan, Xinhui,
Maarten Lankhorst, Maxime Ripard, Alex Williamson, Jani Nikula,
Rodrigo Vivi, Alex Deucher, intel-gfx, Christian König,
Ben Skeggs
All callers pass NULL as the irq_set_state argument, so remove it and
the ->irq_set_state member in struct vga_device.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 +-
drivers/gpu/drm/i915/display/intel_vga.c | 2 +-
drivers/gpu/drm/nouveau/nouveau_vga.c | 2 +-
drivers/gpu/drm/radeon/radeon_device.c | 2 +-
drivers/gpu/vga/vgaarb.c | 23 +---------------------
drivers/vfio/pci/vfio_pci.c | 2 +-
include/linux/vgaarb.h | 4 +---
7 files changed, 7 insertions(+), 30 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index 53afe0198e52..e433fab6bcf6 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -3715,7 +3715,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,
/* this will fail for cards that aren't VGA class devices, just
* ignore it */
if ((adev->pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA)
- vga_client_register(adev->pdev, adev, NULL, amdgpu_device_vga_set_decode);
+ vga_client_register(adev->pdev, adev, amdgpu_device_vga_set_decode);
if (amdgpu_device_supports_px(ddev)) {
px = true;
diff --git a/drivers/gpu/drm/i915/display/intel_vga.c b/drivers/gpu/drm/i915/display/intel_vga.c
index 833f9ec14493..0222719e0824 100644
--- a/drivers/gpu/drm/i915/display/intel_vga.c
+++ b/drivers/gpu/drm/i915/display/intel_vga.c
@@ -147,7 +147,7 @@ int intel_vga_register(struct drm_i915_private *i915)
* then we do not take part in VGA arbitration and the
* vga_client_register() fails with -ENODEV.
*/
- ret = vga_client_register(pdev, i915, NULL, intel_vga_set_decode);
+ ret = vga_client_register(pdev, i915, intel_vga_set_decode);
if (ret && ret != -ENODEV)
return ret;
diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c b/drivers/gpu/drm/nouveau/nouveau_vga.c
index de7a3a860139..d071c11249a3 100644
--- a/drivers/gpu/drm/nouveau/nouveau_vga.c
+++ b/drivers/gpu/drm/nouveau/nouveau_vga.c
@@ -94,7 +94,7 @@ nouveau_vga_init(struct nouveau_drm *drm)
return;
pdev = to_pci_dev(dev->dev);
- vga_client_register(pdev, dev, NULL, nouveau_vga_set_decode);
+ vga_client_register(pdev, dev, nouveau_vga_set_decode);
/* don't register Thunderbolt eGPU with vga_switcheroo */
if (pci_is_thunderbolt_attached(pdev))
diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
index d781914f8bcb..11e8e42d99b3 100644
--- a/drivers/gpu/drm/radeon/radeon_device.c
+++ b/drivers/gpu/drm/radeon/radeon_device.c
@@ -1434,7 +1434,7 @@ int radeon_device_init(struct radeon_device *rdev,
/* if we have > 1 VGA cards, then disable the radeon VGA resources */
/* this will fail for cards that aren't VGA class devices, just
* ignore it */
- vga_client_register(rdev->pdev, rdev, NULL, radeon_vga_set_decode);
+ vga_client_register(rdev->pdev, rdev, radeon_vga_set_decode);
if (rdev->flags & RADEON_IS_PX)
runtime = true;
diff --git a/drivers/gpu/vga/vgaarb.c b/drivers/gpu/vga/vgaarb.c
index 85b765b80abf..4bde017f6f22 100644
--- a/drivers/gpu/vga/vgaarb.c
+++ b/drivers/gpu/vga/vgaarb.c
@@ -72,9 +72,7 @@ struct vga_device {
unsigned int io_norm_cnt; /* normal IO count */
unsigned int mem_norm_cnt; /* normal MEM count */
bool bridge_has_one_vga;
- /* allow IRQ enable/disable hook */
void *cookie;
- void (*irq_set_state)(void *cookie, bool enable);
unsigned int (*set_vga_decode)(void *cookie, bool decode);
};
@@ -218,13 +216,6 @@ int vga_remove_vgacon(struct pci_dev *pdev)
#endif
EXPORT_SYMBOL(vga_remove_vgacon);
-static inline void vga_irq_set_state(struct vga_device *vgadev, bool state)
-{
- if (vgadev->irq_set_state)
- vgadev->irq_set_state(vgadev->cookie, state);
-}
-
-
/* If we don't ever use VGA arb we should avoid
turning off anything anywhere due to old X servers getting
confused about the boot device not being VGA */
@@ -325,10 +316,8 @@ static struct vga_device *__vga_tryget(struct vga_device *vgadev,
if ((match & conflict->decodes) & VGA_RSRC_LEGACY_IO)
pci_bits |= PCI_COMMAND_IO;
- if (pci_bits) {
- vga_irq_set_state(conflict, false);
+ if (pci_bits)
flags |= PCI_VGA_STATE_CHANGE_DECODES;
- }
}
if (change_bridge)
@@ -365,9 +354,6 @@ static struct vga_device *__vga_tryget(struct vga_device *vgadev,
pci_set_vga_state(vgadev->pdev, true, pci_bits, flags);
- if (!vgadev->bridge_has_one_vga)
- vga_irq_set_state(vgadev, true);
-
vgadev->owns |= wants;
lock_them:
vgadev->locks |= (rsrc & VGA_RSRC_LEGACY_MASK);
@@ -855,15 +841,10 @@ EXPORT_SYMBOL(vga_set_legacy_decoding);
* vga_client_register - register or unregister a VGA arbitration client
* @pdev: pci device of the VGA client
* @cookie: client cookie to be used in callbacks
- * @irq_set_state: irq state change callback
* @set_vga_decode: vga decode change callback
*
* Clients have two callback mechanisms they can use.
*
- * @irq_set_state callback: If a client can't disable its GPUs VGA
- * resources, then we need to be able to ask it to turn off its irqs when we
- * turn off its mem and io decoding.
- *
* @set_vga_decode callback: If a client can disable its GPU VGA resource, it
* will get a callback from this to set the encode/decode state.
*
@@ -882,7 +863,6 @@ EXPORT_SYMBOL(vga_set_legacy_decoding);
* Returns: 0 on success, -1 on failure
*/
int vga_client_register(struct pci_dev *pdev, void *cookie,
- void (*irq_set_state)(void *cookie, bool state),
unsigned int (*set_vga_decode)(void *cookie,
bool decode))
{
@@ -895,7 +875,6 @@ int vga_client_register(struct pci_dev *pdev, void *cookie,
if (!vgadev)
goto bail;
- vgadev->irq_set_state = irq_set_state;
vgadev->set_vga_decode = set_vga_decode;
vgadev->cookie = cookie;
ret = 0;
diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c
index 47d13a1fb7fb..cc7d7592e7b1 100644
--- a/drivers/vfio/pci/vfio_pci.c
+++ b/drivers/vfio/pci/vfio_pci.c
@@ -1954,7 +1954,7 @@ static int vfio_pci_vga_init(struct vfio_pci_device *vdev)
if (!vfio_pci_is_vga(pdev))
return 0;
- ret = vga_client_register(pdev, vdev, NULL, vfio_pci_set_vga_decode);
+ ret = vga_client_register(pdev, vdev, vfio_pci_set_vga_decode);
if (ret)
return ret;
vga_set_legacy_decoding(pdev, vfio_pci_set_vga_decode(vdev, false));
diff --git a/include/linux/vgaarb.h b/include/linux/vgaarb.h
index 7bca61a08700..ea45d3e86fff 100644
--- a/include/linux/vgaarb.h
+++ b/include/linux/vgaarb.h
@@ -52,7 +52,6 @@ struct pci_dev *vga_default_device(void);
void vga_set_default_device(struct pci_dev *pdev);
int vga_remove_vgacon(struct pci_dev *pdev);
int vga_client_register(struct pci_dev *pdev, void *cookie,
- void (*irq_set_state)(void *cookie, bool state),
unsigned int (*set_vga_decode)(void *cookie, bool state));
#else /* CONFIG_VGA_ARB */
static inline void vga_set_legacy_decoding(struct pci_dev *pdev,
@@ -79,7 +78,6 @@ static inline int vga_remove_vgacon(struct pci_dev *pdev)
return 0;
}
static inline int vga_client_register(struct pci_dev *pdev, void *cookie,
- void (*irq_set_state)(void *cookie, bool state),
unsigned int (*set_vga_decode)(void *cookie, bool state))
{
return 0;
@@ -118,7 +116,7 @@ static inline int vga_get_uninterruptible(struct pci_dev *pdev,
static inline void vga_client_unregister(struct pci_dev *pdev)
{
- vga_client_register(pdev, NULL, NULL, NULL);
+ vga_client_register(pdev, NULL, NULL);
}
#endif /* LINUX_VGA_H */
--
2.30.2
_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [Nouveau] [PATCH 7/7] vgaarb: don't pass a cookie to vga_client_register
2021-07-16 6:16 [Nouveau] misc vgaarb cleanups Christoph Hellwig
` (5 preceding siblings ...)
2021-07-16 6:16 ` [Nouveau] [PATCH 6/7] vgaarb: remove the unused irq_set_state argument to vga_client_register Christoph Hellwig
@ 2021-07-16 6:16 ` Christoph Hellwig
2021-07-16 11:40 ` [Nouveau] misc vgaarb cleanups Rodrigo Vivi
7 siblings, 0 replies; 13+ messages in thread
From: Christoph Hellwig @ 2021-07-16 6:16 UTC (permalink / raw)
To: David Airlie, Daniel Vetter
Cc: Joonas Lahtinen, kvm, amd-gfx, nouveau, dri-devel, Pan, Xinhui,
Maarten Lankhorst, Maxime Ripard, Alex Williamson, Jani Nikula,
Rodrigo Vivi, Alex Deucher, intel-gfx, Christian König,
Ben Skeggs
The VGA arbitration is entirely based on pci_dev structures, so just pass
that back to the set_vga_decode callback.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 9 ++++----
drivers/gpu/drm/i915/display/intel_vga.c | 7 ++++---
drivers/gpu/drm/nouveau/nouveau_vga.c | 6 +++---
drivers/gpu/drm/radeon/radeon_device.c | 9 ++++----
drivers/gpu/vga/vgaarb.c | 24 +++++++++-------------
drivers/vfio/pci/vfio_pci.c | 9 ++++----
include/linux/vgaarb.h | 10 ++++-----
7 files changed, 36 insertions(+), 38 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
index e433fab6bcf6..8398daa0c06a 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
@@ -1266,15 +1266,16 @@ bool amdgpu_device_need_post(struct amdgpu_device *adev)
/**
* amdgpu_device_vga_set_decode - enable/disable vga decode
*
- * @cookie: amdgpu_device pointer
+ * @pdev: PCI device pointer
* @state: enable/disable vga decode
*
* Enable/disable vga decode (all asics).
* Returns VGA resource flags.
*/
-static unsigned int amdgpu_device_vga_set_decode(void *cookie, bool state)
+static unsigned int amdgpu_device_vga_set_decode(struct pci_dev *pdev,
+ bool state)
{
- struct amdgpu_device *adev = cookie;
+ struct amdgpu_device *adev = drm_to_adev(pci_get_drvdata(pdev));
amdgpu_asic_set_vga_state(adev, state);
if (state)
return VGA_RSRC_LEGACY_IO | VGA_RSRC_LEGACY_MEM |
@@ -3715,7 +3716,7 @@ int amdgpu_device_init(struct amdgpu_device *adev,
/* this will fail for cards that aren't VGA class devices, just
* ignore it */
if ((adev->pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA)
- vga_client_register(adev->pdev, adev, amdgpu_device_vga_set_decode);
+ vga_client_register(adev->pdev, amdgpu_device_vga_set_decode);
if (amdgpu_device_supports_px(ddev)) {
px = true;
diff --git a/drivers/gpu/drm/i915/display/intel_vga.c b/drivers/gpu/drm/i915/display/intel_vga.c
index 0222719e0824..16c250700985 100644
--- a/drivers/gpu/drm/i915/display/intel_vga.c
+++ b/drivers/gpu/drm/i915/display/intel_vga.c
@@ -121,9 +121,9 @@ intel_vga_set_state(struct drm_i915_private *i915, bool enable_decode)
}
static unsigned int
-intel_vga_set_decode(void *cookie, bool enable_decode)
+intel_vga_set_decode(struct pci_dev *pdev, bool enable_decode)
{
- struct drm_i915_private *i915 = cookie;
+ struct drm_i915_private *i915 = pdev_to_i915(pdev);
intel_vga_set_state(i915, enable_decode);
@@ -136,6 +136,7 @@ intel_vga_set_decode(void *cookie, bool enable_decode)
int intel_vga_register(struct drm_i915_private *i915)
{
+
struct pci_dev *pdev = to_pci_dev(i915->drm.dev);
int ret;
@@ -147,7 +148,7 @@ int intel_vga_register(struct drm_i915_private *i915)
* then we do not take part in VGA arbitration and the
* vga_client_register() fails with -ENODEV.
*/
- ret = vga_client_register(pdev, i915, intel_vga_set_decode);
+ ret = vga_client_register(pdev, intel_vga_set_decode);
if (ret && ret != -ENODEV)
return ret;
diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c b/drivers/gpu/drm/nouveau/nouveau_vga.c
index d071c11249a3..60cd8c0463df 100644
--- a/drivers/gpu/drm/nouveau/nouveau_vga.c
+++ b/drivers/gpu/drm/nouveau/nouveau_vga.c
@@ -11,9 +11,9 @@
#include "nouveau_vga.h"
static unsigned int
-nouveau_vga_set_decode(void *priv, bool state)
+nouveau_vga_set_decode(struct pci_dev *pdev, bool state)
{
- struct nouveau_drm *drm = nouveau_drm(priv);
+ struct nouveau_drm *drm = nouveau_drm(pci_get_drvdata(pdev));
struct nvif_object *device = &drm->client.device.object;
if (drm->client.device.info.family == NV_DEVICE_INFO_V0_CURIE &&
@@ -94,7 +94,7 @@ nouveau_vga_init(struct nouveau_drm *drm)
return;
pdev = to_pci_dev(dev->dev);
- vga_client_register(pdev, dev, nouveau_vga_set_decode);
+ vga_client_register(pdev, nouveau_vga_set_decode);
/* don't register Thunderbolt eGPU with vga_switcheroo */
if (pci_is_thunderbolt_attached(pdev))
diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
index 11e8e42d99b3..cec03238e14d 100644
--- a/drivers/gpu/drm/radeon/radeon_device.c
+++ b/drivers/gpu/drm/radeon/radeon_device.c
@@ -1067,15 +1067,16 @@ void radeon_combios_fini(struct radeon_device *rdev)
/**
* radeon_vga_set_decode - enable/disable vga decode
*
- * @cookie: radeon_device pointer
+ * @pdev: PCI device
* @state: enable/disable vga decode
*
* Enable/disable vga decode (all asics).
* Returns VGA resource flags.
*/
-static unsigned int radeon_vga_set_decode(void *cookie, bool state)
+static unsigned int radeon_vga_set_decode(struct pci_dev *pdev, bool state)
{
- struct radeon_device *rdev = cookie;
+ struct drm_device *dev = pci_get_drvdata(pdev);
+ struct radeon_device *rdev = dev->dev_private;
radeon_vga_set_state(rdev, state);
if (state)
return VGA_RSRC_LEGACY_IO | VGA_RSRC_LEGACY_MEM |
@@ -1434,7 +1435,7 @@ int radeon_device_init(struct radeon_device *rdev,
/* if we have > 1 VGA cards, then disable the radeon VGA resources */
/* this will fail for cards that aren't VGA class devices, just
* ignore it */
- vga_client_register(rdev->pdev, rdev, radeon_vga_set_decode);
+ vga_client_register(rdev->pdev, radeon_vga_set_decode);
if (rdev->flags & RADEON_IS_PX)
runtime = true;
diff --git a/drivers/gpu/vga/vgaarb.c b/drivers/gpu/vga/vgaarb.c
index 4bde017f6f22..569930552957 100644
--- a/drivers/gpu/vga/vgaarb.c
+++ b/drivers/gpu/vga/vgaarb.c
@@ -72,8 +72,7 @@ struct vga_device {
unsigned int io_norm_cnt; /* normal IO count */
unsigned int mem_norm_cnt; /* normal MEM count */
bool bridge_has_one_vga;
- void *cookie;
- unsigned int (*set_vga_decode)(void *cookie, bool decode);
+ unsigned int (*set_decode)(struct pci_dev *pdev, bool decode);
};
static LIST_HEAD(vga_list);
@@ -806,7 +805,7 @@ static void __vga_set_legacy_decoding(struct pci_dev *pdev,
goto bail;
/* don't let userspace futz with kernel driver decodes */
- if (userspace && vgadev->set_vga_decode)
+ if (userspace && vgadev->set_decode)
goto bail;
/* update the device decodes + counter */
@@ -840,12 +839,11 @@ EXPORT_SYMBOL(vga_set_legacy_decoding);
/**
* vga_client_register - register or unregister a VGA arbitration client
* @pdev: pci device of the VGA client
- * @cookie: client cookie to be used in callbacks
- * @set_vga_decode: vga decode change callback
+ * @set_decode: vga decode change callback
*
* Clients have two callback mechanisms they can use.
*
- * @set_vga_decode callback: If a client can disable its GPU VGA resource, it
+ * @set_decode callback: If a client can disable its GPU VGA resource, it
* will get a callback from this to set the encode/decode state.
*
* Rationale: we cannot disable VGA decode resources unconditionally some single
@@ -862,9 +860,8 @@ EXPORT_SYMBOL(vga_set_legacy_decoding);
*
* Returns: 0 on success, -1 on failure
*/
-int vga_client_register(struct pci_dev *pdev, void *cookie,
- unsigned int (*set_vga_decode)(void *cookie,
- bool decode))
+int vga_client_register(struct pci_dev *pdev,
+ unsigned int (*set_decode)(struct pci_dev *pdev, bool decode))
{
int ret = -ENODEV;
struct vga_device *vgadev;
@@ -875,8 +872,7 @@ int vga_client_register(struct pci_dev *pdev, void *cookie,
if (!vgadev)
goto bail;
- vgadev->set_vga_decode = set_vga_decode;
- vgadev->cookie = cookie;
+ vgadev->set_decode = set_decode;
ret = 0;
bail:
@@ -1386,9 +1382,9 @@ static void vga_arbiter_notify_clients(void)
new_state = false;
else
new_state = true;
- if (vgadev->set_vga_decode) {
- new_decodes = vgadev->set_vga_decode(vgadev->cookie,
- new_state);
+ if (vgadev->set_decode) {
+ new_decodes = vgadev->set_decode(vgadev->pdev,
+ new_state);
vga_update_device_decodes(vgadev, new_decodes);
}
}
diff --git a/drivers/vfio/pci/vfio_pci.c b/drivers/vfio/pci/vfio_pci.c
index cc7d7592e7b1..cf27df8048db 100644
--- a/drivers/vfio/pci/vfio_pci.c
+++ b/drivers/vfio/pci/vfio_pci.c
@@ -119,10 +119,9 @@ static bool vfio_pci_is_denylisted(struct pci_dev *pdev)
* has no way to get to it and routing can be disabled externally at the
* bridge.
*/
-static unsigned int vfio_pci_set_vga_decode(void *opaque, bool single_vga)
+static unsigned int vfio_pci_set_decode(struct pci_dev *pdev, bool single_vga)
{
- struct vfio_pci_device *vdev = opaque;
- struct pci_dev *tmp = NULL, *pdev = vdev->pdev;
+ struct pci_dev *tmp = NULL;
unsigned char max_busnr;
unsigned int decodes;
@@ -1954,10 +1953,10 @@ static int vfio_pci_vga_init(struct vfio_pci_device *vdev)
if (!vfio_pci_is_vga(pdev))
return 0;
- ret = vga_client_register(pdev, vdev, vfio_pci_set_vga_decode);
+ ret = vga_client_register(pdev, vfio_pci_set_decode);
if (ret)
return ret;
- vga_set_legacy_decoding(pdev, vfio_pci_set_vga_decode(vdev, false));
+ vga_set_legacy_decoding(pdev, vfio_pci_set_decode(pdev, false));
return 0;
}
diff --git a/include/linux/vgaarb.h b/include/linux/vgaarb.h
index ea45d3e86fff..b4b9137f9792 100644
--- a/include/linux/vgaarb.h
+++ b/include/linux/vgaarb.h
@@ -51,8 +51,8 @@ void vga_put(struct pci_dev *pdev, unsigned int rsrc);
struct pci_dev *vga_default_device(void);
void vga_set_default_device(struct pci_dev *pdev);
int vga_remove_vgacon(struct pci_dev *pdev);
-int vga_client_register(struct pci_dev *pdev, void *cookie,
- unsigned int (*set_vga_decode)(void *cookie, bool state));
+int vga_client_register(struct pci_dev *pdev,
+ unsigned int (*set_decode)(struct pci_dev *pdev, bool state));
#else /* CONFIG_VGA_ARB */
static inline void vga_set_legacy_decoding(struct pci_dev *pdev,
unsigned int decodes)
@@ -77,8 +77,8 @@ static inline int vga_remove_vgacon(struct pci_dev *pdev)
{
return 0;
}
-static inline int vga_client_register(struct pci_dev *pdev, void *cookie,
- unsigned int (*set_vga_decode)(void *cookie, bool state))
+static inline int vga_client_register(struct pci_dev *pdev,
+ unsigned int (*set_decode)(struct pci_dev *pdev, bool state))
{
return 0;
}
@@ -116,7 +116,7 @@ static inline int vga_get_uninterruptible(struct pci_dev *pdev,
static inline void vga_client_unregister(struct pci_dev *pdev)
{
- vga_client_register(pdev, NULL, NULL);
+ vga_client_register(pdev, NULL);
}
#endif /* LINUX_VGA_H */
--
2.30.2
_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [Nouveau] misc vgaarb cleanups
2021-07-16 6:16 [Nouveau] misc vgaarb cleanups Christoph Hellwig
` (6 preceding siblings ...)
2021-07-16 6:16 ` [Nouveau] [PATCH 7/7] vgaarb: don't pass a cookie " Christoph Hellwig
@ 2021-07-16 11:40 ` Rodrigo Vivi
7 siblings, 0 replies; 13+ messages in thread
From: Rodrigo Vivi @ 2021-07-16 11:40 UTC (permalink / raw)
To: Christoph Hellwig
Cc: Joonas Lahtinen, kvm, David Airlie, nouveau, dri-devel, Pan,
Xinhui, Maarten Lankhorst, Maxime Ripard, Alex Williamson,
Jani Nikula, Daniel Vetter, Alex Deucher, amd-gfx, intel-gfx,
Christian König, Ben Skeggs
On Fri, Jul 16, 2021 at 08:16:27AM +0200, Christoph Hellwig wrote:
> Hi all,
>
> this series cleans up a bunch of lose ends in the vgaarb code.
>
> Diffstat:
> drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 11 +-
> drivers/gpu/drm/drm_irq.c | 4
> drivers/gpu/drm/i915/display/intel_vga.c | 9 +-
The parts touching i915 looks clean to me
Acked-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
> drivers/gpu/drm/nouveau/nouveau_vga.c | 8 -
> drivers/gpu/drm/radeon/radeon_device.c | 11 +-
> drivers/gpu/vga/vgaarb.c | 67 +++++-----------
> drivers/vfio/pci/vfio_pci.c | 11 +-
> include/linux/vgaarb.h | 118 ++++++++++-------------------
> 8 files changed, 93 insertions(+), 146 deletions(-)
_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau
^ permalink raw reply [flat|nested] 13+ messages in thread