From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E63DDC44500 for ; Tue, 7 Jul 2026 13:57:46 +0000 (UTC) Received: from kara.freedesktop.org (unknown [131.252.210.166]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1514910ED7D; Tue, 7 Jul 2026 13:57:45 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.de header.i=@suse.de header.b="1ASZGEt6"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="o8QB6u0A"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=suse.de header.i=@suse.de header.b="1ASZGEt6"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="o8QB6u0A"; dkim-atps=neutral Received: from kara.freedesktop.org (localhost [127.0.0.1]) by kara.freedesktop.org (Postfix) with ESMTP id 74AC046F2E; Tue, 7 Jul 2026 13:42:47 +0000 (UTC) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=lists.freedesktop.org; s=20240201; t=1783431767; b=y3ITiLnKTUPdML1ysUjonCubdNPpVE+fgs2GyD1VmUpWrCb9Ndj7Rss4VZRmyUN0FcLKJ tiv/GsmW/EdQcS8g5V+6Btem5XmM1u6UsnULH7qi9H5u9yYIe6Z7r9wLyfuETR11WucmW5F p3tb5bCZD++v9rBa2UdONL0tryQ6eBpzwQJUBWIU40CfW6Qb7G7vvTiDMXXzIx9VrV0aLC/ yU84sBHekEaM7TFTbZ8yt0PlorTSvkbqIyfavgeimJ1E7OAm+5eTrw4wUEJiHCG+JVpxqDr ECnLzR+RPAMpVkHbW4kLNEgzkpME1rV8jSHaN3thW4Rp1DD8k5xEXWpDUmng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=lists.freedesktop.org; s=20240201; t=1783431767; h=from : sender : reply-to : subject : date : message-id : to : cc : mime-version : content-type : content-transfer-encoding : content-id : content-description : resent-date : resent-from : resent-sender : resent-to : resent-cc : resent-message-id : in-reply-to : references : list-id : list-help : list-unsubscribe : list-subscribe : list-post : list-owner : list-archive; bh=cyY+LmUJ9UyYTr8arxvkIun7TSdOph/Uo1pPh/G+dJE=; b=ySr9ztdrpxWZdRH6qOPJlnsRIVTCM5pRo8utj45ZkuVkBA/hbeDDyniI+oNCfSXc7jDqU Xi4rVZw8rQ9V0qkEO5YhhL+w9UyZO9Az3Yb+GnrxtlCKfsbzemHlTs/qqSnBtgablx7RcCK v6Oa2UdRulXZ/psP+1mWyR/2gNcz3tbKXGVUxb+OubDL3qExd/Ppsk8H2TaCYraWWVKHTue ODzyeu0PJXmN79U4yZkG7jI62HERc2f+n7mpwzWhjxseJWl1Qg9QJE0S/jlXKle2Wzd6HrF 8QNl6QYG66LqDeHPWiycL2vHVPfdc4zy8mb1AfUVSuOvJ8FeVbYDDFNh8ttQ== ARC-Authentication-Results: i=1; mail.freedesktop.org; dkim=pass header.d=suse.de; arc=none (Message is not ARC signed); dmarc=pass (Used From Domain Record) header.from=suse.de policy.dmarc=none Authentication-Results: mail.freedesktop.org; dkim=pass header.d=suse.de; arc=none (Message is not ARC signed); dmarc=pass (Used From Domain Record) header.from=suse.de policy.dmarc=none Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by kara.freedesktop.org (Postfix) with ESMTPS id 1C63D46F2B for ; Tue, 7 Jul 2026 13:42:43 +0000 (UTC) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6809710ED60 for ; Tue, 7 Jul 2026 13:57:40 +0000 (UTC) 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 6719A75BEA; Tue, 7 Jul 2026 13:57:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1783432651; 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=cyY+LmUJ9UyYTr8arxvkIun7TSdOph/Uo1pPh/G+dJE=; b=1ASZGEt6pKO0yr4s+zqrhXX1UYkecQziH/BT24rgcYnRYBqQ6BBEYadOxmXvcuCplIEIq7 S7wX54u9RE5MnBj9yxsWUyxPKzlCNEQm/uknguc836BOQCfOYv5jCqzLwebUvnG0pC46wO yrKs59qyFJc6iF3WoIZVWNtpV7cgdUc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1783432651; 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=cyY+LmUJ9UyYTr8arxvkIun7TSdOph/Uo1pPh/G+dJE=; b=o8QB6u0AaEuV/aI7dvHIVZZE26IxHVvqraLqoi0N7oJAFXx4QsTtyip/+R+YnhQksnHaNU iepdTv5FoHNxO2Cw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1783432651; 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=cyY+LmUJ9UyYTr8arxvkIun7TSdOph/Uo1pPh/G+dJE=; b=1ASZGEt6pKO0yr4s+zqrhXX1UYkecQziH/BT24rgcYnRYBqQ6BBEYadOxmXvcuCplIEIq7 S7wX54u9RE5MnBj9yxsWUyxPKzlCNEQm/uknguc836BOQCfOYv5jCqzLwebUvnG0pC46wO yrKs59qyFJc6iF3WoIZVWNtpV7cgdUc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1783432651; 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=cyY+LmUJ9UyYTr8arxvkIun7TSdOph/Uo1pPh/G+dJE=; b=o8QB6u0AaEuV/aI7dvHIVZZE26IxHVvqraLqoi0N7oJAFXx4QsTtyip/+R+YnhQksnHaNU iepdTv5FoHNxO2Cw== 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 D4988779AF; Tue, 7 Jul 2026 13:57:30 +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 2CumMsoFTWoFSgAAD6G6ig (envelope-from ); Tue, 07 Jul 2026 13:57:30 +0000 From: Thomas Zimmermann To: lukas@wunner.de, jfalempe@redhat.com, alexander.deucher@amd.com, christian.koenig@amd.com, airlied@gmail.com, simona@ffwll.ch, maarten.lankhorst@linux.intel.com, mripard@kernel.org, jani.nikula@linux.intel.com, joonas.lahtinen@linux.intel.com, rodrigo.vivi@intel.com, tursulin@ursulin.net, lyude@redhat.com, dakr@kernel.org, deller@gmx.de Subject: [PATCH 03/10] vga_switcheroo: Add pre_switch callback to client ops Date: Tue, 7 Jul 2026 15:38:10 +0200 Message-ID: <20260707135724.247562-4-tzimmermann@suse.de> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260707135724.247562-1-tzimmermann@suse.de> References: <20260707135724.247562-1-tzimmermann@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Action: no action X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-0.998]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; ARC_NA(0.00)[]; FREEMAIL_TO(0.00)[wunner.de,redhat.com,amd.com,gmail.com,ffwll.ch,linux.intel.com,kernel.org,intel.com,ursulin.net,gmx.de]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; MIME_TRACE(0.00)[0:+]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCPT_COUNT_TWELVE(0.00)[22]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns,suse.de:email,suse.de:dkim,suse.de:mid]; FROM_EQ_ENVFROM(0.00)[]; R_RATELIMIT(0.00)[to_ip_from(RLgosu6qu4h11rje89ht7rjgg5)]; RCVD_TLS_ALL(0.00)[]; DKIM_TRACE(0.00)[suse.de:+]; TO_DN_SOME(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com,gmx.de] X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Queue-Id: 6719A75BEA Message-ID-Hash: HHJCO5Y4BRR7U3MIXQBFQMR35FPYFU23 X-Message-ID-Hash: HHJCO5Y4BRR7U3MIXQBFQMR35FPYFU23 X-MailFrom: tzimmermann@suse.de X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, nouveau@lists.freedesktop.org, linux-fbdev@vger.kernel.org, sashiko-reviews@lists.linux.dev X-Mailman-Version: 3.3.8 Precedence: list List-Id: Nouveau development list Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Add pre_switch to struct vga_switcheroo_client_ops to inform the switcheroo client about upcoming switches of the outputs. This callback is intended to replace the hard-coded call to fbdev's fb_switch_outputs(). With DRM supporting more clients than just fbdev emulation, something more flexible is required. Signed-off-by: Thomas Zimmermann --- drivers/gpu/vga/vga_switcheroo.c | 4 +++- include/linux/vga_switcheroo.h | 12 +++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/vga/vga_switcheroo.c b/drivers/gpu/vga/vga_switcheroo.c index 22cf52b78b75..bdf1e56ae891 100644 --- a/drivers/gpu/vga/vga_switcheroo.c +++ b/drivers/gpu/vga/vga_switcheroo.c @@ -733,8 +733,10 @@ static int vga_switchto_stage2(struct vga_switcheroo_client *new_client) if (!active->driver_power_control) set_audio_state(active->id, VGA_SWITCHEROO_OFF); + if (new_client->ops->pre_switch) + new_client->ops->pre_switch(new_client->pdev); #if defined(CONFIG_FB) - if (new_client->fb_info) + else if (new_client->fb_info) fb_switch_outputs(new_client->fb_info); #endif diff --git a/include/linux/vga_switcheroo.h b/include/linux/vga_switcheroo.h index 7e6ac0114d55..d2ce30d8b6f7 100644 --- a/include/linux/vga_switcheroo.h +++ b/include/linux/vga_switcheroo.h @@ -127,23 +127,29 @@ struct vga_switcheroo_handler { * @set_gpu_state: do the equivalent of suspend/resume for the card. * Mandatory. This should not cut power to the discrete GPU, * which is the job of the handler + * @gpu_bound: Optional. Called before switching the outputs to the device. * @reprobe: poll outputs. * Optional. This gets called after waking the GPU and switching * the outputs to it * @can_switch: check if the device is in a position to switch now. * Mandatory. The client should return false if a user space process * has one of its device files open + * @pre_switch: prepare switch + * Optional. This gets called before switching the outputs to the + * GPU. Allows drivers to prepare for the switch. * @gpu_bound: notify the client id to audio client when the GPU is bound. * * Client callbacks. A client can be either a GPU or an audio device on a GPU. - * The @set_gpu_state and @can_switch methods are mandatory, @reprobe may be - * set to NULL. For audio clients, the @reprobe member is bogus. - * OTOH, @gpu_bound is only for audio clients, and not used for GPU clients. + * The @set_gpu_state and @can_switch methods are mandatory, @pre_switch and + * @reprobe may be set to NULL. For audio clients, the @pre_switch and + * @reprobe members are bogus. OTOH, @gpu_bound is only for audio clients, + * and not used for GPU clients. */ struct vga_switcheroo_client_ops { void (*set_gpu_state)(struct pci_dev *dev, enum vga_switcheroo_state); void (*reprobe)(struct pci_dev *dev); bool (*can_switch)(struct pci_dev *dev); + void (*pre_switch)(struct pci_dev *dev); void (*gpu_bound)(struct pci_dev *dev, enum vga_switcheroo_client_id); }; -- 2.54.0 From mboxrd@z Thu Jan 1 00:00:00 1970 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 D19A53ED135 for ; Tue, 7 Jul 2026 13:57:43 +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=1783432665; cv=none; b=SUECQ8SjUdNOHigf5Ay12gdkpMSwMLhJiEzS9JYI7ZS1KHkAoW2LJYwatP6hASGcIIka70vdT06LxgXay5EuF11MVcHV6EmeSFe2An4XdOsSiDiZQrF1H+tZwaIGtJg6iL2LjjBSH0ckeItiIZcwsMBkmbJyQpS4SelPXawTwOU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783432665; c=relaxed/simple; bh=dCpkXkrXkGCB3OnMPVRF8mshtA+6Qp5NuA2wzmPvOYE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qq3MT/2nfUYzT/2b+kbXeSsFSljfg+JfVsA8Tdfy9SsJJcHKY8mwkKpBq6DRiFY5ORT3r/7bjO5Y4rszeFTKmOH/fJPLRig77HiN5ld4w3rJ8ghL25BpxJfmyvqhxb+2Md7bGOqqmiHxyKtMXwvyEbAKQdZiRDdS9UabFSf10l8= 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=1ASZGEt6; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=o8QB6u0A; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=1ASZGEt6; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=o8QB6u0A; 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="1ASZGEt6"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="o8QB6u0A"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="1ASZGEt6"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="o8QB6u0A" 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 6719A75BEA; Tue, 7 Jul 2026 13:57:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1783432651; 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=cyY+LmUJ9UyYTr8arxvkIun7TSdOph/Uo1pPh/G+dJE=; b=1ASZGEt6pKO0yr4s+zqrhXX1UYkecQziH/BT24rgcYnRYBqQ6BBEYadOxmXvcuCplIEIq7 S7wX54u9RE5MnBj9yxsWUyxPKzlCNEQm/uknguc836BOQCfOYv5jCqzLwebUvnG0pC46wO yrKs59qyFJc6iF3WoIZVWNtpV7cgdUc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1783432651; 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=cyY+LmUJ9UyYTr8arxvkIun7TSdOph/Uo1pPh/G+dJE=; b=o8QB6u0AaEuV/aI7dvHIVZZE26IxHVvqraLqoi0N7oJAFXx4QsTtyip/+R+YnhQksnHaNU iepdTv5FoHNxO2Cw== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=1ASZGEt6; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=o8QB6u0A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1783432651; 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=cyY+LmUJ9UyYTr8arxvkIun7TSdOph/Uo1pPh/G+dJE=; b=1ASZGEt6pKO0yr4s+zqrhXX1UYkecQziH/BT24rgcYnRYBqQ6BBEYadOxmXvcuCplIEIq7 S7wX54u9RE5MnBj9yxsWUyxPKzlCNEQm/uknguc836BOQCfOYv5jCqzLwebUvnG0pC46wO yrKs59qyFJc6iF3WoIZVWNtpV7cgdUc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1783432651; 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=cyY+LmUJ9UyYTr8arxvkIun7TSdOph/Uo1pPh/G+dJE=; b=o8QB6u0AaEuV/aI7dvHIVZZE26IxHVvqraLqoi0N7oJAFXx4QsTtyip/+R+YnhQksnHaNU iepdTv5FoHNxO2Cw== 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 D4988779AF; Tue, 7 Jul 2026 13:57:30 +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 2CumMsoFTWoFSgAAD6G6ig (envelope-from ); Tue, 07 Jul 2026 13:57:30 +0000 From: Thomas Zimmermann To: lukas@wunner.de, jfalempe@redhat.com, alexander.deucher@amd.com, christian.koenig@amd.com, airlied@gmail.com, simona@ffwll.ch, maarten.lankhorst@linux.intel.com, mripard@kernel.org, jani.nikula@linux.intel.com, joonas.lahtinen@linux.intel.com, rodrigo.vivi@intel.com, tursulin@ursulin.net, lyude@redhat.com, dakr@kernel.org, deller@gmx.de Cc: dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, nouveau@lists.freedesktop.org, linux-fbdev@vger.kernel.org, sashiko-reviews@lists.linux.dev, Thomas Zimmermann Subject: [PATCH 03/10] vga_switcheroo: Add pre_switch callback to client ops Date: Tue, 7 Jul 2026 15:38:10 +0200 Message-ID: <20260707135724.247562-4-tzimmermann@suse.de> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260707135724.247562-1-tzimmermann@suse.de> References: <20260707135724.247562-1-tzimmermann@suse.de> Precedence: bulk X-Mailing-List: linux-fbdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Flag: NO X-Rspamd-Action: no action X-Spam-Level: X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-0.998]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; ARC_NA(0.00)[]; FREEMAIL_TO(0.00)[wunner.de,redhat.com,amd.com,gmail.com,ffwll.ch,linux.intel.com,kernel.org,intel.com,ursulin.net,gmx.de]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; MIME_TRACE(0.00)[0:+]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCPT_COUNT_TWELVE(0.00)[22]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns,suse.de:email,suse.de:dkim,suse.de:mid]; FROM_EQ_ENVFROM(0.00)[]; R_RATELIMIT(0.00)[to_ip_from(RLgosu6qu4h11rje89ht7rjgg5)]; RCVD_TLS_ALL(0.00)[]; DKIM_TRACE(0.00)[suse.de:+]; TO_DN_SOME(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com,gmx.de] X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Queue-Id: 6719A75BEA X-Spam-Score: -3.01 Add pre_switch to struct vga_switcheroo_client_ops to inform the switcheroo client about upcoming switches of the outputs. This callback is intended to replace the hard-coded call to fbdev's fb_switch_outputs(). With DRM supporting more clients than just fbdev emulation, something more flexible is required. Signed-off-by: Thomas Zimmermann --- drivers/gpu/vga/vga_switcheroo.c | 4 +++- include/linux/vga_switcheroo.h | 12 +++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/vga/vga_switcheroo.c b/drivers/gpu/vga/vga_switcheroo.c index 22cf52b78b75..bdf1e56ae891 100644 --- a/drivers/gpu/vga/vga_switcheroo.c +++ b/drivers/gpu/vga/vga_switcheroo.c @@ -733,8 +733,10 @@ static int vga_switchto_stage2(struct vga_switcheroo_client *new_client) if (!active->driver_power_control) set_audio_state(active->id, VGA_SWITCHEROO_OFF); + if (new_client->ops->pre_switch) + new_client->ops->pre_switch(new_client->pdev); #if defined(CONFIG_FB) - if (new_client->fb_info) + else if (new_client->fb_info) fb_switch_outputs(new_client->fb_info); #endif diff --git a/include/linux/vga_switcheroo.h b/include/linux/vga_switcheroo.h index 7e6ac0114d55..d2ce30d8b6f7 100644 --- a/include/linux/vga_switcheroo.h +++ b/include/linux/vga_switcheroo.h @@ -127,23 +127,29 @@ struct vga_switcheroo_handler { * @set_gpu_state: do the equivalent of suspend/resume for the card. * Mandatory. This should not cut power to the discrete GPU, * which is the job of the handler + * @gpu_bound: Optional. Called before switching the outputs to the device. * @reprobe: poll outputs. * Optional. This gets called after waking the GPU and switching * the outputs to it * @can_switch: check if the device is in a position to switch now. * Mandatory. The client should return false if a user space process * has one of its device files open + * @pre_switch: prepare switch + * Optional. This gets called before switching the outputs to the + * GPU. Allows drivers to prepare for the switch. * @gpu_bound: notify the client id to audio client when the GPU is bound. * * Client callbacks. A client can be either a GPU or an audio device on a GPU. - * The @set_gpu_state and @can_switch methods are mandatory, @reprobe may be - * set to NULL. For audio clients, the @reprobe member is bogus. - * OTOH, @gpu_bound is only for audio clients, and not used for GPU clients. + * The @set_gpu_state and @can_switch methods are mandatory, @pre_switch and + * @reprobe may be set to NULL. For audio clients, the @pre_switch and + * @reprobe members are bogus. OTOH, @gpu_bound is only for audio clients, + * and not used for GPU clients. */ struct vga_switcheroo_client_ops { void (*set_gpu_state)(struct pci_dev *dev, enum vga_switcheroo_state); void (*reprobe)(struct pci_dev *dev); bool (*can_switch)(struct pci_dev *dev); + void (*pre_switch)(struct pci_dev *dev); void (*gpu_bound)(struct pci_dev *dev, enum vga_switcheroo_client_id); }; -- 2.54.0