From patchwork Fri Feb 2 11:58:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Zimmermann X-Patchwork-Id: 13542828 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3BFA713DB9E for ; Fri, 2 Feb 2024 12:01:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706875308; cv=none; b=qr3ofTdRDm02HqyLhOPk3HN8HYRddGZn3ZN8+WTwiCU5ybPw/cdZ/Um0/nE0oB7EasOJAKtLTUo5xriU3i55MUu4Wf4T/A+X0sQIAP4v9CK2tGDN55av2n8kenmHkaUKy9PeMBuPWa0u9kscDkH1weq/OhA8A7HF0XQi3gqttkg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706875308; c=relaxed/simple; bh=cII07ZVkYr5EYEbiTAIRFoGZj9yihKnhBm6Dzc5b8hI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XBlc1ztCxUyBVSrki1ZcWYxRMCbJPfMI79yfT55BsXxtU3sv0q8EYgbk9mFMzY+A3EbuQilJUYNk/LdYwc8ksJvAo/kBEMbdSk06mxxMrBBhZh/mMFCfP1JUXSaK6gPyGJa8PY2hvBAvayi5T549IxZMa7PmhVNIw/+uza/ICAM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=i9FPphYC; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=CDCrybok; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=i9FPphYC; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=CDCrybok; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="i9FPphYC"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="CDCrybok"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="i9FPphYC"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="CDCrybok" Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 7EDC02234C; Fri, 2 Feb 2024 12:01:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1706875304; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=G8nCDHPTtkmTE95MOrSrMIvvtI4MS6W1afM0QAvTJ0w=; b=i9FPphYCtgdcbZTtRFoTL6cIPxFchHSH0CVG9ATcSI2KDBPv4C1/B//+bJZg06/cUIf2Il 9ZNFQTTnA/qzLNIoanJHVPfQzTIQZvtCVynJvAa2r8E2SibJ7zXMkYOXhjLBT6AdpwiGJq 8J3vKEdfaqs/iUg4/1sMerPxoQX24X8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1706875304; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=G8nCDHPTtkmTE95MOrSrMIvvtI4MS6W1afM0QAvTJ0w=; b=CDCrybokwTEYDTydY32NXf2rxisMtcO7eBjVMcpr4kf/geYBtfd1LSDFi54hDs+O3gf46N iL0jJQWAPspzcIAg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1706875304; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=G8nCDHPTtkmTE95MOrSrMIvvtI4MS6W1afM0QAvTJ0w=; b=i9FPphYCtgdcbZTtRFoTL6cIPxFchHSH0CVG9ATcSI2KDBPv4C1/B//+bJZg06/cUIf2Il 9ZNFQTTnA/qzLNIoanJHVPfQzTIQZvtCVynJvAa2r8E2SibJ7zXMkYOXhjLBT6AdpwiGJq 8J3vKEdfaqs/iUg4/1sMerPxoQX24X8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1706875304; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=G8nCDHPTtkmTE95MOrSrMIvvtI4MS6W1afM0QAvTJ0w=; b=CDCrybokwTEYDTydY32NXf2rxisMtcO7eBjVMcpr4kf/geYBtfd1LSDFi54hDs+O3gf46N iL0jJQWAPspzcIAg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 084FF13A61; Fri, 2 Feb 2024 12:01:44 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id 2D3VAKjZvGWfeAAAD6G6ig (envelope-from ); Fri, 02 Feb 2024 12:01:44 +0000 From: Thomas Zimmermann To: javierm@redhat.com, pjones@redhat.com, deller@gmx.de, ardb@kernel.org Cc: dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, Thomas Zimmermann Subject: [PATCH v2 5/8] firmware/sysfb: Create firmware device only for enabled PCI devices Date: Fri, 2 Feb 2024 12:58:46 +0100 Message-ID: <20240202120140.3517-6-tzimmermann@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240202120140.3517-1-tzimmermann@suse.de> References: <20240202120140.3517-1-tzimmermann@suse.de> Precedence: bulk X-Mailing-List: linux-fbdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Level: X-Spamd-Bar: / Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=i9FPphYC; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=CDCrybok X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-0.01 / 50.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; BROKEN_CONTENT_TYPE(1.50)[]; RCVD_COUNT_THREE(0.00)[3]; DKIM_TRACE(0.00)[suse.de:+]; MX_GOOD(-0.01)[]; RCPT_COUNT_SEVEN(0.00)[7]; NEURAL_HAM_SHORT(-0.20)[-1.000]; FREEMAIL_TO(0.00)[redhat.com,gmx.de,kernel.org]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; BAYES_HAM(-0.00)[10.21%]; ARC_NA(0.00)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCVD_DKIM_ARC_DNSWL_HI(-1.00)[]; FROM_HAS_DN(0.00)[]; DWL_DNSWL_MED(-2.00)[suse.de:dkim]; FREEMAIL_ENVRCPT(0.00)[gmx.de]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; NEURAL_HAM_LONG(-1.00)[-1.000]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_IN_DNSWL_HI(-0.50)[2a07:de40:b281:104:10:150:64:97:from]; RCVD_TLS_ALL(0.00)[] X-Spam-Score: -0.01 X-Rspamd-Queue-Id: 7EDC02234C X-Spam-Flag: NO Test if the firmware framebuffer's parent PCI device, if any, has been enabled. If not, the firmware framebuffer is most likely not working. Hence, do not create a device for the firmware framebuffer on disabled PCI devices. So far, efifb tracked the status of the PCI parent device internally and did not bind if it was disabled. This patch implements the functionality for all firmware framebuffers. v2: * rework sysfb_pci_dev_is_enabled() (Javier) Signed-off-by: Thomas Zimmermann Reviewed-by: Javier Martinez Canillas --- drivers/firmware/sysfb.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/drivers/firmware/sysfb.c b/drivers/firmware/sysfb.c index d02945b0d8ea1..ab5cbc0326f6d 100644 --- a/drivers/firmware/sysfb.c +++ b/drivers/firmware/sysfb.c @@ -70,13 +70,39 @@ void sysfb_disable(void) } EXPORT_SYMBOL_GPL(sysfb_disable); +#if defined(CONFIG_PCI) +static __init bool sysfb_pci_dev_is_enabled(struct pci_dev *pdev) +{ + /* + * TODO: Try to integrate this code into the PCI subsystem + */ + int ret; + u16 command; + + ret = pci_read_config_word(pdev, PCI_COMMAND, &command); + if (ret != PCIBIOS_SUCCESSFUL) + return false; + if (!(command & PCI_COMMAND_MEMORY)) + return false; + return true; +} +#else +static __init bool sysfb_pci_dev_is_enabled(struct pci_dev *pdev) +{ + return false; +} +#endif + static __init struct device *sysfb_parent_dev(const struct screen_info *si) { struct pci_dev *pdev; pdev = screen_info_pci_dev(si); - if (pdev) + if (pdev) { + if (!sysfb_pci_dev_is_enabled(pdev)) + return ERR_PTR(-ENODEV); return &pdev->dev; + } return NULL; } @@ -97,6 +123,8 @@ static __init int sysfb_init(void) sysfb_apply_efi_quirks(); parent = sysfb_parent_dev(si); + if (IS_ERR(parent)) + goto unlock_mutex; /* try to create a simple-framebuffer device */ compatible = sysfb_parse_mode(si, &mode);