Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2317901pxa; Mon, 24 Aug 2020 10:44:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwU6Zu64R4Ha2+tZArghep4AATwPRc6b1taFpb+fr1fqQjB2qxlE9fDKLdJvhtGKYJNKQaO X-Received: by 2002:a17:906:80da:: with SMTP id a26mr6362152ejx.311.1598291088007; Mon, 24 Aug 2020 10:44:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598291088; cv=none; d=google.com; s=arc-20160816; b=cuuJxUsy5A5aOq9t2pX62c0wSRcavofDkyAsw3ZcDWMqFlgYubyevLPABlAg71JdWm eTukjip9KjgOkenHaWFBHlhy+WSgB5+5get+jS9Q3D47yi838X5Dd2XfNqOwf1qC6h60 0Y5T8PHyMUvB9bWN64MA6m3P8APxHR0i3cinLhfymbp9b1eRXHR0T9vSrYKzVEshlnE/ rTQMNVTP5/kUEYakunjfD65jvKU739BNqwcXRiwgi4Y06RaRAiJKFQQE1lNzFOTJfr95 KpUBd1U8eIQ6osKz/L3JO9KkeCeugczg7qDiXbghIqH3k0Tjm6UG/wP+lp2f0EK0FzlF Z/cg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:organization:references:in-reply-to:date:cc:to:reply-to :from:subject:message-id:dkim-signature; bh=KPku6gi3dxvRkdI/qQKB9W9BzXhpWhnoZ4SMbqlznzE=; b=Jw0q+2X7XZO29aNIwiBwM0tbUNiJAl7R713L2FmDhdRxUhXknFV+4gQpGAB2pXfXf/ y9pe8DGmwSHE5LB+X6Q09toQi+OBZF5cp95Qo7Py1WcyI826d+PrwyZ9H9sdUkx9C+HH +PFLNzzeAZH0jCxDtvWhGDoBzD1DXfizu9dpCcu28gB9k/nGrh1Th5ltmshd84TORfR0 SEYv6jxG+ASswutfjM20TOrTHTxf26RVA1//i5PJ5tSPjO3WObot2uJIrKCqRsbqBlgu wTRnJfzre8rbeP63AjvEO2G1sOkSBOSQ/XP05y+kAFzJQAI2Dr8hURt87LQbOqcWiBu7 BW+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bXg65SK1; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v25si2756631edy.530.2020.08.24.10.44.24; Mon, 24 Aug 2020 10:44:47 -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=@redhat.com header.s=mimecast20190719 header.b=bXg65SK1; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727112AbgHXRm4 (ORCPT + 99 others); Mon, 24 Aug 2020 13:42:56 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:28008 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726793AbgHXRmw (ORCPT ); Mon, 24 Aug 2020 13:42:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1598290970; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KPku6gi3dxvRkdI/qQKB9W9BzXhpWhnoZ4SMbqlznzE=; b=bXg65SK1sTenbD5tg5QWqqZ+v3IlolYU2OjTOCsHBcMSpwF1p7rdGkwIKVjnKublSMgndJ FC1q73beKoRX6wwjwiND58pJQlrdiQcN9LNMNHfutt2sD3cNSGHs3z8FWViRSqM38W2ofg W/2Yj7H3sMvAQBJIrR89IwohqF8wZ3s= Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-236-XZfdCM-KOCq2AyJ0s2BPWg-1; Mon, 24 Aug 2020 13:42:44 -0400 X-MC-Unique: XZfdCM-KOCq2AyJ0s2BPWg-1 Received: by mail-qt1-f199.google.com with SMTP id w1so4775667qto.4 for ; Mon, 24 Aug 2020 10:42:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:reply-to:to:cc:date :in-reply-to:references:organization:user-agent:mime-version :content-transfer-encoding; bh=KPku6gi3dxvRkdI/qQKB9W9BzXhpWhnoZ4SMbqlznzE=; b=Z5bfdqQXNqCTuy4ZwPg9ghjNMxUhZJSg4qYC4XDXiGo7W6DVT/EukbAFfPo94mfXZR lgUdBMU4m0ZFZsn92K8CL8RTrw4gchRUgdDpG2TGufT8JtTAdAI05UyK2mzq5/EKqQ9L BEYLxn3tjTugJ9K7fy38viIsp2oCRbccv+gRAe+yGvirXq39ABs5XBVlc+Ale4v1DI+g UNjBLmar8kcse6MUXdg/tCddhcOgjL5XxBITYqe+AHWa/DXmXQZud2iQd5RFah0RM+fG CG7YuBVjt+G0XjCTP8y63G2Q+3TFgf4LXX3SnmPOhb/ySezteTEa8+gMsRbMlAUie1TA qaXQ== X-Gm-Message-State: AOAM530y0jIiy0vs0IPZu7P/EHfbhcDxZRqnEmT9qsegBbsnkQiV9pRG wv3M/Z8/stERslnLVLnOLhFbTe5TKIffrmVT1BiJJgHz3pm3IEdku3SPucEN3XuRAU2kbgvxJcG aHqiibis8MF1Ct6PFDFBWy80a X-Received: by 2002:aed:27c8:: with SMTP id m8mr5875606qtg.302.1598290960264; Mon, 24 Aug 2020 10:42:40 -0700 (PDT) X-Received: by 2002:aed:27c8:: with SMTP id m8mr5875581qtg.302.1598290959896; Mon, 24 Aug 2020 10:42:39 -0700 (PDT) Received: from Whitewolf.lyude.net (pool-108-49-102-102.bstnma.fios.verizon.net. [108.49.102.102]) by smtp.gmail.com with ESMTPSA id y26sm11209366qto.75.2020.08.24.10.42.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Aug 2020 10:42:39 -0700 (PDT) Message-ID: Subject: Re: [PATCH] drm/dp_mst: Add ddc i2c device links for DP MST connectors From: Lyude Paul Reply-To: lyude@redhat.com To: imre.deak@intel.com, Sam McNally , Wayne Lin Cc: LKML , Daniel Vetter , David Airlie , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , dri-devel@lists.freedesktop.org Date: Mon, 24 Aug 2020 13:42:38 -0400 In-Reply-To: <20200820180312.GC2423@ideak-desk.fi.intel.com> References: <20200729161510.1.Iaa9c3d7c4332cf8717653f3d3ae6f2b955aa3fc6@changeid> <20200814145956.GA12962@ideak-desk.fi.intel.com> <20200820180312.GC2423@ideak-desk.fi.intel.com> Organization: Red Hat Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.5 (3.36.5-1.fc32) MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 2020-08-20 at 21:03 +0300, Imre Deak wrote: > On Thu, Aug 20, 2020 at 12:27:03PM +1000, Sam McNally wrote: > > > > [...] > > > > 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. > > Re-reading the code, a DRM connector is created whenever the MST port is > an output port, so even in the case of an output branch port. > > I'm still not sure why we can't register/unregister the I2C bus whenever > creating/removing the DRM connector. That's also the scope of the AUX > bus, which is what I2C depends on, and if a port doesn't support I2C > messaging then the corresponding AUX messages would be NAKed. FWIW - I'm totally fine with this, as long as it works :) > > --Imre > > > [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 > > > > -- Sincerely, Lyude Paul (she/her) Software Engineer at Red Hat