From patchwork Mon Nov 13 08:51:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Martinez Canillas X-Patchwork-Id: 164368 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b909:0:b0:403:3b70:6f57 with SMTP id t9csp1076306vqg; Mon, 13 Nov 2023 00:54:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IFMI34OcN0DCKBZIr2qCY6bqmMyGGRq9bOIBfpAEJOTdVt3zukJVJG9tTXAxnqa2aTPzOrb X-Received: by 2002:a05:6808:151f:b0:3a8:436f:3fff with SMTP id u31-20020a056808151f00b003a8436f3fffmr9856962oiw.26.1699865687823; Mon, 13 Nov 2023 00:54:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699865687; cv=none; d=google.com; s=arc-20160816; b=xJ13xobo4rfn3lSWjZihTjUt26Z62tX2E+zJV9zfn5hdFUsNV/Dz2UjOhM7r6Ioo5L vVz4rc8ESyVdBL6oWXbPp6PG4dPki1u/wgLcuAy97IQjkzkheA8YoAxbroWeXKgNDJtK Gf99gbgZAd87xcIY/m59VM7nFgfUpotAsQm4GQ0fJhGr1rD2uZMzu8/A5/T0MPy9dRMk TR9ArrpB5SpmbhG1i14BM9dyhL6dsUtfNO02G+UKb9N5fbodqWTLhVa18vsdCEdj9A+L iYrCVaL34sPkpuvjVvcDngzX4V8B2b8XeECgHj13MJcCeU9S5mTsXl2njW4F28iJwbgx K3pA== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=cNzwUiFENrfxS16AlOPS5/AIJUox4EDd0wo9fGfe2EM=; fh=xsw4ArzHyifYV/1EfcwLiRhoCvOtrroXd3aLoac78As=; b=vbTfpT/lHuNbsFLiuBnUqjbXsiHTmvELacSKanHQlzPoFLRyaZM3dwgmAIhWZBzk2m CFH49X++fiONeXOVFzabyFJ569gsGzga/D4wNEQJEL+8NllTo0zuGNjWrOFcNI7TRo2Y GtjtJXYojb3wynRZnatuX2dBBHhGkzMvWTEkBa+Y0SQ5BPKYaOALdzAzIOy4BgkyeErg FAWOXntCRChprhMJojmYoBIRNSPD6gtHVjAiRfosOMVzZEdDxibghP9VJVhzBTlLvN0F rsTnaPK1pap3fSR7vq9vViaylHwZB3SaR/w2WiYfYKYBGrsYrzPbb06YQtB56oyWo+zk 3IeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=FCJw6202; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id bv184-20020a632ec1000000b005bdc49d22a4si5033630pgb.103.2023.11.13.00.54.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Nov 2023 00:54:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=FCJw6202; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id CFF86807DED8; Mon, 13 Nov 2023 00:54:44 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233224AbjKMIyY (ORCPT + 29 others); Mon, 13 Nov 2023 03:54:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232633AbjKMIyX (ORCPT ); Mon, 13 Nov 2023 03:54:23 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D1AF810D3 for ; Mon, 13 Nov 2023 00:53:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699865613; 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; bh=cNzwUiFENrfxS16AlOPS5/AIJUox4EDd0wo9fGfe2EM=; b=FCJw6202v2DV99SrtFhjFK2SJ+BIzanIvg44p2cy7+WlS8QoFi/bDxQfemAs94HOcNULMQ MJhWHYMssv1IfbLhY9uR3oI3+7ydORtwxM3/77374BdlyPoWzpQvp6jBYfgynGxWR8Zye9 nkvoHzl0R1pxroVQCMs2p9I6szANskQ= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-323-1w2gdU7iMeK0NGF7ZKPZww-1; Mon, 13 Nov 2023 03:53:31 -0500 X-MC-Unique: 1w2gdU7iMeK0NGF7ZKPZww-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-408597a1ae3so27187355e9.0 for ; Mon, 13 Nov 2023 00:53:31 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699865609; x=1700470409; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=cNzwUiFENrfxS16AlOPS5/AIJUox4EDd0wo9fGfe2EM=; b=QxEUzHwqxJqezDHX5lI8Vz5YZlyKJ4YGn0c602zSaiahTifL+xheNsZaezQKanoecC TvcXYQGq9fbkHTNnuxOKBO1PBdnuNyYT8wxtGu6okJ71GAEK9A5UGgpqX8ebddXGhk8A FEYtjPTXxjSf78NW7je3GZ85VhnNQoa6Bvp121rfBiuzFLkNlzMBfT3pAuIFfQQcGssL z9ywrknmYlp035QQDta+cVfk6DdOfmWiqqr9fdjavwL5L/uYvUYTPUma0//05HOvlFE8 9QJNzahIDAtyAjj3y/hz8vyM0ovJHANG5SwktRzJun5NbTfbmGCClJWFF9LyOE3pDWJC c9Jg== X-Gm-Message-State: AOJu0YwVD1Q5lzNJrZ+pkZ3R+BN45HXucJnp68WUJVQM/aMavDaF+fug Q5iPwZ6HiuxX7fwPX4FjD0FpprYs67aCEvYexPVl3sPbzw7BNw682gaCVSiDmRbCU0pIWqkKoSG 41/LFbrf5CjdqQwkOOkooRUgY0Gm42Yyk3aVme3NoICKiEkcmmVwyN40Z44clRMlt8jWGRn7o+T Z7X6trJD8= X-Received: by 2002:a05:600c:198a:b0:409:7aa9:e0b with SMTP id t10-20020a05600c198a00b004097aa90e0bmr4828735wmq.32.1699865609530; Mon, 13 Nov 2023 00:53:29 -0800 (PST) X-Received: by 2002:a05:600c:198a:b0:409:7aa9:e0b with SMTP id t10-20020a05600c198a00b004097aa90e0bmr4828715wmq.32.1699865609141; Mon, 13 Nov 2023 00:53:29 -0800 (PST) Received: from localhost (205.pool92-176-231.dynamic.orange.es. [92.176.231.205]) by smtp.gmail.com with ESMTPSA id j10-20020a05600c300a00b0040773c69fc0sm12890382wmh.11.2023.11.13.00.53.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 13 Nov 2023 00:53:28 -0800 (PST) From: Javier Martinez Canillas To: linux-kernel@vger.kernel.org Cc: Thomas Zimmermann , Ard Biesheuvel , Sima Vetter , Rob Herring , dri-devel@lists.freedesktop.org, Andrew Worsley , Hector Martin , Sergio Lopez , Javier Martinez Canillas , Frank Rowand , Rob Herring , devicetree@vger.kernel.org Subject: [RFC PATCH] of/platform: Disable sysfb if a simple-framebuffer node is found Date: Mon, 13 Nov 2023 09:51:41 +0100 Message-ID: <20231113085305.1823455-1-javierm@redhat.com> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Mon, 13 Nov 2023 00:54:44 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782438363491419077 X-GMAIL-MSGID: 1782438363491419077 Some DT platforms use EFI to boot and in this case the EFI Boot Services may register a EFI_GRAPHICS_OUTPUT_PROTOCOL handle, that will later be queried by the Linux EFI stub to fill the global struct screen_info data. The data is used by the Generic System Framebuffers (sysfb) framework to add a platform device with platform data about the system framebuffer. But if there is a "simple-framebuffer" node in the DT, the OF core will also do the same and add another device for the system framebuffer. This could lead for example, to two platform devices ("simple-framebuffer" and "efi-framebuffer") to be added and matched with their corresponding drivers. So both efifb and simpledrm will be probed, leading to following: [ 0.055752] efifb: framebuffer at 0xbd58dc000, using 16000k, total 16000k [ 0.055755] efifb: mode is 2560x1600x32, linelength=10240, pages=1 [ 0.055758] efifb: scrolling: redraw [ 0.055759] efifb: Truecolor: size=2:10:10:10, shift=30:20:10:0 ... [ 3.295896] simple-framebuffer bd58dc000.framebuffer: [drm] *ERROR* could not acquire memory range [??? 0xffff79f30a29ee40-0x2a5000001a7 flags 0x0]: -16 [ 3.298018] simple-framebuffer: probe of bd58dc000.framebuffer failed with error -16 To prevent the issue, make the OF core to disable sysfb if there is a node with a "simple-framebuffer" compatible. That way only this device will be registered and sysfb would not attempt to register another one using the screen_info data even if this has been filled. This seems the correct thing to do in this case because: a) On a DT platform, the DTB is the single source of truth since is what describes the hardware topology. Even if EFI Boot Services are used to boot the machine. b) The of_platform_default_populate_init() function is called in the arch_initcall_sync() initcall level while the sysfb_init() function is called later in the subsys_initcall() initcall level. Reported-by: Andrew Worsley Closes: https://lore.kernel.org/all/20231111042926.52990-2-amworsley@gmail.com Signed-off-by: Javier Martinez Canillas Reviewed-by: Thomas Zimmermann --- drivers/of/platform.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/drivers/of/platform.c b/drivers/of/platform.c index f235ab55b91e..0a692fdfef59 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c @@ -20,6 +20,7 @@ #include #include #include +#include #include "of_private.h" @@ -621,8 +622,21 @@ static int __init of_platform_default_populate_init(void) } node = of_get_compatible_child(of_chosen, "simple-framebuffer"); - of_platform_device_create(node, NULL, NULL); - of_node_put(node); + if (node) { + /* + * Since a "simple-framebuffer" device is already added + * here, disable the Generic System Framebuffers (sysfb) + * to prevent it from registering another device for the + * system framebuffer later (e.g: using the screen_info + * data that may had been filled as well). + * + * This can happen for example on DT systems that do EFI + * booting and may provide a GOP handle to the EFI stub. + */ + sysfb_disable(); + of_platform_device_create(node, NULL, NULL); + of_node_put(node); + } /* Populate everything else. */ of_platform_default_populate(NULL, NULL, NULL);