From patchwork Thu Aug 30 21:00:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= X-Patchwork-Id: 10582837 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0B0B5174C for ; Thu, 30 Aug 2018 21:06:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EF83A2C290 for ; Thu, 30 Aug 2018 21:06:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E3DA02C31D; Thu, 30 Aug 2018 21:06:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7A7A62C290 for ; Thu, 30 Aug 2018 21:06:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727572AbeHaBKI (ORCPT ); Thu, 30 Aug 2018 21:10:08 -0400 Received: from 183.pool-64.klikom.net ([91.227.64.183]:29822 "EHLO rere.qmqm.pl" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1727539AbeHaBKH (ORCPT ); Thu, 30 Aug 2018 21:10:07 -0400 Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 421ZcJ5k6PzPw; Thu, 30 Aug 2018 22:59:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=rere.qmqm.pl; s=1; t=1535662768; bh=ESBT08hsjhHT/pxVjWanODu2HOO/rl+fiXFpoHNJd1Q=; h=Date:In-Reply-To:References:From:Subject:To:Cc:Cc:Cc:Cc:Cc:Cc:Cc: Cc:Cc:Cc:Cc:From; b=ZgWEm4s7KE6w0BvBgdKIm3fKf87nRu3P0eJrI+nfW9lImAXcS3rXSCXRzMy8jOPE7 31u85re5ImVHnaD4FcHeXKTCPl45wZJyO9kxZyeapXIOsvpkEtWZ0DHg3sckEd7z8O gW/U3d9plbgL0DAmSHpadj57RmCyip6wOFuy0ZPuWaSxOIOomjI2qj5PZhsVfbuXPh CaY/37oCPYX7hSHYI/gQmZdTSspWJiNZYQSF2b+Fk3CX+WQUx9+4jkT405Ihk6v6x0 IL+KTSdg5GWGam1ocDOKHxv0dbsbh305Xs9f06Gz3HuYbN+vhobyutu/i+U++zU3Pa 2F1n3/BMsNvlQ== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.100.0 at mail Date: Thu, 30 Aug 2018 23:00:06 +0200 Message-Id: In-Reply-To: References: From: =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Subject: [PATCH v2 03/12] fbdev: add remove_conflicting_pci_framebuffers() MIME-Version: 1.0 To: dri-devel@lists.freedesktop.org Cc: Bartlomiej Zolnierkiewicz , linux-fbdev@vger.kernel.org Cc: Alex Deucher Cc: Cc: David Airlie Cc: Eric Anholt Cc: Gerd Hoffmann Cc: Cc: Cc: Maxime Ripard Cc: Thierry Reding Cc: Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Almost all PCI drivers using remove_conflicting_framebuffers() wrap it with the same code. Signed-off-by: Michał Mirosław [for v1] Acked-by: Bartlomiej Zolnierkiewicz --- v2: add kerneldoc for DRM helper --- drivers/video/fbdev/core/fbmem.c | 22 ++++++++++++++++++++++ include/drm/drm_fb_helper.h | 24 ++++++++++++++++++++++++ include/linux/fb.h | 2 ++ 3 files changed, 48 insertions(+) diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c index 0df148eb4699..927e016487e9 100644 --- a/drivers/video/fbdev/core/fbmem.c +++ b/drivers/video/fbdev/core/fbmem.c @@ -34,6 +34,7 @@ #include #include #include +#include #include @@ -1802,6 +1803,27 @@ int remove_conflicting_framebuffers(struct apertures_struct *a, } EXPORT_SYMBOL(remove_conflicting_framebuffers); +int remove_conflicting_pci_framebuffers(struct pci_dev *pdev, int res_id, const char *name) +{ + struct apertures_struct *ap; + bool primary = false; + + ap = alloc_apertures(1); + if (!ap) + return -ENOMEM; + + ap->ranges[0].base = pci_resource_start(pdev, res_id); + ap->ranges[0].size = pci_resource_len(pdev, res_id); +#ifdef CONFIG_X86 + primary = pdev->resource[PCI_ROM_RESOURCE].flags & + IORESOURCE_ROM_SHADOW; +#endif + remove_conflicting_framebuffers(ap, name, primary); + kfree(ap); + return 0; +} +EXPORT_SYMBOL(remove_conflicting_pci_framebuffers); + /** * register_framebuffer - registers a frame buffer device * @fb_info: frame buffer info structure diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h index 1c1e53abb25d..6e1fc52d1b1b 100644 --- a/include/drm/drm_fb_helper.h +++ b/include/drm/drm_fb_helper.h @@ -587,4 +587,28 @@ drm_fb_helper_remove_conflicting_framebuffers(struct apertures_struct *a, #endif } +/** + * drm_fb_helper_remove_conflicting_framebuffers - remove firmware framebuffers for PCI devices + * @pdev: PCI device being driven + * @resource_id: index of PCI BAR configuring framebuffer memory + * @name: requesting driver name + * + * This function removes framebuffer devices (eg. initialized by firmware) + * using memory range configured for @pdev's BAR @resource_id. + * + * The function assumes that PCI device with shadowed ROM is drives a primary + * display and so kicks out vga16fb. + */ +static inline int +drm_fb_helper_remove_conflicting_pci_framebuffers(struct pci_dev *pdev, + int resource_id, + const char *name) +{ +#if IS_REACHABLE(CONFIG_FB) + return remove_conflicting_pci_framebuffers(pdev, resource_id, name); +#else + return 0; +#endif +} + #endif diff --git a/include/linux/fb.h b/include/linux/fb.h index aa74a228bb92..abeffd55b66a 100644 --- a/include/linux/fb.h +++ b/include/linux/fb.h @@ -632,6 +632,8 @@ extern ssize_t fb_sys_write(struct fb_info *info, const char __user *buf, extern int register_framebuffer(struct fb_info *fb_info); extern int unregister_framebuffer(struct fb_info *fb_info); extern int unlink_framebuffer(struct fb_info *fb_info); +extern int remove_conflicting_pci_framebuffers(struct pci_dev *pdev, int res_id, + 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);