Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp4343216rwn; Sun, 11 Sep 2022 09:56:17 -0700 (PDT) X-Google-Smtp-Source: AA6agR6Frs8RLsSo1j6RrbibpKTPtRfOn7SToV2vkDp13sEpcfFzzwZV0xsrrpE5kUgZaP1QxD8X X-Received: by 2002:a17:907:8a14:b0:731:2198:627b with SMTP id sc20-20020a1709078a1400b007312198627bmr16601197ejc.635.1662915377430; Sun, 11 Sep 2022 09:56:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662915377; cv=none; d=google.com; s=arc-20160816; b=WjSJ2ukZHeh77CGTpEVtv/fa+u0mM19X9QOceGAqLaHErev4cf57/uLYUGYYXnt/n8 1dCheAHefRNCJw5ta8CGrDpaufbpzuBCVHjjs3BBII4x/GpfIkxA2GdUub07tMPFZiAE gGDmwMlzge5695a0sUXQ6CiTObE663tjiDrOlTcU7DLSf6N0BnezEV0KFqWanWsTLRiW XSgT5OxaNNj9rEh/v5j/uxaX8E5KLHOQvetQb0KPlHIiWzz/cwNPXso1jwwcIeLo8eTh WyW+nzOsMtYzu8r1oLxXpCkN3cOCsnhWUyJ/PH+HPYjMuPjo56KVFdTss60owVoQ60G1 gNeg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:dkim-filter; bh=Z4QMTDUS2dSBcOU+9vvtM4dEnmR8yddlU4SZvyzFekg=; b=J019pgocW421sVeR6Qg7Z+hY3p3Qi148It7diKRH9Hsp31Pm77TDkb2JaCGthKrBpO nHE19LJJRXfLT/W///oy7iLXITWjb8S/nENVP6s5CMGeTh4dyy3E3Wao7HjJsPRnUlEO UuiCMuE9IKoRQMdVVEpclYAq3a77SPuWQlJrrJAs8tWD4Kp+oCPnI2WN7L1YdJ8SwiRs hBoxehocpegeYhngzp32c1VE98g6AI0Z1iXjz1N7mXbtUGG0hCQCn30flCUQFVzouoZD IRDokokJXo86j+lDbY4c3krcrufDr6Qek2hYkni4vRFg4bP3qhGsQHRHBdqpjla3gmHq iBVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=MyEWnvVu; 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 q18-20020a50cc92000000b0044785ed87d7si5075518edi.404.2022.09.11.09.55.52; Sun, 11 Sep 2022 09:56:17 -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=MyEWnvVu; 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 S229767AbiIKQWC (ORCPT + 99 others); Sun, 11 Sep 2022 12:22:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229593AbiIKQVU (ORCPT ); Sun, 11 Sep 2022 12:21:20 -0400 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E176713F3C; Sun, 11 Sep 2022 09:21:19 -0700 (PDT) Received: by linux.microsoft.com (Postfix, from userid 1127) id A2339204CA0B; Sun, 11 Sep 2022 09:21:19 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com A2339204CA0B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1662913279; bh=Z4QMTDUS2dSBcOU+9vvtM4dEnmR8yddlU4SZvyzFekg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=MyEWnvVu3dsnLw8poRMoSa6YY4x+ckJRSbanuAxolY57UgncQ/5UQ+l9jr53JK81v PIs46XiNi9Hg4WrlJ7w36VjWdXmy/ggnXWlBEbl/RvVoo5lnBVOAWWyA9wZc7XSdvq zsKLYL5uvtfx38ZTYt18HPcGhzmKMTFf0FFo+8Sc= Date: Sun, 11 Sep 2022 09:21:19 -0700 From: Saurabh Singh Sengar To: Thomas Zimmermann Cc: 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: Re: [PATCH] drm/hyperv: Don't rely on screen_info.lfb_base for Gen1 VMs Message-ID: <20220911162119.GB7754@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> References: <1662734639-27164-1-git-send-email-ssengar@linux.microsoft.com> <14302178-c797-8635-4325-070f78b7f805@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <14302178-c797-8635-4325-070f78b7f805@suse.de> User-Agent: Mutt/1.5.21 (2010-09-15) 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 On Sat, Sep 10, 2022 at 08:11:24PM +0200, Thomas Zimmermann wrote: > Hi > > Am 09.09.22 um 16:43 schrieb Saurabh Sengar: > >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, > > Using screen_info here seems wrong in any case. You want to remove > the framebuffer devices that conflict with your driver, which might > be unrelated to screen_info. AFAICT the correct solution would > always retrieve the PCI device for removal (i.e., always do the else > branch). In a Gen2 VM, the Hyper-V frame buffer device is presented only as a VMbus device. It's not presented as a PCI device like it is in a Gen1 VM. This would have worked if we had the frame buffer device available as PCI device in Gen2 but unfortunately thats not the case here. Regards, Saurabh > > Best regard > Thomas > > >+ 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; > > -- > Thomas Zimmermann > Graphics Driver Developer > SUSE Software Solutions Germany GmbH > Maxfeldstr. 5, 90409 N?rnberg, Germany > (HRB 36809, AG N?rnberg) > Gesch?ftsf?hrer: Ivo Totev