Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp1297693lqe; Mon, 8 Apr 2024 05:15:09 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVyZzHc8pKNwUsfov6styoi+pW46mK9VOxk/Urs5OrKRoD9zXlpgNT2OsjrbKFubLV+aiho9hexthD19K2akaeB6jD7zDRzFi0e5cRyYg== X-Google-Smtp-Source: AGHT+IEsFUjFmTDw2dhWVrF9TpcvH6GxY01TkVrCrDhfmkcYONIKnTA7GvuhoXmy1v+vOAmqEnnP X-Received: by 2002:a17:903:28c:b0:1e3:d8ae:df34 with SMTP id j12-20020a170903028c00b001e3d8aedf34mr8832733plr.11.1712578509093; Mon, 08 Apr 2024 05:15:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712578509; cv=pass; d=google.com; s=arc-20160816; b=Iv3bZHWvq6C9fJQM6EWWpkfUMz2T6RjPWJxCgRNFxiPklOEEv5uNSSrmOxkuPiYiZM w2xPLvszTSJARt95vrm1vsuJNV+1UyO3RK5xOtA64lvm6wZQdDGMFKFwJjn8U8ll51iX xA3ot4YKZ2euv+WAywV1sdSxSfTaC3fSiOdcXQ30vt0yxQdogxKyYKXfhr6Njh0BUTU5 JU2C6uL5RsFBnOvQ4AC775ZBPhPg2bjHiSB8JE9UO0+iKgQC/1YwLXqqStETHR16g0fH FcCzeBinnWbgPGprrNs1oFuWQK2l4ea69fYVcL3v2qFGd1tBZmt5JXbUo7JmfFtTyInH EsuQ== 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=Igjl10yuomMk3PN7ebbNB0w0IBWFYpA9G3CdD49rZ30=; fh=6TxI++JWpFc/Xb9uu6X8x2mrgMBcvpAULi6iAj6TIgY=; b=fVNCsOd1+I+FuzfwbdEsNa2609/xHK+PcALwIOwfEragGOQhjN6mJvmnhfvcox3Li1 s3Rdjm5AM5yypYStZKNTsba/GemuI9HNEDfvSYYsExJwqAyA43ZBjREKs5U08H42MV6/ w2WLIMnIzgo9UYpFgjz4au0SxJv8IN2vfPFoPPtkDvtcrj+ypjrn8pNMEbEvEXSGlKo0 yHOG72riPsJIfICKYOuMy9X6eh0c8tggLHX1aQAODiqS15D+qduZWZiMfV/7YVpH3rbg V3Q0srUjGxGeNLyNmrN0oGZ4FLCIss0ymIQCLEYltzC5ZFQz7zBz0QJ+VYz7zfymVciQ TDAA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=stfBO71f; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-135308-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-135308-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id h10-20020a170902f7ca00b001e23723701fsi6069838plw.515.2024.04.08.05.15.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Apr 2024 05:15:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-135308-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=stfBO71f; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-135308-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-135308-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id EB6D4282F79 for ; Mon, 8 Apr 2024 12:14:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B9C846A8AE; Mon, 8 Apr 2024 12:14:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="stfBO71f" 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 D9CC76A33B; Mon, 8 Apr 2024 12:14:35 +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=1712578476; cv=none; b=Zow68kSzT+c/OYyaS4bvFbkEL4AEgtrku76OH4xMjJsrBxPLK89tx5d5fOYOVv3Z+VzCv+WSI5Zlk8fLUlcpsBzWPon4/geVi1oB0iCQJ8/jJLAYAAr0OWaUUhE/akiS4L1qMnUvBWmZAOACQYFZbyOU2RMh7NsTAhNBqaYELzs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712578476; c=relaxed/simple; bh=x+FsxZWRAjPjLs6UXRrQ4jbrSYbaGPFtemQodRNwj0Q=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=QomQLE1AM9x+TbfurQJuR2Kr/ZvQY/H22PmAAhjvpQ+okUMW+FQEN9g7+hPQ5wkRCSBTvDEXWk44iu+8sQqsxn+bW9+VJWTAcW1FXBWxRe53RknSs18V1mGuLxEjAQoVy4yXIK3FCVv5gzxf61oKK8aIPL8mwqQ4GErYFkVfI1c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=stfBO71f; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4CE6FC433C7; Mon, 8 Apr 2024 12:14:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712578475; bh=x+FsxZWRAjPjLs6UXRrQ4jbrSYbaGPFtemQodRNwj0Q=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=stfBO71fztxYkHI6vQb0jBV0kkAT+9xNUYlPLhYKidsvrIigy4SLLrRQrckt/8Ovw /xMaqUilw8ZVL/gTLnwzb+gETQokd2aLRtEJa57lwprg50osIy3lj1OGAeewn24yM3 kom4j8UtMNnJmq2jM1IbJMp4AGA6hx2yDi2WJYp2hHyEBagjcLYSniK1GRc6Uqq67f 1ghx88gA6ywGh94lZdWi03fvYNNtBQKZJiWYIV+tDQFI28zLcnzYDl4yabYGJ8CQWk iDcJvIv2DlSNv63+RcelicnrMEBP7Y3AfiZFY4czY3UdHyoJRlcJS6/7/mHlcGCjlv 9dAXU6vYEo5hA== Received: from johan by xi.lan with local (Exim 4.97.1) (envelope-from ) id 1rtntN-000000002B9-0kG0; Mon, 08 Apr 2024 14:14:29 +0200 Date: Mon, 8 Apr 2024 14:14:29 +0200 From: Johan Hovold To: Dmitry Baryshkov Cc: Bryan O'Donoghue , Heikki Krogerus , Bjorn Andersson , Konrad Dybcio , Greg Kroah-Hartman , linux-arm-msm@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Caleb Connolly Subject: Re: [PATCH v2] usb: typec: qcom-pmic-typec: split HPD bridge alloc and registration Message-ID: References: <20240408-qc-pmic-typec-hpd-split-v2-1-1704f5321b73@linaro.org> <2ejpom6ykci6o7d7luwa2ao4stpm24aoyi66aoncxcqcwgidxz@gcsqvpb3s7nr> 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: On Mon, Apr 08, 2024 at 02:48:44PM +0300, Dmitry Baryshkov wrote: > On Mon, 8 Apr 2024 at 14:44, Johan Hovold wrote: > > > > On Mon, Apr 08, 2024 at 01:49:48PM +0300, Dmitry Baryshkov wrote: > > > On Mon, Apr 08, 2024 at 09:11:32AM +0200, Johan Hovold wrote: > > > > On Mon, Apr 08, 2024 at 04:06:40AM +0300, Dmitry Baryshkov wrote: > > > > > If a probe function returns -EPROBE_DEFER after creating another device > > > > > there is a change of ending up in a probe deferral loop, (see commit > > > > > fbc35b45f9f6 ("Add documentation on meaning of -EPROBE_DEFER"). > > > > > > > > > > In order to prevent such probe-defer loops caused by qcom-pmic-typec > > > > > driver, use the API added by Johan Hovold and move HPD bridge > > > > > registration to the end of the probe function. > > > > > > > > You should be more specific here: which function called after > > > > qcom_pmic_typec_probe() can trigger a probe deferral? > > > > > > > > I doubt that applies to tcpm->port_start() and tcpm->pdphy_start() in > > > > which case the bridge should be added before those calls unless there > > > > are other reasons for not doing so, which then also should be mentioned. > > > > > > > > I suspect the trouble is with tcpm_register_port(), but please spell > > > > that out and mention in which scenarios that function may return > > > > -EPROBE_DEFER. > > > > > > The probe loop comes from from tcpm_register_port(), you are right. > > > However then putting bridge registration before the _start() functions > > > is also incorrect as this will be prone to use-after-free errors that > > > you have fixed in pmic-glink. > > > > You obviously have to mention that in the commit message as that is a > > separate change and also one that looks broken as you're now registering > > resources after the device has gone "live". > > No. I'm registering a child device rather than a resource. There's no difference. You're registering a resource for someone else to consume. And it's not obvious that this does not lead to missed events, etc. in this case. > > So you also need to explain why you think that is safe, if it should be > > done at all. You're essentially just papering over a DRM bug in the > > unlikely event that probe fails. > > Unfortunately, as pointed out by Reported-by, Caleb has actually hit > the probe failure loop. The probe loop is probably real, I don't don't doubt that, but you still need to explain when tcpm_register_port() can return -EPROBE_DEFER. But the point is, you don't have to register the bridge after *starting* the port to fix the probe loop. You're doing that for other, questionable reasons and you don't explain why in the commit message so that others can evaluate your reasoning. Johan