From patchwork Wed May 13 19:50:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukas Wunner X-Patchwork-Id: 7000771 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 78462C05AC for ; Wed, 12 Aug 2015 11:40:07 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DBDDA20678 for ; Wed, 12 Aug 2015 11:40:05 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 82271206FD for ; Wed, 12 Aug 2015 11:40:04 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 582D16EB3E; Wed, 12 Aug 2015 04:39:57 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mailout3.hostsharing.net (mailout3.hostsharing.net [176.9.242.54]) by gabe.freedesktop.org (Postfix) with ESMTPS id 195806EB31 for ; Wed, 12 Aug 2015 04:39:56 -0700 (PDT) Received: from h08.hostsharing.net (h08.hostsharing.net [83.223.95.28]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mailout3.hostsharing.net (Postfix) with ESMTPS id E61A7101C04A7; Wed, 12 Aug 2015 13:33:17 +0200 (CEST) Received: from localhost (6-38-90-81.adsl.cmo.de [81.90.38.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by h08.hostsharing.net (Postfix) with ESMTPSA id ED29D60423EA; Wed, 12 Aug 2015 13:33:14 +0200 (CEST) X-Mailbox-Line: From 38d3a35d277771b86e59879c2db25f434e7fbcb2 Mon Sep 17 00:00:00 2001 Message-Id: <38d3a35d277771b86e59879c2db25f434e7fbcb2.1439288957.git.lukas@wunner.de> In-Reply-To: <9eed8ede6f15a254ad578e783b050e1c585d5a15.1439288957.git.lukas@wunner.de> References: <29bed586baf62f6be77b7ab0ba1b8f5cb3be3aad.1439288957.git.lukas@wunner.de> <164b43588e80baaddb7a4d1081785c4d03a89c4b.1439288957.git.lukas@wunner.de> <27944adb13aa1ab246ee4a1ebb833e397324d073.1439288957.git.lukas@wunner.de> <2ac3eca0759cedd1009221cbef908605f8d29e1e.1439288957.git.lukas@wunner.de> <832f1cfceab9d9403b541b51733b87110fd8e019.1439288957.git.lukas@wunner.de> <88b49891e95ced43bfb57cc8472bb69985827153.1439288957.git.lukas@wunner.de> <2032c8103fc62d709f10be04a54b4df5c6302ad2.1439288957.git.lukas@wunner.de> <5aa64781469028545deb0f0360f56dad5dbe0057.1439288957.git.lukas@wunner.de> <53015af5b9a91332d3d74ef54fff587395447ecf.1439288957.git.lukas@wunner.de> <3313fb587249b00537dbcde127223151652427ec.1439288957.git.lukas@wunner.de> <9eed8ede6f15a254ad578e783b050e1c585d5a15.1439288957.git.lukas@wunner.de> From: Lukas Wunner Date: Wed, 13 May 2015 21:50:08 +0200 Subject: [PATCH v2 19/22 EXPERIMENTAL] drm: Amend struct drm_dp_aux with connector attribute To: dri-devel@lists.freedesktop.org Cc: Andreas Heider , Paul Hordiienko , William Brown , Bruno Bierbaumer , Matthew Garrett , Dave Airlie X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-0.8 required=5.0 tests=BAYES_00, DATE_IN_PAST_96_XX, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On dual GPU laptops which cannot switch the AUX channel separately from the main link and therefore rely on proxying through the vga_switcheroo active client, we need to restrict this to eDP so that only communication to the internal panel is proxied and not to external DP-connected displays which cannot be switched between GPUs, at least on the retina MacBook Pro. Therefore, amend struct drm_dp_aux with a pointer to the connector that the AUX channel belongs to so that we can check the connector type before using proxying. It actually seems more intuitive that the parent of an AUX channel is a specific connector rather than a device: The device an AUX channel belongs to can be determined from the connector by following connector->dev, but the connector an AUX channel belongs to cannot be unambiguously determined from dev since a device may have multiple DP connectors. Unfortunately we cannot remove the dev attribute since the msm driver calls drm_dp_aux_register way before initializing the connector, and the tegra driver uses a distinct of_device_id for the AUX channel so that it initializes separately from the connector. These two drivers set the newly added connector attribute in struct drm_dp_aux in a delayed fashion, i.e. upon initializing the connector. They are not known to be used for dual GPU laptops right now but maybe they will be in the future, so it seems reasonable to set the attribute in these drivers as well. Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=88861 Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=61115 Tested-by: Paul Hordiienko [MBP 6,2 2010 intel ILK + nvidia GT216 pre-retina] Tested-by: William Brown [MBP 8,2 2011 intel SNB + amd turks pre-retina] Tested-by: Lukas Wunner [MBP 9,1 2012 intel IVB + nvidia GK107 pre-retina] Tested-by: Bruno Bierbaumer [MBP 11,3 2013 intel HSW + nvidia GK107 retina -- work in progress] Signed-off-by: Lukas Wunner --- drivers/gpu/drm/i915/intel_dp.c | 1 + drivers/gpu/drm/msm/edp/edp_connector.c | 2 ++ drivers/gpu/drm/nouveau/nouveau_connector.c | 1 + drivers/gpu/drm/radeon/atombios_dp.c | 1 + drivers/gpu/drm/tegra/sor.c | 1 + include/drm/drm_dp_helper.h | 5 +++++ 6 files changed, 11 insertions(+) diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c index 23aa4ff..2b5a8ae 100644 --- a/drivers/gpu/drm/i915/intel_dp.c +++ b/drivers/gpu/drm/i915/intel_dp.c @@ -1066,6 +1066,7 @@ intel_dp_aux_init(struct intel_dp *intel_dp, struct intel_connector *connector) intel_dp->aux.name = name; intel_dp->aux.dev = dev->dev; + intel_dp->aux.connector = &connector->base; intel_dp->aux.transfer = intel_dp_aux_transfer; DRM_DEBUG_KMS("registering %s bus for %s\n", name, diff --git a/drivers/gpu/drm/msm/edp/edp_connector.c b/drivers/gpu/drm/msm/edp/edp_connector.c index b4d1b46..5ca3df9 100644 --- a/drivers/gpu/drm/msm/edp/edp_connector.c +++ b/drivers/gpu/drm/msm/edp/edp_connector.c @@ -140,6 +140,8 @@ struct drm_connector *msm_edp_connector_init(struct msm_edp *edp) drm_connector_helper_add(connector, &edp_connector_helper_funcs); + edp->ctrl->drm_aux->connector = connector; + /* We don't support HPD, so only poll status until connected. */ connector->polled = DRM_CONNECTOR_POLL_CONNECT; diff --git a/drivers/gpu/drm/nouveau/nouveau_connector.c b/drivers/gpu/drm/nouveau/nouveau_connector.c index ad59eab..1e5224f 100644 --- a/drivers/gpu/drm/nouveau/nouveau_connector.c +++ b/drivers/gpu/drm/nouveau/nouveau_connector.c @@ -1149,6 +1149,7 @@ nouveau_connector_create(struct drm_device *dev, int index) case DRM_MODE_CONNECTOR_DisplayPort: case DRM_MODE_CONNECTOR_eDP: nv_connector->aux.dev = dev->dev; + nv_connector->aux.connector = connector; nv_connector->aux.transfer = nouveau_connector_aux_xfer; ret = drm_dp_aux_register(&nv_connector->aux); if (ret) { diff --git a/drivers/gpu/drm/radeon/atombios_dp.c b/drivers/gpu/drm/radeon/atombios_dp.c index f81e0d7..495e035 100644 --- a/drivers/gpu/drm/radeon/atombios_dp.c +++ b/drivers/gpu/drm/radeon/atombios_dp.c @@ -232,6 +232,7 @@ void radeon_dp_aux_init(struct radeon_connector *radeon_connector) radeon_connector->ddc_bus->rec.hpd = radeon_connector->hpd.hpd; radeon_connector->ddc_bus->aux.dev = radeon_connector->base.kdev; + radeon_connector->ddc_bus->aux.connector = &radeon_connector->base; if (ASIC_IS_DCE5(rdev)) { if (radeon_auxch) radeon_connector->ddc_bus->aux.transfer = radeon_dp_aux_transfer_native; diff --git a/drivers/gpu/drm/tegra/sor.c b/drivers/gpu/drm/tegra/sor.c index 7591d89..372a05f 100644 --- a/drivers/gpu/drm/tegra/sor.c +++ b/drivers/gpu/drm/tegra/sor.c @@ -1480,6 +1480,7 @@ static int tegra_sor_init(struct host1x_client *client) drm_connector_helper_add(&sor->output.connector, &tegra_sor_connector_helper_funcs); sor->output.connector.dpms = DRM_MODE_DPMS_OFF; + sor->dpaux->aux->connector = &sor->output.connector; drm_encoder_init(drm, &sor->output.encoder, &tegra_sor_encoder_funcs, DRM_MODE_ENCODER_TMDS); diff --git a/include/drm/drm_dp_helper.h b/include/drm/drm_dp_helper.h index 2e86f64..c8e693e 100644 --- a/include/drm/drm_dp_helper.h +++ b/include/drm/drm_dp_helper.h @@ -658,6 +658,7 @@ struct drm_dp_aux_msg { * @name: user-visible name of this AUX channel and the I2C-over-AUX adapter * @ddc: I2C adapter that can be used for I2C-over-AUX communication * @dev: pointer to struct device that is the parent for this AUX channel + * @connector: pointer to connector that is the parent for this AUX channel * @hw_mutex: internal mutex used for locking transfers * @transfer: transfers a message representing a single AUX transaction * @@ -667,6 +668,9 @@ struct drm_dp_aux_msg { * The .name field may be used to specify the name of the I2C adapter. If set to * NULL, dev_name() of .dev will be used. * + * The .connector field should be set to a pointer to the connector that + * the AUX channel belongs to. + * * Drivers provide a hardware-specific implementation of how transactions * are executed via the .transfer() function. A pointer to a drm_dp_aux_msg * structure describing the transaction is passed into this function. Upon @@ -694,6 +698,7 @@ struct drm_dp_aux { const char *name; struct i2c_adapter ddc; struct device *dev; + struct drm_connector *connector; struct mutex hw_mutex; ssize_t (*transfer)(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg);