intel-gfx.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Dadap <ddadap@nvidia.com>
To: <dri-devel@lists.freedesktop.org>, <lukas@wunner.de>,
	<intel-gfx@lists.freedesktop.org>, <jani.nikula@linux.intel.com>,
	<joonas.lahtinen@linux.intel.com>, <rodrigo.vivi@intel.com>
Cc: Daniel Dadap <ddadap@nvidia.com>
Subject: [Intel-gfx] [PATCH 3/6] vga-switcheroo: notify clients of pending/completed switch events
Date: Mon, 27 Jul 2020 15:51:09 -0500	[thread overview]
Message-ID: <20200727205112.27698-4-ddadap@nvidia.com> (raw)
In-Reply-To: <20200727205112.27698-1-ddadap@nvidia.com>

Add a new vga-switcheroo client callback to allow clients to register
for receiving notifications when a mux switch is pending, completed,
or failed. This allows individual client drivers to prepare for or
respond to mux switches to and from the registered client device.

Signed-off-by: Daniel Dadap <ddadap@nvidia.com>
---
 drivers/gpu/vga/vga_switcheroo.c | 29 ++++++++++++++++++++++++++++-
 include/linux/vga_switcheroo.h   | 18 ++++++++++++++++++
 2 files changed, 46 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/vga/vga_switcheroo.c b/drivers/gpu/vga/vga_switcheroo.c
index a4fc78c4bf4f..6392dc92696b 100644
--- a/drivers/gpu/vga/vga_switcheroo.c
+++ b/drivers/gpu/vga/vga_switcheroo.c
@@ -756,14 +756,41 @@ static int vga_switchto_stage2(struct vga_switcheroo_client *new_client,
 	if (new_client->fb_info)
 		fbcon_remap_all(new_client->fb_info);
 
+	if (active->ops->notify)
+		active->ops->notify(active->pdev,
+			VGA_SWITCHEROO_NOTIFY_SWITCH_AWAY,
+			VGA_SWITCHEROO_NOTIFY_SWITCH_PENDING);
+	if (new_client->ops->notify)
+		new_client->ops->notify(new_client->pdev,
+			VGA_SWITCHEROO_NOTIFY_SWITCH_TO,
+			VGA_SWITCHEROO_NOTIFY_SWITCH_PENDING);
+
 	active->switched = false;
 	mutex_lock(&vgasr_priv.mux_hw_lock);
 	ret = vgasr_priv.handler->switchto(new_client->id);
 	mutex_unlock(&vgasr_priv.mux_hw_lock);
-	if (ret)
+	if (ret) {
+		if (active->ops->notify)
+			active->ops->notify(active->pdev,
+				VGA_SWITCHEROO_NOTIFY_SWITCH_AWAY,
+				VGA_SWITCHEROO_NOTIFY_SWITCH_FAILED);
+		if (new_client->ops->notify)
+			new_client->ops->notify(new_client->pdev,
+				VGA_SWITCHEROO_NOTIFY_SWITCH_TO,
+				VGA_SWITCHEROO_NOTIFY_SWITCH_FAILED);
 		return ret;
+	}
 	new_client->switched = true;
 
+	if (active->ops->notify)
+		active->ops->notify(active->pdev,
+			VGA_SWITCHEROO_NOTIFY_SWITCH_AWAY,
+			VGA_SWITCHEROO_NOTIFY_SWITCH_COMPLETE);
+	if (new_client->ops->notify)
+		new_client->ops->notify(new_client->pdev,
+			VGA_SWITCHEROO_NOTIFY_SWITCH_TO,
+			VGA_SWITCHEROO_NOTIFY_SWITCH_COMPLETE);
+
 	if (new_client->ops->reprobe)
 		new_client->ops->reprobe(new_client->pdev);
 
diff --git a/include/linux/vga_switcheroo.h b/include/linux/vga_switcheroo.h
index 63e6d6e5786e..2dc8ebc84fd4 100644
--- a/include/linux/vga_switcheroo.h
+++ b/include/linux/vga_switcheroo.h
@@ -90,6 +90,17 @@ enum vga_switcheroo_client_id {
 	VGA_SWITCHEROO_MAX_CLIENTS,
 };
 
+enum vga_switcheroo_notify_direction {
+	VGA_SWITCHEROO_NOTIFY_SWITCH_TO,
+	VGA_SWITCHEROO_NOTIFY_SWITCH_AWAY,
+};
+
+enum vga_switcheroo_notify_action {
+	VGA_SWITCHEROO_NOTIFY_SWITCH_PENDING,
+	VGA_SWITCHEROO_NOTIFY_SWITCH_COMPLETE,
+	VGA_SWITCHEROO_NOTIFY_SWITCH_FAILED,
+};
+
 /**
  * struct vga_switcheroo_handler - handler callbacks
  * @init: initialize handler.
@@ -134,6 +145,10 @@ struct vga_switcheroo_handler {
  * 	Mandatory. The client should return false if a user space process
  * 	has one of its device files open
  * @gpu_bound: notify the client id to audio client when the GPU is bound.
+ * @notify: notify clients of pending and completed switches
+ *	Optional. This gets called for both active and inactive clients,
+ *	before a switch begins, and after a switch successfully completes
+ *	or fails.
  *
  * 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
@@ -145,6 +160,9 @@ struct vga_switcheroo_client_ops {
 	void (*reprobe)(struct pci_dev *dev);
 	bool (*can_switch)(struct pci_dev *dev);
 	void (*gpu_bound)(struct pci_dev *dev, enum vga_switcheroo_client_id);
+	void (*notify)(struct pci_dev *dev,
+		       enum vga_switcheroo_notify_direction,
+		       enum vga_switcheroo_notify_action);
 };
 
 #if defined(CONFIG_VGA_SWITCHEROO)
-- 
2.18.4

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2020-07-27 21:35 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <ba78cd19-45ad-b17e-5174-256cc11f36c2%40nvidia.com>
2020-07-27 20:51 ` [Intel-gfx] [PATCH 0/6] vga-switcheroo: initial dynamic mux switch support Daniel Dadap
2020-07-27 20:51   ` [Intel-gfx] [PATCH 1/6] vga-switcheroo: add new "immediate" switch event type Daniel Dadap
2020-07-27 20:51   ` [Intel-gfx] [PATCH 2/6] vga-switcheroo: Add a way to test for the active client Daniel Dadap
2020-07-27 20:51   ` Daniel Dadap [this message]
2020-07-27 20:51   ` [Intel-gfx] [PATCH 4/6] i915: implement vga-switcheroo reprobe() callback Daniel Dadap
2020-07-27 20:51   ` [Intel-gfx] [PATCH 5/6] i915: fail atomic commit when muxed away Daniel Dadap
2020-07-27 20:51   ` [Intel-gfx] [PATCH 6/6] i915: bail out of eDP link training while mux-switched away Daniel Dadap
2020-07-28  9:32   ` [Intel-gfx] [PATCH 0/6] vga-switcheroo: initial dynamic mux switch support daniel
2020-07-27 22:05 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for series starting with [1/6] vga-switcheroo: add new "immediate" switch event type Patchwork
2020-07-27 22:06 ` [Intel-gfx] ✗ Fi.CI.SPARSE: " Patchwork
2020-07-27 22:36 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2020-07-28  0:45 ` [Intel-gfx] ✗ Fi.CI.IGT: failure " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200727205112.27698-4-ddadap@nvidia.com \
    --to=ddadap@nvidia.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=jani.nikula@linux.intel.com \
    --cc=joonas.lahtinen@linux.intel.com \
    --cc=lukas@wunner.de \
    --cc=rodrigo.vivi@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).