Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp5816162rwp; Mon, 17 Jul 2023 09:51:08 -0700 (PDT) X-Google-Smtp-Source: APBJJlE1V/mDSWsc4RTl1ZpGoU6fezZuCZOglra+ktAmUumULlj1axnonVBgXKDwk7we6b+9dg7I X-Received: by 2002:a17:906:7787:b0:993:e81a:f093 with SMTP id s7-20020a170906778700b00993e81af093mr13296269ejm.26.1689612667835; Mon, 17 Jul 2023 09:51:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689612667; cv=none; d=google.com; s=arc-20160816; b=LzAFi1VMjJ94mG4NeqwYoSuNsRXcjLkk99EWUw0HJkDnKfDTF3MtHbQN5bVyS72LwN nUU+BAT2zZmhCpKSV+a4goN6GbxzyL5PmZ3Vk654JTr9olt06z5dsRwBbXb5dgysWo0+ 7l3NzETgZ3xno5vhAqIFQf0a/VSrYrOLfogR42XJ4J/gVHOQw90F4a7Vfy1Ir/3a7UPj D+Qd06TyqZs6qeVzq7wqMn737BWHtT6zrQp7rnlvtRb3pK4k0D3BXZyuTTNRIG/rEP/Q M+CqG/6gbqVLJQBatKxIxTsjkggeNzXcSX2XTeERWvWT4sWjUOYaDIasw4KLTWiPTaYL W/Zg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=w67yv7yjYvIF/XNyIzYgPXf9bA/dNPk1GmMORO3bdmg=; fh=bVDdEgrgNUJkLpuBip2qwGD6otKPyJXPJZav5mk3Zxg=; b=cDohXLR262QpUguGHUHCLBSDTQQP/BYmm1it44KbfZY4A6wBxa+E06Ospl2RIlBvpP l6/C6IrLbnzMXXpnEynFZU8cyZkKiIkcD16wnMrXh41J2Yn6dUb9g3FxgMaVtHfC6lUC Pm7+c1386SEWDuKuhMYEnSerPfbTo8ZtBGqwV3oQ7C0S7/YKOGGxPkzvDJJdtg0y1B+j iUykg/7n79c7Zl4500bZ14wv50C/V8WAfCMVt5oAj+OYG3xekIppvX8SzPiCjvVpxrDp c+M0U6pmHO3feEyvXbZKyj8JBzFiUlqi9HFEBGObs1xrrpUEESjUCzhJUSuJmveqNPQf d+EQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=l0JMfhsy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lg15-20020a170906f88f00b00989623654c0si14539399ejb.823.2023.07.17.09.50.43; Mon, 17 Jul 2023 09:51:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=l0JMfhsy; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230293AbjGQP5f (ORCPT + 99 others); Mon, 17 Jul 2023 11:57:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230100AbjGQP5e (ORCPT ); Mon, 17 Jul 2023 11:57:34 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 694D61A8 for ; Mon, 17 Jul 2023 08:57:33 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id EA6D161146 for ; Mon, 17 Jul 2023 15:57:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5C433C433CD for ; Mon, 17 Jul 2023 15:57:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689609452; bh=tvDXX50eV0510jxsIGXoT/FDUwk5Yt+r7BtNl9UglPk=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=l0JMfhsyT/TjCvHj86lEa2Opnrt4GzAGkH83Z8tUl3CL0qsUKMdnK/EaZNxBbmHg3 8ulPDN9HOY1KL2Dn4x07yoIoa0YA+TFtI+tqx2ytx/VzkP5Dd4+5aISNz/QrIKVVQA DStAns0ALunKPxBmx/OcrUw+ynA4FPAuyjw/S5IZShkPtkceQ9YuxTsEBD0GahrGTH J79fyIWaXOr+TRkNCfrbpjrMvRFVuQsr6rQMv29fZOCebeyA5ypx9scl0cJp6VvfUw FkK4UOpKOl8agWbRsXf8GtZ8gpBF6fHsLE3pGeE2Buh3EZ8Kn/i0IZ1yNZoj7NDRkX ZHKgRfQL022Tg== Received: by mail-il1-f170.google.com with SMTP id e9e14a558f8ab-3459baa237bso29512365ab.3 for ; Mon, 17 Jul 2023 08:57:32 -0700 (PDT) X-Gm-Message-State: ABy/qLZVhy3/yAsdxy2SHgnitj+Mx9GURS/kEGg3ARAesd35BpYGKYSQ Hed5QrVc0nVJgdqg9gBVSclWBSQaOiV8ITxy0NTP5A== X-Received: by 2002:a05:6e02:1e07:b0:346:5a8b:53f3 with SMTP id g7-20020a056e021e0700b003465a8b53f3mr189745ila.26.1689609451630; Mon, 17 Jul 2023 08:57:31 -0700 (PDT) MIME-Version: 1.0 References: <20230710085922.1871465-1-wenst@chromium.org> In-Reply-To: <20230710085922.1871465-1-wenst@chromium.org> From: Robert Foss Date: Mon, 17 Jul 2023 17:57:20 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2] drm/bridge: anx7625: Drop device lock before drm_helper_hpd_irq_event() To: Chen-Yu Tsai Cc: Andrzej Hajda , Neil Armstrong , Laurent Pinchart , Jonas Karlman , Jernej Skrabec , Xin Ji , =?UTF-8?B?TsOtY29sYXMgRi4gUi4gQS4gUHJhZG8=?= , AngeloGioacchino Del Regno , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 10, 2023 at 10:59=E2=80=AFAM Chen-Yu Tsai = wrote: > > The device lock is used to serialize the low level power sequencing > operations. Since drm_helper_hpd_irq_event() could end up calling > .atomic_enable, which also calls power sequencing functions through > runtime PM, this results in a real deadlock. This was observed on an > MT8192-based Chromebook's external display (with appropriate patches [1] > and DT changes applied). > > Move the drm_helper_hpd_irq_event() call outside of the lock range. The > lock only needs to be held so that the device status can be read back. > This is the bare minimum change to avoid the deadlock. The lock could > be dropped completely and have pm_runtime_get_if_in_use() increase the > reference count, but this is not the same as pm_runtime_suspended(). > > Dropping the lock completely also causes the internal display of the > same device to not function correctly if the internal bridge's > interrupt line is added in the device tree. Both the internal and > external display of said device each use one anx7625 bridge. > > [1] https://lore.kernel.org/dri-devel/20230112042104.4107253-1-treapking@= chromium.org/ > > Fixes: 60487584a79a ("drm/bridge: anx7625: refactor power control to use = runtime PM framework") > Signed-off-by: Chen-Yu Tsai > --- > Changes since v1: > - restore early return if event < 0 > > drivers/gpu/drm/bridge/analogix/anx7625.c | 14 ++++++++------ > 1 file changed, 8 insertions(+), 6 deletions(-) > > diff --git a/drivers/gpu/drm/bridge/analogix/anx7625.c b/drivers/gpu/drm/= bridge/analogix/anx7625.c > index 866d018f4bb1..e93eba89d5ee 100644 > --- a/drivers/gpu/drm/bridge/analogix/anx7625.c > +++ b/drivers/gpu/drm/bridge/analogix/anx7625.c > @@ -1593,18 +1593,20 @@ static void anx7625_work_func(struct work_struct = *work) > > mutex_lock(&ctx->lock); > > - if (pm_runtime_suspended(&ctx->client->dev)) > - goto unlock; > + if (pm_runtime_suspended(&ctx->client->dev)) { > + mutex_unlock(&ctx->lock); > + return; > + } > > event =3D anx7625_hpd_change_detect(ctx); > + > + mutex_unlock(&ctx->lock); > + > if (event < 0) > - goto unlock; > + return; > > if (ctx->bridge_attached) > drm_helper_hpd_irq_event(ctx->bridge.dev); > - > -unlock: > - mutex_unlock(&ctx->lock); > } > > static irqreturn_t anx7625_intr_hpd_isr(int irq, void *data) > -- > 2.41.0.255.g8b1d071c50-goog > LGTM, let's snooze this until next week, incase someone comes up with an is= sue. Reviewed-by: Robert Foss