From patchwork Thu Aug 30 21:00:05 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: 10582805 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 EFA9F174C for ; Thu, 30 Aug 2018 21:02:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E0FFF2C30B for ; Thu, 30 Aug 2018 21:02:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D2E712C30E; Thu, 30 Aug 2018 21:02: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=-2.1 required=2.0 tests=BAYES_00,DKIM_ADSP_ALL, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=no version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 436E82C30B for ; Thu, 30 Aug 2018 21:02:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:To:MIME-Version:Subject:From:References :In-Reply-To:Message-Id:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=QzODWBEmpQoqY3UC8nTrDPzDr6ELsoDG1lxC/zHTJkU=; b=LoENUg+y8Xto5a J2joyibSB+T1Ed0d2uZj0/RkMog0Cv6JPlpVYrKXcLME5yHRUH1iO5RA5EbTBHveBEeMmODYZGXz/ XbLVri7uYhVoahGlAUlE4YUJ0ONCjoaiA0J+XX9vQntoAXtwtsqH8qP3A/5rrfkEZQexvoNNq4adC 3+H0QyR6eRmV8qIq9L7WT6V3YtOeuLNpL35rZKHrwDvEdV/Si4bjEINuf0NHfww8GDNPRVPqJTbWj VOWN8dF+iqLaygUvcnV5jOTcbRHCYzK6CjTXjEYYpsD7f5WqUlYplw411R/MntpU2lFLt1Ku8U28U 2lm+aofNvz9a7t42+rJg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fvU4k-0006eA-JG; Thu, 30 Aug 2018 21:01:58 +0000 Received: from rere.qmqm.pl ([91.227.64.183]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fvU3D-00056z-Lh for linux-arm-kernel@lists.infradead.org; Thu, 30 Aug 2018 21:00:28 +0000 Received: from remote.user (localhost [127.0.0.1]) by rere.qmqm.pl (Postfix) with ESMTPSA id 421ZcJ25lTzLG; 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=23C/qzqkj8RjChvPXX8rs991ajnnysY2BBYNx0j+xsM=; h=Date:In-Reply-To:References:From:Subject:To:Cc:Cc:Cc:Cc:Cc:Cc:Cc: Cc:Cc:Cc:Cc:From; b=goMD5kfurOvo14jT2lxTRTSploLIJiT6vsifeig1YtT1dZ6T/WqzEiUTrCZ13bHNn hRtGDHJP2giMDkGurHmGNiNppvc02evXCHXSDvo0NjrK2jkxwVsr8QZEsbb5bk+sLc 7eLwk1wFEpgH4nA4KHSb8DFs4cic6P6+oB87tRZtTVH97IPz0YY9AfJTCbPD6/U0vD 1KP66ChmgcykcVkh239ZlnCjjp5z1kX7CZcVqBlVDisXBtvfh8MDplmazGcFWhxx/p 2A2lHtQFGRfPycCPuM1OlDY6qIPXrzVbvCR/5yGD3b+ollO3HgVoKvom1mD1KzD+q9 d8vs27od/YAQQ== X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.100.0 at mail Date: Thu, 30 Aug 2018 23:00:05 +0200 Message-Id: <7e3a48e397298b38d7ddc7f45d48226d1f5db3e4.1535656077.git.mirq-linux@rere.qmqm.pl> In-Reply-To: References: From: =?utf-8?b?TWljaGHFgiBNaXJvc8WCYXc=?= Subject: [PATCH v2 02/12] fbdev: allow apertures == NULL in remove_conflicting_framebuffers() MIME-Version: 1.0 To: dri-devel@lists.freedesktop.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180830_140024_069719_F7A17049 X-CRM114-Status: GOOD ( 11.23 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-fbdev@vger.kernel.org, linux-tegra@vger.kernel.org, Bartlomiej Zolnierkiewicz , David Airlie , amd-gfx@lists.freedesktop.org, virtualization@lists.linux-foundation.org, Eric Anholt , Thierry Reding , Gerd Hoffmann , Alex Deucher , Maxime Ripard , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Interpret (otherwise-invalid) NULL apertures argument to mean all-memory range. This will allow to remove several duplicates of this code from drivers in following patches. Signed-off-by: Michał Mirosław [for v1] Acked-by: Bartlomiej Zolnierkiewicz --- v2: added kerneldoc to corresponding DRM helper --- drivers/video/fbdev/core/fbmem.c | 14 ++++++++++++++ include/drm/drm_fb_helper.h | 10 ++++++++++ 2 files changed, 24 insertions(+) diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c index 30a18d4c9de4..0df148eb4699 100644 --- a/drivers/video/fbdev/core/fbmem.c +++ b/drivers/video/fbdev/core/fbmem.c @@ -1779,11 +1779,25 @@ int remove_conflicting_framebuffers(struct apertures_struct *a, const char *name, bool primary) { int ret; + bool do_free = false; + + if (!a) { + a = alloc_apertures(1); + if (!a) + return -ENOMEM; + + a->ranges[0].base = 0; + a->ranges[0].size = ~0; + do_free = true; + } mutex_lock(®istration_lock); ret = do_remove_conflicting_framebuffers(a, name, primary); mutex_unlock(®istration_lock); + if (do_free) + kfree(a); + return ret; } EXPORT_SYMBOL(remove_conflicting_framebuffers); diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h index b069433e7fc1..1c1e53abb25d 100644 --- a/include/drm/drm_fb_helper.h +++ b/include/drm/drm_fb_helper.h @@ -566,6 +566,16 @@ static inline void drm_fb_helper_output_poll_changed(struct drm_device *dev) #endif +/** + * drm_fb_helper_remove_conflicting_framebuffers - remove firmware framebuffers + * @a: memory range, users of which are to be removed + * @name: requesting driver name + * @primary: also kick vga16fb if present + * + * This function removes framebuffer devices (eg. initialized by firmware) + * which use memory range described by @a. If @a is NULL all such devices are + * removed. + */ static inline int drm_fb_helper_remove_conflicting_framebuffers(struct apertures_struct *a, const char *name, bool primary)