From patchwork Mon Sep 16 11:00:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Martinez Canillas X-Patchwork-Id: 13805271 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 816116A357 for ; Mon, 16 Sep 2024 11:00:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726484461; cv=none; b=Re3MwOzYphGSmpxMGFzYknQQLbyDhBJPbYwqQ2qzrtGQ07qnOHAEJGjpDLlKyggK6w9UrbJM0ePInWMP2rqAKje8d5c2i+yLlvFzJydFZlgP6y18nOvPFAspI9R09YJQZvjX+kYEgrlDdRWQjzLXioXjY3OOuIZkWDkHUsUIPEY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726484461; c=relaxed/simple; bh=zXDP/DixJ2nupvnmN46tVoLl7bcTa+g5Dd43FoS8g7Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YfGvTX6eaDms21SCap9AAuqncxDGt9FEn3jgcI8yvPp0cUImf53oaKBnCd83Ng+M9goDiHjR1E2ztlj5mIThgYDRlGC8NSLec6o5A0IcMkQHbRndsyeqRSEZZy5hcljakHuIT/An9UfIuHRKKlshvqGmywIqFcCKhbr48crHY9o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=EjYnroXb; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="EjYnroXb" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1726484458; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=itSh3IrUxrdCZUhjcuF+BB5F77vjj4OFkn+g9OgH098=; b=EjYnroXbxwG388Kj/WlpGG6QOEXMMcA/Bsf2sSzd9yWTuRhyoN9idOiW3fIwVrqJZTCKmQ OM91+1m2GsNfnFUK0RwVDjFNbjicGMZ0f1gAyIqRPtLKqWhdFz5xeuDGNZnqMdCXS6xF+x PWGOlRUmMkNzMnzwBnMgSHn8RGRmECY= 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-450-fwL9iagwMp6NJFWwaWKqzA-1; Mon, 16 Sep 2024 07:00:57 -0400 X-MC-Unique: fwL9iagwMp6NJFWwaWKqzA-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-42cb2c5d634so21521595e9.0 for ; Mon, 16 Sep 2024 04:00:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726484456; x=1727089256; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=itSh3IrUxrdCZUhjcuF+BB5F77vjj4OFkn+g9OgH098=; b=wfL/Inad8A0DVqTygJR7wSZR+3XRYN3LSXmRI0/52O5p8ikZmRfyVo++I88QTSmoyT b7jzVV12+EsuPiUfjhRQRJSuw3LxBi6wgBqQKMUVe5TAb9RAAn6n11E9xzMIRDZf2uCd H7iJX7legd2/NDDlxEZIFG6ITA/ugUQDhKdOxrWLW7h6Y1u4hqVv1fMY+CMpmIcNfHFT fWk/Q7vevwcrLKCrcYOI/k4vI6cXW6JxjMlSuEvqqZs+9BUk1a9pWv+4fka3AmkwAR1E yDiLDU+dyNwRiAK4twksJMlBMXwOeUpufr+dloalYeSyrVOLBtqspsoE5g3u6Tr8wA+Y dulg== X-Forwarded-Encrypted: i=1; AJvYcCVE8I7dQ9mS5nGhYfCOEBLMQagk9bTaXcJm0cjR9gMqGa2YbW1lEf7N/310XpuqzddYnGWJX8ci2U2xYzRcXBM=@lists.linux.dev X-Gm-Message-State: AOJu0YwM/gX/YsEKQXuXle3ta8UpWwB/TPdrmifEcGStdRVW0OakRRlc BBgWAXf/ceUeN/EzibwOqMM+50ZrG+oXjJus78Bo61vhbRBWEg2rFig/LjUgOztxz89poJQTkoV hBNhpvj6hNG+aBKQpFbmOiiU99gPjb0fEEtvD16rVxzsmdzL5IfNYXwpP4rOYm+l7PA== X-Received: by 2002:a05:600c:310a:b0:42b:892d:54c0 with SMTP id 5b1f17b1804b1-42d907221b4mr59982975e9.12.1726484455960; Mon, 16 Sep 2024 04:00:55 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHsgWHRJR4aKx2ppVUW3nxaeapfH3oj46/SJkQvNinWOePbqW+Lc2YXP1lXrRnZng63+W2aKg== X-Received: by 2002:a05:600c:310a:b0:42b:892d:54c0 with SMTP id 5b1f17b1804b1-42d907221b4mr59982735e9.12.1726484455424; Mon, 16 Sep 2024 04:00:55 -0700 (PDT) Received: from localhost ([195.166.127.210]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42d9b055069sm110260975e9.6.2024.09.16.04.00.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Sep 2024 04:00:55 -0700 (PDT) From: Javier Martinez Canillas To: linux-kernel@vger.kernel.org Cc: Brian Norris , dri-devel@lists.freedesktop.org, Borislav Petkov , Julius Werner , Thomas Zimmermann , chrome-platform@lists.linux.dev, intel-gfx@lists.freedesktop.org, Hugues Bruant , Javier Martinez Canillas , Alex Deucher , Dan Carpenter , Helge Deller , Jani Nikula Subject: [PATCH v4 1/2] firmware: sysfb: Add a sysfb_handles_screen_info() helper function Date: Mon, 16 Sep 2024 13:00:25 +0200 Message-ID: <20240916110040.1688511-2-javierm@redhat.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240916110040.1688511-1-javierm@redhat.com> References: <20240916110040.1688511-1-javierm@redhat.com> Precedence: bulk X-Mailing-List: chrome-platform@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com That can be used by drivers to check if the Generic System Framebuffers (sysfb) support can handle the data contained in the global screen_info. Drivers might need this information to know if have to setup the system framebuffer, or if they have to delegate this action to sysfb instead. Suggested-by: Thomas Zimmermann Signed-off-by: Javier Martinez Canillas Reviewed-by: Thomas Zimmermann --- Changes in v4: - New patch to add sysfb_handles_screen_info() helper (Thomas Zimmermann). drivers/firmware/sysfb.c | 19 +++++++++++++++++++ include/linux/sysfb.h | 7 +++++++ 2 files changed, 26 insertions(+) diff --git a/drivers/firmware/sysfb.c b/drivers/firmware/sysfb.c index 02a07d3d0d40..770e74be14f3 100644 --- a/drivers/firmware/sysfb.c +++ b/drivers/firmware/sysfb.c @@ -77,6 +77,25 @@ void sysfb_disable(struct device *dev) } EXPORT_SYMBOL_GPL(sysfb_disable); +/** + * sysfb_handles_screen_info() - reports if sysfb handles the global screen_info + * + * Callers can use sysfb_handles_screen_info() to determine whether the Generic + * System Framebuffers (sysfb) can handle the global screen_info data structure + * or not. Drivers might need this information to know if they have to setup the + * system framebuffer, or if they have to delegate this action to sysfb instead. + * + * Returns: + * True if sysfb handles the global screen_info data structure. + */ +bool sysfb_handles_screen_info(void) +{ + const struct screen_info *si = &screen_info; + + return !!screen_info_video_type(si); +} +EXPORT_SYMBOL_GPL(sysfb_handles_screen_info); + #if defined(CONFIG_PCI) static bool sysfb_pci_dev_is_enabled(struct pci_dev *pdev) { diff --git a/include/linux/sysfb.h b/include/linux/sysfb.h index bef5f06a91de..07cbab516942 100644 --- a/include/linux/sysfb.h +++ b/include/linux/sysfb.h @@ -60,12 +60,19 @@ struct efifb_dmi_info { void sysfb_disable(struct device *dev); +bool sysfb_handles_screen_info(void); + #else /* CONFIG_SYSFB */ static inline void sysfb_disable(struct device *dev) { } +static inline bool sysfb_handles_screen_info(void) +{ + return false; +} + #endif /* CONFIG_SYSFB */ #ifdef CONFIG_EFI From patchwork Mon Sep 16 11:00:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Martinez Canillas X-Patchwork-Id: 13805272 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4CA2B155725 for ; Mon, 16 Sep 2024 11:01:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726484464; cv=none; b=T9YLcoT+iJ8CgpMbEDRdXODVN2kNCwfFL1kf4CeQVf3auU8aDZ58+aHK78KpQcGGFt0swsChpq9TXINul8FGaSe4G3X/iHu1J5ozdtgaen2VTB3RHPxMM7oOYyPoLw8MJ2aLMHfX8cxvnnYKMEVwrsb0/vhK/Tsazf51KC/T9kI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726484464; c=relaxed/simple; bh=mxagBuP3eu3IAKCLOLfRcfBz9gvaoYDB9uCXJ+9hXkI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ImFrfr2awc7Zr90+4Kwhc/eSJgkmlnmqI0HSx09pmyBWE0RoTFyFkYRR/H/4CmMLayAz+qhPkB5b4tWFnbPg2XZG0Qg0us7+0pzO7D6Kbo5FqBbX4rTUadj6nKyY2DpVtXQdcwlIaMvP7SgQEOTuh/xmdbVUrMuAcCf7SF7MNoQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=dAGpzON8; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="dAGpzON8" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1726484462; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eEjIF7qtpeO5gdAg8m1MkAHfmOzMzhqhggl+Nd1IK9g=; b=dAGpzON8Q5kaPH8cE/rPoBS2sY72pwINs5CcovcngEJlYtnS/qU7H1DpdZ2DF5o/fkAtrW XZCQ/iAIkNtRbq/RtXNNfvcWVaq5TiImUWfvKesRVW8/sWe3FVm0gLzmkTRMd062JJ2ybX 2iaHNRw83PkP19mCbxor63itQ2Yh/fQ= 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-470-yaflcvgHPFGrlU77zKBFaw-1; Mon, 16 Sep 2024 07:00:59 -0400 X-MC-Unique: yaflcvgHPFGrlU77zKBFaw-1 Received: by mail-wm1-f70.google.com with SMTP id 5b1f17b1804b1-42cb89fbb8cso27763775e9.0 for ; Mon, 16 Sep 2024 04:00:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726484458; x=1727089258; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=eEjIF7qtpeO5gdAg8m1MkAHfmOzMzhqhggl+Nd1IK9g=; b=XwvZHdWdCJKDQiO6c5gXGLDoF+D112o2OJr0VutkpoIFNMngxTq4GNTfa3yrclVGGP hT9vCYoknKZ1zgYrSnGbF7atsVpiCdyMs9DSRhJD38NN8VCnCZ7ONIS/Z87QEza4G5L7 GRO+HMTaqoIpnqHdmOQqOYBM9zOeRQOJwRQaLc8tMQWlhIQan9aSnALb7TVMSC5RVJc2 mzYIhIAKXSYHztxhz6NfuolhyFIuqyorZeo6LBsLuS18Ku/V+kdeqIgBP0Ay8UlJ+lwO h3ee5/Y4FfLl2SgotU/Qbf1yePuanKMTaoNleIcGVnUdYBACiHDmM6nA47fgX0JhypzZ 5pRQ== X-Forwarded-Encrypted: i=1; AJvYcCUpwnfSrnJ4i4AQ6fDZB1iuP4zY5lG6hL0fB2OIqJS2mwH0oky3SRifM1F0dh4lFcbTVPF5PhnJjgZ6AvpM3yg=@lists.linux.dev X-Gm-Message-State: AOJu0YzWEgZzX7bDmsuDeLdefZIk3MvhgUxhSnuFp2K2dA1Gs0zcJDUw PvKf/LuFF0OsgqdZtHwLizyucjrbPZNgRF8foVkO8R2r0c32+L6TCn08Y4/M6Zc0o5O8EZrMp7G 4Cyp78RBWUEA+4wAldcCUZzeIh7Jq4cp4aK8gvAIsnjH1Z3BT/i0GVjZBOD1+kvgCYw== X-Received: by 2002:a05:600c:21d1:b0:42c:de2f:da27 with SMTP id 5b1f17b1804b1-42cde2fdb54mr105453535e9.2.1726484457613; Mon, 16 Sep 2024 04:00:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGuoN48esuPwjXdzhGeiLsvhSvLtwnfWmyh0YiWdZ01XdL7xeFl8Crpz10A2XtyhhYWXONvEQ== X-Received: by 2002:a05:600c:21d1:b0:42c:de2f:da27 with SMTP id 5b1f17b1804b1-42cde2fdb54mr105453355e9.2.1726484457174; Mon, 16 Sep 2024 04:00:57 -0700 (PDT) Received: from localhost ([195.166.127.210]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42cc137556esm200901665e9.1.2024.09.16.04.00.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Sep 2024 04:00:56 -0700 (PDT) From: Javier Martinez Canillas To: linux-kernel@vger.kernel.org Cc: Brian Norris , dri-devel@lists.freedesktop.org, Borislav Petkov , Julius Werner , Thomas Zimmermann , chrome-platform@lists.linux.dev, intel-gfx@lists.freedesktop.org, Hugues Bruant , Javier Martinez Canillas , Tzung-Bi Shih Subject: [PATCH v4 2/2] firmware: coreboot: Don't register a pdev if screen_info data is present Date: Mon, 16 Sep 2024 13:00:26 +0200 Message-ID: <20240916110040.1688511-3-javierm@redhat.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240916110040.1688511-1-javierm@redhat.com> References: <20240916110040.1688511-1-javierm@redhat.com> Precedence: bulk X-Mailing-List: chrome-platform@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com On coreboot platforms, a system framebuffer may be provided to the Linux kernel by filling a LB_TAG_FRAMEBUFFER entry in the coreboot table. But a coreboot payload (e.g: SeaBIOS) could also provide its own framebuffer information to the Linux kernel. If that's the case, arch x86 boot code will fill the global screen_info data and this used by the Generic System Framebuffers (sysfb) framework, to register a platform device with pdata about the system's framebuffer. But later, the framebuffer_coreboot driver will try to do the same and attempt to register a "simple-framebuffer" platform device (using the information from the coreboot table), which will lead to an error due a device with the same name already being registered: sysfs: cannot create duplicate filename '/bus/platform/devices/simple-framebuffer.0' ... coreboot: could not register framebuffer framebuffer coreboot8: probe with driver framebuffer failed with error -17 To prevent this issue, make the framebuffer_core driver to not register a platform device if the global struct screen_info data has been filled. Reported-by: Brian Norris Closes: https://lore.kernel.org/all/ZuCG-DggNThuF4pj@b20ea791c01f/T/#ma7fb65acbc1a56042258adac910992bb225a20d2 Suggested-by: Julius Werner Signed-off-by: Javier Martinez Canillas Reviewed-by: Thomas Zimmermann Reviewed-by: Brian Norris Reviewed-by: Julius Werner --- Changes in v4: - Use a sysfb_handles_screen_info() helper instead of screen_info_video_type() to fix build errors on platforms that don't define a struct screen_info (Thomas Zimmermann). Changes in v3: - Fix coreboot spelling to be all in lowercase (Julius Werner). Changes in v2: - Declare the struct screen_info as constant variable (Thomas Zimmermann). - Use screen_info_video_type() instead of checking the screen_info video types directly (Thomas Zimmermann). - Fix missing "device" word in a comment (Brian Norris). - Fix some mispellings in a comment (Brian Norris). - Change error code returned from -EINVAL to -ENODEV (Brian Norris). drivers/firmware/google/framebuffer-coreboot.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/firmware/google/framebuffer-coreboot.c b/drivers/firmware/google/framebuffer-coreboot.c index daadd71d8ddd..c68c9f56370f 100644 --- a/drivers/firmware/google/framebuffer-coreboot.c +++ b/drivers/firmware/google/framebuffer-coreboot.c @@ -15,6 +15,7 @@ #include #include #include +#include #include "coreboot_table.h" @@ -36,6 +37,19 @@ static int framebuffer_probe(struct coreboot_device *dev) .format = NULL, }; + /* + * On coreboot systems, the advertised LB_TAG_FRAMEBUFFER entry + * in the coreboot table should only be used if the payload did + * not pass a framebuffer information to the Linux kernel. + * + * If the global screen_info data has been filled, the Generic + * System Framebuffers (sysfb) will already register a platform + * device and pass that screen_info as platform_data to a driver + * that can scan-out using the system provided framebuffer. + */ + if (sysfb_handles_screen_info()) + return -ENODEV; + if (!fb->physical_address) return -ENODEV;