Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp2096024rwn; Fri, 9 Sep 2022 08:28:01 -0700 (PDT) X-Google-Smtp-Source: AA6agR49r7IyGH3797ID2DkSwz69qLmkLpCJ6dI7lq1GWWNMVkNZYO180SNRtw8lNiWkqYHHWjGn X-Received: by 2002:a17:907:2710:b0:773:dd39:6344 with SMTP id w16-20020a170907271000b00773dd396344mr6552032ejk.411.1662737281536; Fri, 09 Sep 2022 08:28:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662737281; cv=none; d=google.com; s=arc-20160816; b=cFqRBwk5ECWpEppNkRJJZp7jsUgOamYlWQcRvmPB35GYtmqnf1F+ElK0NiE6IPH1Zl C6BeApZF178JnnadADBjbHSEpNynTj5/+5i+zxYlbT1Ax4DEfaOgh3pXaokLmzfoTtoV QP2zmRpgXmq1sNaw7Pn74sCOeUn2UlgVU22vzqs767yfV5ahH/4ALCuiiJSBRN3B5yct pzo+ijo4GCp5ctNvrH/gbOeN4u3cOs38rv/7Cf8usmlv8tsqqWmgClgHAw4fei551Ypw TJifQTjmyHOqVvErEiTAbNvvGlQu8bvvAHzSPH1o9mZitizn2J9Nb2X9TeVEpJhutZek oH0A== 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=+jd4U7/A0qtxB/62Y20V/gk1Y4XdI3jkHh2RaPiXZ/I=; b=LwjCx80e9mY6oQdBDXqAB9w1SZQgpFFKfb+hZvV7cHsz2mqPGpfS1UacuEF2rV+jYy 202PPdNwgkzaSI03xDyUjIRMbAiqnppTUQ/zPkEcjcixWdMSvxqUabE9p946SJV3FKRy kJlR7KjA0V1SZA7WFjOA4fWcDh8Dwm/bxSoahnManV5Row9TJsI9jmCHSWw8xTEWyCJd 8ywPrGHIRlf3fhi4KOTBnaaROZP0LYNia2PnwQfkrNJRI1fxWKXaYkrG4nL6pDzDzPXI 7IPYIo9SvfV+Not9teUrXfkikL7GkfF+52bEQBGNuE0oW36/iHALe0P2sWVgQZS8qNP+ 3MKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=eGTMRMp8; 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 cw10-20020a170906c78a00b007416895306fsi550895ejb.645.2022.09.09.08.27.35; Fri, 09 Sep 2022 08:28:01 -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=eGTMRMp8; 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 S232033AbiIIOoM (ORCPT + 99 others); Fri, 9 Sep 2022 10:44:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232063AbiIIOoJ (ORCPT ); Fri, 9 Sep 2022 10:44:09 -0400 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 919E211779A; Fri, 9 Sep 2022 07:44:06 -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 A06C0204A5BC; Fri, 9 Sep 2022 07:44:05 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com A06C0204A5BC DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1662734645; bh=+jd4U7/A0qtxB/62Y20V/gk1Y4XdI3jkHh2RaPiXZ/I=; h=From:To:Subject:Date:From; b=eGTMRMp8N6BQf1LZnHUksGbEsFeDg2LsXJlo2WWvaGu0g6eym7kXlAd3Nqs+Si5co JK4nZmY4L9WvZAVGFMaVHUfvRU2TYVnjYMhre2OLj8GcgfWC14dO2TbD4FJJn+zo1B DaKBbAZqGbYZYmLirrHUdVQ0Kmkd/BzmwHVXU3cM= 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, mikelley@microsoft.com Subject: [PATCH] drm/hyperv: Don't rely on screen_info.lfb_base for Gen1 VMs Date: Fri, 9 Sep 2022 07:43:59 -0700 Message-Id: <1662734639-27164-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 hyperv_setup_vram tries to remove conflicting framebuffer based on 'screen_info'. As observed in past due to some bug or wrong setting in grub, the 'screen_info' fields may not be set for Gen1, and in such cases drm_aperture_remove_conflicting_framebuffers will not do anything useful. For Gen1 VMs, it should always be possible to get framebuffer conflict removed using PCI device instead. Fixes: a0ab5abced55 ("drm/hyperv : Removing the restruction of VRAM allocation with PCI bar size") Signed-off-by: Saurabh Sengar --- drivers/gpu/drm/hyperv/hyperv_drm_drv.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/hyperv/hyperv_drm_drv.c b/drivers/gpu/drm/hyperv/hyperv_drm_drv.c index 6d11e7938c83..b0cc974efa45 100644 --- a/drivers/gpu/drm/hyperv/hyperv_drm_drv.c +++ b/drivers/gpu/drm/hyperv/hyperv_drm_drv.c @@ -73,12 +73,28 @@ static int hyperv_setup_vram(struct hyperv_drm_device *hv, struct hv_device *hdev) { struct drm_device *dev = &hv->dev; + struct pci_dev *pdev; int ret; - drm_aperture_remove_conflicting_framebuffers(screen_info.lfb_base, - screen_info.lfb_size, - false, - &hyperv_driver); + if (efi_enabled(EFI_BOOT)) { + drm_aperture_remove_conflicting_framebuffers(screen_info.lfb_base, + screen_info.lfb_size, + false, + &hyperv_driver); + } 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; + } + + ret = drm_aperture_remove_conflicting_pci_framebuffers(pdev, &hyperv_driver); + pci_dev_put(pdev); + if (ret) { + drm_err(dev, "Not able to remove boot fb\n"); + return ret; + } + } hv->fb_size = (unsigned long)hv->mmio_megabytes * 1024 * 1024; -- 2.34.1