public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm: Fix support for PCI domains
@ 2010-08-06  3:55 Benjamin Herrenschmidt
  2010-08-06  7:11 ` Michel Dänzer
  2010-08-12 21:30 ` Geert Uytterhoeven
  0 siblings, 2 replies; 7+ messages in thread
From: Benjamin Herrenschmidt @ 2010-08-06  3:55 UTC (permalink / raw)
  To: Dave Airlie; +Cc: dri-devel, linux-kernel@vger.kernel.org

(For some reason I thought that went in ages ago ...)

This fixes support for PCI domains in what should hopefully be a backward
compatible way along with a change to libdrm.

When the interface version is set to 1.4, we assume userspace understands
domains and the world is at peace. We thus pass proper domain numbers
instead of 0 to userspace.

The newer libdrm will then try 1.4 first, and fallback to 1.1, along with
ignoring domains in the later case (well, except on alpha of course)

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
 drivers/gpu/drm/drm_ioctl.c |    1 +
 include/drm/drmP.h          |   18 +++++++++++++-----
 include/drm/drm_core.h      |    2 +-
 3 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
index 9b9ff46..d7b2bd6 100644
--- a/drivers/gpu/drm/drm_ioctl.c
+++ b/drivers/gpu/drm/drm_ioctl.c
@@ -322,6 +322,7 @@ int drm_setversion(struct drm_device *dev, void *data, struct drm_file *file_pri
 		if (sv->drm_di_minor >= 1) {
 			/*
 			 * Version 1.1 includes tying of DRM to specific device
+			 * Version 1.4 has proper PCI domain support
 			 */
 			drm_set_busid(dev, file_priv);
 		}
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index c1b9871..6d4bad5 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -1071,11 +1071,19 @@ static __inline__ int drm_core_check_feature(struct drm_device *dev,
 	return ((dev->driver->driver_features & feature) ? 1 : 0);
 }
 
-#ifdef __alpha__
-#define drm_get_pci_domain(dev) dev->hose->index
-#else
-#define drm_get_pci_domain(dev) 0
-#endif
+static inline int drm_get_pci_domain(struct drm_device *dev)
+{
+#ifndef __alpha__
+	/* For historical reasons, drm_get_pci_domain() is busticated
+	 * on most archs and has to remain so for userspace interface
+	 * < 1.4, except on alpha which was right from the beginning
+	 */
+	if (dev->if_version < 0x10004)
+		return 0;
+#endif /* __alpha__ */
+
+	return pci_domain_nr(dev->pdev->bus);
+}
 
 #if __OS_HAS_AGP
 static inline int drm_core_has_AGP(struct drm_device *dev)
diff --git a/include/drm/drm_core.h b/include/drm/drm_core.h
index 3167390..4e75238 100644
--- a/include/drm/drm_core.h
+++ b/include/drm/drm_core.h
@@ -27,7 +27,7 @@
 #define CORE_DATE		"20060810"
 
 #define DRM_IF_MAJOR	1
-#define DRM_IF_MINOR	3
+#define DRM_IF_MINOR	4
 
 #define CORE_MAJOR	1
 #define CORE_MINOR	1



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

* Re: [PATCH] drm: Fix support for PCI domains
  2010-08-06  3:55 [PATCH] drm: Fix support for PCI domains Benjamin Herrenschmidt
@ 2010-08-06  7:11 ` Michel Dänzer
  2010-08-12 21:30 ` Geert Uytterhoeven
  1 sibling, 0 replies; 7+ messages in thread
From: Michel Dänzer @ 2010-08-06  7:11 UTC (permalink / raw)
  To: Benjamin Herrenschmidt
  Cc: Dave Airlie, dri-devel, linux-kernel@vger.kernel.org

On Fre, 2010-08-06 at 13:55 +1000, Benjamin Herrenschmidt wrote: 
> (For some reason I thought that went in ages ago ...)
> 
> This fixes support for PCI domains in what should hopefully be a backward
> compatible way along with a change to libdrm.
> 
> When the interface version is set to 1.4, we assume userspace understands
> domains and the world is at peace. We thus pass proper domain numbers
> instead of 0 to userspace.
> 
> The newer libdrm will then try 1.4 first, and fallback to 1.1, along with
> ignoring domains in the later case (well, except on alpha of course)
> 
> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>

Reviewed-by: Michel Dänzer <michel@daenzer.net>

Thanks for tackling this, Ben!


-- 
Earthling Michel Dänzer           |                http://www.vmware.com
Libre software enthusiast         |          Debian, X and DRI developer

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

* Re: [PATCH] drm: Fix support for PCI domains
  2010-08-06  3:55 [PATCH] drm: Fix support for PCI domains Benjamin Herrenschmidt
  2010-08-06  7:11 ` Michel Dänzer
@ 2010-08-12 21:30 ` Geert Uytterhoeven
  2010-08-12 23:33   ` Dave Airlie
  1 sibling, 1 reply; 7+ messages in thread
From: Geert Uytterhoeven @ 2010-08-12 21:30 UTC (permalink / raw)
  To: Benjamin Herrenschmidt
  Cc: Dave Airlie, dri-devel, linux-kernel@vger.kernel.org

On Fri, Aug 6, 2010 at 05:55, Benjamin Herrenschmidt
<benh@kernel.crashing.org> wrote:
> (For some reason I thought that went in ages ago ...)
>
> This fixes support for PCI domains in what should hopefully be a backward
> compatible way along with a change to libdrm.
>
> When the interface version is set to 1.4, we assume userspace understands
> domains and the world is at peace. We thus pass proper domain numbers
> instead of 0 to userspace.
>
> The newer libdrm will then try 1.4 first, and fallback to 1.1, along with
> ignoring domains in the later case (well, except on alpha of course)
>
> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> ---
>  drivers/gpu/drm/drm_ioctl.c |    1 +
>  include/drm/drmP.h          |   18 +++++++++++++-----
>  include/drm/drm_core.h      |    2 +-
>  3 files changed, 15 insertions(+), 6 deletions(-)

> diff --git a/include/drm/drmP.h b/include/drm/drmP.h
> index c1b9871..6d4bad5 100644
> --- a/include/drm/drmP.h
> +++ b/include/drm/drmP.h
> @@ -1071,11 +1071,19 @@ static __inline__ int drm_core_check_feature(struct drm_device *dev,
>        return ((dev->driver->driver_features & feature) ? 1 : 0);
>  }
>
> -#ifdef __alpha__
> -#define drm_get_pci_domain(dev) dev->hose->index
> -#else
> -#define drm_get_pci_domain(dev) 0
> -#endif
> +static inline int drm_get_pci_domain(struct drm_device *dev)
> +{
> +#ifndef __alpha__
> +       /* For historical reasons, drm_get_pci_domain() is busticated
> +        * on most archs and has to remain so for userspace interface
> +        * < 1.4, except on alpha which was right from the beginning
> +        */
> +       if (dev->if_version < 0x10004)
> +               return 0;
> +#endif /* __alpha__ */
> +
> +       return pci_domain_nr(dev->pdev->bus);

error: implicit declaration of function ‘pci_domain_nr’

on m68k without PCI.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH] drm: Fix support for PCI domains
  2010-08-12 21:30 ` Geert Uytterhoeven
@ 2010-08-12 23:33   ` Dave Airlie
  2010-08-12 23:45     ` Jesse Barnes
  0 siblings, 1 reply; 7+ messages in thread
From: Dave Airlie @ 2010-08-12 23:33 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Benjamin Herrenschmidt, dri-devel, linux-kernel@vger.kernel.org,
	Jesse Barnes

On Fri, Aug 13, 2010 at 7:30 AM, Geert Uytterhoeven
<geert@linux-m68k.org> wrote:
> On Fri, Aug 6, 2010 at 05:55, Benjamin Herrenschmidt
> <benh@kernel.crashing.org> wrote:
>> (For some reason I thought that went in ages ago ...)
>>
>> This fixes support for PCI domains in what should hopefully be a backward
>> compatible way along with a change to libdrm.
>>
>> When the interface version is set to 1.4, we assume userspace understands
>> domains and the world is at peace. We thus pass proper domain numbers
>> instead of 0 to userspace.
>>
>> The newer libdrm will then try 1.4 first, and fallback to 1.1, along with
>> ignoring domains in the later case (well, except on alpha of course)
>>
>> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
>> ---
>>  drivers/gpu/drm/drm_ioctl.c |    1 +
>>  include/drm/drmP.h          |   18 +++++++++++++-----
>>  include/drm/drm_core.h      |    2 +-
>>  3 files changed, 15 insertions(+), 6 deletions(-)
>
>> diff --git a/include/drm/drmP.h b/include/drm/drmP.h
>> index c1b9871..6d4bad5 100644
>> --- a/include/drm/drmP.h
>> +++ b/include/drm/drmP.h
>> @@ -1071,11 +1071,19 @@ static __inline__ int drm_core_check_feature(struct drm_device *dev,
>>        return ((dev->driver->driver_features & feature) ? 1 : 0);
>>  }
>>
>> -#ifdef __alpha__
>> -#define drm_get_pci_domain(dev) dev->hose->index
>> -#else
>> -#define drm_get_pci_domain(dev) 0
>> -#endif
>> +static inline int drm_get_pci_domain(struct drm_device *dev)
>> +{
>> +#ifndef __alpha__
>> +       /* For historical reasons, drm_get_pci_domain() is busticated
>> +        * on most archs and has to remain so for userspace interface
>> +        * < 1.4, except on alpha which was right from the beginning
>> +        */
>> +       if (dev->if_version < 0x10004)
>> +               return 0;
>> +#endif /* __alpha__ */
>> +
>> +       return pci_domain_nr(dev->pdev->bus);
>
> error: implicit declaration of function ‘pci_domain_nr’
> on m68k without PCI.

I don't think I want to add an ifdef CONFIG_PCI into the drm layer for
this, since we seem to be okay everywhere else,

lets ask jbarnes, not sure if its safe to just add this to the
!CONFIG_PCI section of the linux/pci.h

Dave.

>
>

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

* Re: [PATCH] drm: Fix support for PCI domains
  2010-08-12 23:33   ` Dave Airlie
@ 2010-08-12 23:45     ` Jesse Barnes
  2010-08-13  0:22       ` Dave Airlie
  0 siblings, 1 reply; 7+ messages in thread
From: Jesse Barnes @ 2010-08-12 23:45 UTC (permalink / raw)
  To: Dave Airlie
  Cc: Geert Uytterhoeven, Benjamin Herrenschmidt, dri-devel,
	linux-kernel@vger.kernel.org

On Fri, 13 Aug 2010 09:33:35 +1000
Dave Airlie <airlied@gmail.com> wrote:

> On Fri, Aug 13, 2010 at 7:30 AM, Geert Uytterhoeven
> <geert@linux-m68k.org> wrote:
> > On Fri, Aug 6, 2010 at 05:55, Benjamin Herrenschmidt
> > <benh@kernel.crashing.org> wrote:
> >> (For some reason I thought that went in ages ago ...)
> >>
> >> This fixes support for PCI domains in what should hopefully be a backward
> >> compatible way along with a change to libdrm.
> >>
> >> When the interface version is set to 1.4, we assume userspace understands
> >> domains and the world is at peace. We thus pass proper domain numbers
> >> instead of 0 to userspace.
> >>
> >> The newer libdrm will then try 1.4 first, and fallback to 1.1, along with
> >> ignoring domains in the later case (well, except on alpha of course)
> >>
> >> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> >> ---
> >>  drivers/gpu/drm/drm_ioctl.c |    1 +
> >>  include/drm/drmP.h          |   18 +++++++++++++-----
> >>  include/drm/drm_core.h      |    2 +-
> >>  3 files changed, 15 insertions(+), 6 deletions(-)
> >
> >> diff --git a/include/drm/drmP.h b/include/drm/drmP.h
> >> index c1b9871..6d4bad5 100644
> >> --- a/include/drm/drmP.h
> >> +++ b/include/drm/drmP.h
> >> @@ -1071,11 +1071,19 @@ static __inline__ int drm_core_check_feature(struct drm_device *dev,
> >>        return ((dev->driver->driver_features & feature) ? 1 : 0);
> >>  }
> >>
> >> -#ifdef __alpha__
> >> -#define drm_get_pci_domain(dev) dev->hose->index
> >> -#else
> >> -#define drm_get_pci_domain(dev) 0
> >> -#endif
> >> +static inline int drm_get_pci_domain(struct drm_device *dev)
> >> +{
> >> +#ifndef __alpha__
> >> +       /* For historical reasons, drm_get_pci_domain() is busticated
> >> +        * on most archs and has to remain so for userspace interface
> >> +        * < 1.4, except on alpha which was right from the beginning
> >> +        */
> >> +       if (dev->if_version < 0x10004)
> >> +               return 0;
> >> +#endif /* __alpha__ */
> >> +
> >> +       return pci_domain_nr(dev->pdev->bus);
> >
> > error: implicit declaration of function ‘pci_domain_nr’
> > on m68k without PCI.
> 
> I don't think I want to add an ifdef CONFIG_PCI into the drm layer for
> this, since we seem to be okay everywhere else,
> 
> lets ask jbarnes, not sure if its safe to just add this to the
> !CONFIG_PCI section of the linux/pci.h

Hm, so pci_domain_nr should just return 0 on platforms where
CONFIG_PCI_DOMAINS isn't set.  I'd expect that to be the case when
CONFIG_PCI=n...  Maybe we just need to shuffle the definition around?

-- 
Jesse Barnes, Intel Open Source Technology Center

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

* Re: [PATCH] drm: Fix support for PCI domains
  2010-08-12 23:45     ` Jesse Barnes
@ 2010-08-13  0:22       ` Dave Airlie
  2010-08-13  0:35         ` Jesse Barnes
  0 siblings, 1 reply; 7+ messages in thread
From: Dave Airlie @ 2010-08-13  0:22 UTC (permalink / raw)
  To: Jesse Barnes
  Cc: Geert Uytterhoeven, Benjamin Herrenschmidt, dri-devel,
	linux-kernel@vger.kernel.org

[-- Attachment #1: Type: text/plain, Size: 2941 bytes --]

On Fri, Aug 13, 2010 at 9:45 AM, Jesse Barnes <jbarnes@virtuousgeek.org> wrote:
> On Fri, 13 Aug 2010 09:33:35 +1000
> Dave Airlie <airlied@gmail.com> wrote:
>
>> On Fri, Aug 13, 2010 at 7:30 AM, Geert Uytterhoeven
>> <geert@linux-m68k.org> wrote:
>> > On Fri, Aug 6, 2010 at 05:55, Benjamin Herrenschmidt
>> > <benh@kernel.crashing.org> wrote:
>> >> (For some reason I thought that went in ages ago ...)
>> >>
>> >> This fixes support for PCI domains in what should hopefully be a backward
>> >> compatible way along with a change to libdrm.
>> >>
>> >> When the interface version is set to 1.4, we assume userspace understands
>> >> domains and the world is at peace. We thus pass proper domain numbers
>> >> instead of 0 to userspace.
>> >>
>> >> The newer libdrm will then try 1.4 first, and fallback to 1.1, along with
>> >> ignoring domains in the later case (well, except on alpha of course)
>> >>
>> >> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
>> >> ---
>> >>  drivers/gpu/drm/drm_ioctl.c |    1 +
>> >>  include/drm/drmP.h          |   18 +++++++++++++-----
>> >>  include/drm/drm_core.h      |    2 +-
>> >>  3 files changed, 15 insertions(+), 6 deletions(-)
>> >
>> >> diff --git a/include/drm/drmP.h b/include/drm/drmP.h
>> >> index c1b9871..6d4bad5 100644
>> >> --- a/include/drm/drmP.h
>> >> +++ b/include/drm/drmP.h
>> >> @@ -1071,11 +1071,19 @@ static __inline__ int drm_core_check_feature(struct drm_device *dev,
>> >>        return ((dev->driver->driver_features & feature) ? 1 : 0);
>> >>  }
>> >>
>> >> -#ifdef __alpha__
>> >> -#define drm_get_pci_domain(dev) dev->hose->index
>> >> -#else
>> >> -#define drm_get_pci_domain(dev) 0
>> >> -#endif
>> >> +static inline int drm_get_pci_domain(struct drm_device *dev)
>> >> +{
>> >> +#ifndef __alpha__
>> >> +       /* For historical reasons, drm_get_pci_domain() is busticated
>> >> +        * on most archs and has to remain so for userspace interface
>> >> +        * < 1.4, except on alpha which was right from the beginning
>> >> +        */
>> >> +       if (dev->if_version < 0x10004)
>> >> +               return 0;
>> >> +#endif /* __alpha__ */
>> >> +
>> >> +       return pci_domain_nr(dev->pdev->bus);
>> >
>> > error: implicit declaration of function ‘pci_domain_nr’
>> > on m68k without PCI.
>>
>> I don't think I want to add an ifdef CONFIG_PCI into the drm layer for
>> this, since we seem to be okay everywhere else,
>>
>> lets ask jbarnes, not sure if its safe to just add this to the
>> !CONFIG_PCI section of the linux/pci.h
>
> Hm, so pci_domain_nr should just return 0 on platforms where
> CONFIG_PCI_DOMAINS isn't set.  I'd expect that to be the case when
> CONFIG_PCI=n...  Maybe we just need to shuffle the definition around?

I suspect something like the attached would suffice.

Or maybe moving the CONFIG_PCI_DOMAINS checkout outside CONFIG_PCI.

Dave.

[-- Attachment #2: mydiff --]
[-- Type: application/octet-stream, Size: 434 bytes --]

diff --git a/include/linux/pci.h b/include/linux/pci.h
index f26fda7..b6cb5f6 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1212,6 +1212,9 @@ static inline struct pci_dev *pci_get_bus_and_slot(unsigned int bus,
 						unsigned int devfn)
 { return NULL; }
 
+static inline int pci_domain_nr(struct pci_bus *bus)
+{ return 0; }
+
 #define dev_is_pci(d) (false)
 #define dev_is_pf(d) (false)
 #define dev_num_vf(d) (0)

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

* Re: [PATCH] drm: Fix support for PCI domains
  2010-08-13  0:22       ` Dave Airlie
@ 2010-08-13  0:35         ` Jesse Barnes
  0 siblings, 0 replies; 7+ messages in thread
From: Jesse Barnes @ 2010-08-13  0:35 UTC (permalink / raw)
  To: Dave Airlie
  Cc: Geert Uytterhoeven, Benjamin Herrenschmidt, dri-devel,
	linux-kernel@vger.kernel.org

> > Hm, so pci_domain_nr should just return 0 on platforms where
> > CONFIG_PCI_DOMAINS isn't set.  I'd expect that to be the case when
> > CONFIG_PCI=n...  Maybe we just need to shuffle the definition
> > around?
> 
> I suspect something like the attached would suffice.
> 
> Or maybe moving the CONFIG_PCI_DOMAINS checkout outside CONFIG_PCI.

Yeah, that looks ok, and better than putting it in drm.  I'll apply to
my for-linus branch for the next PCI fixes pull.

Thanks,
Jesse

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

end of thread, other threads:[~2010-08-13  0:35 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-06  3:55 [PATCH] drm: Fix support for PCI domains Benjamin Herrenschmidt
2010-08-06  7:11 ` Michel Dänzer
2010-08-12 21:30 ` Geert Uytterhoeven
2010-08-12 23:33   ` Dave Airlie
2010-08-12 23:45     ` Jesse Barnes
2010-08-13  0:22       ` Dave Airlie
2010-08-13  0:35         ` Jesse Barnes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox