Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4450602imw; Tue, 19 Jul 2022 06:54:07 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sygcBuic9FCYe4D3nq2EAVu/kYgDnKQZERLZTub1xOCsttSbKbZSmClKN4mzg6T/DYbNiu X-Received: by 2002:a05:6402:430a:b0:43a:9ece:d6f8 with SMTP id m10-20020a056402430a00b0043a9eced6f8mr44269928edc.361.1658238847299; Tue, 19 Jul 2022 06:54:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658238847; cv=none; d=google.com; s=arc-20160816; b=qWW9zFuv7660mfslyJd975HBBjjfBKOlWxvzlbdE0pacucMolrXX+a0Lyvl+m0XS1v o5MVDQ/1qOD2VvvJ3jmuQwYLzQbeY4z4nPfQ8Qm+oXc/yVBububGbBg9//BFWHZ8i41R 2EJwenVplj/BeKEXIigdjlJEhdLnweMGkT3ea9QM2WYLRJA+hFmtolxGX7dK+MF5BjG7 4qSkVA5FhdgIAT7NvtRNIKyL0yE9vWxtLU71TvLEC7s1Pov2kKKQw0WVFg2UwGeWiDlR kzH1r4GnrIJDFELydcFnS4tSIuQHCp/REgDufai9S/5gDY1dO09N2RY6VwHXLXl0bVx+ PNpg== 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=L+EI+LWjq6WLaeKkFfiOKECECCwU0aZVHV2ons32kIk=; b=PFZ0jLbDsT03NQfY2uR6C2Y8An8ijlk0bQTW7LG4ceGhzdRBI2zp6e3q/w2QjypsO6 IRAX0i/nYLkEhQ1AY9sY3a9s5ymN9Nad7qvpc547czh+/AOH5kfmcSfbc1MCJOEBgvI9 IJk0Z7WPwvVWS9Y07Zx/Zet5rS1CnrpNrVZqz1OT+kbvHcyTLPuSZlKW+sCGSu+3x0jW Ast4EO+yPsUdqbYZ2WHZoIJqHGq0HS10Nd9qpfoUgGh3yZ8GEkWupfGEVDMG5Fkqr2bj qGdX6+u1FUjDbjX8PKFLGyvFKSishhVkoOFDoQoT1Cc4syBwNYm2K1KGm1+K3TXRIcz7 oNNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ez0ntYQl; 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 y12-20020a170906470c00b007136091f459si16041691ejq.302.2022.07.19.06.53.42; Tue, 19 Jul 2022 06:54:07 -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=ez0ntYQl; 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 S243017AbiGSNGD (ORCPT + 99 others); Tue, 19 Jul 2022 09:06:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243184AbiGSNEt (ORCPT ); Tue, 19 Jul 2022 09:04:49 -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 4201E9E466; Tue, 19 Jul 2022 05:26:43 -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 B4530B81B21; Tue, 19 Jul 2022 12:26:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1F64DC341CA; Tue, 19 Jul 2022 12:26:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1658233601; bh=SuF4v3Uz5uTNz8Vjlm3/PnuewX3rlJ5M1kikWnOZ87c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ez0ntYQlRQ1yCwuMgCz60BnaXmVXWbVs/sIUQu95swXx6r3VZd/xamKIsguAZDr7S 4VaY3mBHndg0RhCF/1UZAfvCZnbpnYXE8usgkHCl6Z4sqdbgHrnnTH5EIVfjl4F805 W86329KMOiQvkzWudVsc4EbUINC1THsqe7Wdn7jw= 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.18 176/231] firmware: sysfb: Add sysfb_disable() helper function Date: Tue, 19 Jul 2022 13:54:21 +0200 Message-Id: <20220719114728.976344526@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220719114714.247441733@linuxfoundation.org> References: <20220719114714.247441733@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 bde376e9de3c0bc55eedc8956b0f114c05531595 ] This can be used by subsystems to unregister a platform device registered by sysfb and also to disable future platform device registration in sysfb. Suggested-by: Daniel Vetter Signed-off-by: Javier Martinez Canillas Reviewed-by: Daniel Vetter Link: https://patchwork.freedesktop.org/patch/msgid/20220607182338.344270-3-javierm@redhat.com Signed-off-by: Sasha Levin --- .../driver-api/firmware/other_interfaces.rst | 6 +++ drivers/firmware/sysfb.c | 54 ++++++++++++++++--- include/linux/sysfb.h | 12 +++++ 3 files changed, 66 insertions(+), 6 deletions(-) diff --git a/Documentation/driver-api/firmware/other_interfaces.rst b/Documentation/driver-api/firmware/other_interfaces.rst index b81794e0cfbb..06ac89adaafb 100644 --- a/Documentation/driver-api/firmware/other_interfaces.rst +++ b/Documentation/driver-api/firmware/other_interfaces.rst @@ -13,6 +13,12 @@ EDD Interfaces .. kernel-doc:: drivers/firmware/edd.c :internal: +Generic System Framebuffers Interface +------------------------------------- + +.. kernel-doc:: drivers/firmware/sysfb.c + :export: + Intel Stratix10 SoC Service Layer --------------------------------- Some features of the Intel Stratix10 SoC require a level of privilege diff --git a/drivers/firmware/sysfb.c b/drivers/firmware/sysfb.c index b032f40a92de..1f276f108cc9 100644 --- a/drivers/firmware/sysfb.c +++ b/drivers/firmware/sysfb.c @@ -34,21 +34,59 @@ #include #include +static struct platform_device *pd; +static DEFINE_MUTEX(disable_lock); +static bool disabled; + +static bool sysfb_unregister(void) +{ + if (IS_ERR_OR_NULL(pd)) + return false; + + platform_device_unregister(pd); + pd = NULL; + + return true; +} + +/** + * sysfb_disable() - disable the Generic System Framebuffers support + * + * This disables the registration of system framebuffer devices that match the + * generic drivers that make use of the system framebuffer set up by firmware. + * + * It also unregisters a device if this was already registered by sysfb_init(). + * + * Context: The function can sleep. A @disable_lock mutex is acquired to serialize + * against sysfb_init(), that registers a system framebuffer device. + */ +void sysfb_disable(void) +{ + mutex_lock(&disable_lock); + sysfb_unregister(); + disabled = true; + mutex_unlock(&disable_lock); +} +EXPORT_SYMBOL_GPL(sysfb_disable); + static __init int sysfb_init(void) { struct screen_info *si = &screen_info; struct simplefb_platform_data mode; - struct platform_device *pd; const char *name; bool compatible; - int ret; + int ret = 0; + + mutex_lock(&disable_lock); + if (disabled) + goto unlock_mutex; /* try to create a simple-framebuffer device */ compatible = sysfb_parse_mode(si, &mode); if (compatible) { pd = sysfb_create_simplefb(si, &mode); if (!IS_ERR(pd)) - return 0; + goto unlock_mutex; } /* if the FB is incompatible, create a legacy framebuffer device */ @@ -60,8 +98,10 @@ static __init int sysfb_init(void) name = "platform-framebuffer"; pd = platform_device_alloc(name, 0); - if (!pd) - return -ENOMEM; + if (!pd) { + ret = -ENOMEM; + goto unlock_mutex; + } sysfb_apply_efi_quirks(pd); @@ -73,9 +113,11 @@ static __init int sysfb_init(void) if (ret) goto err; - return 0; + goto unlock_mutex; err: platform_device_put(pd); +unlock_mutex: + mutex_unlock(&disable_lock); return ret; } diff --git a/include/linux/sysfb.h b/include/linux/sysfb.h index 708152e9037b..8ba8b5be5567 100644 --- a/include/linux/sysfb.h +++ b/include/linux/sysfb.h @@ -55,6 +55,18 @@ struct efifb_dmi_info { int flags; }; +#ifdef CONFIG_SYSFB + +void sysfb_disable(void); + +#else /* CONFIG_SYSFB */ + +static inline void sysfb_disable(void) +{ +} + +#endif /* CONFIG_SYSFB */ + #ifdef CONFIG_EFI extern struct efifb_dmi_info efifb_dmi_list[]; -- 2.35.1