public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [Q] How to tell we're using the KMS (during suspend/resume) outside the graphics driver
@ 2010-03-06 21:36 Rafael J. Wysocki
  2010-03-09 11:01 ` Luca Tettamanti
  0 siblings, 1 reply; 12+ messages in thread
From: Rafael J. Wysocki @ 2010-03-06 21:36 UTC (permalink / raw)
  To: LKML
  Cc: Linux PCI, pm list, dri-devel, Jesse Barnes, Matthew Garrett,
	ACPI Devel Maling List

Hi,

For at least two reasons it would be beneficial for some code outisde the
graphics driver(s) to know if the KMS are used.

First, in the non-KMS (ie. UMS) case we probably wouldn't want to call
acpi_video_resume(), because that has a potential to mess up with the GPU
(it actually is known to do that on at least one system).

Second, in the KMS case, we'd be able to skip the kernel VT switch, because
the KMS driver uses its own framebuffer anyway.

So, is there any reasonable way to check that from the outside of the graphics
driver?  It should be general enough to cover the cases when there are two
graphics adapters with different drivers in the system and so forth.

Rafael

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

* Re: [Q] How to tell we're using the KMS (during suspend/resume)  outside the graphics driver
  2010-03-06 21:36 [Q] How to tell we're using the KMS (during suspend/resume) outside the graphics driver Rafael J. Wysocki
@ 2010-03-09 11:01 ` Luca Tettamanti
  2010-03-09 11:34   ` Rafael J. Wysocki
  0 siblings, 1 reply; 12+ messages in thread
From: Luca Tettamanti @ 2010-03-09 11:01 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: LKML, Matthew Garrett, Linux PCI, Jesse Barnes,
	ACPI Devel Maling List, pm list, dri-devel

On Sat, Mar 6, 2010 at 10:36 PM, Rafael J. Wysocki <rjw@sisk.pl> wrote:
> Hi,
>
> For at least two reasons it would be beneficial for some code outisde the
> graphics driver(s) to know if the KMS are used.
>
> First, in the non-KMS (ie. UMS) case we probably wouldn't want to call
> acpi_video_resume(), because that has a potential to mess up with the GPU
> (it actually is known to do that on at least one system).
>
> Second, in the KMS case, we'd be able to skip the kernel VT switch, because
> the KMS driver uses its own framebuffer anyway.
>
> So, is there any reasonable way to check that from the outside of the graphics
> driver?  It should be general enough to cover the cases when there are two
> graphics adapters with different drivers in the system and so forth.

Inside the kernel? If you have a struct pci_dev you can get the
associated struct drm_device with pci_get_drvdata and then check the
KMS feature: drm_core_check_feature(dev, DRIVER_MODESET).
I'm note sure how to check that a device is graphic card though :|

Luca

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

* Re: [Q] How to tell we're using the KMS (during suspend/resume) outside the graphics driver
  2010-03-09 11:01 ` Luca Tettamanti
@ 2010-03-09 11:34   ` Rafael J. Wysocki
  2010-03-09 11:38     ` Rafał Miłecki
  2010-03-09 16:16     ` James Simmons
  0 siblings, 2 replies; 12+ messages in thread
From: Rafael J. Wysocki @ 2010-03-09 11:34 UTC (permalink / raw)
  To: Luca Tettamanti
  Cc: LKML, Matthew Garrett, Linux PCI, Jesse Barnes,
	ACPI Devel Maling List, pm list, dri-devel

On Tuesday 09 March 2010, Luca Tettamanti wrote:
> On Sat, Mar 6, 2010 at 10:36 PM, Rafael J. Wysocki <rjw@sisk.pl> wrote:
> > Hi,
> >
> > For at least two reasons it would be beneficial for some code outisde the
> > graphics driver(s) to know if the KMS are used.
> >
> > First, in the non-KMS (ie. UMS) case we probably wouldn't want to call
> > acpi_video_resume(), because that has a potential to mess up with the GPU
> > (it actually is known to do that on at least one system).
> >
> > Second, in the KMS case, we'd be able to skip the kernel VT switch, because
> > the KMS driver uses its own framebuffer anyway.
> >
> > So, is there any reasonable way to check that from the outside of the graphics
> > driver?  It should be general enough to cover the cases when there are two
> > graphics adapters with different drivers in the system and so forth.
> 
> Inside the kernel? If you have a struct pci_dev you can get the
> associated struct drm_device with pci_get_drvdata and then check the
> KMS feature: drm_core_check_feature(dev, DRIVER_MODESET).

Yeah, I know that.

> I'm note sure how to check that a device is graphic card though :|

Well, that's the "outside of the graphics driver" part of my question. :-)

Rafael

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

* Re: [Q] How to tell we're using the KMS (during suspend/resume)  outside the graphics driver
  2010-03-09 11:34   ` Rafael J. Wysocki
@ 2010-03-09 11:38     ` Rafał Miłecki
  2010-03-09 16:16     ` James Simmons
  1 sibling, 0 replies; 12+ messages in thread
From: Rafał Miłecki @ 2010-03-09 11:38 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Luca Tettamanti, LKML, Matthew Garrett, Linux PCI, Jesse Barnes,
	ACPI Devel Maling List, pm list, dri-devel

2010/3/9 Rafael J. Wysocki <rjw@sisk.pl>:
> On Tuesday 09 March 2010, Luca Tettamanti wrote:
>> I'm note sure how to check that a device is graphic card though :|
>
> Well, that's the "outside of the graphics driver" part of my question. :-)

Can we use the same way userspace (DDX) uses to check for KMS? Some
IOCTL I guess?

-- 
Rafał

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

* Re: [Q] How to tell we're using the KMS (during suspend/resume) outside the graphics driver
  2010-03-09 11:34   ` Rafael J. Wysocki
  2010-03-09 11:38     ` Rafał Miłecki
@ 2010-03-09 16:16     ` James Simmons
  2010-03-09 21:08       ` Rafael J. Wysocki
  1 sibling, 1 reply; 12+ messages in thread
From: James Simmons @ 2010-03-09 16:16 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Luca Tettamanti, Matthew Garrett, Linux PCI, LKML, Jesse Barnes,
	ACPI Devel Maling List, pm list, dri-devel


> > > Second, in the KMS case, we'd be able to skip the kernel VT switch, because
> > > the KMS driver uses its own framebuffer anyway.
> > >
> > > So, is there any reasonable way to check that from the outside of the graphics
> > > driver?  It should be general enough to cover the cases when there are two
> > > graphics adapters with different drivers in the system and so forth.
> > 
> > Inside the kernel? If you have a struct pci_dev you can get the
> > associated struct drm_device with pci_get_drvdata and then check the
> > KMS feature: drm_core_check_feature(dev, DRIVER_MODESET).
> 
> Yeah, I know that.
> 
> > I'm note sure how to check that a device is graphic card though :|
> 
> Well, that's the "outside of the graphics driver" part of my question. :-)

if ((pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA)
	....



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

* Re: [Q] How to tell we're using the KMS (during suspend/resume) outside the graphics driver
  2010-03-09 16:16     ` James Simmons
@ 2010-03-09 21:08       ` Rafael J. Wysocki
  2010-03-10  5:50         ` Paul Mundt
  0 siblings, 1 reply; 12+ messages in thread
From: Rafael J. Wysocki @ 2010-03-09 21:08 UTC (permalink / raw)
  To: James Simmons
  Cc: Luca Tettamanti, Matthew Garrett, Linux PCI, LKML, Jesse Barnes,
	ACPI Devel Maling List, pm list, dri-devel

On Tuesday 09 March 2010, James Simmons wrote:
> 
> > > > Second, in the KMS case, we'd be able to skip the kernel VT switch, because
> > > > the KMS driver uses its own framebuffer anyway.
> > > >
> > > > So, is there any reasonable way to check that from the outside of the graphics
> > > > driver?  It should be general enough to cover the cases when there are two
> > > > graphics adapters with different drivers in the system and so forth.
> > > 
> > > Inside the kernel? If you have a struct pci_dev you can get the
> > > associated struct drm_device with pci_get_drvdata and then check the
> > > KMS feature: drm_core_check_feature(dev, DRIVER_MODESET).
> > 
> > Yeah, I know that.
> > 
> > > I'm note sure how to check that a device is graphic card though :|
> > 
> > Well, that's the "outside of the graphics driver" part of my question. :-)
> 
> if ((pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA)
> 	....

I'm not sure if searching through all PCI devices really is an option.

Thanks anyway.

Rafael

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

* Re: [Q] How to tell we're using the KMS (during suspend/resume) outside the graphics driver
  2010-03-09 21:08       ` Rafael J. Wysocki
@ 2010-03-10  5:50         ` Paul Mundt
  2010-03-10 10:54           ` Pauli Nieminen
  0 siblings, 1 reply; 12+ messages in thread
From: Paul Mundt @ 2010-03-10  5:50 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: James Simmons, Luca Tettamanti, Matthew Garrett, Linux PCI, LKML,
	Jesse Barnes, ACPI Devel Maling List, pm list, dri-devel

On Tue, Mar 09, 2010 at 10:08:28PM +0100, Rafael J. Wysocki wrote:
> On Tuesday 09 March 2010, James Simmons wrote:
> > 
> > > > > Second, in the KMS case, we'd be able to skip the kernel VT switch, because
> > > > > the KMS driver uses its own framebuffer anyway.
> > > > >
> > > > > So, is there any reasonable way to check that from the outside of the graphics
> > > > > driver?  It should be general enough to cover the cases when there are two
> > > > > graphics adapters with different drivers in the system and so forth.
> > > > 
> > > > Inside the kernel? If you have a struct pci_dev you can get the
> > > > associated struct drm_device with pci_get_drvdata and then check the
> > > > KMS feature: drm_core_check_feature(dev, DRIVER_MODESET).
> > > 
> > > Yeah, I know that.
> > > 
> > > > I'm note sure how to check that a device is graphic card though :|
> > > 
> > > Well, that's the "outside of the graphics driver" part of my question. :-)
> > 
> > if ((pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA)
> > 	....
> 
> I'm not sure if searching through all PCI devices really is an option.
> 
Why not? The VGA arbitration code tracks a list of VGA class devices, so
could easily be queried. It looks like it might need a bit more work for
PCI hotplug, but it should already have all of the infrastructure you
need for getting at the pdev for the suspend/resume case.

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

* Re: [Q] How to tell we're using the KMS (during suspend/resume)  outside the graphics driver
  2010-03-10  5:50         ` Paul Mundt
@ 2010-03-10 10:54           ` Pauli Nieminen
  2010-03-10 20:56             ` Matthew Garrett
  0 siblings, 1 reply; 12+ messages in thread
From: Pauli Nieminen @ 2010-03-10 10:54 UTC (permalink / raw)
  To: Paul Mundt
  Cc: Rafael J. Wysocki, Matthew Garrett, Luca Tettamanti, Linux PCI,
	LKML, Jesse Barnes, ACPI Devel Maling List, pm list, dri-devel

On Wed, Mar 10, 2010 at 7:50 AM, Paul Mundt <lethal@linux-sh.org> wrote:
> On Tue, Mar 09, 2010 at 10:08:28PM +0100, Rafael J. Wysocki wrote:
>> On Tuesday 09 March 2010, James Simmons wrote:
>> >
>> > > > > Second, in the KMS case, we'd be able to skip the kernel VT switch, because
>> > > > > the KMS driver uses its own framebuffer anyway.
>> > > > >
>> > > > > So, is there any reasonable way to check that from the outside of the graphics
>> > > > > driver?  It should be general enough to cover the cases when there are two
>> > > > > graphics adapters with different drivers in the system and so forth.
>> > > >
>> > > > Inside the kernel? If you have a struct pci_dev you can get the
>> > > > associated struct drm_device with pci_get_drvdata and then check the
>> > > > KMS feature: drm_core_check_feature(dev, DRIVER_MODESET).
>> > >
>> > > Yeah, I know that.
>> > >
>> > > > I'm note sure how to check that a device is graphic card though :|
>> > >
>> > > Well, that's the "outside of the graphics driver" part of my question. :-)
>> >
>> > if ((pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA)
>> >     ....
>>
>> I'm not sure if searching through all PCI devices really is an option.
>>
> Why not? The VGA arbitration code tracks a list of VGA class devices, so
> could easily be queried. It looks like it might need a bit more work for
> PCI hotplug, but it should already have all of the infrastructure you
> need for getting at the pdev for the suspend/resume case.
>
>

It would be better to add interface that can be used to query if a
graphic device supports KMS. This should support multi-gpu setups at
least. I don't think anything prevents running mixed system where
secundary gpu is driven by UMS code in X.

Are you sure that all vga class devices have private device data that
matches private drm_device structure?

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

* Re: [Q] How to tell we're using the KMS (during suspend/resume) outside the graphics driver
  2010-03-10 10:54           ` Pauli Nieminen
@ 2010-03-10 20:56             ` Matthew Garrett
  2010-03-10 21:15               ` Rafael J. Wysocki
  0 siblings, 1 reply; 12+ messages in thread
From: Matthew Garrett @ 2010-03-10 20:56 UTC (permalink / raw)
  To: Pauli Nieminen
  Cc: Paul Mundt, Rafael J. Wysocki, Luca Tettamanti, Linux PCI, LKML,
	Jesse Barnes, ACPI Devel Maling List, pm list, dri-devel

As far as the ACPI video driver goes, acpi_get_physical_pci_device() 
will give you something to work with. For the console-switching case, I 
think the most reasonable plan is probably to add a flag to the console 
drivers to indicate whether or not they support reprogramming the 
hardware themselves, and then walk all active console drivers. There'd 
need to be a way for fb drivers to tell fbcon that they can handle it.

-- 
Matthew Garrett | mjg59@srcf.ucam.org

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

* Re: [Q] How to tell we're using the KMS (during suspend/resume) outside the graphics driver
  2010-03-10 20:56             ` Matthew Garrett
@ 2010-03-10 21:15               ` Rafael J. Wysocki
  2010-03-10 21:17                 ` Matthew Garrett
  0 siblings, 1 reply; 12+ messages in thread
From: Rafael J. Wysocki @ 2010-03-10 21:15 UTC (permalink / raw)
  To: Matthew Garrett
  Cc: Pauli Nieminen, Paul Mundt, Luca Tettamanti, Linux PCI, LKML,
	Jesse Barnes, ACPI Devel Maling List, pm list, dri-devel

On Wednesday 10 March 2010, Matthew Garrett wrote:
> As far as the ACPI video driver goes, acpi_get_physical_pci_device() 
> will give you something to work with.

Hmm.  Did you mean acpi_get_physical_device()?

Which acpi_device should I call that for?

> For the console-switching case, I think the most reasonable plan is probably
> to add a flag to the console drivers to indicate whether or not they support
> reprogramming the hardware themselves, and then walk all active console
> drivers. There'd need to be a way for fb drivers to tell fbcon that they can
> handle it.

Yes, that sounds reasonable.

Rafael

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

* Re: [Q] How to tell we're using the KMS (during suspend/resume) outside the graphics driver
  2010-03-10 21:15               ` Rafael J. Wysocki
@ 2010-03-10 21:17                 ` Matthew Garrett
  2010-04-06  7:47                   ` Rafał Miłecki
  0 siblings, 1 reply; 12+ messages in thread
From: Matthew Garrett @ 2010-03-10 21:17 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Pauli Nieminen, Paul Mundt, Luca Tettamanti, Linux PCI, LKML,
	Jesse Barnes, ACPI Devel Maling List, pm list, dri-devel

On Wed, Mar 10, 2010 at 10:15:26PM +0100, Rafael J. Wysocki wrote:
> On Wednesday 10 March 2010, Matthew Garrett wrote:
> > As far as the ACPI video driver goes, acpi_get_physical_pci_device() 
> > will give you something to work with.
> 
> Hmm.  Did you mean acpi_get_physical_device()?

Ah, no, acpi_get_pci_dev.

> Which acpi_device should I call that for?

The video one. acpi_video_bus_check does something very similar to check 
whether the device actually exists.

-- 
Matthew Garrett | mjg59@srcf.ucam.org

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

* Re: [Q] How to tell we're using the KMS (during suspend/resume)  outside the graphics driver
  2010-03-10 21:17                 ` Matthew Garrett
@ 2010-04-06  7:47                   ` Rafał Miłecki
  0 siblings, 0 replies; 12+ messages in thread
From: Rafał Miłecki @ 2010-04-06  7:47 UTC (permalink / raw)
  To: Matthew Garrett
  Cc: Rafael J. Wysocki, Pauli Nieminen, Paul Mundt, Luca Tettamanti,
	Linux PCI, LKML, Jesse Barnes, ACPI Devel Maling List, pm list,
	dri-devel

2010/3/10 Matthew Garrett <mjg59@srcf.ucam.org>:
> On Wed, Mar 10, 2010 at 10:15:26PM +0100, Rafael J. Wysocki wrote:
>> On Wednesday 10 March 2010, Matthew Garrett wrote:
>> > As far as the ACPI video driver goes, acpi_get_physical_pci_device()
>> > will give you something to work with.
>>
>> Hmm.  Did you mean acpi_get_physical_device()?
>
> Ah, no, acpi_get_pci_dev.

So, AFAIU acpi_get_pci_dev will give me pointer to struct pci_dev of
video card, yes?

There is some path I could use then:

struct pci_dev {
    .....
    struct pci_driver *driver;	/* which driver has allocated this device */
    .....
}

struct pci_driver {
    .....
    struct device_driver	driver;
    .....
}

Finally, struct device_driver is defined in device.h. Should I add flag
bool is_kms
to this struct then?

AFAIK we can not do anything with struct driver_private *p... Or is
there unified struct for video card drivers? We could then add flag
is_kms to some struct pointed by struct driver_private *p.

-- 
Rafał

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

end of thread, other threads:[~2010-04-06  7:48 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-06 21:36 [Q] How to tell we're using the KMS (during suspend/resume) outside the graphics driver Rafael J. Wysocki
2010-03-09 11:01 ` Luca Tettamanti
2010-03-09 11:34   ` Rafael J. Wysocki
2010-03-09 11:38     ` Rafał Miłecki
2010-03-09 16:16     ` James Simmons
2010-03-09 21:08       ` Rafael J. Wysocki
2010-03-10  5:50         ` Paul Mundt
2010-03-10 10:54           ` Pauli Nieminen
2010-03-10 20:56             ` Matthew Garrett
2010-03-10 21:15               ` Rafael J. Wysocki
2010-03-10 21:17                 ` Matthew Garrett
2010-04-06  7:47                   ` Rafał Miłecki

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