From patchwork Fri Apr 8 16:13:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Martinez Canillas X-Patchwork-Id: 558992 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D03ADC433FE for ; Fri, 8 Apr 2022 16:13:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231460AbiDHQPz (ORCPT ); Fri, 8 Apr 2022 12:15:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229944AbiDHQPv (ORCPT ); Fri, 8 Apr 2022 12:15:51 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 75CE9ECB35 for ; Fri, 8 Apr 2022 09:13:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1649434425; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zcEitY10iZAiJ+J3+u8UtqIoWNDWTfj8MjNNemYgu3M=; b=TVAIMyQF/40HM6WGtubk/3SslJndD1IjwPGZd4ekZtj8FZG4pU/UaBkc2e6chNiPC6AlKS +9UAGNS0F+9rf0qgU259drvP7Nj4RpJNBni867rzhIiybO5ENs5rYnHP29y6XomYeqIjgB TKwQ2zpPfeGAK1rvYDwc6op0ay3+3rM= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-388-azkfzhqJNHiLfFgKTufWfQ-1; Fri, 08 Apr 2022 12:13:44 -0400 X-MC-Unique: azkfzhqJNHiLfFgKTufWfQ-1 Received: by mail-wm1-f69.google.com with SMTP id x8-20020a7bc768000000b0038e73173886so4568130wmk.6 for ; Fri, 08 Apr 2022 09:13:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zcEitY10iZAiJ+J3+u8UtqIoWNDWTfj8MjNNemYgu3M=; b=6zJc4+HxqE/I/tQQvsWS9vOvuemAcW0dmpji65YBBg9DiXyrXIGkSNDMFjEjsIG5Ir k6XxtFnxMKrIgAmtdk+pFsKgWI60zmaS66guYSHcg3UlnElM3vpfSyrP35+XAfrO5g8J LN8rwiAP3tFOwrm6oi5JNF3Eic0xuWGE4yT27Go83pzG/WrT08U82oWS64eUaO3R76Dm FkL27Zh2sDQW7GYb3YAtnusZIk1puClFQ/tGOS1tAHnhf8m0GIgUht/NXVsCMwi3ERiB LO7MBOP2uaN49ym4c6TknOqAe3cSlqByxt0/aDgTJhdK9x6VzwIBdXnfNQ9OXnrJGWai cZ6A== X-Gm-Message-State: AOAM530futK86Kr0VOf5wMIMuU/Zn9ijp1htpkSLiDLyfHD/jOiJjrjT SIP+KDSupiKUwTm0TQLpv0fZtLskIuXWTWd2My3SrgHVBOznrX5sTkcaiUs1zXqL6MA/y7IIAPI Poxh8HcmhnMqmpZAmsv8vLpc= X-Received: by 2002:a5d:6785:0:b0:204:f8f:8fab with SMTP id v5-20020a5d6785000000b002040f8f8fabmr15369341wru.353.1649434423620; Fri, 08 Apr 2022 09:13:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxt3Rj+zw8mIsN24LhLbQy+hWefHkvvpTKfeMVqAFvoZziJC7qiikDxng1MGBPfgLZBQiYEtg== X-Received: by 2002:a5d:6785:0:b0:204:f8f:8fab with SMTP id v5-20020a5d6785000000b002040f8f8fabmr15369313wru.353.1649434423340; Fri, 08 Apr 2022 09:13:43 -0700 (PDT) Received: from minerva.home ([92.176.231.205]) by smtp.gmail.com with ESMTPSA id t15-20020adfeb8f000000b002060d26c211sm14377455wrn.114.2022.04.08.09.13.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Apr 2022 09:13:43 -0700 (PDT) From: Javier Martinez Canillas To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , Daniel Vetter , dri-devel@lists.freedesktop.org, Thomas Zimmermann , Javier Martinez Canillas , Alex Deucher , Changcheng Deng , Daniel Vetter , Guenter Roeck , Helge Deller , Sam Ravnborg , Tetsuo Handa , Zhen Lei , linux-fbdev@vger.kernel.org Subject: [PATCH v2 3/5] fbdev: Restart conflicting fb removal loop when unregistering devices Date: Fri, 8 Apr 2022 18:13:20 +0200 Message-Id: <20220408161322.270176-4-javierm@redhat.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220408161322.270176-1-javierm@redhat.com> References: <20220408161322.270176-1-javierm@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org Drivers that want to remove registered conflicting framebuffers prior to register their own framebuffer, calls remove_conflicting_framebuffers(). This function takes the registration_lock mutex, to prevent a races when drivers register framebuffer devices. But if a conflicting framebuffer device is found, the underlaying platform device is unregistered and this will lead to the platform driver .remove callback to be called, which in turn will call to the unregister_framebuffer() that takes the same lock. To prevent this, a struct fb_info.forced_out field was used as indication to unregister_framebuffer() whether the mutex has to be grabbed or not. A cleaner solution is to drop the lock before platform_device_unregister() so unregister_framebuffer() can take it when called from the fbdev driver, and just grab the lock again after the device has been registered and do a removal loop restart. Since the framebuffer devices will already be removed, the loop would just finish when no more conflicting framebuffers are found. Suggested-by: Daniel Vetter Signed-off-by: Javier Martinez Canillas Reviewed-by: Daniel Vetter --- (no changes since v1) drivers/video/fbdev/core/fbmem.c | 29 +++++++++++++++++++---------- include/linux/fb.h | 1 - 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c index bdd00d381bbc..bcdbbe543466 100644 --- a/drivers/video/fbdev/core/fbmem.c +++ b/drivers/video/fbdev/core/fbmem.c @@ -1553,6 +1553,7 @@ static void do_remove_conflicting_framebuffers(struct apertures_struct *a, { int i; +restart_removal: /* check all firmware fbs and kick off if the base addr overlaps */ for_each_registered_fb(i) { struct apertures_struct *gen_aper; @@ -1576,16 +1577,28 @@ static void do_remove_conflicting_framebuffers(struct apertures_struct *a, * VESA, EFI, etc. A native driver will then be able to * allocate the memory range. * - * If it's not a platform device, at least print a warning. A - * fix would add code to remove the device from the system. + * Drop the lock because if the device is unregistered, its + * drivers will call to unregister_framebuffer() that takes + * this lock. */ + mutex_unlock(®istration_lock); if (dev_is_platform(device)) { - registered_fb[i]->forced_out = true; platform_device_unregister(to_platform_device(device)); } else { + /* + * If it's not a platform device, at least print a warning. A + * fix would add to code to remove the device from the system. + */ pr_warn("fb%d: cannot remove device\n", i); - do_unregister_framebuffer(registered_fb[i]); + /* call unregister_framebuffer() so it can take the lock */ + unregister_framebuffer(registered_fb[i]); } + mutex_lock(®istration_lock); + /* + * Restart the removal loop now that the device has been + * unregistered and its associated framebuffer gone. + */ + goto restart_removal; } } } @@ -1892,13 +1905,9 @@ EXPORT_SYMBOL(register_framebuffer); void unregister_framebuffer(struct fb_info *fb_info) { - bool forced_out = fb_info->forced_out; - - if (!forced_out) - mutex_lock(®istration_lock); + mutex_lock(®istration_lock); do_unregister_framebuffer(fb_info); - if (!forced_out) - mutex_unlock(®istration_lock); + mutex_unlock(®istration_lock); } EXPORT_SYMBOL(unregister_framebuffer); diff --git a/include/linux/fb.h b/include/linux/fb.h index f95da1af9ff6..b781bc721113 100644 --- a/include/linux/fb.h +++ b/include/linux/fb.h @@ -502,7 +502,6 @@ struct fb_info { } *apertures; bool skip_vt_switch; /* no VT switch on suspend/resume required */ - bool forced_out; /* set when being removed by another driver */ }; static inline struct apertures_struct *alloc_apertures(unsigned int max_num) { From patchwork Fri Apr 8 16:13:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Martinez Canillas X-Patchwork-Id: 559541 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4CC38C4321E for ; Fri, 8 Apr 2022 16:13:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229944AbiDHQPz (ORCPT ); Fri, 8 Apr 2022 12:15:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229537AbiDHQPx (ORCPT ); Fri, 8 Apr 2022 12:15:53 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id E67AF39BA4 for ; Fri, 8 Apr 2022 09:13:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1649434428; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7QI3SswaraTV8idrWcTwBVC+GiIL0ijW6quL8YZNa3g=; b=M3A6/acuehP4pghs7lbcXYlRcrvqgcCiesf0C7wwQH53XQcCZVS6HIvSV08a9UVqsZl4yh 1u+FJVBz9bha77tD/9m6YnBUJD71BaJ9MVTuCcF8WQN/RxGPioohCSIiWn4dEqvlhfkE7d 9V0LkH6Z9BjeJ/ImIJLaf+oKHbXYS2E= Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-207-jiIK7-XUNA2um1L1TktoNA-1; Fri, 08 Apr 2022 12:13:47 -0400 X-MC-Unique: jiIK7-XUNA2um1L1TktoNA-1 Received: by mail-wm1-f69.google.com with SMTP id z16-20020a05600c0a1000b0038bebbd8548so6159947wmp.3 for ; Fri, 08 Apr 2022 09:13:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7QI3SswaraTV8idrWcTwBVC+GiIL0ijW6quL8YZNa3g=; b=im14cncukq78D3rH0Vqs5NYfBmX6GfvzVNhNI1RiATNyAhR8Z+YMinWt1ssC5nEFVp cvyFdKwn6brAqgQYRStKcP0/4UbLYoc+yAz+R0FQUybta2G0JwVmkPiT+qSV3fbdXJ6w ih+oPtGE89XjuyhlDBUBV+R3wyFTT7hHsOYbhXdF7RLEJrXYVgXLcZmFrou21ZFu7uPs JcLnic6NEXAn+wPUZL5tRxCLctSxuETGaYJtalPTR9n1KqUWEbZPBYeYn6C8u52WgZOi OeIF371mMRAS0QOlAO2bieEtyG2KE+Nxt6kaX7Qos2M9fOWwnv+SxilB75qh4Yfl2OHT 6ypg== X-Gm-Message-State: AOAM533owmLzBmByFNk9vW5/N6k1n8hZioRKtBZTQyf2ZjyETEYPUlr8 d6dMHaNO3u5HXrvZcQEf0w+CuMhXS8GEo8w5aEiN5d3aqsJRKhPQWcCdc8Z4oxmrq0Gk9fjlfYX dNnpr9rEoRKGjCH/sNSqk5d0= X-Received: by 2002:adf:fa4c:0:b0:205:7cb2:e6f0 with SMTP id y12-20020adffa4c000000b002057cb2e6f0mr15284858wrr.218.1649434425686; Fri, 08 Apr 2022 09:13:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyYRy6iFg+nUxs9pKZmeBKF3byaeUvogbu8dmOibs9HJxOPyzETU8IRSiW1efmqzGmnYftbww== X-Received: by 2002:adf:fa4c:0:b0:205:7cb2:e6f0 with SMTP id y12-20020adffa4c000000b002057cb2e6f0mr15284837wrr.218.1649434425421; Fri, 08 Apr 2022 09:13:45 -0700 (PDT) Received: from minerva.home ([92.176.231.205]) by smtp.gmail.com with ESMTPSA id t15-20020adfeb8f000000b002060d26c211sm14377455wrn.114.2022.04.08.09.13.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Apr 2022 09:13:45 -0700 (PDT) From: Javier Martinez Canillas To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , Daniel Vetter , dri-devel@lists.freedesktop.org, Thomas Zimmermann , Javier Martinez Canillas , Alex Deucher , Changcheng Deng , Daniel Vetter , Guenter Roeck , Helge Deller , Sam Ravnborg , Xiyu Yang , Zhen Lei , linux-fbdev@vger.kernel.org Subject: [PATCH v2 4/5] fbdev: Fix some race conditions between fbmem and sysfb Date: Fri, 8 Apr 2022 18:13:21 +0200 Message-Id: <20220408161322.270176-5-javierm@redhat.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220408161322.270176-1-javierm@redhat.com> References: <20220408161322.270176-1-javierm@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org The platform devices registered in sysfb match with a firmware-based fbdev or DRM driver, that are used to have early graphics using framebuffers set up by the system firmware. Real DRM drivers later are probed and remove all conflicting framebuffers, leading to these platform devices for generic drivers to be unregistered. But the current solution has two issues that this patch fixes: 1) It is a layering violation for the fbdev core to unregister a device that was registered by sysfb. Instead, the sysfb_try_unregister() helper function can be called for sysfb to attempt unregistering the device if is the one registered. 2) The sysfb_init() function could be called after a DRM driver is probed and requested to unregister devices for drivers with a conflicting fb. To prevent this, disable any future sysfb platform device registration by calling sysfb_disable(), if a driver requested to remove conflicting framebuffers with remove_conflicting_framebuffers(). There are video drivers (e.g: vga16fb) that register their own device and don't use the sysfb infrastructure for that, so an unregistration has to be forced by fbmem if sysfb_try_unregister() fails to do the unregister. Suggested-by: Daniel Vetter Signed-off-by: Javier Martinez Canillas Reviewed-by: Daniel Vetter --- Changes in v2: - Explain in the commit message that fbmem has to unregister the device as fallback if a driver registered the device itself (Daniel Vetter). - Also explain that fallback in a comment in the code (Daniel Vetter). - Don't encode in fbmem the assumption that sysfb will always register platform devices (Daniel Vetter). - Add a FIXME comment about drivers registering devices (Daniel Vetter). drivers/video/fbdev/core/fbmem.c | 42 +++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c index bcdbbe543466..6cb73193410e 100644 --- a/drivers/video/fbdev/core/fbmem.c +++ b/drivers/video/fbdev/core/fbmem.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -1582,22 +1583,30 @@ static void do_remove_conflicting_framebuffers(struct apertures_struct *a, * this lock. */ mutex_unlock(®istration_lock); - if (dev_is_platform(device)) { - platform_device_unregister(to_platform_device(device)); - } else { - /* - * If it's not a platform device, at least print a warning. A - * fix would add to code to remove the device from the system. - */ - pr_warn("fb%d: cannot remove device\n", i); - /* call unregister_framebuffer() so it can take the lock */ - unregister_framebuffer(registered_fb[i]); + if (!sysfb_try_unregister(device)) { + if (dev_is_platform(device)) { + /* + * FIXME: sysfb didn't register this device, is a platform + * device registered by a video driver (e.g: vga16fb), so + * force its unregistration here. A proper fix would be to + * move all device registration to the sysfb infrastructure. + */ + platform_device_unregister(to_platform_device(device)); + } else { + /* + * If it's not a platform device, at least print a warning. A + * fix would add to code to remove the device from the system. + */ + pr_warn("fb%d: cannot remove device\n", i); + /* call unregister_framebuffer() so it can take the lock */ + unregister_framebuffer(registered_fb[i]); + } } - mutex_lock(®istration_lock); /* * Restart the removal loop now that the device has been * unregistered and its associated framebuffer gone. */ + mutex_lock(®istration_lock); goto restart_removal; } } @@ -1758,6 +1767,17 @@ int remove_conflicting_framebuffers(struct apertures_struct *a, do_free = true; } + /* + * If a driver asked to unregister a platform device registered by + * sysfb, then can be assumed that this is a driver for a display + * that is set up by the system firmware and has a generic driver. + * + * Drivers for devices that don't have a generic driver will never + * ask for this, so let's assume that a real driver for the display + * was already probed and prevent sysfb to register devices later. + */ + sysfb_disable(); + mutex_lock(®istration_lock); do_remove_conflicting_framebuffers(a, name, primary); mutex_unlock(®istration_lock); From patchwork Fri Apr 8 16:13:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Martinez Canillas X-Patchwork-Id: 558991 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 52E51C4332F for ; Fri, 8 Apr 2022 16:13:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230402AbiDHQP4 (ORCPT ); Fri, 8 Apr 2022 12:15:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229578AbiDHQPx (ORCPT ); Fri, 8 Apr 2022 12:15:53 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1615811A0E for ; Fri, 8 Apr 2022 09:13:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1649434429; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+NpBw4lqbBFDRVqxgjOkgfaUZ1HLPBwF1iC6qPlab68=; b=gZC2T1piZGsRDNhvpGq6AFJrepK8Zp7z4dZR5KXE86WNIlmEM+dAThwlflxn0lmdQi39yf Raj6/HvdNwyGU1aT2WJHruOOdxjEVyWKPx0m8PcF/YyAtcPGDrShhBCM7UR1yp0R+++FQI Z8zWARRwlYvldtOvz6UC34Tyonjwi1A= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-137-EqKSsFTuP0eY4XcD6DRhdQ-1; Fri, 08 Apr 2022 12:13:48 -0400 X-MC-Unique: EqKSsFTuP0eY4XcD6DRhdQ-1 Received: by mail-wr1-f72.google.com with SMTP id z16-20020adff1d0000000b001ef7dc78b23so2349765wro.12 for ; Fri, 08 Apr 2022 09:13:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=+NpBw4lqbBFDRVqxgjOkgfaUZ1HLPBwF1iC6qPlab68=; b=ZRBEAmlTxdYUPd0qpGnmLQhs9FtDFgQfRN5s5okrJrjHVyHFHi4kuOMXAm7Xx9GoqI v2ptD6eX/CvS+5qRUlKmdlPvFLQGkFBjF4nKALeYJ5ZAnyAxtYusuoG+WQAudpz9qy5g KEofrb+hgs3pjgJIVzCSQFglMoTH2KBvcLWnqNYqitBU4DgjXq5e/O0hDiLM6viQOTMl 1vvdU3PxAkf9Neo6bW+jaCVMqxil4yA7qMMLjU5nVQbEnukvoX+vHoMwQBGxSS6PsCJh J9yHhQn5cPn5dzr+6bhzVbpf9+jHv8qeQoFOdTNnNsaE+eH2PenbSX8/UxSZUFuXd49Y oIaA== X-Gm-Message-State: AOAM533dYbB0OfFUreHT+msDAdLTUdh22kQI8J+e5/oTyPPxRkIPdkAw Y4X6DYiKYhybelsDayxCCA/4/ruaI0Uvjje7XH5oe/zdDaFsnC3yCToklID5e5Z37tmhoMkFzBn RMIursfEOEbEr8jXH1cyfS5w= X-Received: by 2002:a5d:526f:0:b0:206:1c39:810f with SMTP id l15-20020a5d526f000000b002061c39810fmr15159304wrc.139.1649434426833; Fri, 08 Apr 2022 09:13:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwORWvYYZa7FXQJJTC1f/+l/2/E9uRlYGrj8t0VKR/7z+nDTMUHBSWhuUjM5hw14PF+grH6Sg== X-Received: by 2002:a5d:526f:0:b0:206:1c39:810f with SMTP id l15-20020a5d526f000000b002061c39810fmr15159279wrc.139.1649434426543; Fri, 08 Apr 2022 09:13:46 -0700 (PDT) Received: from minerva.home ([92.176.231.205]) by smtp.gmail.com with ESMTPSA id t15-20020adfeb8f000000b002060d26c211sm14377455wrn.114.2022.04.08.09.13.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Apr 2022 09:13:46 -0700 (PDT) From: Javier Martinez Canillas To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , Daniel Vetter , dri-devel@lists.freedesktop.org, Thomas Zimmermann , Zack Rusin , Javier Martinez Canillas , Hans de Goede , Ilya Trukhanov , Daniel Vetter , Peter Jones , linux-fbdev@vger.kernel.org, Helge Deller Subject: [PATCH v2 5/5] Revert "fbdev: Prevent probing generic drivers if a FB is already registered" Date: Fri, 8 Apr 2022 18:13:22 +0200 Message-Id: <20220408161322.270176-6-javierm@redhat.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220408161322.270176-1-javierm@redhat.com> References: <20220408161322.270176-1-javierm@redhat.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org From: Daniel Vetter This reverts commit fb561bf9abde49f7e00fdbf9ed2ccf2d86cac8ee. With commit 27599aacbaefcbf2af7b06b0029459bbf682000d Author: Thomas Zimmermann Date: Tue Jan 25 10:12:18 2022 +0100 fbdev: Hot-unplug firmware fb devices on forced removal this should be fixed properly and we can remove this somewhat hackish check here (e.g. this won't catch drm drivers if fbdev emulation isn't enabled). Cc: Thomas Zimmermann Cc: Zack Rusin Cc: Javier Martinez Canillas Cc: Zack Rusin Cc: Hans de Goede Cc: Ilya Trukhanov Signed-off-by: Daniel Vetter Signed-off-by: Daniel Vetter Reviewed-by: Javier Martinez Canillas Cc: Peter Jones Cc: linux-fbdev@vger.kernel.org Signed-off-by: Javier Martinez Canillas --- (no changes since v1) drivers/video/fbdev/efifb.c | 11 ----------- drivers/video/fbdev/simplefb.c | 11 ----------- 2 files changed, 22 deletions(-) diff --git a/drivers/video/fbdev/efifb.c b/drivers/video/fbdev/efifb.c index ea42ba6445b2..edca3703b964 100644 --- a/drivers/video/fbdev/efifb.c +++ b/drivers/video/fbdev/efifb.c @@ -351,17 +351,6 @@ static int efifb_probe(struct platform_device *dev) char *option = NULL; efi_memory_desc_t md; - /* - * Generic drivers must not be registered if a framebuffer exists. - * If a native driver was probed, the display hardware was already - * taken and attempting to use the system framebuffer is dangerous. - */ - if (num_registered_fb > 0) { - dev_err(&dev->dev, - "efifb: a framebuffer is already registered\n"); - return -EINVAL; - } - if (screen_info.orig_video_isVGA != VIDEO_TYPE_EFI || pci_dev_disabled) return -ENODEV; diff --git a/drivers/video/fbdev/simplefb.c b/drivers/video/fbdev/simplefb.c index 94fc9c6d0411..0ef41173325a 100644 --- a/drivers/video/fbdev/simplefb.c +++ b/drivers/video/fbdev/simplefb.c @@ -413,17 +413,6 @@ static int simplefb_probe(struct platform_device *pdev) struct simplefb_par *par; struct resource *res, *mem; - /* - * Generic drivers must not be registered if a framebuffer exists. - * If a native driver was probed, the display hardware was already - * taken and attempting to use the system framebuffer is dangerous. - */ - if (num_registered_fb > 0) { - dev_err(&pdev->dev, - "simplefb: a framebuffer is already registered\n"); - return -EINVAL; - } - if (fb_get_options("simplefb", NULL)) return -ENODEV;