Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4450185imw; Tue, 19 Jul 2022 06:53:32 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uTUESES6lyyThyON4SWL5847HhUWNRg+AzH/N14UUdwPWeB6eWJVFroA4/bNkZjfva4gF1 X-Received: by 2002:aa7:d702:0:b0:43a:5296:df67 with SMTP id t2-20020aa7d702000000b0043a5296df67mr43330297edq.314.1658238812008; Tue, 19 Jul 2022 06:53:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658238812; cv=none; d=google.com; s=arc-20160816; b=WQqywMTusA+x2PAjMdV0MHYJa0JEY3IUOU7mq//kqbpzkMUYA4tldUSkNST57TyDOx UV9T1QU4PlfI0eT9zWbPAc5BiS+5tpZOyBXbU9SwnZrxJrGMVdB9sCiujaJIvSpCcTw4 6wSh8D0KE4U6JzBbkAJNASFlOAeLKlKfwoGyEtKCuKfsl63jhq7qOQEbWlfRftq7Su/u gdqn31r3WOfRPR0n9maSIMdr9oUG5p/ozHMu1A9LJrPLwVlMnfvYcQXauVs59q86lZoo 9mGCYPk7BWF334jLw/01YEGPvWsMiWIQ/A2BYT0nKSdE3CU5wBrIWZbug6JIZv81S0ks suwQ== 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=msJddV4yAIpRM9YbV1X9xLZgcE0RcBC3iBCY9CPLF3s=; b=b6qFe8pVFlG/F9uVketq/RiEbOuHrFBcGvsC2drcmlL73YmihalJZD53eVPzA4heRC F6DCsWQ0JGYxm6ckfRZxbBZtNsbIhHHSfGnvtp919RyxqxWXyVCkWl+Vbd1jnYIDzwic X+Sr2KihVwwDB9krzRrcL+3HWeCwxB8ehR2jj7abipUFRKSDN55GDbKRzy46XqZWni4G vySH1dT0fmWpk4+XtMVqW32YuOxXOmoT39uGK+pXSi85MruyT0LS8aQS7XIXOsyijnun mp/oMbNAY6t5Eh5nIfHDwZTHeHRV125Wz6jBvxrDkfT7h9Lln5ATYlrtlqL16hHGf/GN y8rw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=z1hW1NUc; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gr19-20020a170906e2d300b0072b48390b56si17162231ejb.755.2022.07.19.06.53.07; Tue, 19 Jul 2022 06:53:31 -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=z1hW1NUc; 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 S238042AbiGSMlu (ORCPT + 99 others); Tue, 19 Jul 2022 08:41:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241447AbiGSMjk (ORCPT ); Tue, 19 Jul 2022 08:39:40 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A36754678; Tue, 19 Jul 2022 05:16:01 -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 ams.source.kernel.org (Postfix) with ESMTPS id 48EABB81B2C; Tue, 19 Jul 2022 12:16:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9AD2BC341C6; Tue, 19 Jul 2022 12:15:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658232959; bh=8O3ZQuy9J4xSUIsyBruFrghnBpeTv8Iso0xD86jU81w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=z1hW1NUco6fH8yVAJdRiZowlEqmqupn5FBvJCVNcfdOhYIwDJ8/4eZvujCKT1F0Rm QBQOFodulWTuokggHS4omklHNTegv6ROn3tgYs0f4waEvp7J4SV300At0uO56FnRQr mz1RJEZy2gXXAFVKaOn8o6zzad/wpfKN0bAZ9/8w= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Daniel Vetter , Javier Martinez Canillas , Sasha Levin Subject: [PATCH 5.15 125/167] fbdev: Disable sysfb device registration when removing conflicting FBs Date: Tue, 19 Jul 2022 13:54:17 +0200 Message-Id: <20220719114708.699232278@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220719114656.750574879@linuxfoundation.org> References: <20220719114656.750574879@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.8 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: X-Mailing-List: linux-kernel@vger.kernel.org From: Javier Martinez Canillas [ Upstream commit ee7a69aa38d87a3bbced7b8245c732c05ed0c6ec ] The platform devices registered by sysfb match with firmware-based DRM or fbdev drivers, that are used to have early graphics using a framebuffer provided by the system firmware. DRM or fbdev drivers later are probed and remove conflicting framebuffers, leading to these platform devices for generic drivers to be unregistered. But the current solution has a race, since the sysfb_init() function could be called after a DRM or fbdev driver is probed and request to unregister the devices for drivers with conflicting framebuffes. To prevent this, disable any future sysfb platform device registration by calling sysfb_disable(), if a driver requests to remove the conflicting framebuffers. Suggested-by: Daniel Vetter Signed-off-by: Javier Martinez Canillas Reviewed-by: Daniel Vetter Link: https://patchwork.freedesktop.org/patch/msgid/20220607182338.344270-4-javierm@redhat.com Signed-off-by: Sasha Levin --- drivers/video/fbdev/core/fbmem.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) --- 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 @@ -1786,6 +1787,17 @@ int remove_conflicting_framebuffers(stru 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);