From patchwork Wed Jul 19 12:39:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 13318932 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B4967EB64DA for ; Wed, 19 Jul 2023 12:41:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=exkWgSGSe006ohG6lqAInwuxIR/oDq43C/kZBZ+xvmk=; b=pSR4XlLINBGlYe VX02jweVzqTTSOnf+a2MzE0z9D/vp2wsGKNk/fF6xF7djxIv7JOinMjTcuWKDucl/pBkLGpS623u/ r20X8H1hSqPG7Xqu9K3KFu3BgBonkrcKp1nCGmElndh5gaRMEW0ByjHaw1fqM99lf1n6qoSbM+yxT F7A/gY6+qOiex/nH3NktPrQPDj7EgPljYQQkOrtsmEYpJSdTUBdzBSVaSRAWMLAz130MyesTpMbW1 /Y1+1bUjApRBYGr0OJ7HAG6kzzNS3BtfKrKYGvOBTSMyLOIR2BLYN2KowlBgByLT7jVzqg+24Va34 ZwQ/sn8NCg01nl7428/A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qM6Uq-007RVZ-24; Wed, 19 Jul 2023 12:41:36 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qM6Un-007RTW-0T; Wed, 19 Jul 2023 12:41:34 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 9834960B5E; Wed, 19 Jul 2023 12:41:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 88321C43391; Wed, 19 Jul 2023 12:41:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689770491; bh=9fW6U6BHu4TUL4RWpVUJbdMggGEj9FTfMpLEh+DKB4A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bQx8YO5rdZGaGJpL2Tgt6DTW/RbyR/A8QofqucAc+4eXdqqSGZqRJ1SkbMDzh4BLI 2NLToZZIHIF9hyPL+Cyk9ib9veIe3JFCFQPNi1M5+29webS34B7tOY2yr6coi1kyR9 68cbQ5j1lku+Y3+WAYkMKAfJYmwUgtN18hZyJw7RPd8HjbKYCKDKOoyZuP0RMlDEPX GCkx3VMGRM6F3nmHYu2QILv1caInSzegNyJm5qhaqJg/HU5Vh3+s6GYahBrXTRz+u2 q5NpRtNW4/xAU+AMW7Nj2hyg2oXsH5ekaaNx3M1dPNTw9WEqMuc5GB/KyGcnL8ktIs NotTDXWPm4GSw== From: Arnd Bergmann To: linux-fbdev@vger.kernel.org, Thomas Zimmermann , Helge Deller , Javier Martinez Canillas Cc: Arnd Bergmann , "David S. Miller" , "K. Y. Srinivasan" , Ard Biesheuvel , Borislav Petkov , Brian Cain , Catalin Marinas , Christophe Leroy , Daniel Vetter , Dave Hansen , David Airlie , Deepak Rawat , Dexuan Cui , Dinh Nguyen , Greg Kroah-Hartman , Guo Ren , Haiyang Zhang , Huacai Chen , Ingo Molnar , John Paul Adrian Glaubitz , Khalid Aziz , Linus Walleij , Matt Turner , Max Filippov , Michael Ellerman , Nicholas Piggin , Palmer Dabbelt , Russell King , Thomas Bogendoerfer , Thomas Gleixner , WANG Xuerui , Wei Liu , Will Deacon , x86@kernel.org, linux-alpha@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-efi@vger.kernel.org, linux-csky@vger.kernel.org, linux-hexagon@vger.kernel.org, linux-ia64@vger.kernel.org, loongarch@lists.linux.dev, linux-mips@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-hyperv@vger.kernel.org, dri-devel@lists.freedesktop.org Subject: [PATCH v2 8/9] hyperv: avoid dependency on screen_info Date: Wed, 19 Jul 2023 14:39:43 +0200 Message-Id: <20230719123944.3438363-9-arnd@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230719123944.3438363-1-arnd@kernel.org> References: <20230719123944.3438363-1-arnd@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230719_054133_276693_9ED4E858 X-CRM114-Status: GOOD ( 20.12 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org From: Arnd Bergmann The two hyperv framebuffer drivers (hyperv_fb or hyperv_drm_drv) access the global screen_info in order to take over from the sysfb framebuffer, which in turn could be handled by simplefb, simpledrm or efifb. Similarly, the vmbus_drv code marks the original EFI framebuffer as reserved, but this is not required if there is no sysfb. As a preparation for making screen_info itself more local to the sysfb helper code, add a compile-time conditional in all three files that relate to hyperv fb and just skip this code if there is no sysfb that needs to be unregistered. Signed-off-by: Arnd Bergmann Reviewed-by: Javier Martinez Canillas --- drivers/gpu/drm/hyperv/hyperv_drm_drv.c | 7 ++++--- drivers/hv/vmbus_drv.c | 6 ++++-- drivers/video/fbdev/hyperv_fb.c | 8 ++++---- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/hyperv/hyperv_drm_drv.c b/drivers/gpu/drm/hyperv/hyperv_drm_drv.c index 8026118c6e033..9a44a00effc24 100644 --- a/drivers/gpu/drm/hyperv/hyperv_drm_drv.c +++ b/drivers/gpu/drm/hyperv/hyperv_drm_drv.c @@ -73,9 +73,10 @@ static int hyperv_setup_vram(struct hyperv_drm_device *hv, struct drm_device *dev = &hv->dev; int ret; - drm_aperture_remove_conflicting_framebuffers(screen_info.lfb_base, - screen_info.lfb_size, - &hyperv_driver); + if (IS_ENABLED(CONFIG_SYSFB)) + drm_aperture_remove_conflicting_framebuffers(screen_info.lfb_base, + screen_info.lfb_size, + &hyperv_driver); hv->fb_size = (unsigned long)hv->mmio_megabytes * 1024 * 1024; diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c index 67f95a29aeca5..5bc059e8a9f5f 100644 --- a/drivers/hv/vmbus_drv.c +++ b/drivers/hv/vmbus_drv.c @@ -2100,8 +2100,10 @@ static void __maybe_unused vmbus_reserve_fb(void) if (efi_enabled(EFI_BOOT)) { /* Gen2 VM: get FB base from EFI framebuffer */ - start = screen_info.lfb_base; - size = max_t(__u32, screen_info.lfb_size, 0x800000); + if (IS_ENABLED(CONFIG_SYSFB)) { + start = screen_info.lfb_base; + size = max_t(__u32, screen_info.lfb_size, 0x800000); + } } else { /* Gen1 VM: get FB base from PCI */ pdev = pci_get_device(PCI_VENDOR_ID_MICROSOFT, diff --git a/drivers/video/fbdev/hyperv_fb.c b/drivers/video/fbdev/hyperv_fb.c index b331452aab4fb..7e0d1c4235549 100644 --- a/drivers/video/fbdev/hyperv_fb.c +++ b/drivers/video/fbdev/hyperv_fb.c @@ -1030,7 +1030,7 @@ static int hvfb_getmem(struct hv_device *hdev, struct fb_info *info) goto getmem_done; } pr_info("Unable to allocate enough contiguous physical memory on Gen 1 VM. Using MMIO instead.\n"); - } else { + } else if (IS_ENABLED(CONFIG_SYSFB)) { base = screen_info.lfb_base; size = screen_info.lfb_size; } @@ -1076,13 +1076,13 @@ static int hvfb_getmem(struct hv_device *hdev, struct fb_info *info) getmem_done: aperture_remove_conflicting_devices(base, size, KBUILD_MODNAME); - if (gen2vm) { + if (!gen2vm) { + pci_dev_put(pdev); + } else if (IS_ENABLED(CONFIG_SYSFB)) { /* framebuffer is reallocated, clear screen_info to avoid misuse from kexec */ screen_info.lfb_size = 0; screen_info.lfb_base = 0; screen_info.orig_video_isVGA = 0; - } else { - pci_dev_put(pdev); } return 0;