Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp98104ybg; Tue, 22 Oct 2019 16:50:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqwRQ5udtyOfPqGtzyOHFxhwZLpB5VD3y70MA4pE9ZwbRnloheOEkOLUiYgk4o7WLJvsyZIr X-Received: by 2002:aa7:d852:: with SMTP id f18mr7928169eds.110.1571788254537; Tue, 22 Oct 2019 16:50:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571788254; cv=none; d=google.com; s=arc-20160816; b=DaNT0mmIohoYlc5FSqCzIeXgNCrXhziDFTPXycaKXOVhGnqTilktOwZs2rFcywcstI 0viRLK3KZcDgaBRCFVCWpEDOjCTXdrDyUOkNHb8rFjVyq8zlWhdlZELk+F8Zh7attFoa b/1Hy63fE1OpciL6ZTS4szr11QOKbK1kZwoZjHAX7fsN1fISUm/3xrojck79jY3y97on XLWzbT3N3Ls8P1BcmZXN/5VlRUCgx+rwbcztXjRP/FsUoLd9WJwBayoSbM1fP+z1BUEB SFkTZCoVAdXGTPb1hD01CmwF0pthQgK3XFulrCLWk6NBDtE6vz/AkUnhQRt+yrpg5QrH /mYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=uWT/91UjYG+pRZcitLYG0hQ77Zt8GLqkiDgF5fsNM4I=; b=jFDdu/t2/fPqcMNFZB8/DJbWzB/251A9BdvLNOkSxgiCFjhmJI24XxGKl7myDem34L NPWNUmk97ej0fb+hKx6XWnrbOLhSzU4OsMhOGsRORvBgiFBniJNfcXMEn1MXH4vZ3jKu AHXLj+nBIb2NCtRgoJQ7IUqqWduVQWOGB02CY05jbgZqi21nhgCkrl9x0Sp7C7iQmVvB lnuxfODPU1bGa6UxpvLE320mPb/6srLbljgW7RDXe2YzukhwFhQEzLBd7K7s//H2kMkU 9K7F2ucXx8KZIlp/5qHD36cABNuZgPhDqphLLyO69eJpEk7n8SLJfpV4dqwFgphqCK9D cTtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@poorly.run header.s=google header.b=Vpzqcwbm; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k1si5710446eji.76.2019.10.22.16.50.16; Tue, 22 Oct 2019 16:50:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@poorly.run header.s=google header.b=Vpzqcwbm; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388682AbfJVUOh (ORCPT + 99 others); Tue, 22 Oct 2019 16:14:37 -0400 Received: from mail-yb1-f194.google.com ([209.85.219.194]:35720 "EHLO mail-yb1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387999AbfJVUOh (ORCPT ); Tue, 22 Oct 2019 16:14:37 -0400 Received: by mail-yb1-f194.google.com with SMTP id i6so5583720ybe.2 for ; Tue, 22 Oct 2019 13:14:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=poorly.run; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=uWT/91UjYG+pRZcitLYG0hQ77Zt8GLqkiDgF5fsNM4I=; b=Vpzqcwbm24NKQ2QXaeqLT9/Ve60BsfofS5RLmhJdZTxTjUvjY/jAw5mWfeiskCTnoh GxSWZWW+83K3fdZoJxz7bgcBm/RjZYUsmcj998XrFrep4sOc0W3cKMPkmvlf5AMYSk9i sx+x7Ot9QNU1Flr+6zsZw34aXN7XCMDADD2F2W+uTtkHcL/YCL2hZ914FWAfRO7+yVeM VJZjXoTgNXB1OY4bo1PQDjjSGMJc7mMEDaZqRsRq9BYer+yArpitWdgE3bypKHWKYk22 X7h3nDHBpb51BFX9pWuieF/3BfcHQhp4bu7QF54TrhC13zI9Gev1Rq94OVslw0lAOd2o n5Mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to:user-agent; bh=uWT/91UjYG+pRZcitLYG0hQ77Zt8GLqkiDgF5fsNM4I=; b=HFALkd6JPFXQ8pWziO29ZfQfW0Ibkg4B8cuIhGSP4FPhzQ3aEQmpCeAP9oCb2M5O05 osJA+7PghcoDFR9jaucLzY9Y5ZLiIIaOu5hpKjGCTrcd1TRGLLaKp5TBDcAoKi26YxdQ bd5oxlmKSo5516qynQ3sFWmXFKiaEp1xqYIxY347WIfb8/tKfe+LXE9rTqXnrXDfURX+ cVAd4qNmwm0nSDjI4jUn9C517ke3FXKvFwCdDp8EyDtTRotn94IcD64JxI/RpeWyUdT/ fca6vJnYTt3YKkSSRu9+LQqPt/BcvDb5Z2hYDHD2qo3iu28p173zbZDkx8Ry4sSZAowL VXkQ== X-Gm-Message-State: APjAAAUY3rijMRdkdn07caobIMI8FbNBLB0OUV5M7E9jBldK7YmVyZZe YClQ531ekXs1+kWX0tZeXKda3Q== X-Received: by 2002:a25:77ce:: with SMTP id s197mr3799322ybc.228.1571775276083; Tue, 22 Oct 2019 13:14:36 -0700 (PDT) Received: from localhost ([2620:0:1013:11:89c6:2139:5435:371d]) by smtp.gmail.com with ESMTPSA id d191sm210244ywd.71.2019.10.22.13.14.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2019 13:14:35 -0700 (PDT) Date: Tue, 22 Oct 2019 16:14:35 -0400 From: Sean Paul To: Lyude Paul Cc: dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, nouveau@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, Juston Li , Imre Deak , Ville =?iso-8859-1?Q?Syrj=E4l=E4?= , Harry Wentland , Daniel Vetter , Sean Paul , Maarten Lankhorst , Maxime Ripard , David Airlie , Daniel Vetter , linux-kernel@vger.kernel.org Subject: Re: [PATCH v5 07/14] drm/dp_mst: Don't forget to update port->input in drm_dp_mst_handle_conn_stat() Message-ID: <20191022201435.GD212858@art_vandelay> References: <20191022023641.8026-1-lyude@redhat.com> <20191022023641.8026-8-lyude@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20191022023641.8026-8-lyude@redhat.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 21, 2019 at 10:36:02PM -0400, Lyude Paul wrote: > This probably hasn't caused any problems up until now since it's > probably nearly impossible to encounter this in the wild, however if we > were to receive a connection status notification from the MST hub after > resume while we're in the middle of reprobing the link addresses for a > topology then there's a much larger chance that a port could have > changed from being an output port to input port (or vice versa). If we > forget to update this bit of information, we'll potentially ignore a > valid PDT change on a downstream port because we think it's an input > port. > > So, make sure we read the input_port field in connection status > notifications in drm_dp_mst_handle_conn_stat() to prevent this from > happening once we've implemented suspend/resume reprobing. > > Cc: Juston Li > Cc: Imre Deak > Cc: Ville Syrj?l? > Cc: Harry Wentland > Cc: Daniel Vetter > Signed-off-by: Lyude Paul > Reviewed-by: Sean Paul > --- > drivers/gpu/drm/drm_dp_mst_topology.c | 52 +++++++++++++++++++-------- > 1 file changed, 38 insertions(+), 14 deletions(-) > > diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c > index 7bf4db91ff90..c8e218b902ae 100644 > --- a/drivers/gpu/drm/drm_dp_mst_topology.c > +++ b/drivers/gpu/drm/drm_dp_mst_topology.c > @@ -2079,18 +2079,40 @@ drm_dp_mst_handle_conn_stat(struct drm_dp_mst_branch *mstb, > { > struct drm_dp_mst_topology_mgr *mgr = mstb->mgr; > struct drm_dp_mst_port *port; > - int old_ddps; > - bool dowork = false; > + int old_ddps, ret; > + u8 new_pdt; > + bool dowork = false, create_connector = false; > > port = drm_dp_get_port(mstb, conn_stat->port_number); > if (!port) > return; > > - /* Locking is only needed if the port's exposed to userspace */ > - if (port->connector) > + if (port->connector) { > + if (!port->input && conn_stat->input_port) { > + /* > + * We can't remove a connector from an already exposed > + * port, so just throw the port out and make sure we > + * reprobe the link address of it's parent MSTB > + */ > + drm_dp_mst_topology_unlink_port(mgr, port); > + mstb->link_address_sent = false; > + dowork = true; > + goto out; > + } > + > + /* > + * Locking is only needed if the port's exposed to userspace > + */ optional nit: this will still fit on one line > drm_modeset_lock(&mgr->base.lock, NULL); > + } else if (port->input && !conn_stat->input_port) { > + create_connector = true; > + /* Reprobe link address so we get num_sdp_streams */ > + mstb->link_address_sent = false; > + dowork = true; > + } > > old_ddps = port->ddps; > + port->input = conn_stat->input_port; > port->mcs = conn_stat->message_capability_status; > port->ldps = conn_stat->legacy_device_plug_status; > port->ddps = conn_stat->displayport_device_plug_status; > @@ -2103,21 +2125,23 @@ drm_dp_mst_handle_conn_stat(struct drm_dp_mst_branch *mstb, > } > } > > - if (!port->input) { > - int ret = drm_dp_port_set_pdt(port, > - conn_stat->peer_device_type); > - if (ret == 1) { > - dowork = true; > - } else if (ret < 0) { > - DRM_ERROR("Failed to change PDT for port %p: %d\n", > - port, ret); > - dowork = false; > - } > + new_pdt = port->input ? DP_PEER_DEVICE_NONE : conn_stat->peer_device_type; > + > + ret = drm_dp_port_set_pdt(port, new_pdt); > + if (ret == 1) { > + dowork = true; > + } else if (ret < 0) { > + DRM_ERROR("Failed to change PDT for port %p: %d\n", > + port, ret); > + dowork = false; > } > > if (port->connector) > drm_modeset_unlock(&mgr->base.lock); > + else if (create_connector) > + drm_dp_mst_port_add_connector(mstb, port); > > +out: > drm_dp_mst_topology_put_port(port); > if (dowork) > queue_work(system_long_wq, &mstb->mgr->work); > -- > 2.21.0 > -- Sean Paul, Software Engineer, Google / Chromium OS