<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 26 May 2015, at 10:13, Samuel Pitoiset <<a href="mailto:samuel.pitoiset@gmail.com" class="">samuel.pitoiset@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">On 05/26/2015 12:22 AM, Pierre Moreau wrote:</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">Signed-off-by: Pierre Moreau <<a href="mailto:pierre.morrow@free.fr" class="">pierre.morrow@free.fr</a>><br class="">---<br class=""> drm/nouveau/nouveau_acpi.c | 53 ++++++++++++++++++++++++++++++++++++++++++++--<br class=""> drm/nouveau/nouveau_acpi.h | 2 ++<br class=""> drm/nouveau/nouveau_drm.c | 6 ++++--<br class=""> drm/nouveau/nouveau_vga.c | 10 +++++----<br class=""> 4 files changed, 63 insertions(+), 8 deletions(-)<br class=""><br class="">diff --git a/drm/nouveau/nouveau_acpi.c b/drm/nouveau/nouveau_acpi.c<br class="">index 104d291..3d6a1ea 100644<br class="">--- a/drm/nouveau/nouveau_acpi.c<br class="">+++ b/drm/nouveau/nouveau_acpi.c<br class="">@@ -29,6 +29,10 @@<br class=""> #define NOUVEAU_DSM_OPTIMUS_SET_POWERDOWN (NOUVEAU_DSM_OPTIMUS_POWERDOWN_PS3 | NOUVEAU_DSM_OPTIMUS_FLAGS_CHANGED)<br class=""> +#define NOUVEAU_DSM_GMUX_V1_CAPS (3 << 6)<br class="">+<br class="">+#define NOUVEAU_DSM_GMUX_V2_CAPS (1 << 1)<br class="">+<br class=""> /* result of the optimus caps function */<br class=""> #define OPTIMUS_ENABLED (1 << 0)<br class=""> #define OPTIMUS_STATUS_MASK (3 << 3)<br class="">@@ -45,6 +49,7 @@<br class=""> static struct nouveau_dsm_priv {<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span>bool mux_detected;<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span>bool optimus_detected;<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>bool gmux_detected;<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span>acpi_handle dhandle;<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span>acpi_handle rom_handle;<br class=""> } nouveau_dsm_priv;<br class="">@@ -57,8 +62,13 @@ bool nouveau_has_mux(void) {<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span>return nouveau_dsm_priv.mux_detected;<br class=""> }<br class=""> +bool nouveau_has_gmux(void) {<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>return nouveau_dsm_priv.gmux_detected;<br class="">+}<br class="">+<br class=""> #define NOUVEAU_DSM_HAS_MUX 0x1<br class=""> #define NOUVEAU_DSM_HAS_OPT 0x2<br class="">+#define NOUVEAU_DSM_HAS_GMUX 0x4<br class=""> #ifdef CONFIG_VGA_SWITCHEROO<br class=""> static const uint32_t nouveau_mux_dsm_rid = 0x00000102;<br class="">@@ -73,6 +83,18 @@ static const char nouveau_op_dsm_muid[] = {<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span>0xA7, 0x2B, 0x60, 0x42, 0xA6, 0xB5, 0xBE, 0xE0,<br class=""> };<br class=""> +static const uint32_t nouveau_gmux_v1_dsm_rid = 0x0000101;<br class="">+static const char nouveau_gmux_v1_dsm_muid[] = {<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>0xA6, 0x69, 0x86, 0x99, 0xE9, 0x8B, 0xFB, 0x49,<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>0xBD, 0xDB, 0x51, 0xA1, 0xEF, 0xE1, 0x9C, 0x3D,<br class="">+};<br class="">+<br class="">+static const uint32_t nouveau_gmux_v2_dsm_rid = 0x0000001;<br class="">+static const char nouveau_gmux_v2_dsm_muid[] = {<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>0xC6, 0xB7, 0xB5, 0xA0, 0x18, 0x13, 0x1C, 0x44,<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>0xB0, 0xC9, 0xFE, 0x69, 0x5E, 0xAF, 0x94, 0x9B,<br class="">+};<br class="">+<br class=""> static int nouveau_evaluate_optimus_dsm(acpi_handle handle, int func, int arg, uint32_t *result)<br class=""> {<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span>int i;<br class="">@@ -161,6 +183,17 @@ static int nouveau_evaluate_mux_dsm(acpi_handle handle, int func, int arg)<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span>return ret;<br class=""> }<br class=""> +static int nouveau_check_gmux_dsm(acpi_handle handle)<br class="">+{<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>bool has_v1 = acpi_check_dsm(handle, nouveau_gmux_v1_dsm_muid,<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-converted-space"> </span> nouveau_gmux_v1_dsm_rid,<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-converted-space"> </span> NOUVEAU_DSM_GMUX_V1_CAPS);<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>bool has_v2 = acpi_check_dsm(handle, nouveau_gmux_v2_dsm_muid,<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-converted-space"> </span> nouveau_gmux_v2_dsm_rid,<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-converted-space"> </span> NOUVEAU_DSM_GMUX_V2_CAPS);<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>return has_v1 || has_v2;<br class="">+}<br class="">+<br class=""> static int nouveau_dsm_switch_mux(acpi_handle handle, int mux_id)<br class=""> {<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span>mxm_wmi_call_mxmx(mux_id == NOUVEAU_DSM_MUX_LED_STAMINA ? MXM_MXDS_ADAPTER_IGD : MXM_MXDS_ADAPTER_0);<br class="">@@ -238,6 +271,9 @@ static int nouveau_dsm_pci_probe(struct pci_dev *pdev)<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-converted-space"> </span> 1 << NOUVEAU_DSM_MUX_POWER))<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>retval |= NOUVEAU_DSM_HAS_MUX;<br class=""> +<span class="Apple-tab-span" style="white-space: pre;"> </span>if (nouveau_check_gmux_dsm(dhandle))<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>retval |= NOUVEAU_DSM_HAS_GMUX;<br class="">+<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span>if (nouveau_check_optimus_dsm(dhandle))<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>retval |= NOUVEAU_DSM_HAS_OPT;<br class=""> @@ -263,6 +299,7 @@ static bool nouveau_dsm_detect(void)<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span>struct pci_dev *pdev = NULL;<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span>int has_dsm = 0;<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span>int has_optimus = 0;<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>bool has_gmux = false;<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span>int vga_count = 0;<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span>bool guid_valid;<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span>int retval;<br class="">@@ -283,6 +320,8 @@ static bool nouveau_dsm_detect(void)<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>has_dsm |= 1;<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>if (retval & NOUVEAU_DSM_HAS_OPT)<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>has_optimus = 1;<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>if (retval & NOUVEAU_DSM_HAS_GMUX)<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>has_gmux = true;<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span>}<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span>while ((pdev = pci_get_class(PCI_CLASS_DISPLAY_3D << 8, pdev)) != NULL) {<br class="">@@ -293,9 +332,11 @@ static bool nouveau_dsm_detect(void)<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>has_dsm |= 1;<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>if (retval & NOUVEAU_DSM_HAS_OPT)<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>has_optimus = 1;<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>if (retval & NOUVEAU_DSM_HAS_GMUX)<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>has_gmux = true;<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span>}<br class=""> -<span class="Apple-tab-span" style="white-space: pre;"> </span>/* find the optimus DSM or the mux DSM */<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>/* find the optimus DSM, the mux DSM or the gmux DSM */<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span>if (has_optimus == 1) {<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>acpi_get_name(nouveau_dsm_priv.dhandle, ACPI_FULL_PATHNAME,<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>&buffer);<br class="">@@ -310,6 +351,13 @@ static bool nouveau_dsm_detect(void)<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>acpi_method_name);<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>nouveau_dsm_priv.mux_detected = true;<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>ret = true;<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>} else if (has_gmux) {<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>acpi_get_name(nouveau_dsm_priv.dhandle, ACPI_FULL_PATHNAME,<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>&buffer);<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>printk(KERN_INFO "VGA switcheroo: detected gmux DSM switching method %s handle\n",<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>acpi_method_name);<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>nouveau_dsm_priv.gmux_detected = true;<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>ret = true;<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span>}<br class=""> @@ -321,7 +369,8 @@ void nouveau_register_dsm_handler(void)<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span>bool r;<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span>r = nouveau_dsm_detect();<br class="">-<span class="Apple-tab-span" style="white-space: pre;"> </span>if (!r)<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>/* Apple Gmux will register its own vga switcheroo handler */<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>if (!r || nouveau_has_gmux())<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>return;<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span>vga_switcheroo_register_handler(&nouveau_dsm_handler);<br class="">diff --git a/drm/nouveau/nouveau_acpi.h b/drm/nouveau/nouveau_acpi.h<br class="">index 2bd88a8..7fcfe82 100644<br class="">--- a/drm/nouveau/nouveau_acpi.h<br class="">+++ b/drm/nouveau/nouveau_acpi.h<br class="">@@ -6,6 +6,7 @@<br class=""> #if defined(CONFIG_ACPI) && defined(CONFIG_X86)<br class=""> bool nouveau_is_optimus(void);<br class=""> bool nouveau_has_mux(void);<br class="">+bool nouveau_has_gmux(void);<br class=""> void nouveau_register_dsm_handler(void);<br class=""> void nouveau_unregister_dsm_handler(void);<br class=""> void nouveau_switcheroo_optimus_dsm(void);<br class="">@@ -15,6 +16,7 @@ void *nouveau_acpi_edid(struct drm_device *, struct drm_connector *);<br class=""> #else<br class=""> static inline bool nouveau_is_optimus(void) { return false; };<br class=""> static inline bool nouveau_has_mux(void) { return false; };<br class="">+static inline bool nouveau_has_gmux(void) { return false; };<br class=""> static inline void nouveau_register_dsm_handler(void) {}<br class=""> static inline void nouveau_unregister_dsm_handler(void) {}<br class=""> static inline void nouveau_switcheroo_optimus_dsm(void) {}<br class="">diff --git a/drm/nouveau/nouveau_drm.c b/drm/nouveau/nouveau_drm.c<br class="">index c06a7a1..702aff8 100644<br class="">--- a/drm/nouveau/nouveau_drm.c<br class="">+++ b/drm/nouveau/nouveau_drm.c<br class="">@@ -719,7 +719,8 @@ nouveau_pmops_runtime_suspend(struct device *dev)<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span>}<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span>/* are we optimus enabled? */<br class="">-<span class="Apple-tab-span" style="white-space: pre;"> </span>if (nouveau_runtime_pm == -1 && !nouveau_is_optimus() && !nouveau_has_mux()) {<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>if (nouveau_runtime_pm == -1 &&<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-converted-space"> </span> !nouveau_is_optimus() && !nouveau_has_mux() && !nouveau_has_gmux()) {<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>DRM_DEBUG_DRIVER("failing to power off - not optimus\n");<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>pm_runtime_forbid(dev);<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>return -EBUSY;<br class="">@@ -780,7 +781,8 @@ nouveau_pmops_runtime_idle(struct device *dev)<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span>}<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span>/* are we optimus enabled? */<br class="">-<span class="Apple-tab-span" style="white-space: pre;"> </span>if (nouveau_runtime_pm == -1 && !nouveau_is_optimus() && !nouveau_has_mux()) {<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>if (nouveau_runtime_pm == -1 &&<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-converted-space"> </span> !nouveau_is_optimus() && !nouveau_has_mux() && !nouveau_has_gmux()) {<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>DRM_DEBUG_DRIVER("failing to power off - not optimus\n");<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>pm_runtime_forbid(dev);<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>return -EBUSY;<br class="">diff --git a/drm/nouveau/nouveau_vga.c b/drm/nouveau/nouveau_vga.c<br class="">index 9a6328f..3a7a9b9 100644<br class="">--- a/drm/nouveau/nouveau_vga.c<br class="">+++ b/drm/nouveau/nouveau_vga.c<br class="">@@ -96,11 +96,12 @@ nouveau_vga_init(struct nouveau_drm *drm)<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span>if (nouveau_runtime_pm == 1)<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>runtime = true;<br class="">-<span class="Apple-tab-span" style="white-space: pre;"> </span>if ((nouveau_runtime_pm == -1) && (nouveau_is_optimus() || nouveau_has_mux()))<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>if ((nouveau_runtime_pm == -1) &&<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-converted-space"> </span> (nouveau_is_optimus() || nouveau_has_mux() || nouveau_has_gmux()))<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>runtime = true;<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span>vga_switcheroo_register_client(dev->pdev, &nouveau_switcheroo_ops, runtime);<br class=""> -<span class="Apple-tab-span" style="white-space: pre;"> </span>if (runtime && nouveau_has_mux() && !nouveau_is_optimus())<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>if (runtime && (nouveau_has_mux() || nouveau_has_gmux()) && !nouveau_is_optimus())<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>vga_switcheroo_init_domain_pm_ops(drm->dev->dev, &drm->vga_pm_domain);<br class=""> }<br class=""> @@ -112,11 +113,12 @@ nouveau_vga_fini(struct nouveau_drm *drm)<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span>if (nouveau_runtime_pm == 1)<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>runtime = true;<br class="">-<span class="Apple-tab-span" style="white-space: pre;"> </span>if ((nouveau_runtime_pm == -1) && (nouveau_is_optimus() || nouveau_has_mux()))<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>if ((nouveau_runtime_pm == -1) &&<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-converted-space"> </span> (nouveau_is_optimus() || nouveau_has_mux() || nouveau_has_gmux()))<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>runtime = true;<br class=""> <br class=""></blockquote><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">You could maybe factorize a bit here by adding nouveau_has_optimus(). What do you think?</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""></div></blockquote><div><br class=""></div><div>I was thinking of something like that, but I wasn’t sure about the name. Using optimus seems tricky, because you could have nouveau_is_optimus(): false but nouveau_has_optimus(): true…</div><br class=""><blockquote type="cite" class=""><div class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span>vga_switcheroo_unregister_client(dev->pdev);<br class="">-<span class="Apple-tab-span" style="white-space: pre;"> </span>if (runtime && nouveau_has_mux() && !nouveau_is_optimus())<br class="">+<span class="Apple-tab-span" style="white-space: pre;"> </span>if (runtime && (nouveau_has_mux() || nouveau_has_gmux()) && !nouveau_is_optimus())<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;"> </span>vga_switcheroo_fini_domain_pm_ops(drm->dev->dev);<br class=""> <span class="Apple-tab-span" style="white-space: pre;"> </span>vga_client_register(dev->pdev, NULL, NULL, NULL);<br class=""> }</blockquote></div></blockquote></div><br class=""></body></html>