Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp909786pxa; Wed, 19 Aug 2020 19:29:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwOFwNnFIx4XXUJSyiunvqG39EOc0poC0HsMpV16xqncymNWFJ4Hiakms9v0mrwX+Q9q4a+ X-Received: by 2002:aa7:db50:: with SMTP id n16mr853153edt.292.1597890550778; Wed, 19 Aug 2020 19:29:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597890550; cv=none; d=google.com; s=arc-20160816; b=UGQDlZ6h6Ka9Ben27BU7jHyvB/a/r41Vrt6afoMEWsWS8py/5cP7UScRBQMH1YTxpO 4/yTHdRf7OFvTBwErwMd0+fgwRSTwodTg09+9dTBoY/U7Lgyb9Rd7pqYRnSBQiV18ylv YZ4U5bHWQv/8ySkfkJshnf/dzysIDYD04nOdgQGtxsSpoojqB0d+0hYSSkpmscXs4U3P e6lG2QGhDO+z9/TlCyqSq99/rZpIU4TIKqTGHf2NeWAq6Z7Xr8R4LBsp/hd4HvY1ap8S J90U2ZZUzuQylNVJjtSuvQ1VGV7WMjuFGj0mwO/S6WmGUPMI1gDrei/zCbZXkcW228/+ 3haQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=s1iRO5PUEwoxn+BQDVff7Q0S8DqLabJs/zvwZKudU08=; b=VJNxX/uHpkODY1KYbn0FJ8fULL8iCbWMZRkVDKbbH3GEmrtDXVBmjBvSVacg5yiWc9 5yXfIpC5FPCkdnmMnep+mMPZ29yf4JCsxhJJ2fOOhfuuRMKkl3+hUPzAmG1FfgbA/UaR ld3UM15DG7VR7hTwFfhL8WP+uo81LnSMXPdu1Hi7mWRKeNaQydK7wXbA+FyUQyiI+ecK 9rUeBmD3KHwTDSDfwNL2nwvubkffo+FDIW6gmU8wdRVxOy7L/0vGpD+I8fzwjUt3pPbc Ck229XdUqJBRuQ/aMZd04LFq7Sl2A2UH8DVio0QOV3+1GosmQy8aaTAqLfwu1ld8cUit uZFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=R0Ilo9pb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o21si336294ejc.533.2020.08.19.19.28.46; Wed, 19 Aug 2020 19:29:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=R0Ilo9pb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726752AbgHTC1t (ORCPT + 99 others); Wed, 19 Aug 2020 22:27:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48600 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726362AbgHTC1s (ORCPT ); Wed, 19 Aug 2020 22:27:48 -0400 Received: from mail-il1-x143.google.com (mail-il1-x143.google.com [IPv6:2607:f8b0:4864:20::143]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 294C6C061757 for ; Wed, 19 Aug 2020 19:27:46 -0700 (PDT) Received: by mail-il1-x143.google.com with SMTP id p18so497404ilm.7 for ; Wed, 19 Aug 2020 19:27:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=s1iRO5PUEwoxn+BQDVff7Q0S8DqLabJs/zvwZKudU08=; b=R0Ilo9pbEwV1QcELP/G0YHafJ62sW9RW+n0w4aAnjroypno1+q7aUWPEZLH3nVkOg0 xANF+WKw1jpfmzx/hivpmyxc/LJDY8Y2PaEyWSBzlcCwJupAqPwL2eOykaublqH24k+z p0ExxkF/14tS8NEohByRUhzseRbMqB5ucSmEk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=s1iRO5PUEwoxn+BQDVff7Q0S8DqLabJs/zvwZKudU08=; b=FprlRnhGfXNpd37W3DPJs2HwYGLgUUmhLTZk7pITPQdWkjQ8WsNXhrE9H1A0Zern0g BFPh+5sw4wECyTPbL0Hmk4c6qv/e2cUi2WUGmZuG7chulvoRj9jhd3Ap6Ev2gJEdb3lF 1C7+iCy4EJRJgDn5TfB37uKODD8IOJxf1JvRI0LHZs8AOmRLsrTTcTve1DuHD66deKEA ZMQJ3WnIm0rfDNGxSHv7WFefD5+g+lT0wWomqeevnIZL9Mu09nZZNJGeLyZxmbmpnK3M 30mU4VMAfo7S3f4NSkJLOQSn+RfoRoR5J2Rfk2YbOP8zLBwbE6XTrJmpCZm+g/N9dCsU cUOw== X-Gm-Message-State: AOAM532+8lhfiSERgjDVefAjHsjwpJHa1ZYSQdz5UXVVWlcnLUEk6LEt 455XywEdeJBsOODs6LAqY1IPUkNv7q9NweS8juZOaA== X-Received: by 2002:a92:d086:: with SMTP id h6mr831618ilh.205.1597890462056; Wed, 19 Aug 2020 19:27:42 -0700 (PDT) MIME-Version: 1.0 References: <20200729161510.1.Iaa9c3d7c4332cf8717653f3d3ae6f2b955aa3fc6@changeid> <20200814145956.GA12962@ideak-desk.fi.intel.com> In-Reply-To: <20200814145956.GA12962@ideak-desk.fi.intel.com> From: Sam McNally Date: Thu, 20 Aug 2020 12:27:03 +1000 Message-ID: Subject: Re: [PATCH] drm/dp_mst: Add ddc i2c device links for DP MST connectors To: imre.deak@intel.com Cc: LKML , Daniel Vetter , David Airlie , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , dri-devel@lists.freedesktop.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Thanks for the feedback. On Sat, 15 Aug 2020 at 01:00, Imre Deak wrote: > > On Wed, Jul 29, 2020 at 04:15:28PM +1000, Sam McNally wrote: > > As of commit d8bd15b37d32 ("drm/dp_mst: Fix the DDC I2C device > > registration of an MST port"), DP MST DDC I2C devices are consistently > > parented to the underlying DRM device, making it challenging to > > associate the ddc i2c device with its connector from userspace. > > I can't see how was it less challenging before the commit. There is no > guarantee for a CSN message which was the only way for the i2c device to > get reparented to the connector. > Yes, that's true - the state before and after are both unable to support ddc reliable i2c device discovery, and consistency is better. The challenging part certainly is an ongoing affair - I wasn't intending to blame it on that commit, though it has come out that way, unfortunately. Looking at it now, that paragraph doesn't need to reference any commits in particular; I'll rewrite it for the next version. > > Given the need for further refactoring before the i2c devices can be > > parented to their connectors, in the meantime follow the pattern of > > commit e1a29c6c5955 ("drm: Add ddc link in sysfs created by > > drm_connector"), creating sysfs ddc links to the associated i2c device > > for MST DP connectors. > > > > If the connector is created and registered before the i2c device, create > > the link when registering the i2c device; otherwise, create the link > > during late connector registration. > > > > Signed-off-by: Sam McNally > > --- > > > > drivers/gpu/drm/drm_dp_mst_topology.c | 29 +++++++++++++++++++++++++-- > > 1 file changed, 27 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c > > index 1ac874e4e7a1..73a2299c2faa 100644 > > --- a/drivers/gpu/drm/drm_dp_mst_topology.c > > +++ b/drivers/gpu/drm/drm_dp_mst_topology.c > > @@ -2161,11 +2161,23 @@ static void build_mst_prop_path(const struct drm_dp_mst_branch *mstb, > > int drm_dp_mst_connector_late_register(struct drm_connector *connector, > > struct drm_dp_mst_port *port) > > { > > + int ret; > > DRM_DEBUG_KMS("registering %s remote bus for %s\n", > > port->aux.name, connector->kdev->kobj.name); > > > > port->aux.dev = connector->kdev; > > - return drm_dp_aux_register_devnode(&port->aux); > > + ret = drm_dp_aux_register_devnode(&port->aux); > > + if (ret) > > + return ret; > > + > > + if (port->pdt != DP_PEER_DEVICE_NONE && > > + drm_dp_mst_is_end_device(port->pdt, port->mcs)) { > > How can we get here when drm_dp_mst_is_end_device(port) is not true? > AFAICS that's only case where we should create a connector and an i2c > device. (IOW we don't create them for branch ports.) > I'm not sure what you mean. Wouldn't this condition be checked during the registration of any MST connector? This follows the pattern used in drm_dp_mst_port_add_connector() [0], which seems like it's invoked in the same cases as drm_dp_mst_connector_late_register(), modulo early outs for errors. [0] https://cgit.freedesktop.org/drm-tip/tree/drivers/gpu/drm/drm_dp_mst_topology.c?id=1939e049a8ec6cef03a098f7cc99cb0bbcff21c6#n2188 > > + ret = sysfs_create_link(&port->connector->kdev->kobj, > > + &port->aux.ddc.dev.kobj, "ddc"); > > + if (ret) > > + drm_dp_aux_unregister_devnode(&port->aux); > > + } > > + return ret; > > } > > EXPORT_SYMBOL(drm_dp_mst_connector_late_register); > > > > @@ -5490,6 +5502,7 @@ static int drm_dp_mst_register_i2c_bus(struct drm_dp_mst_port *port) > > { > > struct drm_dp_aux *aux = &port->aux; > > struct device *parent_dev = port->mgr->dev->dev; > > + int ret; > > > > aux->ddc.algo = &drm_dp_mst_i2c_algo; > > aux->ddc.algo_data = aux; > > @@ -5504,7 +5517,17 @@ static int drm_dp_mst_register_i2c_bus(struct drm_dp_mst_port *port) > > strlcpy(aux->ddc.name, aux->name ? aux->name : dev_name(parent_dev), > > sizeof(aux->ddc.name)); > > > > - return i2c_add_adapter(&aux->ddc); > > + ret = i2c_add_adapter(&aux->ddc); > > + if (ret) > > + return ret; > > + > > + if (port->connector && port->connector->kdev) { > > + ret = sysfs_create_link(&port->connector->kdev->kobj, > > + &port->aux.ddc.dev.kobj, "ddc"); > > + if (ret) > > + i2c_del_adapter(&port->aux.ddc); > > + } > > + return ret; > > } > > > > /** > > @@ -5513,6 +5536,8 @@ static int drm_dp_mst_register_i2c_bus(struct drm_dp_mst_port *port) > > */ > > static void drm_dp_mst_unregister_i2c_bus(struct drm_dp_mst_port *port) > > { > > + if (port->connector && port->connector->kdev) > > + sysfs_remove_link(&port->connector->kdev->kobj, "ddc"); > > i2c_del_adapter(&port->aux.ddc); > > } > > > > -- > > 2.28.0.rc0.142.g3c755180ce-goog > >