Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp2123541iob; Fri, 20 May 2022 02:31:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzwrW2E+QUP//5bHYibQ1Q5d9LKQAoIfDU9WmfBWxKdutnlo0NsfjuY9YnwwK4gtqXQ4aP+ X-Received: by 2002:a17:907:e89:b0:6f4:98fe:49e7 with SMTP id ho9-20020a1709070e8900b006f498fe49e7mr8047794ejc.425.1653039101957; Fri, 20 May 2022 02:31:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653039101; cv=none; d=google.com; s=arc-20160816; b=gbvaEl7SiOey48ZSSk+1usbeTj7e7wCQTAhC2VFXku15fVURlrwW8RwuBjq6CYMnH1 wOq3o2eIeEQPhjZZK5I5L20rRkrUqt2DXdG9eKnAfKeqHQrK/9CwjYKklgVIfO2KxeD0 4cbAqI4kTGzVrpPJeXKvPuA6zrINzG3dY0i+9O+0tAxt4FjHQqGTBw050aI1ZKgXKCo/ TeZ9GkhxGB72XhSB8kh0J2g/2XPiAxLxU5jHDJWQPMhSy6oVYj+Nt/Bu9qovGmPxwV7B lngOaEkJFJJvqkH2c3mKznSapejRQ//KqrpluRCvTdZEmXyUDlEHu8qe77QUhnMethjy AeSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:to:from:dkim-signature :dkim-filter; bh=l3C4NInvgKvz4oi7EOLCuKiDCvtT7GIwKr04BZ3Yohk=; b=rF8SNsRveB0uSmBV88sncdo+4FmZtKMt3ZiucH4zfmKwI9fO+czuOK5FAau8feoPK9 +ALEUuLljwykrbxnS/AwjlV9jkKdNxdev+Za8xCg1P6xJZF0fxKEk0/a4jxY3GlN1Pql t9oLsvQMlgjHUhvQ90iHeLFZRUlOYT8FYpFvXQMPxe3qWgzJ8/Dx5hsOS5dafi26BQWj RJnfFBZQeK+1aSDVAJ1FdkKgnSYJgzKhCaQkuOqZIvTzhw6g/pAUR0XQKAKmG/3fkN3u XmufFdCz+hfl4wNXR+enFnHhaAWcFn/P0OYv9xVt6Whsx/d1hycHO2CjVTGV2vCdPwML yhUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=WOzpWrc1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hq41-20020a1709073f2900b006f3b5c2ed49si8996086ejc.778.2022.05.20.02.31.14; Fri, 20 May 2022 02:31:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=WOzpWrc1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346324AbiETHUx (ORCPT + 99 others); Fri, 20 May 2022 03:20:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346276AbiETHUs (ORCPT ); Fri, 20 May 2022 03:20:48 -0400 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 89F07140C5; Fri, 20 May 2022 00:20:45 -0700 (PDT) Received: from linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net (linux.microsoft.com [13.77.154.182]) by linux.microsoft.com (Postfix) with ESMTPSA id 0B96320F9C0D; Fri, 20 May 2022 00:20:45 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 0B96320F9C0D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1653031245; bh=l3C4NInvgKvz4oi7EOLCuKiDCvtT7GIwKr04BZ3Yohk=; h=From:To:Subject:Date:From; b=WOzpWrc1VnMzae6Ns5L09zG0PwZGswch3brRhEKx3VaK3VEAJJYxiLLdzrFpkLY03 oigcapwqqaPR67ezwnSJ3jtrV1pZntK7/1PT+LaFHbFcAD8fM47nMhhxlq+d77BxC/ Oo9b+nTyDzatXyR959qwn0noqBErS3AREqQRoT6Y= From: Saurabh Sengar To: ssengar@microsoft.com, drawat.floss@gmail.com, airlied@linux.ie, daniel@ffwll.ch, linux-hyperv@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, decui@microsoft.com, haiyangz@microsoft.com Subject: [PATCH] drm/hyperv : Removing the restruction of VRAM allocation with PCI bar size Date: Fri, 20 May 2022 00:20:40 -0700 Message-Id: <1653031240-13623-1-git-send-email-ssengar@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 X-Spam-Status: No, score=-19.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL, USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There were two different approaches getting used in this driver to allocate vram: 1. VRAM allocation from PCI region for Gen1 2. VRAM alloaction from MMIO region for Gen2 First approach limilts the vram to PCI BAR size, which is 64 MB in most legacy systems. This limits the maximum resolution to be restricted to 64 MB size, and with recent conclusion on fbdev issue its concluded to have similar allocation strategy for both Gen1 and Gen2. This patch unifies the Gen1 and Gen2 vram allocation strategy. Signed-off-by: Saurabh Sengar --- FBdev patch Ref : https://lore.kernel.org/lkml/20220428143746.sya775ro5zi3kgm3@liuwe-devbox-debian-v2/T/ drivers/gpu/drm/hyperv/hyperv_drm_drv.c | 76 ++----------------------- 1 file changed, 4 insertions(+), 72 deletions(-) diff --git a/drivers/gpu/drm/hyperv/hyperv_drm_drv.c b/drivers/gpu/drm/hyperv/hyperv_drm_drv.c index 4a8941fa0815..a32afd84f361 100644 --- a/drivers/gpu/drm/hyperv/hyperv_drm_drv.c +++ b/drivers/gpu/drm/hyperv/hyperv_drm_drv.c @@ -69,57 +69,8 @@ static struct pci_driver hyperv_pci_driver = { .remove = hyperv_pci_remove, }; -static int hyperv_setup_gen1(struct hyperv_drm_device *hv) -{ - struct drm_device *dev = &hv->dev; - struct pci_dev *pdev; - int ret; - - 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; - } - - ret = drm_aperture_remove_conflicting_pci_framebuffers(pdev, &hyperv_driver); - if (ret) { - drm_err(dev, "Not able to remove boot fb\n"); - return ret; - } - - if (pci_request_region(pdev, 0, DRIVER_NAME) != 0) - drm_warn(dev, "Cannot request framebuffer, boot fb still active?\n"); - - if ((pdev->resource[0].flags & IORESOURCE_MEM) == 0) { - drm_err(dev, "Resource at bar 0 is not IORESOURCE_MEM\n"); - ret = -ENODEV; - goto error; - } - - hv->fb_base = pci_resource_start(pdev, 0); - hv->fb_size = pci_resource_len(pdev, 0); - if (!hv->fb_base) { - drm_err(dev, "Resource not available\n"); - ret = -ENODEV; - goto error; - } - - hv->fb_size = min(hv->fb_size, - (unsigned long)(hv->mmio_megabytes * 1024 * 1024)); - hv->vram = devm_ioremap(&pdev->dev, hv->fb_base, hv->fb_size); - if (!hv->vram) { - drm_err(dev, "Failed to map vram\n"); - ret = -ENOMEM; - } - -error: - pci_dev_put(pdev); - return ret; -} - -static int hyperv_setup_gen2(struct hyperv_drm_device *hv, - struct hv_device *hdev) +static int hyperv_setup_gen(struct hyperv_drm_device *hv, + struct hv_device *hdev) { struct drm_device *dev = &hv->dev; int ret; @@ -181,10 +132,7 @@ static int hyperv_vmbus_probe(struct hv_device *hdev, goto err_hv_set_drv_data; } - if (efi_enabled(EFI_BOOT)) - ret = hyperv_setup_gen2(hv, hdev); - else - ret = hyperv_setup_gen1(hv); + ret = hyperv_setup_gen(hv, hdev); if (ret) goto err_vmbus_close; @@ -225,29 +173,13 @@ 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); - /* - * 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); - } + vmbus_free_mmio(hv->mem->start, hv->fb_size); return 0; } -- 2.25.1