Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp1281207lqe; Mon, 8 Apr 2024 04:44:30 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW2YWN2lHjSr/Tt6mmrJ3KNMzZTHXdHjRnSt4iJgzlkjxGILakuzlaKEJb7lLvwJgn7wErBNpS619JXsvmW/saVQdrjPLhv7CWyh3ULSA== X-Google-Smtp-Source: AGHT+IFeCWuDd04zV7kbqDBOkUc7V1OCXcA4C2hdiNGaqatdPDtkPWTP56pDaqSRhCalB2vRkIJB X-Received: by 2002:a17:907:7d90:b0:a51:ce36:1534 with SMTP id oz16-20020a1709077d9000b00a51ce361534mr3063273ejc.48.1712576669964; Mon, 08 Apr 2024 04:44:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712576669; cv=pass; d=google.com; s=arc-20160816; b=dDCLi49ltE0GasnMftx3kAwL9H/lZYZDWZm3uWrtP7quh4QcdOR5CRkHeewWBAFLeq plVLSkOwLVcgGk8cKl3uefXFLF20GAUqH6lxPefp5Awj1pq2fRkC3rvT92xABj1SaLQr JkTZ/i8kPzL/M5pz2M37VmfdaQDh+v2foKcWcfvBuVVtFTvFHEbXisCc/b0HpKjBO/yx D9AmUKvMGWrobjU6k9hOVvJm+5PY07eoXoN5yy+2HuQHMU58bnLA9yT4TN2GYNjjtjpb ludngfgH4us+P465xgtCMa/PPTieAOvrCCVbChb0ORoBSS+Vw9REwhjQE2dBHHpL91Df UwRA== 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=N0FFN/FZVwKwPhJXmYBHq6iAUFiLBqc7mXKGw5ZmsCw=; fh=6TxI++JWpFc/Xb9uu6X8x2mrgMBcvpAULi6iAj6TIgY=; b=g9HIK14H9E54y7q5u7SODPtd/53pWNuRCTd4949DptNfQY1X78xN6wZFy/khzwjjar 8ytbaDst1+avHL/AXCan0hzVp8qCcxJ/Y7QZyvKC0p76x95PewZ+q/SDIzbLz15rIIbr HzQOsfdIAEj4jYh4oZNZyNwt+rxtPHlqfLYq28xaKROnUvXxN3jwwLoNskzvJ2h06bxf D18/9k5By5Kn0Hxzabds2RPikDTODecmdSryZQ7ttzpgGMqm5T9e32lV/ynMtt5v5kqL uID/ZgY8wKU5itESpAFI3yUYyxPiOACiZmu1wM+JT9nvZvPfBXOWYuYCNX+LFFV4fkH+ Q0jg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pctBE7b0; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-135273-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-135273-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. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id y20-20020a1709060a9400b00a466a2e212dsi3476991ejf.665.2024.04.08.04.44.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Apr 2024 04:44:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-135273-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=pctBE7b0; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-135273-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-135273-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 AF46E1F22C9E for ; Mon, 8 Apr 2024 11:44:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D496C6A012; Mon, 8 Apr 2024 11:44:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="pctBE7b0" 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 0315E1E497; Mon, 8 Apr 2024 11:44:19 +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=1712576660; cv=none; b=HziM+z4ufE97Zn54gNHZs8bIx+t3UQsgzO+uVpSPUEplUYHjflV5MuI2yZFhYihFLwpHQAHfq7rTI5t5OUy2N4Kccjdghl2dWJNm0IRn/Dyoo0nU8+1cYrn1i569ehPPR4yYsssACLna0p3xS9c7fXuSwbllR1TspqJTBU8pJGU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712576660; c=relaxed/simple; bh=YwMk2sIjr/LU7uq/dt950KZqYE1jbfLBSLM57hjh1mg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=qOOrMg+jgry7IlzUPEtkFJYESetWGvt6/9gPZ4P2xwbhzTbslIxKhbBTUskB3OAbAgdtqHECEAjExPyn4QeS7X4t2eS+UjcLLIz8UP3CtZIF90zdtVAzs0WMsd4M4uB6iXapNVGX15AJi9UDD0vZIKimW0JeT9YRI3l/gcmkGRY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=pctBE7b0; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id B5979C433C7; Mon, 8 Apr 2024 11:44:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712576659; bh=YwMk2sIjr/LU7uq/dt950KZqYE1jbfLBSLM57hjh1mg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=pctBE7b0BI+BJkA9ICXOPNVn9+1fVk2T4OkDUXngGV6h5xWft033NVMyhyyYTEQIK PHQFaTNWB2O2IHq01X3zOR0kaXc0ISBIrvl25PTnXZptDrzNEamS6DA7YWGbX/UKBe QrmpeXSq/w3riyD76Dhy4pet0w037EknZaS/rEK/M+aRCcUILRv2GeO1xIUEeuwArJ gl8qx1duzyyNTCkl+pqvK1CeWnQVcEMkw3aB3W+/Q+hkki81Ci74f0Y6BSK7D2IwdF CxkTXWKxNGB/e1QUFSfMNbZSsfHbswwGp2SDv07uCQXn5KFSxqfFVQPQRyJ+clL5q1 bzFaj8H/5rvpA== Received: from johan by xi.lan with local (Exim 4.97.1) (envelope-from ) id 1rtnQ5-000000001oi-2HN3; Mon, 08 Apr 2024 13:44:14 +0200 Date: Mon, 8 Apr 2024 13:44:13 +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: <2ejpom6ykci6o7d7luwa2ao4stpm24aoyi66aoncxcqcwgidxz@gcsqvpb3s7nr> 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". 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. Johan