All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dexuan Cui <decui@microsoft.com>
To: Daniel Vetter <daniel@ffwll.ch>, Deepak Rawat <drawat.floss@gmail.com>
Cc: "linux-hyperv@vger.kernel.org" <linux-hyperv@vger.kernel.org>,
	Wei Hu <weh@microsoft.com>,
	Tang Shaofeng <shaofeng.tang@intel.com>,
	Haiyang Zhang <haiyangz@microsoft.com>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	"Michael Kelley \(LINUX\)" <mikelley@microsoft.com>,
	Gerd Hoffmann <kraxel@redhat.com>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	Sam Ravnborg <sam@ravnborg.org>
Subject: RE: [PATCH 1/2] drm/hyperv: Add DRM driver for hyperv synthetic video device
Date: Tue, 4 Apr 2023 16:07:30 +0000	[thread overview]
Message-ID: <SA1PR21MB1335DE8A38834B824F1692E7BF939@SA1PR21MB1335.namprd21.prod.outlook.com> (raw)
In-Reply-To: <CAKMK7uHRTcdZxreD5ymc2TsV9LNePeR=JgvJbnO-q2_wN99kEA@mail.gmail.com>

> From: Daniel Vetter <daniel@ffwll.ch>
> Sent: Tuesday, April 4, 2023 6:21 AM
> ...
> On Sat, 2 Jan 2021 at 07:03, Deepak Rawat <drawat.floss@gmail.com> wrote:
> > +/*
> > + * PCI/vmbus interface
> > + */
> > +
> > +static int hyperv_pci_probe(struct pci_dev *pdev,
> > +                           const struct pci_device_id *ent)
> > +{
> > +       return 0;
> > +}
> 
> Why do you have this dummy driver when it does nothing? Can it just be
> deleted? If it's just to have a driver, then we really don't need that
> on linux, there's no requirement to have a device driver for every
> device in a system.
> 
> If you actually need to make sure that this pci device isn't passed to
> a guest vm or something like that, then the main driver must ensure
> that the pci driver is bound (ideally with component.c because
> otherwise you'll get the unbind/rebind dance wrong in one of the
> bazillion of subtle ways). Just having a driver doesn't stop anyone
> from unbinding it and then wreaking havoc.
> -Daniel

The hyperv_drm driver is a DRM version of the device driver for the
Hyper-V synthetic framebuffer VMBus device. Originally the device's
driver is hyperv_fb (drivers/video/fbdev/hyperv_fb.c), and commit
7ad968472160 ("hyperv-fb: add pci stub") introduced the dummy
pci_probe function in hyperv_fb:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=7ad9684721606efbfb9b347346816e1e6baff8bb

hyperv_drm just copied the dummy pci_probe function from
hyperv_fb.

When a Linux VM runs on Hyper-V, it can be a Generation-1 VM
(legacy BIOS) or a Generation-2 VM (UEFI). In a Generation-1 VM,
the framebuffer device is presented to the VM both as a Hyper-V
synthetic framebuffer VMBus device and as a legacy PCI graphics
device. We'd like to let hyperv_fb or hyeprv_drm control the device,
and would like to avoid any PCI device driver for the legacy PCI
device, so commit 7ad968472160 uses the dummy pci_probe
function as a trick for this purpose. The commit says "Another
effect is that the xorg vesa driver will not attach to the device
and thus the Xorg server will automatically use the fbdev
driver instead."

As you pointed out, I suspect the unbind/rebind scenario is
still problematic, but AFAIK normally nobody would like to
do that.

Thanks,
Dexuan

WARNING: multiple messages have this Message-ID (diff)
From: Dexuan Cui <decui@microsoft.com>
To: Daniel Vetter <daniel@ffwll.ch>, Deepak Rawat <drawat.floss@gmail.com>
Cc: "linux-hyperv@vger.kernel.org" <linux-hyperv@vger.kernel.org>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	Gerd Hoffmann <kraxel@redhat.com>,
	Sam Ravnborg <sam@ravnborg.org>,
	Haiyang Zhang <haiyangz@microsoft.com>,
	Wei Hu <weh@microsoft.com>,
	Tang Shaofeng <shaofeng.tang@intel.com>,
	"Michael Kelley (LINUX)" <mikelley@microsoft.com>
Subject: RE: [PATCH 1/2] drm/hyperv: Add DRM driver for hyperv synthetic video device
Date: Tue, 4 Apr 2023 16:07:30 +0000	[thread overview]
Message-ID: <SA1PR21MB1335DE8A38834B824F1692E7BF939@SA1PR21MB1335.namprd21.prod.outlook.com> (raw)
In-Reply-To: <CAKMK7uHRTcdZxreD5ymc2TsV9LNePeR=JgvJbnO-q2_wN99kEA@mail.gmail.com>

> From: Daniel Vetter <daniel@ffwll.ch>
> Sent: Tuesday, April 4, 2023 6:21 AM
> ...
> On Sat, 2 Jan 2021 at 07:03, Deepak Rawat <drawat.floss@gmail.com> wrote:
> > +/*
> > + * PCI/vmbus interface
> > + */
> > +
> > +static int hyperv_pci_probe(struct pci_dev *pdev,
> > +                           const struct pci_device_id *ent)
> > +{
> > +       return 0;
> > +}
> 
> Why do you have this dummy driver when it does nothing? Can it just be
> deleted? If it's just to have a driver, then we really don't need that
> on linux, there's no requirement to have a device driver for every
> device in a system.
> 
> If you actually need to make sure that this pci device isn't passed to
> a guest vm or something like that, then the main driver must ensure
> that the pci driver is bound (ideally with component.c because
> otherwise you'll get the unbind/rebind dance wrong in one of the
> bazillion of subtle ways). Just having a driver doesn't stop anyone
> from unbinding it and then wreaking havoc.
> -Daniel

The hyperv_drm driver is a DRM version of the device driver for the
Hyper-V synthetic framebuffer VMBus device. Originally the device's
driver is hyperv_fb (drivers/video/fbdev/hyperv_fb.c), and commit
7ad968472160 ("hyperv-fb: add pci stub") introduced the dummy
pci_probe function in hyperv_fb:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=7ad9684721606efbfb9b347346816e1e6baff8bb

hyperv_drm just copied the dummy pci_probe function from
hyperv_fb.

When a Linux VM runs on Hyper-V, it can be a Generation-1 VM
(legacy BIOS) or a Generation-2 VM (UEFI). In a Generation-1 VM,
the framebuffer device is presented to the VM both as a Hyper-V
synthetic framebuffer VMBus device and as a legacy PCI graphics
device. We'd like to let hyperv_fb or hyeprv_drm control the device,
and would like to avoid any PCI device driver for the legacy PCI
device, so commit 7ad968472160 uses the dummy pci_probe
function as a trick for this purpose. The commit says "Another
effect is that the xorg vesa driver will not attach to the device
and thus the Xorg server will automatically use the fbdev
driver instead."

As you pointed out, I suspect the unbind/rebind scenario is
still problematic, but AFAIK normally nobody would like to
do that.

Thanks,
Dexuan

  reply	other threads:[~2023-04-04 16:07 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-02  6:03 [PATCH 1/2] drm/hyperv: Add DRM driver for hyperv synthetic video device Deepak Rawat
2021-01-02  6:03 ` Deepak Rawat
2021-01-02  6:03 ` [PATCH 2/2] MAINTAINERS: Add maintainer for hyperv " Deepak Rawat
2021-01-02  6:03   ` Deepak Rawat
2021-01-04 13:03 ` [PATCH 1/2] drm/hyperv: Add DRM driver for hyperv synthetic " Thomas Zimmermann
2021-01-04 13:03   ` Thomas Zimmermann
2021-01-05  2:27   ` Deepak Rawat
2021-01-05  2:27     ` Deepak Rawat
2021-01-05  8:07     ` Thomas Zimmermann
2021-01-05  8:07       ` Thomas Zimmermann
2021-01-05 11:04       ` Gerd Hoffmann
2021-01-05 11:04         ` Gerd Hoffmann
2021-01-05 11:30         ` Thomas Zimmermann
2021-01-05 11:30           ` Thomas Zimmermann
2021-01-06  4:01           ` Deepak Rawat
2021-01-06  4:01             ` Deepak Rawat
2023-04-04 13:20 ` Daniel Vetter
2023-04-04 13:20   ` Daniel Vetter
2023-04-04 16:07   ` Dexuan Cui [this message]
2023-04-04 16:07     ` Dexuan Cui

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=SA1PR21MB1335DE8A38834B824F1692E7BF939@SA1PR21MB1335.namprd21.prod.outlook.com \
    --to=decui@microsoft.com \
    --cc=daniel@ffwll.ch \
    --cc=drawat.floss@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=haiyangz@microsoft.com \
    --cc=kraxel@redhat.com \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=mikelley@microsoft.com \
    --cc=sam@ravnborg.org \
    --cc=shaofeng.tang@intel.com \
    --cc=tzimmermann@suse.de \
    --cc=weh@microsoft.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.