From: Deepak Rawat <drawat.floss@gmail.com>
To: Mohammed Gamal <mgamal@redhat.com>,
linux-hyperv@vger.kernel.org, dri-devel@lists.freedesktop.org,
decui@microsoft.com
Cc: linux-kernel@vger.kernel.org, daniel@ffwll.ch, airlied@linux.ie
Subject: Re: [PATCH] drm/hyperv: Fix device removal on Gen1 VMs
Date: Fri, 19 Nov 2021 16:42:28 -0800 [thread overview]
Message-ID: <ec14aa50bbf1ebcf4e7edd54a3f5ad7409951cbb.camel@gmail.com> (raw)
In-Reply-To: <20211119112900.300537-1-mgamal@redhat.com>
Thanks for the patch.
Reviewed-by: Deepak Rawat <drawat.floss@gmail.com>
I will push this to drm-fixes, let me know otherwise.
Deepak
On Fri, 2021-11-19 at 12:29 +0100, Mohammed Gamal wrote:
> The Hyper-V DRM driver tries to free MMIO region on removing
> the device regardless of VM type, while Gen1 VMs don't use MMIO
> and hence causing the kernel to crash on a NULL pointer dereference.
>
> Fix this by making deallocating MMIO only on Gen2 machines and
> implement
> removal for Gen1
>
> Fixes: 76c56a5affeb ("drm/hyperv: Add DRM driver for hyperv synthetic
> video device")
>
> Signed-off-by: Mohammed Gamal <mgamal@redhat.com>
> ---
> drivers/gpu/drm/hyperv/hyperv_drm_drv.c | 19 ++++++++++++++++++-
> 1 file changed, 18 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/hyperv/hyperv_drm_drv.c
> b/drivers/gpu/drm/hyperv/hyperv_drm_drv.c
> index cd818a629183..9f923beb7d8d 100644
> --- a/drivers/gpu/drm/hyperv/hyperv_drm_drv.c
> +++ b/drivers/gpu/drm/hyperv/hyperv_drm_drv.c
> @@ -225,12 +225,29 @@ static int hyperv_vmbus_remove(struct hv_device
> *hdev)
> {
> struct drm_device *dev = hv_get_drvdata(hdev);
> struct hyperv_drm_device *hv = to_hv(dev);
> + struct pci_dev *pdev;
>
> drm_dev_unplug(dev);
> drm_atomic_helper_shutdown(dev);
> vmbus_close(hdev->channel);
> hv_set_drvdata(hdev, NULL);
> - vmbus_free_mmio(hv->mem->start, hv->fb_size);
> +
> + /*
> + * Free allocated MMIO memory only on Gen2 VMs.
> + * On Gen1 VMs, release the PCI device
> + */
> + if (efi_enabled(EFI_BOOT)) {
> + vmbus_free_mmio(hv->mem->start, hv->fb_size);
> + } else {
> + pdev = pci_get_device(PCI_VENDOR_ID_MICROSOFT,
> + PCI_DEVICE_ID_HYPERV_VIDEO, NULL);
> + if (!pdev) {
> + drm_err(dev, "Unable to find PCI Hyper-V
> video\n");
> + return -ENODEV;
> + }
> + pci_release_region(pdev, 0);
> + pci_dev_put(pdev);
> + }
>
> return 0;
> }
prev parent reply other threads:[~2021-11-20 0:42 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-19 11:29 [PATCH] drm/hyperv: Fix device removal on Gen1 VMs Mohammed Gamal
2021-11-20 0:42 ` Deepak Rawat [this message]
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=ec14aa50bbf1ebcf4e7edd54a3f5ad7409951cbb.camel@gmail.com \
--to=drawat.floss@gmail.com \
--cc=airlied@linux.ie \
--cc=daniel@ffwll.ch \
--cc=decui@microsoft.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mgamal@redhat.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox