Received: by 2002:ab2:710b:0:b0:1ef:a325:1205 with SMTP id z11csp953795lql; Tue, 12 Mar 2024 03:09:15 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXpt12Hnc5N7t1gaE+BPFWQ+0AkRGC0hYIcVJuIHEcSdqyzlh+9jW0gZBD1mkszu0GLS6VNrXHkQ5jFjZgA2ZrbqbywcU4je6bbS3Au8w== X-Google-Smtp-Source: AGHT+IGwPR+Vkb5PqFY040qFyPs8gJLOlSjcHEP0o5kVJ4wqcWUvjFlwHND5QTgSsAOLe/MBAp8H X-Received: by 2002:a50:d483:0:b0:567:e812:e44e with SMTP id s3-20020a50d483000000b00567e812e44emr5938227edi.18.1710238155181; Tue, 12 Mar 2024 03:09:15 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710238155; cv=pass; d=google.com; s=arc-20160816; b=w1grTmwjhSG6tfKzthXx8rkeQBtOmgVZjPx3cfwxWWipYLaggw5RehsS6UEBEGKxq4 EWuvPYMWucNh5EXKQ0pSofhqakEHQzKURypSKXPG8zcc2rqD6GBcCPWIYJ+kygWGlDbt r2O9Xgyt4k/9/GUwkM1UqnbVp84jrqmOgN+ZRjsjwf3IRtDQhu31Mmx5duSF7UouAGQj 9KdyWsdMidUnx1z8VRRKgG6Tm4K7AVpdOBXk2WhbkJw9K3unWmLJZz52RS/POYHTjeqY A8rfGqUyWqhQQxLpyvHUWkyZrkYHNZZymTd1ga3s9X6yoZKshNp3PAgg3V6oqWcG6ldj P/Iw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=P364z5p7b0gwOmjb5egYI5Iw8E4hpUmzIUCNaUrAAb4=; fh=/Tvl+uDAQ0HiiOTkl8shMIh6FPVPcGwJkfACwg8QSrE=; b=vOlPgpOfi1s4PYsIoeNiwcu7Pc0wqGmc411vDrj3Fq9j97wyJHu2/y9FFM9+lh0Fel +duSb1Ws51EBKlr4QUzMw8nPUBOAmXMqzoMf9ylr/L7OH/+oygPUlR0EboBWQFWIOQuq Vups5/I73ZMBS1mezH9IlTe6OS1H3yptAZnDWmoVWSPdw0JzoWLfeur27RPrzN9HmMBN CbsjGfzMMKqDIsSNF66ySNLHdFCMvhoPuxWwyCcwrZEH7qKu4cJ3FT4i11Ag1r9J/T6L QrSZ9vC2o7MaERSBaaETiRbLIDN7WzcUm/VtNdYh5dn4KMwzt+enh3qlfVikbc4+qjex /VjQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bwpDKae3; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-100093-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-100093-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id er17-20020a056402449100b005683b59e6f0si3267818edb.629.2024.03.12.03.09.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Mar 2024 03:09:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-100093-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bwpDKae3; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-100093-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-100093-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id C1F3D1F22F51 for ; Tue, 12 Mar 2024 10:09:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C214178661; Tue, 12 Mar 2024 10:09:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="bwpDKae3" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E7BB33D3A7; Tue, 12 Mar 2024 10:09:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710238146; cv=none; b=BeZYDQSkxeRT446SvfmiZkhnpKCuAr4+xjpuakJHZFoMU4FuY1Yr9dp/0Rx8tITYG2Cgi5Anb7QTnUnLwgdcwurqg2KQK1Keo/5GwudOj0ZhYAxake7L16E4PN09zpeXls5idgex16ZsHsc7NpbDSUFW+xRpAC02Ugm0uDK6IAs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710238146; c=relaxed/simple; bh=AbfRb7Kg3IljFjwdymBcsCC9K7rYKzeKaZKP5Wl6L6w=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=FBI3FKk1+F+oP6FZskuQFUga1UDvuV6rRAhtqXYw6j63vGp2TiSlyBQ+QUX0py/Xf/d6kzIsgxnAER6IrhrLMPIjDh0M2TBcX1pJ8XPK18D0F5T5BLLrI6ad1Ieech3FagFI0r+Nb2vHFB4skoM6566n/Tbyht4XPNnjV7eN6ow= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=bwpDKae3; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7EAFEC433F1; Tue, 12 Mar 2024 10:09:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1710238145; bh=AbfRb7Kg3IljFjwdymBcsCC9K7rYKzeKaZKP5Wl6L6w=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=bwpDKae3eYTmJz4L6IDtofbiuUok6opahnBlZq94FCd30Y3GIjgNw5ETcXZQ0R+cL HaVf2wBHGruoBOsRZVGRviZ1ELu8yX06EEA21vuhSVigxG4hDCAzW7P8DOFxHhWJKd z8bcmOa/UpsQNkrTnjbroOkwelh2nknMidzWfeDIW/o23UvQW4xWEg2fhyxzpgGpLW 9QBWdpPN5bn7kaDc2jQpgX+8oGSdx+NOgY1SAmr/VYd1fHJb/Uti/hOAfVDbNppxkX 4ef4Nrwf20XwYhy7qlq0EX2CV1Yf6hq0v+Z06RdToUb3X/WzEfa2H4GZZE/BG6NWRH px3uHIF7tsqkw== Received: from johan by xi.lan with local (Exim 4.97.1) (envelope-from ) id 1rjz4J-000000007YQ-0ATZ; Tue, 12 Mar 2024 11:09:11 +0100 Date: Tue, 12 Mar 2024 11:09:11 +0100 From: Johan Hovold To: Abhinav Kumar Cc: freedreno@lists.freedesktop.org, Rob Clark , Dmitry Baryshkov , Sean Paul , Marijn Suijten , David Airlie , Daniel Vetter , Kuogee Hsieh , dri-devel@lists.freedesktop.org, swboyd@chromium.org, quic_jesszhan@quicinc.com, quic_parellan@quicinc.com, quic_bjorande@quicinc.com, Rob Clark , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] drm/msm/dp: move link_ready out of HPD event thread Message-ID: References: <20240308214532.1404038-1-quic_abhinavk@quicinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240308214532.1404038-1-quic_abhinavk@quicinc.com> On Fri, Mar 08, 2024 at 01:45:32PM -0800, Abhinav Kumar wrote: > There are cases where the userspace might still send another > frame after the HPD disconnect causing a modeset cycle after > a disconnect. This messes the internal state machine of MSM DP driver > and can lead to a crash as there can be an imbalance between > bridge_disable() and bridge_enable(). Can you be more specific here? What steps would lead to this issue and how exactly does is mess with the state machine? Is there an easy way to reproduce it (e.g. by instrumenting the code with some sleep)? The hotplug code is really convoluted and having a clear description of the problem is needed to evaluate the patch (including when revisiting it some time from now when I've forgotten about how this state machine works). As you know, we ran into a related issue on sc8280xp (X13s) since 6.8-rc1, but that did not involve any user space interaction at all. For reference, there are some more details in this thread: https://lore.kernel.org/all/Ze8Ke_M2xHyPYCu-@hovoldconsulting.com/ > This was also previously reported on [1] for which [2] was posted > and helped resolve the issue by rejecting commits if the DP is not > in connected state. > > The change resolved the bug but there can also be another race condition. > If hpd_event_thread does not pick up the EV_USER_NOTIFICATION and process it > link_ready will also not be set to false allowing the frame to sneak in. How could the event thread fail to pick up the notification event? Or do you mean there's a race window before it has been processed? > Lets move setting link_ready outside of hpd_event_thread() processing to > eliminate a window of race condition. As we discussed in thread above, this patch does not eliminate the race, even if it may reduce the race window. > [1] : https://gitlab.freedesktop.org/drm/msm/-/issues/17 > [2] : https://lore.kernel.org/all/1664408211-25314-1-git-send-email-quic_khsieh@quicinc.com/ > > Fixes: 8a3b4c17f863 ("drm/msm/dp: employ bridge mechanism for display enable and disable") > Signed-off-by: Abhinav Kumar > @@ -466,6 +466,8 @@ static int dp_display_notify_disconnect(struct device *dev) > { > struct dp_display_private *dp = dev_get_dp_display_private(dev); > > + dp->dp_display.link_ready = false; As I also pointed out in the other thread, setting link_ready to false here means that any spurious connect event (during physical disconnect) will always be processed, something which can currently lead to a leaked runtime pm reference. Wasting some power is of course preferred over crashing the machine, but please take it into consideration anyway. Especially if your intention with this patch was to address the resets we saw with sc8280xp which are gone since the HPD notify revert (which fixed the hotplug detect issue that left the bridge in a half-initialised state). > + > dp_add_event(dp, EV_USER_NOTIFICATION, false, 0); > > return 0; Johan