Message ID | 20221024112935.205547130@linuxfoundation.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp392326wru; Mon, 24 Oct 2022 04:35:06 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6GyPyUZV3IXhL6DyLjb2wj0ZSUSEWI0hJY+tQNKbiNL5Ikx+SF8aPKygjKNQ4PArqxaGVc X-Received: by 2002:a17:906:8a4b:b0:7a7:3e17:7f91 with SMTP id gx11-20020a1709068a4b00b007a73e177f91mr4719313ejc.331.1666611305884; Mon, 24 Oct 2022 04:35:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666611305; cv=none; d=google.com; s=arc-20160816; b=R6nrDhLTpe/zla0nWwTGFVcXuylzwS9zgjkaN38+A1Bt3iUCGzrZF5YzEcgSGCOl7f mbj6KXnwdITZ8ueR+ixR1zkFAPmjqH7tgBI4yM1i0acFKS4IapvQcU1mxs1hUlqvuG0X 5IJYBqWJ/FViqyMpf2ebYKUTVr8Al/gPylpltb9hHXfKyOvDWPxULe5vQn1aa8rfBs+M RXx3eTcZyDfpFrJ/EozZYvyj30YVwUIhpo8paCk64b/Y55blDllh3z60IRhbubM1tSbG KFXASgfCTZ/unlml8QzgM7XEe2ONZXKv6Xdq7aM7iLNq5JkgDThnkvnGfSNz4Qo5sx7I AoBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=N78nEbmFZ74tmTCM0GauoHq5KO+7EFPw1GirhmSppMo=; b=QI6Vb1tJ8tSagb6QkAiRZpAd35t2yQTEUNuBmHP6rJsiqJnUGTpFSrHf20tzcjZcGC 44hroyrLYbSmXcaUJhgFO/DOhoS3HoatyWmq8Dwh1LgG8mHxR6AE8wy7Lq9+pTPl2LW9 XDmbd3SQI0eNgNxf/GuCY0SIMxbcy+uTlZwTSgH8x0Iza5XjAFk9XCfCppOWLHrR2XvE QRHFYN/yRx7+2ALLz9H29p/ejU/XuT9BrmGW61G64N+ecfVZQ1A9R+SLh5DAIb81ERt/ LTqQp0uFxxRqup7+8Ybe8W4dM6+kkHLViBom1+RpOksi5BerGh5Mxd5nZIB8PSZ3CXZS XaAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=bDIs9f3r; 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=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ga8-20020a1709070c0800b0077a5733ac08si18201761ejc.601.2022.10.24.04.34.42; Mon, 24 Oct 2022 04:35:05 -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=@linuxfoundation.org header.s=korg header.b=bDIs9f3r; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229572AbiJXLcz (ORCPT <rfc822;pwkd43@gmail.com> + 99 others); Mon, 24 Oct 2022 07:32:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230358AbiJXLcc (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 24 Oct 2022 07:32:32 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 044045FC2C; Mon, 24 Oct 2022 04:32:14 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8618861268; Mon, 24 Oct 2022 11:32:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9612AC433C1; Mon, 24 Oct 2022 11:32:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666611131; bh=nbjQeXROngc2BgaLrDgQ8Atv+F63c5SSrmNcFzJYIyQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bDIs9f3rwV76RQkEpCn/4z0WliVVH3ZF1FzRZO0ATjnXap3BKtKLouxaHcpR5FnK8 F/FGm7aHBUaPsmzYfmzCVh5ZUWveWdhG8hR/N372mZpTF8Hasp04xivgFGFAautfCd ev54IFWdaU/4LF7xr9pQdIh4aR6RTCUb/15nmVSw= From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>, stable@vger.kernel.org, Thomas Zimmermann <tzimmermann@suse.de>, Javier Martinez Canillas <javierm@redhat.com> Subject: [PATCH 6.0 20/20] fbdev/core: Remove remove_conflicting_pci_framebuffers() Date: Mon, 24 Oct 2022 13:31:22 +0200 Message-Id: <20221024112935.205547130@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024112934.415391158@linuxfoundation.org> References: <20221024112934.415391158@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747568616597312213?= X-GMAIL-MSGID: =?utf-8?q?1747568616597312213?= |
Series |
None
|
|
Commit Message
Greg KH
Oct. 24, 2022, 11:31 a.m. UTC
From: Thomas Zimmermann <tzimmermann@suse.de> commit 9d69ef1838150c7d87afc1a87aa658c637217585 upstream. Remove remove_conflicting_pci_framebuffers() and implement similar functionality in aperture_remove_conflicting_pci_device(), which was the only caller. Removes an otherwise unused interface and streamlines the aperture helper. No functional changes. Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com> Link: https://patchwork.freedesktop.org/patch/msgid/20220718072322.8927-5-tzimmermann@suse.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> --- drivers/video/aperture.c | 30 ++++++++++++++---------- drivers/video/fbdev/core/fbmem.c | 48 --------------------------------------- include/linux/fb.h | 2 - 3 files changed, 18 insertions(+), 62 deletions(-)
Comments
On 24/10/2022 13:31, Greg Kroah-Hartman wrote: > From: Thomas Zimmermann <tzimmermann@suse.de> > > commit 9d69ef1838150c7d87afc1a87aa658c637217585 upstream. > > Remove remove_conflicting_pci_framebuffers() and implement similar > functionality in aperture_remove_conflicting_pci_device(), which was > the only caller. Removes an otherwise unused interface and streamlines > the aperture helper. No functional changes. > > Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> > Reviewed-by: Javier Martinez Canillas <javierm@redhat.com> > Link: https://patchwork.freedesktop.org/patch/msgid/20220718072322.8927-5-tzimmermann@suse.de > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> > --- > drivers/video/aperture.c | 30 ++++++++++++++---------- > drivers/video/fbdev/core/fbmem.c | 48 --------------------------------------- > include/linux/fb.h | 2 - > 3 files changed, 18 insertions(+), 62 deletions(-) > > --- a/drivers/video/aperture.c > +++ b/drivers/video/aperture.c > @@ -335,30 +335,36 @@ EXPORT_SYMBOL(aperture_remove_conflictin > */ > int aperture_remove_conflicting_pci_devices(struct pci_dev *pdev, const char *name) > { > + bool primary = false; > resource_size_t base, size; > int bar, ret; > > - /* > - * WARNING: Apparently we must kick fbdev drivers before vgacon, > - * otherwise the vga fbdev driver falls over. > - */ > -#if IS_REACHABLE(CONFIG_FB) > - ret = remove_conflicting_pci_framebuffers(pdev, name); > - if (ret) > - return ret; > +#ifdef CONFIG_X86 > + primary = pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW; > #endif > - ret = vga_remove_vgacon(pdev); > - if (ret) > - return ret; > > for (bar = 0; bar < PCI_STD_NUM_BARS; ++bar) { > if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM)) > continue; > + > base = pci_resource_start(pdev, bar); > size = pci_resource_len(pdev, bar); > - aperture_detach_devices(base, size); > + ret = aperture_remove_conflicting_devices(base, size, primary, name); > + if (ret) > + break; > } > > + if (ret) > + return ret; > + > + /* > + * WARNING: Apparently we must kick fbdev drivers before vgacon, > + * otherwise the vga fbdev driver falls over. > + */ > + ret = vga_remove_vgacon(pdev); > + if (ret) > + return ret; > + > return 0; > > } > --- a/drivers/video/fbdev/core/fbmem.c > +++ b/drivers/video/fbdev/core/fbmem.c > @@ -1788,54 +1788,6 @@ int remove_conflicting_framebuffers(stru > EXPORT_SYMBOL(remove_conflicting_framebuffers); > > /** > - * remove_conflicting_pci_framebuffers - remove firmware-configured framebuffers for PCI devices > - * @pdev: PCI device > - * @name: requesting driver name > - * > - * This function removes framebuffer devices (eg. initialized by firmware) > - * using memory range configured for any of @pdev's memory bars. > - * > - * The function assumes that PCI device with shadowed ROM drives a primary > - * display and so kicks out vga16fb. > - */ > -int remove_conflicting_pci_framebuffers(struct pci_dev *pdev, const char *name) > -{ > - struct apertures_struct *ap; > - bool primary = false; > - int err, idx, bar; > - > - for (idx = 0, bar = 0; bar < PCI_STD_NUM_BARS; bar++) { > - if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM)) > - continue; > - idx++; > - } > - > - ap = alloc_apertures(idx); > - if (!ap) > - return -ENOMEM; > - > - for (idx = 0, bar = 0; bar < PCI_STD_NUM_BARS; bar++) { > - if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM)) > - continue; > - ap->ranges[idx].base = pci_resource_start(pdev, bar); > - ap->ranges[idx].size = pci_resource_len(pdev, bar); > - pci_dbg(pdev, "%s: bar %d: 0x%lx -> 0x%lx\n", __func__, bar, > - (unsigned long)pci_resource_start(pdev, bar), > - (unsigned long)pci_resource_end(pdev, bar)); > - idx++; > - } > - > -#ifdef CONFIG_X86 > - primary = pdev->resource[PCI_ROM_RESOURCE].flags & > - IORESOURCE_ROM_SHADOW; > -#endif > - err = remove_conflicting_framebuffers(ap, name, primary); > - kfree(ap); > - return err; > -} > -EXPORT_SYMBOL(remove_conflicting_pci_framebuffers); > - > -/** > * register_framebuffer - registers a frame buffer device > * @fb_info: frame buffer info structure > * > --- a/include/linux/fb.h > +++ b/include/linux/fb.h > @@ -615,8 +615,6 @@ extern ssize_t fb_sys_write(struct fb_in > /* drivers/video/fbmem.c */ > extern int register_framebuffer(struct fb_info *fb_info); > extern void unregister_framebuffer(struct fb_info *fb_info); > -extern int remove_conflicting_pci_framebuffers(struct pci_dev *pdev, > - const char *name); > extern int remove_conflicting_framebuffers(struct apertures_struct *a, > const char *name, bool primary); > extern int fb_prepare_logo(struct fb_info *fb_info, int rotate); > > > > Hello, this patch seems to disable console/framebuffer when vfio-pci is used. I hava 2 nvidia GPUs one is used for host and other is passed through to VM. Now after this patch, when vfio-pci module is loaded with parameter ids=10de:2486,10de:228b, console is lost/frozen, last message is that vfio-pci module was loaded and then there is no more output. This PCI IDs (10de:2486,10de:228b) are for secondary GPU, primary/boot GPU is used for host and boot messages are displayed on primary/boot GPU. Using dmesg I see this messages after vfio-pci is loaded: [ 3.993601] VFIO - User Level meta-driver version: 0.3 [ 4.020239] Console: switching to colour dummy device 80x25 [ 4.020335] vfio-pci 0000:1a:00.0: vgaarb: changed VGA decodes: olddecodes=io+mem,decodes=none:owns=none [ 4.020722] vfio_pci: add [10de:2486[ffffffff:ffffffff]] class 0x000000/00000000 [ 4.116616] vfio_pci: add [10de:228b[ffffffff:ffffffff]] class 0x000000/00000000 I guess the problem here is "Console: switching to colour dummy device 80x25", but I don't know why this happens. Last working kernel is 6.0.3, after upgrading to 6.0.4 (and 6.0.5, 6.0.6), console is no longer working. By git bisecting it seems bad commit is af9ac541e88390d97b01d5e8c77309d2637c1d4c.
(cc: Alex Williamson) Hi Am 01.11.22 um 09:42 schrieb Boris V.: > On 24/10/2022 13:31, Greg Kroah-Hartman wrote: >> From: Thomas Zimmermann <tzimmermann@suse.de> >> >> commit 9d69ef1838150c7d87afc1a87aa658c637217585 upstream. >> >> Remove remove_conflicting_pci_framebuffers() and implement similar >> functionality in aperture_remove_conflicting_pci_device(), which was >> the only caller. Removes an otherwise unused interface and streamlines >> the aperture helper. No functional changes. >> >> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> >> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com> >> Link: >> https://patchwork.freedesktop.org/patch/msgid/20220718072322.8927-5-tzimmermann@suse.de >> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> >> --- >> drivers/video/aperture.c | 30 ++++++++++++++---------- >> drivers/video/fbdev/core/fbmem.c | 48 >> --------------------------------------- >> include/linux/fb.h | 2 - >> 3 files changed, 18 insertions(+), 62 deletions(-) >> >> --- a/drivers/video/aperture.c >> +++ b/drivers/video/aperture.c >> @@ -335,30 +335,36 @@ EXPORT_SYMBOL(aperture_remove_conflictin >> */ >> int aperture_remove_conflicting_pci_devices(struct pci_dev *pdev, >> const char *name) >> { >> + bool primary = false; >> resource_size_t base, size; >> int bar, ret; >> - /* >> - * WARNING: Apparently we must kick fbdev drivers before vgacon, >> - * otherwise the vga fbdev driver falls over. >> - */ >> -#if IS_REACHABLE(CONFIG_FB) >> - ret = remove_conflicting_pci_framebuffers(pdev, name); >> - if (ret) >> - return ret; >> +#ifdef CONFIG_X86 >> + primary = pdev->resource[PCI_ROM_RESOURCE].flags & >> IORESOURCE_ROM_SHADOW; >> #endif >> - ret = vga_remove_vgacon(pdev); >> - if (ret) >> - return ret; >> for (bar = 0; bar < PCI_STD_NUM_BARS; ++bar) { >> if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM)) >> continue; >> + >> base = pci_resource_start(pdev, bar); >> size = pci_resource_len(pdev, bar); >> - aperture_detach_devices(base, size); >> + ret = aperture_remove_conflicting_devices(base, size, >> primary, name); >> + if (ret) >> + break; >> } >> + if (ret) >> + return ret; >> + >> + /* >> + * WARNING: Apparently we must kick fbdev drivers before vgacon, >> + * otherwise the vga fbdev driver falls over. >> + */ >> + ret = vga_remove_vgacon(pdev); >> + if (ret) >> + return ret; >> + >> return 0; >> } >> --- a/drivers/video/fbdev/core/fbmem.c >> +++ b/drivers/video/fbdev/core/fbmem.c >> @@ -1788,54 +1788,6 @@ int remove_conflicting_framebuffers(stru >> EXPORT_SYMBOL(remove_conflicting_framebuffers); >> /** >> - * remove_conflicting_pci_framebuffers - remove firmware-configured >> framebuffers for PCI devices >> - * @pdev: PCI device >> - * @name: requesting driver name >> - * >> - * This function removes framebuffer devices (eg. initialized by >> firmware) >> - * using memory range configured for any of @pdev's memory bars. >> - * >> - * The function assumes that PCI device with shadowed ROM drives a >> primary >> - * display and so kicks out vga16fb. >> - */ >> -int remove_conflicting_pci_framebuffers(struct pci_dev *pdev, const >> char *name) >> -{ >> - struct apertures_struct *ap; >> - bool primary = false; >> - int err, idx, bar; >> - >> - for (idx = 0, bar = 0; bar < PCI_STD_NUM_BARS; bar++) { >> - if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM)) >> - continue; >> - idx++; >> - } >> - >> - ap = alloc_apertures(idx); >> - if (!ap) >> - return -ENOMEM; >> - >> - for (idx = 0, bar = 0; bar < PCI_STD_NUM_BARS; bar++) { >> - if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM)) >> - continue; >> - ap->ranges[idx].base = pci_resource_start(pdev, bar); >> - ap->ranges[idx].size = pci_resource_len(pdev, bar); >> - pci_dbg(pdev, "%s: bar %d: 0x%lx -> 0x%lx\n", __func__, bar, >> - (unsigned long)pci_resource_start(pdev, bar), >> - (unsigned long)pci_resource_end(pdev, bar)); >> - idx++; >> - } >> - >> -#ifdef CONFIG_X86 >> - primary = pdev->resource[PCI_ROM_RESOURCE].flags & >> - IORESOURCE_ROM_SHADOW; >> -#endif >> - err = remove_conflicting_framebuffers(ap, name, primary); >> - kfree(ap); >> - return err; >> -} >> -EXPORT_SYMBOL(remove_conflicting_pci_framebuffers); >> - >> -/** >> * register_framebuffer - registers a frame buffer device >> * @fb_info: frame buffer info structure >> * >> --- a/include/linux/fb.h >> +++ b/include/linux/fb.h >> @@ -615,8 +615,6 @@ extern ssize_t fb_sys_write(struct fb_in >> /* drivers/video/fbmem.c */ >> extern int register_framebuffer(struct fb_info *fb_info); >> extern void unregister_framebuffer(struct fb_info *fb_info); >> -extern int remove_conflicting_pci_framebuffers(struct pci_dev *pdev, >> - const char *name); >> extern int remove_conflicting_framebuffers(struct apertures_struct *a, >> const char *name, bool primary); >> extern int fb_prepare_logo(struct fb_info *fb_info, int rotate); >> >> >> >> > > Hello, > > this patch seems to disable console/framebuffer when vfio-pci is used. > I hava 2 nvidia GPUs one is used for host and other is passed through to > VM. Vfio uses this helper to unload the driver before passing it to a VM AFAIU. But unless you're using nouveau, you're on your own. Best regards Thomas > Now after this patch, when vfio-pci module is loaded with parameter > ids=10de:2486,10de:228b, > console is lost/frozen, last message is that vfio-pci module was loaded > and then there is no more output. > This PCI IDs (10de:2486,10de:228b) are for secondary GPU, primary/boot > GPU is used for host and boot messages are displayed on primary/boot GPU. > > Using dmesg I see this messages after vfio-pci is loaded: > > [ 3.993601] VFIO - User Level meta-driver version: 0.3 > [ 4.020239] Console: switching to colour dummy device 80x25 > [ 4.020335] vfio-pci 0000:1a:00.0: vgaarb: changed VGA decodes: > olddecodes=io+mem,decodes=none:owns=none > [ 4.020722] vfio_pci: add [10de:2486[ffffffff:ffffffff]] class > 0x000000/00000000 > [ 4.116616] vfio_pci: add [10de:228b[ffffffff:ffffffff]] class > 0x000000/00000000 > > I guess the problem here is "Console: switching to colour dummy device > 80x25", but I don't know why this happens. > Last working kernel is 6.0.3, after upgrading to 6.0.4 (and 6.0.5, > 6.0.6), console is no longer working. > By git bisecting it seems bad commit is > af9ac541e88390d97b01d5e8c77309d2637c1d4c. > -- 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
On 01/11/2022 11:34, Thomas Zimmermann wrote: > (cc: Alex Williamson) > > Hi > > Am 01.11.22 um 09:42 schrieb Boris V.: >> On 24/10/2022 13:31, Greg Kroah-Hartman wrote: >>> From: Thomas Zimmermann <tzimmermann@suse.de> >>> >>> commit 9d69ef1838150c7d87afc1a87aa658c637217585 upstream. >>> >>> Remove remove_conflicting_pci_framebuffers() and implement similar >>> functionality in aperture_remove_conflicting_pci_device(), which was >>> the only caller. Removes an otherwise unused interface and streamlines >>> the aperture helper. No functional changes. >>> >>> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> >>> Reviewed-by: Javier Martinez Canillas <javierm@redhat.com> >>> Link: >>> https://patchwork.freedesktop.org/patch/msgid/20220718072322.8927-5-tzimmermann@suse.de >>> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> >>> --- >>> drivers/video/aperture.c | 30 ++++++++++++++---------- >>> drivers/video/fbdev/core/fbmem.c | 48 >>> --------------------------------------- >>> include/linux/fb.h | 2 - >>> 3 files changed, 18 insertions(+), 62 deletions(-) >>> >>> --- a/drivers/video/aperture.c >>> +++ b/drivers/video/aperture.c >>> @@ -335,30 +335,36 @@ EXPORT_SYMBOL(aperture_remove_conflictin >>> */ >>> int aperture_remove_conflicting_pci_devices(struct pci_dev *pdev, >>> const char *name) >>> { >>> + bool primary = false; >>> resource_size_t base, size; >>> int bar, ret; >>> - /* >>> - * WARNING: Apparently we must kick fbdev drivers before vgacon, >>> - * otherwise the vga fbdev driver falls over. >>> - */ >>> -#if IS_REACHABLE(CONFIG_FB) >>> - ret = remove_conflicting_pci_framebuffers(pdev, name); >>> - if (ret) >>> - return ret; >>> +#ifdef CONFIG_X86 >>> + primary = pdev->resource[PCI_ROM_RESOURCE].flags & >>> IORESOURCE_ROM_SHADOW; >>> #endif >>> - ret = vga_remove_vgacon(pdev); >>> - if (ret) >>> - return ret; >>> for (bar = 0; bar < PCI_STD_NUM_BARS; ++bar) { >>> if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM)) >>> continue; >>> + >>> base = pci_resource_start(pdev, bar); >>> size = pci_resource_len(pdev, bar); >>> - aperture_detach_devices(base, size); >>> + ret = aperture_remove_conflicting_devices(base, size, >>> primary, name); >>> + if (ret) >>> + break; >>> } >>> + if (ret) >>> + return ret; >>> + >>> + /* >>> + * WARNING: Apparently we must kick fbdev drivers before vgacon, >>> + * otherwise the vga fbdev driver falls over. >>> + */ >>> + ret = vga_remove_vgacon(pdev); >>> + if (ret) >>> + return ret; >>> + >>> return 0; >>> } >>> --- a/drivers/video/fbdev/core/fbmem.c >>> +++ b/drivers/video/fbdev/core/fbmem.c >>> @@ -1788,54 +1788,6 @@ int remove_conflicting_framebuffers(stru >>> EXPORT_SYMBOL(remove_conflicting_framebuffers); >>> /** >>> - * remove_conflicting_pci_framebuffers - remove firmware-configured >>> framebuffers for PCI devices >>> - * @pdev: PCI device >>> - * @name: requesting driver name >>> - * >>> - * This function removes framebuffer devices (eg. initialized by >>> firmware) >>> - * using memory range configured for any of @pdev's memory bars. >>> - * >>> - * The function assumes that PCI device with shadowed ROM drives a >>> primary >>> - * display and so kicks out vga16fb. >>> - */ >>> -int remove_conflicting_pci_framebuffers(struct pci_dev *pdev, const >>> char *name) >>> -{ >>> - struct apertures_struct *ap; >>> - bool primary = false; >>> - int err, idx, bar; >>> - >>> - for (idx = 0, bar = 0; bar < PCI_STD_NUM_BARS; bar++) { >>> - if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM)) >>> - continue; >>> - idx++; >>> - } >>> - >>> - ap = alloc_apertures(idx); >>> - if (!ap) >>> - return -ENOMEM; >>> - >>> - for (idx = 0, bar = 0; bar < PCI_STD_NUM_BARS; bar++) { >>> - if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM)) >>> - continue; >>> - ap->ranges[idx].base = pci_resource_start(pdev, bar); >>> - ap->ranges[idx].size = pci_resource_len(pdev, bar); >>> - pci_dbg(pdev, "%s: bar %d: 0x%lx -> 0x%lx\n", __func__, bar, >>> - (unsigned long)pci_resource_start(pdev, bar), >>> - (unsigned long)pci_resource_end(pdev, bar)); >>> - idx++; >>> - } >>> - >>> -#ifdef CONFIG_X86 >>> - primary = pdev->resource[PCI_ROM_RESOURCE].flags & >>> - IORESOURCE_ROM_SHADOW; >>> -#endif >>> - err = remove_conflicting_framebuffers(ap, name, primary); >>> - kfree(ap); >>> - return err; >>> -} >>> -EXPORT_SYMBOL(remove_conflicting_pci_framebuffers); >>> - >>> -/** >>> * register_framebuffer - registers a frame buffer device >>> * @fb_info: frame buffer info structure >>> * >>> --- a/include/linux/fb.h >>> +++ b/include/linux/fb.h >>> @@ -615,8 +615,6 @@ extern ssize_t fb_sys_write(struct fb_in >>> /* drivers/video/fbmem.c */ >>> extern int register_framebuffer(struct fb_info *fb_info); >>> extern void unregister_framebuffer(struct fb_info *fb_info); >>> -extern int remove_conflicting_pci_framebuffers(struct pci_dev *pdev, >>> - const char *name); >>> extern int remove_conflicting_framebuffers(struct apertures_struct >>> *a, >>> const char *name, bool primary); >>> extern int fb_prepare_logo(struct fb_info *fb_info, int rotate); >>> >>> >>> >>> >> >> Hello, >> >> this patch seems to disable console/framebuffer when vfio-pci is used. >> I hava 2 nvidia GPUs one is used for host and other is passed through >> to VM. > > Vfio uses this helper to unload the driver before passing it to a VM > AFAIU. But unless you're using nouveau, you're on your own. > > Best regards > Thomas > But this happens at boot, when vfio-pci module is loaded. Not when VM is started. And console/framebuffer is unloaded for primary/boot GPU, not the one passed to VM. Also no GPU driver is loaded at this point. And there was no problem before, it stopped working with 6.0.4 kernel.
--- a/drivers/video/aperture.c +++ b/drivers/video/aperture.c @@ -335,30 +335,36 @@ EXPORT_SYMBOL(aperture_remove_conflictin */ int aperture_remove_conflicting_pci_devices(struct pci_dev *pdev, const char *name) { + bool primary = false; resource_size_t base, size; int bar, ret; - /* - * WARNING: Apparently we must kick fbdev drivers before vgacon, - * otherwise the vga fbdev driver falls over. - */ -#if IS_REACHABLE(CONFIG_FB) - ret = remove_conflicting_pci_framebuffers(pdev, name); - if (ret) - return ret; +#ifdef CONFIG_X86 + primary = pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW; #endif - ret = vga_remove_vgacon(pdev); - if (ret) - return ret; for (bar = 0; bar < PCI_STD_NUM_BARS; ++bar) { if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM)) continue; + base = pci_resource_start(pdev, bar); size = pci_resource_len(pdev, bar); - aperture_detach_devices(base, size); + ret = aperture_remove_conflicting_devices(base, size, primary, name); + if (ret) + break; } + if (ret) + return ret; + + /* + * WARNING: Apparently we must kick fbdev drivers before vgacon, + * otherwise the vga fbdev driver falls over. + */ + ret = vga_remove_vgacon(pdev); + if (ret) + return ret; + return 0; } --- a/drivers/video/fbdev/core/fbmem.c +++ b/drivers/video/fbdev/core/fbmem.c @@ -1788,54 +1788,6 @@ int remove_conflicting_framebuffers(stru EXPORT_SYMBOL(remove_conflicting_framebuffers); /** - * remove_conflicting_pci_framebuffers - remove firmware-configured framebuffers for PCI devices - * @pdev: PCI device - * @name: requesting driver name - * - * This function removes framebuffer devices (eg. initialized by firmware) - * using memory range configured for any of @pdev's memory bars. - * - * The function assumes that PCI device with shadowed ROM drives a primary - * display and so kicks out vga16fb. - */ -int remove_conflicting_pci_framebuffers(struct pci_dev *pdev, const char *name) -{ - struct apertures_struct *ap; - bool primary = false; - int err, idx, bar; - - for (idx = 0, bar = 0; bar < PCI_STD_NUM_BARS; bar++) { - if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM)) - continue; - idx++; - } - - ap = alloc_apertures(idx); - if (!ap) - return -ENOMEM; - - for (idx = 0, bar = 0; bar < PCI_STD_NUM_BARS; bar++) { - if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM)) - continue; - ap->ranges[idx].base = pci_resource_start(pdev, bar); - ap->ranges[idx].size = pci_resource_len(pdev, bar); - pci_dbg(pdev, "%s: bar %d: 0x%lx -> 0x%lx\n", __func__, bar, - (unsigned long)pci_resource_start(pdev, bar), - (unsigned long)pci_resource_end(pdev, bar)); - idx++; - } - -#ifdef CONFIG_X86 - primary = pdev->resource[PCI_ROM_RESOURCE].flags & - IORESOURCE_ROM_SHADOW; -#endif - err = remove_conflicting_framebuffers(ap, name, primary); - kfree(ap); - return err; -} -EXPORT_SYMBOL(remove_conflicting_pci_framebuffers); - -/** * register_framebuffer - registers a frame buffer device * @fb_info: frame buffer info structure * --- a/include/linux/fb.h +++ b/include/linux/fb.h @@ -615,8 +615,6 @@ extern ssize_t fb_sys_write(struct fb_in /* drivers/video/fbmem.c */ extern int register_framebuffer(struct fb_info *fb_info); extern void unregister_framebuffer(struct fb_info *fb_info); -extern int remove_conflicting_pci_framebuffers(struct pci_dev *pdev, - const char *name); extern int remove_conflicting_framebuffers(struct apertures_struct *a, const char *name, bool primary); extern int fb_prepare_logo(struct fb_info *fb_info, int rotate);