Received: by 2002:a05:6a10:83d0:0:0:0:0 with SMTP id o16csp61554pxh; Thu, 7 Apr 2022 14:01:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwUjP3tktFzuJZdsIytCSr62fRBfk7oiI8yznTtUj0b+UHsI2+SdtK8f5DKG8XUfByqM8Ry X-Received: by 2002:a05:6808:1a26:b0:2da:1bae:5186 with SMTP id bk38-20020a0568081a2600b002da1bae5186mr6777066oib.144.1649365278027; Thu, 07 Apr 2022 14:01:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649365278; cv=none; d=google.com; s=arc-20160816; b=zfPnvHKDy4XEgpQgxLbkQaFdYh7pbrQU/lWSc6xO1rSD2DJUCmRZb/XCCwUlQMtev/ CcNruZfDsfkoc2KCma1OmFjubF5FD3mH370IoSSHrFSa1N3I236NPlZbbSqjfYURrLNJ K4u0fpDf2Os/bo3HYS22BXzcP+xA9KIL32D2p8NDqrQVwxTTh97fMv8+wl1yiVcTv9/6 DW7qNaDurd+9XgVa6HG5YUbooETF5hhcaJD3IBNJtyLQkxLiv8Us075jpDCvEGsJZZoZ r+EhdmliUYnTUyVRBY/eFtdKDGd6TzqLUsQ05nU5EaxsdSSb/Tm3/SsSOhf7CghTHCui ZRPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:mail-followup-to:message-id:subject:cc:to:from:date :dkim-signature; bh=qH1ao1Sv89tAmypsC25LX+raBksixuJK/BXtSJIZNVY=; b=H5TfCAhnXox/bRfS0Xd3xsp4EUj66FfbcYA+Hnj8CkVj92HwP29xOt64gTSEXbRNiD BNxXsYdQxEukOHztfFRfptftrXjh/dETHt6BZHyfDyDUD0ImgcGhPmbLh9Brt7x6jfLQ rB5hq9xnUF8DyLtq1fizvpxb8NbgccoH8gecV5GH4x276ikA4ByKy0pzGoCc0UL00vRp nAfW3F0iUcs+yJLdp8pgQYhLYAO5hPwNAQEIgVWUEkgOpeLBjhWMe99Xmv1XgaBoTWye R4W5PxnkXZv1aokMmick06x02fi9TaGM3WPQ2djZV3Hp6o0V69ses8AN9S+Rhha1Lf/w iEag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=fAbafEwV; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id k2-20020a056870148200b000da7476563esi11320812oab.303.2022.04.07.14.01.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Apr 2022 14:01:18 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@ffwll.ch header.s=google header.b=fAbafEwV; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id BBE3744DCEB; Thu, 7 Apr 2022 13:05:42 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232769AbiDGJIj (ORCPT + 99 others); Thu, 7 Apr 2022 05:08:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233175AbiDGJIf (ORCPT ); Thu, 7 Apr 2022 05:08:35 -0400 Received: from mail-ej1-x643.google.com (mail-ej1-x643.google.com [IPv6:2a00:1450:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B1CEEEA756 for ; Thu, 7 Apr 2022 02:06:31 -0700 (PDT) Received: by mail-ej1-x643.google.com with SMTP id ot30so9378775ejb.12 for ; Thu, 07 Apr 2022 02:06:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to; bh=qH1ao1Sv89tAmypsC25LX+raBksixuJK/BXtSJIZNVY=; b=fAbafEwVVzZIPTmi+s1aa1APtfjN/g7TFqYJJOZzKrvIEQeu6qOJhnNCJqurVwYJ06 8EcvXB9YHcuxOvzk0cFHZ151BJTEG1CYB6t0HmQa/H+LavWbcpGkc76P2b4bYgUT0BPA daFv05Ohzp/OQ5GvBvBjz9mY3r7//Lt/9Bl6s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to; bh=qH1ao1Sv89tAmypsC25LX+raBksixuJK/BXtSJIZNVY=; b=3UpwCISGMJ1hz4mkPdjR69D4KGh3jpYIL0PKypPLmlhV704WN5mgB0ExS9046JdQTC lT32ABx/LIu+mY4NUEyk5UMMKhHxf4kpb3l85Z+4uDqueffRtDYIZybZrWbzlKFI46w8 5SEuKLmCKVY8OhMYEKvKVaylfFEJY9Vltl+wLCHqRrUCGls0TUpfsUyloKMjh2236dYN EWoY/Nm4X7RIGtkb/bQCTktK0jNXxoCkuNHSa0buvzi6OkAtWi7jmj7bi4BDpFos4LIs uGkIfGNgSpuywzxY1jKHUjAmBIT5tR5VfZNbODGZ2JXo0UoTdWOlOqCF0i4VsPWSMcOR 6yjw== X-Gm-Message-State: AOAM533za8JEYAvydw4uK6DbjdyRPPuf6S7mBnDxxZhLEwg/ASIyiA5j mFSBvncNi1zqrSBgXWN+4GbUYg== X-Received: by 2002:a17:907:94c6:b0:6da:9561:ce0 with SMTP id dn6-20020a17090794c600b006da95610ce0mr12001579ejc.342.1649322390205; Thu, 07 Apr 2022 02:06:30 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id u5-20020a170906b10500b006ce6fa4f510sm7415695ejy.165.2022.04.07.02.06.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Apr 2022 02:06:29 -0700 (PDT) Date: Thu, 7 Apr 2022 11:06:28 +0200 From: Daniel Vetter To: Javier Martinez Canillas Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Thomas Zimmermann , Daniel Vetter , Borislav Petkov , Greg Kroah-Hartman Subject: Re: [RESEND RFC PATCH 2/5] firmware: sysfb: Add helpers to unregister a pdev and disable registration Message-ID: Mail-Followup-To: Javier Martinez Canillas , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Thomas Zimmermann , Borislav Petkov , Greg Kroah-Hartman References: <20220406213919.600294-1-javierm@redhat.com> <20220406213919.600294-3-javierm@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220406213919.600294-3-javierm@redhat.com> X-Operating-System: Linux phenom 5.10.0-8-amd64 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=no 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 On Wed, Apr 06, 2022 at 11:39:16PM +0200, Javier Martinez Canillas wrote: > These 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 > --- > > drivers/firmware/sysfb.c | 47 +++++++++++++++++++++++++++++++++++----- > include/linux/sysfb.h | 19 ++++++++++++++++ > 2 files changed, 60 insertions(+), 6 deletions(-) > > diff --git a/drivers/firmware/sysfb.c b/drivers/firmware/sysfb.c > index b032f40a92de..08ae78c083f1 100644 > --- a/drivers/firmware/sysfb.c > +++ b/drivers/firmware/sysfb.c > @@ -34,21 +34,52 @@ > #include > #include > > +static struct platform_device *pd; > +static DEFINE_MUTEX(load_lock); > +static bool disabled; > + > +void sysfb_disable(void) > +{ > + mutex_lock(&load_lock); > + disabled = true; > + mutex_unlock(&load_lock); > +} > +EXPORT_SYMBOL_GPL(sysfb_disable); > + > +bool sysfb_try_unregister(struct device *dev) > +{ > + bool ret = true; > + > + mutex_lock(&load_lock); > + if (!pd || pd != to_platform_device(dev)) > + return false; > + > + platform_device_unregister(to_platform_device(dev)); > + pd = NULL; > + mutex_unlock(&load_lock); > + > + return ret; > +} > +EXPORT_SYMBOL_GPL(sysfb_try_unregister); Kerneldoc for these plus adding that to Documentation/firmware/other_interfaces.rst would be really neat. With that added Reviewed-by: Daniel Vetter > + > 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(&load_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 +91,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 +106,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(&load_lock); > return ret; > } > > diff --git a/include/linux/sysfb.h b/include/linux/sysfb.h > index 708152e9037b..e8c0313fac8f 100644 > --- a/include/linux/sysfb.h > +++ b/include/linux/sysfb.h > @@ -55,6 +55,25 @@ struct efifb_dmi_info { > int flags; > }; > > +#ifdef CONFIG_SYSFB > + > +void sysfb_disable(void); > +bool sysfb_try_unregister(struct device *dev); > + > +#else /* CONFIG_SYSFB */ > + > +static inline void sysfb_disable(void) > +{ > + > +} > + > +static inline bool sysfb_try_unregister(struct device *dev) > +{ > + return false; > +} > + > +#endif /* CONFIG_SYSFB */ > + > #ifdef CONFIG_EFI > > extern struct efifb_dmi_info efifb_dmi_list[]; > -- > 2.35.1 > -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch