Nouveau Archive on lore.kernel.org
 help / color / Atom feed
* [Nouveau] [PATCH] drm/nouveau/pci: rework AGP dependency
@ 2021-02-25 12:52 Arnd Bergmann
  2021-02-25 12:59 ` Christian König
  0 siblings, 1 reply; 3+ messages in thread
From: Arnd Bergmann @ 2021-02-25 12:52 UTC (permalink / raw)
  To: Ben Skeggs, David Airlie, Daniel Vetter
  Cc: Arnd Bergmann, nouveau, linux-kernel, dri-devel, Christian König

From: Arnd Bergmann <arnd@arndb.de>

I noticed a warning from 'nm' when CONFIG_TRIM_UNUSED_KSYMS is set
and IS_REACHABLE(CONFIG_AGP) is false:

drivers/gpu/drm/nouveau/nvkm/subdev/pci/agp.o: no symbols

I later found this is completely harmless and we should find a way
to suppress the warning, but at that point I had already done a
cleanup patch to address this instance.

It turns out this code could be improved anyway, as the current version
behaves unexpectedly when AGP is a loadable module but nouveau is built-in
itself, in which case it silently omits agp support.

A better way to handle this is with a Kconfig dependency that requires
AGP either to be disabled, or forces nouveau to be a module for AGP=m.
With this change, the compile-time hack can be removed and lld no
longer warns.

Fixes: 340b0e7c500a ("drm/nouveau/pci: merge agp handling from nouveau drm")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/gpu/drm/nouveau/Kbuild                 | 1 +
 drivers/gpu/drm/nouveau/Kconfig                | 1 +
 drivers/gpu/drm/nouveau/nvkm/subdev/pci/Kbuild | 2 +-
 drivers/gpu/drm/nouveau/nvkm/subdev/pci/agp.c  | 2 --
 drivers/gpu/drm/nouveau/nvkm/subdev/pci/agp.h  | 9 +++++----
 5 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/Kbuild b/drivers/gpu/drm/nouveau/Kbuild
index 60586fb8275e..173b8d9d85e3 100644
--- a/drivers/gpu/drm/nouveau/Kbuild
+++ b/drivers/gpu/drm/nouveau/Kbuild
@@ -15,6 +15,7 @@ nouveau-y := $(nvif-y)
 #- code also used by various userspace tools/tests
 include $(src)/nvkm/Kbuild
 nouveau-y += $(nvkm-y)
+nouveau-m += $(nvkm-m)
 
 # DRM - general
 ifdef CONFIG_X86
diff --git a/drivers/gpu/drm/nouveau/Kconfig b/drivers/gpu/drm/nouveau/Kconfig
index 278e048235a9..90276a557a70 100644
--- a/drivers/gpu/drm/nouveau/Kconfig
+++ b/drivers/gpu/drm/nouveau/Kconfig
@@ -2,6 +2,7 @@
 config DRM_NOUVEAU
 	tristate "Nouveau (NVIDIA) cards"
 	depends on DRM && PCI && MMU
+	depends on AGP || !AGP
 	select IOMMU_API
 	select FW_LOADER
 	select DRM_KMS_HELPER
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/pci/Kbuild b/drivers/gpu/drm/nouveau/nvkm/subdev/pci/Kbuild
index 174bdf995271..a400c680cf65 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/pci/Kbuild
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/pci/Kbuild
@@ -1,5 +1,5 @@
 # SPDX-License-Identifier: MIT
-nvkm-y += nvkm/subdev/pci/agp.o
+nvkm-$(CONFIG_AGP) += nvkm/subdev/pci/agp.o
 nvkm-y += nvkm/subdev/pci/base.o
 nvkm-y += nvkm/subdev/pci/pcie.o
 nvkm-y += nvkm/subdev/pci/nv04.o
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/pci/agp.c b/drivers/gpu/drm/nouveau/nvkm/subdev/pci/agp.c
index 385a90f91ed6..86c9e1d658af 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/pci/agp.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/pci/agp.c
@@ -20,7 +20,6 @@
  * OTHER DEALINGS IN THE SOFTWARE.
  */
 #include "agp.h"
-#ifdef __NVKM_PCI_AGP_H__
 #include <core/option.h>
 
 struct nvkm_device_agp_quirk {
@@ -172,4 +171,3 @@ nvkm_agp_ctor(struct nvkm_pci *pci)
 
 	pci->agp.mtrr = arch_phys_wc_add(pci->agp.base, pci->agp.size);
 }
-#endif
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/pci/agp.h b/drivers/gpu/drm/nouveau/nvkm/subdev/pci/agp.h
index ad4d3621d02b..041fe1fbf093 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/pci/agp.h
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/pci/agp.h
@@ -1,15 +1,14 @@
-/* SPDX-License-Identifier: MIT */
-#include "priv.h"
-#if defined(CONFIG_AGP) || (defined(CONFIG_AGP_MODULE) && defined(MODULE))
 #ifndef __NVKM_PCI_AGP_H__
 #define __NVKM_PCI_AGP_H__
 
+/* SPDX-License-Identifier: MIT */
+#include "priv.h"
+#if IS_ENABLED(CONFIG_AGP)
 void nvkm_agp_ctor(struct nvkm_pci *);
 void nvkm_agp_dtor(struct nvkm_pci *);
 void nvkm_agp_preinit(struct nvkm_pci *);
 int nvkm_agp_init(struct nvkm_pci *);
 void nvkm_agp_fini(struct nvkm_pci *);
-#endif
 #else
 static inline void nvkm_agp_ctor(struct nvkm_pci *pci) {}
 static inline void nvkm_agp_dtor(struct nvkm_pci *pci) {}
@@ -17,3 +16,5 @@ static inline void nvkm_agp_preinit(struct nvkm_pci *pci) {}
 static inline int nvkm_agp_init(struct nvkm_pci *pci) { return -ENOSYS; }
 static inline void nvkm_agp_fini(struct nvkm_pci *pci) {}
 #endif
+
+#endif
-- 
2.29.2

_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Nouveau] [PATCH] drm/nouveau/pci: rework AGP dependency
  2021-02-25 12:52 [Nouveau] [PATCH] drm/nouveau/pci: rework AGP dependency Arnd Bergmann
@ 2021-02-25 12:59 ` Christian König
  2021-02-25 15:46   ` Daniel Vetter
  0 siblings, 1 reply; 3+ messages in thread
From: Christian König @ 2021-02-25 12:59 UTC (permalink / raw)
  To: Arnd Bergmann, Ben Skeggs, David Airlie, Daniel Vetter
  Cc: Arnd Bergmann, nouveau, linux-kernel, dri-devel

Am 25.02.21 um 13:52 schrieb Arnd Bergmann:
> From: Arnd Bergmann <arnd@arndb.de>
>
> I noticed a warning from 'nm' when CONFIG_TRIM_UNUSED_KSYMS is set
> and IS_REACHABLE(CONFIG_AGP) is false:
>
> drivers/gpu/drm/nouveau/nvkm/subdev/pci/agp.o: no symbols
>
> I later found this is completely harmless and we should find a way
> to suppress the warning, but at that point I had already done a
> cleanup patch to address this instance.
>
> It turns out this code could be improved anyway, as the current version
> behaves unexpectedly when AGP is a loadable module but nouveau is built-in
> itself, in which case it silently omits agp support.
>
> A better way to handle this is with a Kconfig dependency that requires
> AGP either to be disabled, or forces nouveau to be a module for AGP=m.
> With this change, the compile-time hack can be removed and lld no
> longer warns.
>
> Fixes: 340b0e7c500a ("drm/nouveau/pci: merge agp handling from nouveau drm")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>   drivers/gpu/drm/nouveau/Kbuild                 | 1 +
>   drivers/gpu/drm/nouveau/Kconfig                | 1 +
>   drivers/gpu/drm/nouveau/nvkm/subdev/pci/Kbuild | 2 +-
>   drivers/gpu/drm/nouveau/nvkm/subdev/pci/agp.c  | 2 --
>   drivers/gpu/drm/nouveau/nvkm/subdev/pci/agp.h  | 9 +++++----
>   5 files changed, 8 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/gpu/drm/nouveau/Kbuild b/drivers/gpu/drm/nouveau/Kbuild
> index 60586fb8275e..173b8d9d85e3 100644
> --- a/drivers/gpu/drm/nouveau/Kbuild
> +++ b/drivers/gpu/drm/nouveau/Kbuild
> @@ -15,6 +15,7 @@ nouveau-y := $(nvif-y)
>   #- code also used by various userspace tools/tests
>   include $(src)/nvkm/Kbuild
>   nouveau-y += $(nvkm-y)
> +nouveau-m += $(nvkm-m)
>   
>   # DRM - general
>   ifdef CONFIG_X86
> diff --git a/drivers/gpu/drm/nouveau/Kconfig b/drivers/gpu/drm/nouveau/Kconfig
> index 278e048235a9..90276a557a70 100644
> --- a/drivers/gpu/drm/nouveau/Kconfig
> +++ b/drivers/gpu/drm/nouveau/Kconfig
> @@ -2,6 +2,7 @@
>   config DRM_NOUVEAU
>   	tristate "Nouveau (NVIDIA) cards"
>   	depends on DRM && PCI && MMU
> +	depends on AGP || !AGP

My first thought was WTF? But then I realized that this totally makes sense.

We should probably have the same for radeon as well.

Apart from that the patch is Acked-by: Christian König 
<christian.koenig@amd.com>

>   	select IOMMU_API
>   	select FW_LOADER
>   	select DRM_KMS_HELPER
> diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/pci/Kbuild b/drivers/gpu/drm/nouveau/nvkm/subdev/pci/Kbuild
> index 174bdf995271..a400c680cf65 100644
> --- a/drivers/gpu/drm/nouveau/nvkm/subdev/pci/Kbuild
> +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/pci/Kbuild
> @@ -1,5 +1,5 @@
>   # SPDX-License-Identifier: MIT
> -nvkm-y += nvkm/subdev/pci/agp.o
> +nvkm-$(CONFIG_AGP) += nvkm/subdev/pci/agp.o
>   nvkm-y += nvkm/subdev/pci/base.o
>   nvkm-y += nvkm/subdev/pci/pcie.o
>   nvkm-y += nvkm/subdev/pci/nv04.o
> diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/pci/agp.c b/drivers/gpu/drm/nouveau/nvkm/subdev/pci/agp.c
> index 385a90f91ed6..86c9e1d658af 100644
> --- a/drivers/gpu/drm/nouveau/nvkm/subdev/pci/agp.c
> +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/pci/agp.c
> @@ -20,7 +20,6 @@
>    * OTHER DEALINGS IN THE SOFTWARE.
>    */
>   #include "agp.h"
> -#ifdef __NVKM_PCI_AGP_H__
>   #include <core/option.h>
>   
>   struct nvkm_device_agp_quirk {
> @@ -172,4 +171,3 @@ nvkm_agp_ctor(struct nvkm_pci *pci)
>   
>   	pci->agp.mtrr = arch_phys_wc_add(pci->agp.base, pci->agp.size);
>   }
> -#endif
> diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/pci/agp.h b/drivers/gpu/drm/nouveau/nvkm/subdev/pci/agp.h
> index ad4d3621d02b..041fe1fbf093 100644
> --- a/drivers/gpu/drm/nouveau/nvkm/subdev/pci/agp.h
> +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/pci/agp.h
> @@ -1,15 +1,14 @@
> -/* SPDX-License-Identifier: MIT */
> -#include "priv.h"
> -#if defined(CONFIG_AGP) || (defined(CONFIG_AGP_MODULE) && defined(MODULE))
>   #ifndef __NVKM_PCI_AGP_H__
>   #define __NVKM_PCI_AGP_H__
>   
> +/* SPDX-License-Identifier: MIT */
> +#include "priv.h"
> +#if IS_ENABLED(CONFIG_AGP)
>   void nvkm_agp_ctor(struct nvkm_pci *);
>   void nvkm_agp_dtor(struct nvkm_pci *);
>   void nvkm_agp_preinit(struct nvkm_pci *);
>   int nvkm_agp_init(struct nvkm_pci *);
>   void nvkm_agp_fini(struct nvkm_pci *);
> -#endif
>   #else
>   static inline void nvkm_agp_ctor(struct nvkm_pci *pci) {}
>   static inline void nvkm_agp_dtor(struct nvkm_pci *pci) {}
> @@ -17,3 +16,5 @@ static inline void nvkm_agp_preinit(struct nvkm_pci *pci) {}
>   static inline int nvkm_agp_init(struct nvkm_pci *pci) { return -ENOSYS; }
>   static inline void nvkm_agp_fini(struct nvkm_pci *pci) {}
>   #endif
> +
> +#endif

_______________________________________________
Nouveau mailing list
Nouveau@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/nouveau

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Nouveau] [PATCH] drm/nouveau/pci: rework AGP dependency
  2021-02-25 12:59 ` Christian König
@ 2021-02-25 15:46   ` Daniel Vetter
  0 siblings, 0 replies; 3+ messages in thread
From: Daniel Vetter @ 2021-02-25 15:46 UTC (permalink / raw)
  To: Christian König
  Cc: Arnd Bergmann, Arnd Bergmann, David Airlie, Nouveau Dev,
	Linux Kernel Mailing List, dri-devel, Ben Skeggs

On Thu, Feb 25, 2021 at 1:59 PM Christian König
<christian.koenig@amd.com> wrote:
>
> Am 25.02.21 um 13:52 schrieb Arnd Bergmann:
> > From: Arnd Bergmann <arnd@arndb.de>
> >
> > I noticed a warning from 'nm' when CONFIG_TRIM_UNUSED_KSYMS is set
> > and IS_REACHABLE(CONFIG_AGP) is false:
> >
> > drivers/gpu/drm/nouveau/nvkm/subdev/pci/agp.o: no symbols
> >
> > I later found this is completely harmless and we should find a way
> > to suppress the warning, but at that point I had already done a
> > cleanup patch to address this instance.
> >
> > It turns out this code could be improved anyway, as the current version
> > behaves unexpectedly when AGP is a loadable module but nouveau is built-in
> > itself, in which case it silently omits agp support.
> >
> > A better way to handle this is with a Kconfig dependency that requires
> > AGP either to be disabled, or forces nouveau to be a module for AGP=m.
> > With this change, the compile-time hack can be removed and lld no
> > longer warns.
> >
> > Fixes: 340b0e7c500a ("drm/nouveau/pci: merge agp handling from nouveau drm")
> > Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> > ---
> >   drivers/gpu/drm/nouveau/Kbuild                 | 1 +
> >   drivers/gpu/drm/nouveau/Kconfig                | 1 +
> >   drivers/gpu/drm/nouveau/nvkm/subdev/pci/Kbuild | 2 +-
> >   drivers/gpu/drm/nouveau/nvkm/subdev/pci/agp.c  | 2 --
> >   drivers/gpu/drm/nouveau/nvkm/subdev/pci/agp.h  | 9 +++++----
> >   5 files changed, 8 insertions(+), 7 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/nouveau/Kbuild b/drivers/gpu/drm/nouveau/Kbuild
> > index 60586fb8275e..173b8d9d85e3 100644
> > --- a/drivers/gpu/drm/nouveau/Kbuild
> > +++ b/drivers/gpu/drm/nouveau/Kbuild
> > @@ -15,6 +15,7 @@ nouveau-y := $(nvif-y)
> >   #- code also used by various userspace tools/tests
> >   include $(src)/nvkm/Kbuild
> >   nouveau-y += $(nvkm-y)
> > +nouveau-m += $(nvkm-m)
> >
> >   # DRM - general
> >   ifdef CONFIG_X86
> > diff --git a/drivers/gpu/drm/nouveau/Kconfig b/drivers/gpu/drm/nouveau/Kconfig
> > index 278e048235a9..90276a557a70 100644
> > --- a/drivers/gpu/drm/nouveau/Kconfig
> > +++ b/drivers/gpu/drm/nouveau/Kconfig
> > @@ -2,6 +2,7 @@
> >   config DRM_NOUVEAU
> >       tristate "Nouveau (NVIDIA) cards"
> >       depends on DRM && PCI && MMU
> > +     depends on AGP || !AGP
>
> My first thought was WTF? But then I realized that this totally makes sense.

depends on SYM || !SYM

is essentially

optional depends on SYM

when SYM is a tri-state. I think there was even patches to kconfig to
add something like that since it's such a common pattern. Might be
neat to resurrect that for more clarity.
-Daniel

> We should probably have the same for radeon as well.
>
> Apart from that the patch is Acked-by: Christian König
> <christian.koenig@amd.com>
>
> >       select IOMMU_API
> >       select FW_LOADER
> >       select DRM_KMS_HELPER
> > diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/pci/Kbuild b/drivers/gpu/drm/nouveau/nvkm/subdev/pci/Kbuild
> > index 174bdf995271..a400c680cf65 100644
> > --- a/drivers/gpu/drm/nouveau/nvkm/subdev/pci/Kbuild
> > +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/pci/Kbuild
> > @@ -1,5 +1,5 @@
> >   # SPDX-License-Identifier: MIT
> > -nvkm-y += nvkm/subdev/pci/agp.o
> > +nvkm-$(CONFIG_AGP) += nvkm/subdev/pci/agp.o
> >   nvkm-y += nvkm/subdev/pci/base.o
> >   nvkm-y += nvkm/subdev/pci/pcie.o
> >   nvkm-y += nvkm/subdev/pci/nv04.o
> > diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/pci/agp.c b/drivers/gpu/drm/nouveau/nvkm/subdev/pci/agp.c
> > index 385a90f91ed6..86c9e1d658af 100644
> > --- a/drivers/gpu/drm/nouveau/nvkm/subdev/pci/agp.c
> > +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/pci/agp.c
> > @@ -20,7 +20,6 @@
> >    * OTHER DEALINGS IN THE SOFTWARE.
> >    */
> >   #include "agp.h"
> > -#ifdef __NVKM_PCI_AGP_H__
> >   #include <core/option.h>
> >
> >   struct nvkm_device_agp_quirk {
> > @@ -172,4 +171,3 @@ nvkm_agp_ctor(struct nvkm_pci *pci)
> >
> >       pci->agp.mtrr = arch_phys_wc_add(pci->agp.base, pci->agp.size);
> >   }
> > -#endif
> > diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/pci/agp.h b/drivers/gpu/drm/nouveau/nvkm/subdev/pci/agp.h
> > index ad4d3621d02b..041fe1fbf093 100644
> > --- a/drivers/gpu/drm/nouveau/nvkm/subdev/pci/agp.h
> > +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/pci/agp.h
> > @@ -1,15 +1,14 @@
> > -/* SPDX-License-Identifier: MIT */
> > -#include "priv.h"
> > -#if defined(CONFIG_AGP) || (defined(CONFIG_AGP_MODULE) && defined(MODULE))
> >   #ifndef __NVKM_PCI_AGP_H__
> >   #define __NVKM_PCI_AGP_H__
> >
> > +/* SPDX-License-Identifier: MIT */
> > +#include "priv.h"
> > +#if IS_ENABLED(CONFIG_AGP)
> >   void nvkm_agp_ctor(struct nvkm_pci *);
> >   void nvkm_agp_dtor(struct nvkm_pci *);
> >   void nvkm_agp_preinit(struct nvkm_pci *);
> >   int nvkm_agp_init(struct nvkm_pci *);
> >   void nvkm_agp_fini(struct nvkm_pci *);
> > -#endif
> >   #else
> >   static inline void nvkm_agp_ctor(struct nvkm_pci *pci) {}
> >   static inline void nvkm_agp_dtor(struct nvkm_pci *pci) {}
> > @@ -17,3 +16,5 @@ static inline void nvkm_agp_preinit(struct nvkm_pci *pci) {}
> >   static inline int nvkm_agp_init(struct nvkm_pci *pci) { return -ENOSYS; }
> >   static inline void nvkm_agp_fini(struct nvkm_pci *pci) {}
> >   #endif
> > +
> > +#endif
>


-- 
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] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-25 12:52 [Nouveau] [PATCH] drm/nouveau/pci: rework AGP dependency Arnd Bergmann
2021-02-25 12:59 ` Christian König
2021-02-25 15:46   ` Daniel Vetter

Nouveau Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/nouveau/0 nouveau/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 nouveau nouveau/ https://lore.kernel.org/nouveau \
		nouveau@lists.freedesktop.org
	public-inbox-index nouveau

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.freedesktop.lists.nouveau


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git