From patchwork Sat Feb 17 15:02:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 202643 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp364303dyc; Sat, 17 Feb 2024 07:04:47 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXLBbe6jn9af9PzDpPKco/QXMC8+b3ZsfkFeAocc9mYzivLOsER4QtICRFd6DI7cnzcUGeV4zGt//pCVt6HQHFVfAvsqA== X-Google-Smtp-Source: AGHT+IF6+wWt05JS6Y2erAfhOoC/OREYKPQe1K9mqZplPFkpIdpD88i/eb70voI0m3gguq64qR7N X-Received: by 2002:a17:906:a1cd:b0:a3d:6eb4:9768 with SMTP id bx13-20020a170906a1cd00b00a3d6eb49768mr4741637ejb.46.1708182287453; Sat, 17 Feb 2024 07:04:47 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708182287; cv=pass; d=google.com; s=arc-20160816; b=YYP8L4nuXv0Kg2GzyQSCjLpXIUtXZ7BL+cSPE+oZMcvR7n3i26LwQJuc8KMPEqT144 I/PccfwEQgOj3Mh6VD9vRew0uyQpz3b3npUpOWExDFnZN6Puh+5fQZmvqa5hsi3L9Bbp Lbp6s0k+yMLK+6/dEsNscLBgM4YQV6AjCEh2SdVT2Ir89lS/IqXYrd9s7zbIjBWkT8kv vmvzqIJ4Uh24QHljiT8XdJeIMjH4G53qkU1vDG8PJ2HiwdhfTziokWvgUOKZFz5FOaER sydvhIaKjxaaWwww8LjcV7WoNLr7BhyijZ9NZr9DqxDzUob1VcWK4eVflxYWuDy2RgEl Ts2A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=X1yTF30tRRYkuEKzOUdIvpUcu3gPCLdfG/TO6+W1ENc=; fh=pcX3nLBLzYPdmuawBHbOhWNtQQD3frRXqpw6hcDvZ+Y=; b=O6t5E6Hb0RbiTiSZyb5FABaHwapI1OgkSLE//rKFhzVu49oUfpwPZ/8CBR/mck58oV iyNGC1gNif4vi1RxVLsO90/rTfMrtn4XgLyUm0zxxlaqZn8nA/jDfiiFWTfpzDrrMuvw SH76VXEZLNh1uw+WBBxR/g895FbJcTzh6dmOiiXRkJLWHWfzsXlUH8OR5OMKiRGKVZ9N BbPtirOXMoLl0XcO2aiZT0ODqN5GCQyKVkehG7NOP8yApcpehXhGupFDRKhBg3BHi4iv 8KNryiL957UA9Bbi7QUWSyB49V4DooGRdVf79oLro5wfyt3dZ0BDB3unFfCSaulVdGMg wdOQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=eEqGR0C+; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-69926-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69926-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id l24-20020a1709065a9800b00a3da11e91d4si947565ejq.319.2024.02.17.07.04.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Feb 2024 07:04:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-69926-ouuuleilei=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=eEqGR0C+; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-69926-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69926-ouuuleilei=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 EF09C1F219F6 for ; Sat, 17 Feb 2024 15:04:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 639FA7E567; Sat, 17 Feb 2024 15:03:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="eEqGR0C+" 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 96DF37C0B2; Sat, 17 Feb 2024 15:03:03 +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=1708182183; cv=none; b=CCoKO7Hg7fdIT2keUiUAWP01m1eXRKD8AKYcnEj0U6+FlihDjxcAh8Q+T2dnJypmoeIE9+irhjIxXl2Nendw+dUWsDyrSWp2VbXDptZeH6mG3Q2SoYSNzfpg4r1KkiDmkWexegV62kCSRwGBcPIegFIW3I2oE8k1M0oEqxJxoCU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708182183; c=relaxed/simple; bh=POmhG3XikVsaXc0RusI64Jf3HUeMzGtS54gIumrv1I0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gy0UdPF/6SgLV2fqa2DD/a/eOGnC2H273mobdv9NNxfkgg9hs+wui+w78Tq3wRQSKx/X45K2+vLJLWxhDPXbEsfHOvMMrBgG6z6V5vhWDT45eYGUrDpbotiMQNTzsnNJIRvxX23zP6lrVC/RPfc+qr0i72CB4rHWjoP3EQTZScM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=eEqGR0C+; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 17518C433B1; Sat, 17 Feb 2024 15:03:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708182183; bh=POmhG3XikVsaXc0RusI64Jf3HUeMzGtS54gIumrv1I0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eEqGR0C+9C6T6cV2g4R/ygaPvBNcGscgTTbDfWpt6RqNCVCSNemlDmMiBjLINFF9K vNOWBEXAul5FUj2axKYGDdckCtDO4TfXoy/tk+8sx+M+Nax3pT9M4+S/bHKHCxiynt JVidLDi1X3iyquM1kp0a0kub0LV/yLpN3RHEru2kNVYZ1+NxnuinFZsD6q3h74J/bF QqKCFNwEidPJOkwPHGJM73U2yVQ+4BuksOAvfFpAIVLuaZV050HXeu1xqCZl2QDBHY upv4mvxbKoOiSRj0B/wbcx4RIR8QiHUJlV8SjhAA3Z57ya1yYljjfWRvPgLGCifDKc 1sh5+H+c0Jn0g== Received: from johan by xi.lan with local (Exim 4.97.1) (envelope-from ) id 1rbMDW-000000001Vo-2L8p; Sat, 17 Feb 2024 16:03:02 +0100 From: Johan Hovold To: Bjorn Andersson , Andrzej Hajda , Neil Armstrong , Robert Foss , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Vinod Koul Cc: Jonas Karlman , Laurent Pinchart , Jernej Skrabec , Konrad Dybcio , Kishon Vijay Abraham I , Dmitry Baryshkov , Rob Clark , Abhinav Kumar , Kuogee Hsieh , freedreno@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-phy@lists.infradead.org, Johan Hovold Subject: [PATCH 1/6] drm/bridge: aux-hpd: fix OF node leaks Date: Sat, 17 Feb 2024 16:02:23 +0100 Message-ID: <20240217150228.5788-2-johan+linaro@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240217150228.5788-1-johan+linaro@kernel.org> References: <20240217150228.5788-1-johan+linaro@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791158950250252667 X-GMAIL-MSGID: 1791158950250252667 The two device node references taken during allocation need to be dropped when the auxiliary device is freed. Fixes: 6914968a0b52 ("drm/bridge: properly refcount DT nodes in aux bridge drivers") Cc: Dmitry Baryshkov Cc: Neil Armstrong Signed-off-by: Johan Hovold Reviewed-by: Bjorn Andersson Reviewed-by: Dmitry Baryshkov Reviewed-by: Neil Armstrong Reviewed-by: Neil Armstrong --- drivers/gpu/drm/bridge/aux-hpd-bridge.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/gpu/drm/bridge/aux-hpd-bridge.c b/drivers/gpu/drm/bridge/aux-hpd-bridge.c index bb55f697a181..9e71daf95bde 100644 --- a/drivers/gpu/drm/bridge/aux-hpd-bridge.c +++ b/drivers/gpu/drm/bridge/aux-hpd-bridge.c @@ -25,6 +25,7 @@ static void drm_aux_hpd_bridge_release(struct device *dev) ida_free(&drm_aux_hpd_bridge_ida, adev->id); of_node_put(adev->dev.platform_data); + of_node_put(adev->dev.of_node); kfree(adev); } @@ -74,6 +75,8 @@ struct device *drm_dp_hpd_bridge_register(struct device *parent, ret = auxiliary_device_init(adev); if (ret) { + of_node_put(adev->dev.platform_data); + of_node_put(adev->dev.of_node); ida_free(&drm_aux_hpd_bridge_ida, adev->id); kfree(adev); return ERR_PTR(ret); From patchwork Sat Feb 17 15:02:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 202646 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp368150dyc; Sat, 17 Feb 2024 07:10:43 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUXF8a8oSV44nNXBzaFhT19Zk9yAEkN9k1OFI0VwAlLtPNM7V64Xj19KO+oPNev82Z+1mEphiep54wvOhnKJatgMwAizQ== X-Google-Smtp-Source: AGHT+IGCyEgsyoei5e1bOl/KGq203AMNxIKRwAEzeJpRflXc8gxUDToKyzhHtAhpvnBNYEPuTfMe X-Received: by 2002:a05:6214:5190:b0:68e:faa6:6b59 with SMTP id kl16-20020a056214519000b0068efaa66b59mr8091431qvb.58.1708182643035; Sat, 17 Feb 2024 07:10:43 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708182643; cv=pass; d=google.com; s=arc-20160816; b=BnIy/PmjZmb3R0P6ufhe+l4xP5aIyDEvWXPLwoLtE7QcJHF5QQzYspkdiVM8ihCtlp kb36RoKS8xeZjWHNvgtD5P1SJtoSKy5r0rYWnPMWKlcAo6naBDY/ikmcEmSiQ5/NrntE m8e+k1MkPI4ioy07ZTGzgZYoZ8z25tLrFvxxT4lDar9Sb4PhhX4F3EfM36QTGe8+vIbD 7lJmBWFwSk3rd1tMoWvGsUdN6DF/jBQxDMv2RQIWIuayoUi9OTTGsIpz8b8kZbs1Tufj ct+6VRovkS7hC8qYtEEPTC5efANiF7r9q8ngFdNWu7bSMvvJSEnZAnxhW3X4GhA+tlC0 7YpA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=4or4jf28cyEQy/EgHH5Lu4qwmsHHNSyVxHXcgaKLXS4=; fh=pcX3nLBLzYPdmuawBHbOhWNtQQD3frRXqpw6hcDvZ+Y=; b=cfL30vj7DZUl8gse475xcoue+SWVmkd75b7/Y95zZQUCBBbgAlkUa1YVVEKyZHBu+f XXS2KE2E3adsyazpqnbdHqB+mTfLCEQYMD5fz1DYme+h2ncindX8RHuaH+0RWXxYzx6h qVELYSW/z7G5V0upjCXH5IDCFShfposjX71NulA6dmLbcHDwGxln8MqaUG265SfB5KBH j/E5uE87rR/EvKD/rgK4tWGWpRbZyk8FGqezHtO+IZPGKbYxHtmuS2AuLqv9S4qh8nOO 0RBpJMQZakdli1ox4fIA0n7w7f3RqxIL0Xb3nJpymLQi389v7TfPt4jTPIuPruVb19X7 rBJQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NaZiHiRT; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-69925-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69925-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id jr5-20020a0562142a8500b0068f30acb43esi2135437qvb.225.2024.02.17.07.10.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Feb 2024 07:10:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-69925-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=NaZiHiRT; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-69925-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69925-ouuuleilei=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id B76981C228EF for ; Sat, 17 Feb 2024 15:04:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C86E97E0EC; Sat, 17 Feb 2024 15:03:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NaZiHiRT" 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 92F697C0AA; Sat, 17 Feb 2024 15:03:03 +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=1708182183; cv=none; b=F9AhJbiM7zcdJdu5v/5Wr4RzKe1sPuJWrudiNTpKqurALBXlOi+y/XKbzUR/gpB1n8aC9QNACP6f5o6jm3WdDYMn/BCGaOFP7gPhHVWrV9EGTCHqh/9TtP6NHmGIEGV1RfLgih+30kmvGOukBfhEes1S36UmRo6dhU3UlHeeHX0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708182183; c=relaxed/simple; bh=UrO8iSOZ0DaThfpdYnA1yNkyhVkUZHq2oInX+0bHaNU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=fOwOiv1rNmujBvnTSzwAy0pxWGcHmSgREbaOg5J8AmZREdcKeWwEHCD9MHcgqI/dI026IpFz1CLB/jxeB2PiRt3UhwsQw9igyBMc0m5fUUen6y72+p+zYbMvwIUnHRihwrJZZem5yFOYEZ7ECpRxXxXhr4iYze16QVNT2ToptMM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NaZiHiRT; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 12F4AC43390; Sat, 17 Feb 2024 15:03:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708182183; bh=UrO8iSOZ0DaThfpdYnA1yNkyhVkUZHq2oInX+0bHaNU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NaZiHiRTPIbfPSO9V0T+nG2YbfYd4RoH8ksqJQQ1dehfcWd2IBpfDfHByIOYR552k nFE6hEIT8qeuW8E1DS42blBrIgHYehI0FYTJGCYTibnUeVmyZJiOsvTtME4KgkAEe1 2DZMp8TbZu2Mg7JL+VzvP8/SC4bf+EeS4GljpXWaWwPxOIFZ7DYN71gVu5IEEVjh+w DzXELAT5AkdX51DLJnuyzx5+kHBA06WxIT15EspnGNlrpCt7XfgVUA4CP7eTv9tjWo yjnjggK8Df0jykaNcY2Dpx0NYTW6TsHn3D25leWURtAkgUtuWIOc5QR84HO7i0InVS Lg+4YkPkvcdxQ== Received: from johan by xi.lan with local (Exim 4.97.1) (envelope-from ) id 1rbMDW-000000001Vq-2fLy; Sat, 17 Feb 2024 16:03:02 +0100 From: Johan Hovold To: Bjorn Andersson , Andrzej Hajda , Neil Armstrong , Robert Foss , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Vinod Koul Cc: Jonas Karlman , Laurent Pinchart , Jernej Skrabec , Konrad Dybcio , Kishon Vijay Abraham I , Dmitry Baryshkov , Rob Clark , Abhinav Kumar , Kuogee Hsieh , freedreno@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-phy@lists.infradead.org, Johan Hovold Subject: [PATCH 2/6] drm/bridge: aux-hpd: separate allocation and registration Date: Sat, 17 Feb 2024 16:02:24 +0100 Message-ID: <20240217150228.5788-3-johan+linaro@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240217150228.5788-1-johan+linaro@kernel.org> References: <20240217150228.5788-1-johan+linaro@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791159323270687374 X-GMAIL-MSGID: 1791159323270687374 Combining allocation and registration is an anti-pattern that should be avoided. Add two new functions for allocating and registering an dp-hpd bridge with a proper 'devm' prefix so that it is clear that these are device managed interfaces. devm_drm_dp_hpd_bridge_alloc() devm_drm_dp_hpd_bridge_add() The new interface will be used to fix a use-after-free bug in the Qualcomm PMIC GLINK driver and may prevent similar issues from being introduced elsewhere. The existing drm_dp_hpd_bridge_register() is reimplemented using the above and left in place for now. Signed-off-by: Johan Hovold Reviewed-by: Bjorn Andersson Reviewed-by: Dmitry Baryshkov --- drivers/gpu/drm/bridge/aux-hpd-bridge.c | 67 +++++++++++++++++++------ include/drm/bridge/aux-bridge.h | 15 ++++++ 2 files changed, 67 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/bridge/aux-hpd-bridge.c b/drivers/gpu/drm/bridge/aux-hpd-bridge.c index 9e71daf95bde..6886db2d9e00 100644 --- a/drivers/gpu/drm/bridge/aux-hpd-bridge.c +++ b/drivers/gpu/drm/bridge/aux-hpd-bridge.c @@ -30,16 +30,13 @@ static void drm_aux_hpd_bridge_release(struct device *dev) kfree(adev); } -static void drm_aux_hpd_bridge_unregister_adev(void *_adev) +static void drm_aux_hpd_bridge_free_adev(void *_adev) { - struct auxiliary_device *adev = _adev; - - auxiliary_device_delete(adev); - auxiliary_device_uninit(adev); + auxiliary_device_uninit(_adev); } /** - * drm_dp_hpd_bridge_register - Create a simple HPD DisplayPort bridge + * devm_drm_dp_hpd_bridge_alloc - allocate a HPD DisplayPort bridge * @parent: device instance providing this bridge * @np: device node pointer corresponding to this bridge instance * @@ -47,11 +44,9 @@ static void drm_aux_hpd_bridge_unregister_adev(void *_adev) * DRM_MODE_CONNECTOR_DisplayPort, which terminates the bridge chain and is * able to send the HPD events. * - * Return: device instance that will handle created bridge or an error code - * encoded into the pointer. + * Return: bridge auxiliary device pointer or an error pointer */ -struct device *drm_dp_hpd_bridge_register(struct device *parent, - struct device_node *np) +struct auxiliary_device *devm_drm_dp_hpd_bridge_alloc(struct device *parent, struct device_node *np) { struct auxiliary_device *adev; int ret; @@ -82,13 +77,55 @@ struct device *drm_dp_hpd_bridge_register(struct device *parent, return ERR_PTR(ret); } - ret = auxiliary_device_add(adev); - if (ret) { - auxiliary_device_uninit(adev); + ret = devm_add_action_or_reset(parent, drm_aux_hpd_bridge_free_adev, adev); + if (ret) return ERR_PTR(ret); - } - ret = devm_add_action_or_reset(parent, drm_aux_hpd_bridge_unregister_adev, adev); + return adev; +} +EXPORT_SYMBOL_GPL(devm_drm_dp_hpd_bridge_alloc); + +static void drm_aux_hpd_bridge_del_adev(void *_adev) +{ + auxiliary_device_delete(_adev); +} + +/** + * devm_drm_dp_hpd_bridge_add - register a HDP DisplayPort bridge + * @dev: struct device to tie registration lifetime to + * @adev: bridge auxiliary device to be registered + * + * Returns: zero on success or a negative errno + */ +int devm_drm_dp_hpd_bridge_add(struct device *dev, struct auxiliary_device *adev) +{ + int ret; + + ret = auxiliary_device_add(adev); + if (ret) + return ret; + + return devm_add_action_or_reset(dev, drm_aux_hpd_bridge_del_adev, adev); +} +EXPORT_SYMBOL_GPL(devm_drm_dp_hpd_bridge_add); + +/** + * drm_dp_hpd_bridge_register - allocate and register a HDP DisplayPort bridge + * @parent: device instance providing this bridge + * @np: device node pointer corresponding to this bridge instance + * + * Return: device instance that will handle created bridge or an error pointer + */ +struct device *drm_dp_hpd_bridge_register(struct device *parent, struct device_node *np) +{ + struct auxiliary_device *adev; + int ret; + + adev = devm_drm_dp_hpd_bridge_alloc(parent, np); + if (IS_ERR(adev)) + return ERR_CAST(adev); + + ret = devm_drm_dp_hpd_bridge_add(parent, adev); if (ret) return ERR_PTR(ret); diff --git a/include/drm/bridge/aux-bridge.h b/include/drm/bridge/aux-bridge.h index c4c423e97f06..4453906105ca 100644 --- a/include/drm/bridge/aux-bridge.h +++ b/include/drm/bridge/aux-bridge.h @@ -9,6 +9,8 @@ #include +struct auxiliary_device; + #if IS_ENABLED(CONFIG_DRM_AUX_BRIDGE) int drm_aux_bridge_register(struct device *parent); #else @@ -19,10 +21,23 @@ static inline int drm_aux_bridge_register(struct device *parent) #endif #if IS_ENABLED(CONFIG_DRM_AUX_HPD_BRIDGE) +struct auxiliary_device *devm_drm_dp_hpd_bridge_alloc(struct device *parent, struct device_node *np); +int devm_drm_dp_hpd_bridge_add(struct device *dev, struct auxiliary_device *adev); struct device *drm_dp_hpd_bridge_register(struct device *parent, struct device_node *np); void drm_aux_hpd_bridge_notify(struct device *dev, enum drm_connector_status status); #else +static inline struct auxiliary_device *devm_drm_dp_hpd_bridge_alloc(struct device *parent, + struct device_node *np) +{ + return NULL; +} + +static inline int devm_drm_dp_hpd_bridge_add(struct auxiliary_device *adev) +{ + return 0; +} + static inline struct device *drm_dp_hpd_bridge_register(struct device *parent, struct device_node *np) { From patchwork Sat Feb 17 15:02:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 202642 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp363923dyc; Sat, 17 Feb 2024 07:04:16 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVvs5nFE40C5ka1iuAy21+SXKpsnacXdxuzbmuEw/3QTplW6q6WENDB7LrNs2QvPmQwia05o8tW/GNzBD2GpzPvMZ/YZg== X-Google-Smtp-Source: AGHT+IH4Lvfhg9UzT4hZdolAVzOX1BuCP/5wHpCNq23eNRPxHUliIb/R75df48r/rZdbGy1QU4T/ X-Received: by 2002:a05:6a21:3946:b0:19b:e91c:1a42 with SMTP id ac6-20020a056a21394600b0019be91c1a42mr8548815pzc.55.1708182256264; Sat, 17 Feb 2024 07:04:16 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708182256; cv=pass; d=google.com; s=arc-20160816; b=QeIEwww0ubjdVcHGYdg3p9h1Fbf0PBkV9+bxSCEe1VPOE1A3WIuct5J80tTd6IbQbk 2BWJM+BAhY0iGk1qZEv7aNeRgYi12KK3Jn8xcT1YQ9QDLfdGbo1zO5z0qvySrmTbzpU2 f/EI6HbPOXKTlEiFCY4cvNF736pVDhTsHkba7KMiXXLoJaVEG1/q6NOfq1iFAdOh1ocQ 8OUB+AJC067Wh3BHm6O7ozGN9/fLNFsRadMHzmH7fD4BlHNO8nl+NI05DJbuYceGPLi9 txqdmvLt8b4wq1GkvtA+TTkmQ5jnXNrmZF6TzoSJeHNPyntjVu+L12AQwmzg0hWzRrJC BsEA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=LBdKfMgjbVta8w+24YD1ANN2gzBePuW7TWrMtm4Bva8=; fh=NhU/L9rNBsIMNE7ceTr0gNIN07KbWYaXjk40rkCGvkg=; b=J1ecS9rzL371dNcbxqt5TCUUaDkFfaO2jgg1C3QnSB1MEQF86kJAdfCnWeHuoqErh6 wiXZwLgMg/c4a1EYEeXMAK42RIP8VRcFSHMynioTi8clnYQTfF5CQLPC6t0lc4YGfnzi pMK0aSOhR8ylNf7S6KUWX4ZCZjEAww65She9QLOu/dTk/KhssrSq8iab10fn07ntw4dz fY3gAbxURBtYGBwykmf/JvErtyDk+xBp7T5f+31U/sozwcrUxFWlcWgWdC0oMB6ZTRtg jIYaLhp30KMPCNmKYQKklbmV08s0tdvagJguMPMsuxg41Anw51g35xpl9Ms+jkDycdu+ 0u7Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bsxF0O0z; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-69924-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69924-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id a185-20020a6390c2000000b005cddfe0c82bsi1626703pge.211.2024.02.17.07.04.16 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Feb 2024 07:04:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-69924-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=bsxF0O0z; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-69924-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69924-ouuuleilei=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 14F3828302F for ; Sat, 17 Feb 2024 15:04:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 936367E0E3; Sat, 17 Feb 2024 15:03:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="bsxF0O0z" 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 6C63F7C09F; Sat, 17 Feb 2024 15:03:03 +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=1708182183; cv=none; b=GIwflB0TdwKhk8yOoNo2SLNTT10b67AwxUaaL+NJFDWzvMuGu7ZdY8mTpWFRhxmnUlN4sZsAg3LIkbv2GzoE/2zVl2BfVDRDJ1ifWBTp4nAXkqlpycZJ8dyzwq8lZf9TkOVpmqxIKNJnqHn6EfvUIO0XU7WCKG6w9LNpD+p6Szg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708182183; c=relaxed/simple; bh=7qfwQMTk/6XmuQTgWrrAU6QDNKvMnI+7NUmGueoQmuc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DirQYFZe/HgTvG1zN55Dn0aNfUArbFbZN5FNSaedW3BzdD8n+KwgeDxURF23KsFJSs+KcLje4+Lr9eoUxYF0Hx1I05jRtlNsBsI3AZ9trD/5DzXbAT4XF1tCNK5cMoygTIOYq5z7DlVqsyKWPspmZCFZIFLFSD/AsKn30QQ05rA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=bsxF0O0z; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 02076C433C7; Sat, 17 Feb 2024 15:03:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708182183; bh=7qfwQMTk/6XmuQTgWrrAU6QDNKvMnI+7NUmGueoQmuc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bsxF0O0zWvPp505t1lswvS1c07/vMyEj6NoWQGyVmOanlWHTgZy+BXheaA1LpqFsK 0EOGVlB6+Di9XgzmDKXGhgICuKHjiyS6StSQM/iKM/sGiYqjrPqy58nroPER5ekRMJ ukkP8NVixapjyuC4ugenR6sCoqfLLmhTDNOMMn9M1VDKUa4mcZi8ihmX+5Y1opV6Ik cAlY6KX71aBxy8Juy5Al0MNjz9km7CAkvJjYa8BHjMsEVAAPe66JRSkhhApIMwI48C RfvbdwgLwUXJfb++tbEMIfG0AHo6XVwD7DgIkjQTI9ERYmkSr4oXtVy7IP2V8shnfc yxVs5lHpLMx5Q== Received: from johan by xi.lan with local (Exim 4.97.1) (envelope-from ) id 1rbMDW-000000001Vs-35SB; Sat, 17 Feb 2024 16:03:02 +0100 From: Johan Hovold To: Bjorn Andersson , Andrzej Hajda , Neil Armstrong , Robert Foss , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Vinod Koul Cc: Jonas Karlman , Laurent Pinchart , Jernej Skrabec , Konrad Dybcio , Kishon Vijay Abraham I , Dmitry Baryshkov , Rob Clark , Abhinav Kumar , Kuogee Hsieh , freedreno@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-phy@lists.infradead.org, Johan Hovold , stable@vger.kernel.org Subject: [PATCH 3/6] soc: qcom: pmic_glink_altmode: fix drm bridge use-after-free Date: Sat, 17 Feb 2024 16:02:25 +0100 Message-ID: <20240217150228.5788-4-johan+linaro@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240217150228.5788-1-johan+linaro@kernel.org> References: <20240217150228.5788-1-johan+linaro@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791158917789245069 X-GMAIL-MSGID: 1791158917789245069 A recent DRM series purporting to simplify support for "transparent bridges" and handling of probe deferrals ironically exposed a use-after-free issue on pmic_glink_altmode probe deferral. This has manifested itself as the display subsystem occasionally failing to initialise and NULL-pointer dereferences during boot of machines like the Lenovo ThinkPad X13s. Specifically, the dp-hpd bridge is currently registered before all resources have been acquired which means that it can also be deregistered on probe deferrals. In the meantime there is a race window where the new aux bridge driver (or PHY driver previously) may have looked up the dp-hpd bridge and stored a (non-reference-counted) pointer to the bridge which is about to be deallocated. When the display controller is later initialised, this triggers a use-after-free when attaching the bridges: dp -> aux -> dp-hpd (freed) which may, for example, result in the freed bridge failing to attach: [drm:drm_bridge_attach [drm]] *ERROR* failed to attach bridge /soc@0/phy@88eb000 to encoder TMDS-31: -16 or a NULL-pointer dereference: Unable to handle kernel NULL pointer dereference at virtual address 0000000000000000 ... Call trace: drm_bridge_attach+0x70/0x1a8 [drm] drm_aux_bridge_attach+0x24/0x38 [aux_bridge] drm_bridge_attach+0x80/0x1a8 [drm] dp_bridge_init+0xa8/0x15c [msm] msm_dp_modeset_init+0x28/0xc4 [msm] The DRM bridge implementation is clearly fragile and implicitly built on the assumption that bridges may never go away. In this case, the fix is to move the bridge registration in the pmic_glink_altmode driver to after all resources have been looked up. Incidentally, with the new dp-hpd bridge implementation, which registers child devices, this is also a requirement due to a long-standing issue in driver core that can otherwise lead to a probe deferral loop (see fbc35b45f9f6 ("Add documentation on meaning of -EPROBE_DEFER")). Fixes: 080b4e24852b ("soc: qcom: pmic_glink: Introduce altmode support") Fixes: 2bcca96abfbf ("soc: qcom: pmic-glink: switch to DRM_AUX_HPD_BRIDGE") Cc: stable@vger.kernel.org # 6.3 Cc: Bjorn Andersson Cc: Dmitry Baryshkov Signed-off-by: Johan Hovold Reviewed-by: Bjorn Andersson Reviewed-by: Dmitry Baryshkov --- drivers/soc/qcom/pmic_glink_altmode.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/soc/qcom/pmic_glink_altmode.c b/drivers/soc/qcom/pmic_glink_altmode.c index 5fcd0fdd2faa..b3808fc24c69 100644 --- a/drivers/soc/qcom/pmic_glink_altmode.c +++ b/drivers/soc/qcom/pmic_glink_altmode.c @@ -76,7 +76,7 @@ struct pmic_glink_altmode_port { struct work_struct work; - struct device *bridge; + struct auxiliary_device *bridge; enum typec_orientation orientation; u16 svid; @@ -230,7 +230,7 @@ static void pmic_glink_altmode_worker(struct work_struct *work) else pmic_glink_altmode_enable_usb(altmode, alt_port); - drm_aux_hpd_bridge_notify(alt_port->bridge, + drm_aux_hpd_bridge_notify(&alt_port->bridge->dev, alt_port->hpd_state ? connector_status_connected : connector_status_disconnected); @@ -454,7 +454,7 @@ static int pmic_glink_altmode_probe(struct auxiliary_device *adev, alt_port->index = port; INIT_WORK(&alt_port->work, pmic_glink_altmode_worker); - alt_port->bridge = drm_dp_hpd_bridge_register(dev, to_of_node(fwnode)); + alt_port->bridge = devm_drm_dp_hpd_bridge_alloc(dev, to_of_node(fwnode)); if (IS_ERR(alt_port->bridge)) { fwnode_handle_put(fwnode); return PTR_ERR(alt_port->bridge); @@ -510,6 +510,16 @@ static int pmic_glink_altmode_probe(struct auxiliary_device *adev, } } + for (port = 0; port < ARRAY_SIZE(altmode->ports); port++) { + alt_port = &altmode->ports[port]; + if (!alt_port->bridge) + continue; + + ret = devm_drm_dp_hpd_bridge_add(dev, alt_port->bridge); + if (ret) + return ret; + } + altmode->client = devm_pmic_glink_register_client(dev, altmode->owner_id, pmic_glink_altmode_callback, From patchwork Sat Feb 17 15:02:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 202645 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp365606dyc; Sat, 17 Feb 2024 07:06:42 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU+F0G6Uj3LyFP/e1NbJp9LycP9i/UYA8hd1JNVg24t6ZBk06GxZJ6CnOrP+qNIgCYuUJ/WM8tDm5bli2aD5ZAvcma3tg== X-Google-Smtp-Source: AGHT+IHu700Hsd/3LQ3sPbNPpes8gUIUUw1FuMVl+VbpTPD/wBDaDcXxEnInIh2dx4oLnrGYy598 X-Received: by 2002:a62:9a02:0:b0:6e3:a485:be28 with SMTP id o2-20020a629a02000000b006e3a485be28mr462977pfe.10.1708182402519; Sat, 17 Feb 2024 07:06:42 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708182402; cv=pass; d=google.com; s=arc-20160816; b=b8QN9EntqPRIDoIeFYOgYLSBb5B3zYZGcr9/wIUTlV1/ITi7RQwy2kvcazJSZmekRT oNHOsXbwsMWqyGbqq4Op1if7xUPW2PHOkgQFUj9DVQB5S7mGMwAcZPgMKnZZJB3mcKav ESErjlYZraFOc8tO3M+ty5yOs792gIT8dJ1WwLLbCp5mEQOy1iHzhw2k5dxr9xSIPE76 H8koJPfDgfEqggfKnv46ZC6n/HxOlUmKsmMnS8GTGcUxiFZ31aNZf0yCXuZlk2GZP/v4 wQgK2q9PDxBU2Ix+U+6GHIQ8NOE9dZpJ8tBH+OKex6mvjysyF9/J7XoK8Z6JLQnw6DYe t/aA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=ebxL4fux/ljUy1J2xDGMtxI/G+yEzR54hqvTHFjYmX0=; fh=CaK1Yod/SY9WuBeEqoamXgh70rOHfkBL458m120zYxQ=; b=cSZoj+9uSipoisUPd89k47jW4hzePGqqxIzefcXTRjrhw4ACbVNUztsiQhVWgmrFra HwTGPesqZ7PW8/LDKi9h6B+7LEhkRLzW2Mwl1grF4o676KiuXGWQjQHzHnlrzPKw2uxC 4tSX5Saz5VDhHBMQbXmY2IoFbTulIZHw9hWdtHjrwC98reOHHz8FBy8cG/3XXXGluOE2 K695v2YM8Qlz0w6TQVpmitJ/PlGm+lIWAZO9ACv8m/tbdreRg1UgQ3BU1ZQN0GEYRzzB N7EhQMNvuQggwpciRmQ7WbSZuZrr0nLBoH/ETcb28k2mei2VhI6rTkk54QQTn0XZgrDR 8dJg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OPPejr3i; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-69927-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69927-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id c18-20020a056a00009200b006e0e693c865si1666311pfj.212.2024.02.17.07.06.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Feb 2024 07:06:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-69927-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=OPPejr3i; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-69927-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69927-ouuuleilei=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 sy.mirrors.kernel.org (Postfix) with ESMTPS id B397CB22778 for ; Sat, 17 Feb 2024 15:04:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6A1577E569; Sat, 17 Feb 2024 15:03:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="OPPejr3i" 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 96E287C0B3; Sat, 17 Feb 2024 15:03:03 +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=1708182183; cv=none; b=AZBpSBeZiUBtktARm8JOvNfcT++7e8LMbN2kbDiHfzdfeTgH5oKPDT4Ej4o0ppxQeBUYiwFk3buDQiSNkSd0bnOPs0j4hFnW/U3IuDV+fR9O15CqlyGRGSiWUCkuWOy0YqN9B3n7qfzxnqjLG+7fkQsXFJt0H4VYb3nkGppg/uk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708182183; c=relaxed/simple; bh=7NJQ8xLcC4Pw/NsMyFhL+x4rzV/sXkDltG7OfC8mrxE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lXLasJYtL/PBjtpNRrv1+MUeDDTI9GypjEcPbNehv2CpEMkZK5QXR+Vg6ds9VZUfKh5frS7dXpgcUz6Kf2dYetVzMkwWH+HRfzV/SfiUflUn7pNTbDK2sk7PvSi4KrPMJhuJ+w44kv1942zrD2WnLEMVlh462YWLoOZsGb6FMj0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=OPPejr3i; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1A5D9C433A6; Sat, 17 Feb 2024 15:03:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708182183; bh=7NJQ8xLcC4Pw/NsMyFhL+x4rzV/sXkDltG7OfC8mrxE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OPPejr3iLm85A6MmkuPGuNxKa4BBDq8CYhN+l0KtRM9OD7ghOkDGHoPPEp8ffRASy XdJCp6RK8lS8pgXlDs1Hj5Xj9vFREwv0rv9cxi9CblKdvcPX50V+6bk+7meChV7gxV BGdsS44UNHKTl7J9O6w2HIrZNhFWVyiCbTBKK8eArhami/C6L8mZvn5uTQeLCIeqmH 09ykI0yrNAre727AXakVzgdElSudSpRnaXkjo7eznqZzajpBrvC1z5qsqfojO9EnpM IPow9UV6iG/nabuvgkoFtCJGXW0BtmctJjMHkiKMMJ/xOu1O+ls7EsYicfRiA5jfsG 8PDu0oWeigPgg== Received: from johan by xi.lan with local (Exim 4.97.1) (envelope-from ) id 1rbMDW-000000001Vu-3Stp; Sat, 17 Feb 2024 16:03:02 +0100 From: Johan Hovold To: Bjorn Andersson , Andrzej Hajda , Neil Armstrong , Robert Foss , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Vinod Koul Cc: Jonas Karlman , Laurent Pinchart , Jernej Skrabec , Konrad Dybcio , Kishon Vijay Abraham I , Dmitry Baryshkov , Rob Clark , Abhinav Kumar , Kuogee Hsieh , freedreno@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-phy@lists.infradead.org, Rob Clark , stable@vger.kernel.org, Johan Hovold Subject: [PATCH 4/6] soc: qcom: pmic_glink: Fix boot when QRTR=m Date: Sat, 17 Feb 2024 16:02:26 +0100 Message-ID: <20240217150228.5788-5-johan+linaro@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240217150228.5788-1-johan+linaro@kernel.org> References: <20240217150228.5788-1-johan+linaro@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791159070503521061 X-GMAIL-MSGID: 1791159070503521061 From: Rob Clark We need to bail out before adding/removing devices if we are going to -EPROBE_DEFER. Otherwise boot can get stuck in a probe deferral loop due to a long-standing issue in driver core (see fbc35b45f9f6 ("Add documentation on meaning of -EPROBE_DEFER")). Deregistering the altmode child device can potentially also trigger bugs in the DRM bridge implementation, which does not expect bridges to go away. Suggested-by: Dmitry Baryshkov Signed-off-by: Rob Clark Link: https://lore.kernel.org/r/20231213210644.8702-1-robdclark@gmail.com [ johan: rebase on 6.8-rc4, amend commit message and mention DRM ] Fixes: 58ef4ece1e41 ("soc: qcom: pmic_glink: Introduce base PMIC GLINK driver") Cc: stable@vger.kernel.org # 6.3 Cc: Bjorn Andersson Signed-off-by: Johan Hovold Reviewed-by: Bjorn Andersson Reviewed-by: Dmitry Baryshkov Reviewed-by: Neil Armstrong --- drivers/soc/qcom/pmic_glink.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/drivers/soc/qcom/pmic_glink.c b/drivers/soc/qcom/pmic_glink.c index f4bfd24386f1..f913e9bd57ed 100644 --- a/drivers/soc/qcom/pmic_glink.c +++ b/drivers/soc/qcom/pmic_glink.c @@ -265,10 +265,17 @@ static int pmic_glink_probe(struct platform_device *pdev) pg->client_mask = *match_data; + pg->pdr = pdr_handle_alloc(pmic_glink_pdr_callback, pg); + if (IS_ERR(pg->pdr)) { + ret = dev_err_probe(&pdev->dev, PTR_ERR(pg->pdr), + "failed to initialize pdr\n"); + return ret; + } + if (pg->client_mask & BIT(PMIC_GLINK_CLIENT_UCSI)) { ret = pmic_glink_add_aux_device(pg, &pg->ucsi_aux, "ucsi"); if (ret) - return ret; + goto out_release_pdr_handle; } if (pg->client_mask & BIT(PMIC_GLINK_CLIENT_ALTMODE)) { ret = pmic_glink_add_aux_device(pg, &pg->altmode_aux, "altmode"); @@ -281,17 +288,11 @@ static int pmic_glink_probe(struct platform_device *pdev) goto out_release_altmode_aux; } - pg->pdr = pdr_handle_alloc(pmic_glink_pdr_callback, pg); - if (IS_ERR(pg->pdr)) { - ret = dev_err_probe(&pdev->dev, PTR_ERR(pg->pdr), "failed to initialize pdr\n"); - goto out_release_aux_devices; - } - service = pdr_add_lookup(pg->pdr, "tms/servreg", "msm/adsp/charger_pd"); if (IS_ERR(service)) { ret = dev_err_probe(&pdev->dev, PTR_ERR(service), "failed adding pdr lookup for charger_pd\n"); - goto out_release_pdr_handle; + goto out_release_aux_devices; } mutex_lock(&__pmic_glink_lock); @@ -300,8 +301,6 @@ static int pmic_glink_probe(struct platform_device *pdev) return 0; -out_release_pdr_handle: - pdr_handle_release(pg->pdr); out_release_aux_devices: if (pg->client_mask & BIT(PMIC_GLINK_CLIENT_BATT)) pmic_glink_del_aux_device(pg, &pg->ps_aux); @@ -311,6 +310,8 @@ static int pmic_glink_probe(struct platform_device *pdev) out_release_ucsi_aux: if (pg->client_mask & BIT(PMIC_GLINK_CLIENT_UCSI)) pmic_glink_del_aux_device(pg, &pg->ucsi_aux); +out_release_pdr_handle: + pdr_handle_release(pg->pdr); return ret; } From patchwork Sat Feb 17 15:02:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 202644 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp364550dyc; Sat, 17 Feb 2024 07:05:09 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXrJKw7wLdbKnTm3rtCJkZbV2ab12wKLNqUu1FcYwsq2xS9aJeedZG6CWt5Be0wcEH9qokXj5gFUePPmgRlj5WGG2XJ0Q== X-Google-Smtp-Source: AGHT+IEg1iq37MNSS7vsMfCqPD9EA9UREjs6FyEtHDMkOzQTKc/8o2rAJ6amGj7bFtg6e1tbUrSu X-Received: by 2002:a05:6a00:180d:b0:6e0:a559:d667 with SMTP id y13-20020a056a00180d00b006e0a559d667mr10133971pfa.27.1708182308951; Sat, 17 Feb 2024 07:05:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708182308; cv=pass; d=google.com; s=arc-20160816; b=himGdoU08zmTjZVfNsW+WZO3S9nH//lOrHwTbr3Dd1dBkvsq4uaqgtMjYuu2QJ+XqJ DZjsDH026wz1O6yihIh8piW77YsIpFAV4UJG0Glbuo52VmRUw0yoaQkTIrsdZZ3qKO4N 5QHnNNBBpiAMmGsTe6rL8rSDyZrU6ETgP596zDdcyfKSKer/qP3RJ2rJYD08RnIsBLHZ 1AZbi73dIc2eKpmeEUMNWcFlPjx0JZciyoTHRD4kQRRcHo0iH/sqvpLtFWmhddmwRrx5 GbSNrayNLX0Hk+p+N7sLUmws536tB9gIIIPzEcbnIowCG3X5gl9HFLNtC4CiZ0LGNbYY ujjA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=o0a25HtfcPJejsy1uDB1LRVcNybTZPlBxiOl/ey4334=; fh=Hl8lnpz4ISbBsnoeQao/t6wY6CVeFI0lIzv3X7tdDqA=; b=CQoRdZiDF4s+q11CW+A+h6PpgP3CevGtJqOgXsJ3v0n1Ohk81vg4lKOe3BcmUnPcqk UwO5q00axcKcejTHAuKZ2KMAVqzYucKxm2B0krpalIoIu6dFhZFb7Ga81q/yeiWHt/aB zD73A64NPLaO90BoL40FyuVgYt7C9bJ95iMfRbIIMMLFo9xzNcmFF9EMiG5w6fDCwpZS EHr/4MJdY5eIWRH0V8F/6puPf+eXe8i492CIXwVZT9aRlk2Ai1sNtKZBoTowKKiLPn9c Yy+rxhCt9/VcQVOjDPgGHi3MRuoXQF9CqKx2KVNy2zmsRLhuE73UTuuvaMtywf7AxWIy 3ThQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=YYCrcRG2; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-69921-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69921-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id m6-20020a632606000000b005dc956c2c09si1632124pgm.147.2024.02.17.07.05.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Feb 2024 07:05:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-69921-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=YYCrcRG2; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-69921-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69921-ouuuleilei=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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 9231BB22563 for ; Sat, 17 Feb 2024 15:04:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 437DF7D410; Sat, 17 Feb 2024 15:03:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="YYCrcRG2" 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 6C5CA7B3D0; Sat, 17 Feb 2024 15:03:03 +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=1708182183; cv=none; b=PMggC/IGKfVt4fITT+X9KR3YntsvIBOAlljdQTwpxYKXpxUx7TW3d8s/JFGuUMAjNuYY8hELxAzxq2f4MU6KBsO6zozdMezxR1tBGPyQ63SNR6ZLLizBX+1ux36AUNi5KjSLv1vwHK4XP9HBxSU5hRlSUAEahMMohrzjbZWq3H4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708182183; c=relaxed/simple; bh=gXXEjah83df2mjIZE6PBMMf9QLss5RTOxJWznY2GGWw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CkLjS7Tarl/0VQ5x/BLpigBRZzt4Zl1pzWFTd2D+fDLf7Tr5B5zt+u4GC7g1R7p9WpJb3rgSkToLfq8/VDLV43bFUq+X5Aww53c+xf4Bg6CuRRucJ0NuXaFmp7C5LRnwt7nWmJjtLMFb6VL9qsXAAVUXbWizRi34mxmFkNwKZFc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=YYCrcRG2; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0D7A2C43394; Sat, 17 Feb 2024 15:03:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708182183; bh=gXXEjah83df2mjIZE6PBMMf9QLss5RTOxJWznY2GGWw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YYCrcRG2Bd4HtdSjVhBFoyvNHGakjwLypXKacKIBHXJrLfhpQut/AO/LcBQ3Y0KjF sPdXqHSXykK74eTVnJeNok7niPfXO0Czt/1YPR768rWKLabFR6u9U6X5zIoNHXtfCO USZHcA9Rm8QSNKTbGnvdNY/kIjWyg4w+1ZXDETyizCJSpTAN1qQacxjTa7UDJF9A2O msphIG/8uQP28WXSj7qoecFU1NmlhQEAP7CJjIeye7CoVAI4y/049aiTpZjWH59Xcd XI5S8l0Qbk9Ya0xxP0z0xuzlJ6QUvVP0P3e4nAwJAmqIZ/HBGy+WfJdIV0A5NlROZa yxMde5QWQVT1A== Received: from johan by xi.lan with local (Exim 4.97.1) (envelope-from ) id 1rbMDW-000000001Vw-3n8S; Sat, 17 Feb 2024 16:03:02 +0100 From: Johan Hovold To: Bjorn Andersson , Andrzej Hajda , Neil Armstrong , Robert Foss , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Vinod Koul Cc: Jonas Karlman , Laurent Pinchart , Jernej Skrabec , Konrad Dybcio , Kishon Vijay Abraham I , Dmitry Baryshkov , Rob Clark , Abhinav Kumar , Kuogee Hsieh , freedreno@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-phy@lists.infradead.org, Johan Hovold , stable@vger.kernel.org, Bjorn Andersson Subject: [PATCH 5/6] phy: qcom-qmp-combo: fix drm bridge registration Date: Sat, 17 Feb 2024 16:02:27 +0100 Message-ID: <20240217150228.5788-6-johan+linaro@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240217150228.5788-1-johan+linaro@kernel.org> References: <20240217150228.5788-1-johan+linaro@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791158972733410311 X-GMAIL-MSGID: 1791158972733410311 Due to a long-standing issue in driver core, drivers may not probe defer after having registered child devices to avoid triggering a probe deferral loop (see fbc35b45f9f6 ("Add documentation on meaning of -EPROBE_DEFER")). This could potentially also trigger a bug in the DRM bridge implementation which does not expect bridges to go away even if device links may avoid triggering this (when enabled). Move registration of the DRM aux bridge to after looking up clocks and other resources. Note that PHY creation can in theory also trigger a probe deferral when a 'phy' supply is used. This does not seem to affect the QMP PHY driver but the PHY subsystem should be reworked to address this (i.e. by separating initialisation and registration of the PHY). Fixes: 35921910bbd0 ("phy: qcom: qmp-combo: switch to DRM_AUX_BRIDGE") Fixes: 1904c3f578dc ("phy: qcom-qmp-combo: Introduce drm_bridge") Cc: stable@vger.kernel.org # 6.5 Cc: Bjorn Andersson Cc: Dmitry Baryshkov Signed-off-by: Johan Hovold Reviewed-by: Neil Armstrong Reviewed-by: Bjorn Andersson Reviewed-by: Dmitry Baryshkov Acked-by: Vinod Koul --- drivers/phy/qualcomm/phy-qcom-qmp-combo.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-combo.c b/drivers/phy/qualcomm/phy-qcom-qmp-combo.c index 1ad10110dd25..e19d6a084f10 100644 --- a/drivers/phy/qualcomm/phy-qcom-qmp-combo.c +++ b/drivers/phy/qualcomm/phy-qcom-qmp-combo.c @@ -3566,10 +3566,6 @@ static int qmp_combo_probe(struct platform_device *pdev) if (ret) return ret; - ret = drm_aux_bridge_register(dev); - if (ret) - return ret; - /* Check for legacy binding with child nodes. */ usb_np = of_get_child_by_name(dev->of_node, "usb3-phy"); if (usb_np) { @@ -3589,6 +3585,10 @@ static int qmp_combo_probe(struct platform_device *pdev) if (ret) goto err_node_put; + ret = drm_aux_bridge_register(dev); + if (ret) + goto err_node_put; + pm_runtime_set_active(dev); ret = devm_pm_runtime_enable(dev); if (ret) From patchwork Sat Feb 17 15:02:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 202641 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp363830dyc; Sat, 17 Feb 2024 07:04:08 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVinIGWNHKI5M2EC8vdnIVp58j9ZRRI1IqhgRd87jPI3tsSyVklIiglE4j8FeNfICHRM3oLHZ1mDAcSmLBE8DivgHZLsw== X-Google-Smtp-Source: AGHT+IFeX/1XWr8ijlccTPVvTgfa097UG19sPtm7AGzPIorU7+r7tmeLeCWeyB7UUsoSs+wnQ9Ga X-Received: by 2002:aa7:c646:0:b0:563:f889:24bd with SMTP id z6-20020aa7c646000000b00563f88924bdmr2637328edr.8.1708182248761; Sat, 17 Feb 2024 07:04:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708182248; cv=pass; d=google.com; s=arc-20160816; b=bqjkSoOiKII3s9CXN0i1m83p0FZoKD+HnWKl8Ni2GF42a/KyNCBW0R2fr0DR+f/G0f ECRSGNj6WCjjUAuC/jQXHPPYD1+dJym4eunkiGNWOwsWQOY58SKC/KnIbmvBHv+Y6F2F 0NwCeqTEgQeg4aZt4GAcucumIyIeUiNQRvWebjUzbQrauS7mHS2V9Fw+/VU2tXRs6Uod UmM5m2caRAdvx959QKzum3tL0lOJizr+1BbJEhgllvADffsWgF5g6MlG+I9c0n1SH5HH qgYsy+Ib3RSeCiBcC/aGV3A3dKuc325WnCf9QY5hdBkd73mgoIHTYC83Q3/vv0CdGTLt +3Yg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=uO7Qqwlv8mo3/9G/wxUNyNO/NNGfnz8/LGi2MgkntX4=; fh=Hl8lnpz4ISbBsnoeQao/t6wY6CVeFI0lIzv3X7tdDqA=; b=gTdvPf2U5kERmT9sr00Aynt95QisV8LJStBSR3wA21fWIjzm38KgaRXtABmPHeAQpH 5k6bSnrSVqN5bixsMLrIIv4G0tNg8uUjza67yNwzkJGkU63j654Hqjb3crgHQEKtJ41N nDKmsi0CGKrO8HzTodR+pP8Pl44+IrXM1g4g3/waNjVB8Ib35CYtm3eiwg42HiaY3Dfy dbVydX7J4rt+ZPJJU6cD3i5Af2mE9OtZiOMsUVvu4ajJDtqFfkypnSe5DP+XrRerWkUp mFufEoLapWU/xkhWG4F0dgwtj+4Pyfhzxmd49oDNWWVx9wLm0L9g6o7kdzAiqRSTjmH2 2XGA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Dk3HLJ7y; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-69922-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69922-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id d4-20020a50f684000000b00563e5923b69si898830edn.647.2024.02.17.07.04.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 17 Feb 2024 07:04:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-69922-ouuuleilei=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=Dk3HLJ7y; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-69922-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69922-ouuuleilei=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 617351F21A4C for ; Sat, 17 Feb 2024 15:04:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 26B477D40A; Sat, 17 Feb 2024 15:03:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Dk3HLJ7y" 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 6C57C69DE6; Sat, 17 Feb 2024 15:03:03 +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=1708182183; cv=none; b=gM8RWOfn6NNZ68WQz7UT9hMzZiVHcW74gbNNYuDeKHdjkd/PYw9Rywoh+gtcGnMV1ZmWWD7/Yz8l4kEbWNhf/+g/ophwB7727sKrS97XgUSaTZAMHQsK5lKrI/vDyZKbw8t7tPQV5/ws1WOpWhjzoGTg3qPGcPHtDirAVjC/l3c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708182183; c=relaxed/simple; bh=E7peNP5XvxWfotZQJXcvlEV4QrXxAGb8fVXnSMSgPFc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oZJzgc/FrqRSoY0oAUvFEBcCrK/VV+eip2dXuU9tCmAr5v+yJVWZ3fQkACnriFgWrvatSTDRvai2ghIRGlbUzNPu36QDWg8tfEM7QLUJMPwohxMF6XOKzKCFuq6lFctGy9KtvFuasoTxfnOKm1HeeRgd+7ZTtVQR9C+2d4YMJRQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Dk3HLJ7y; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 05E98C433F1; Sat, 17 Feb 2024 15:03:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708182183; bh=E7peNP5XvxWfotZQJXcvlEV4QrXxAGb8fVXnSMSgPFc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Dk3HLJ7yF2q4ypNSoZdXkmm0aPgQCR7FYvJT9iw+lGINaaGvc2xX2ebCULvFlg36z kg3r/qLyz+ERxutx4KEI5MbR/7iNf/Lpm/fYTcaE+tSB7UCJwcQKuJhvet4uGTQvbj rof9weCUaGRieOlItOAbq7is6pzcG8M8db3wJjwnOFJ/7zE/wgx/Qr+R0/0bmWe4xC tgkDLMNz3/jO7oNW6ZrSxB6yKgxga37TRMVA5DSDXRnjIws81+QskGbPRszwbtPE/b NUhdJgV3ly89vY/6IBys0iGEqVscmwG5scY0CA2Nod9ifVSTAzeYdt0OSDnzlv+eyP 5eDMgBOxAdAvA== Received: from johan by xi.lan with local (Exim 4.97.1) (envelope-from ) id 1rbMDW-000000001Vy-47Zd; Sat, 17 Feb 2024 16:03:03 +0100 From: Johan Hovold To: Bjorn Andersson , Andrzej Hajda , Neil Armstrong , Robert Foss , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Vinod Koul Cc: Jonas Karlman , Laurent Pinchart , Jernej Skrabec , Konrad Dybcio , Kishon Vijay Abraham I , Dmitry Baryshkov , Rob Clark , Abhinav Kumar , Kuogee Hsieh , freedreno@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-phy@lists.infradead.org, Johan Hovold , stable@vger.kernel.org, Bjorn Andersson Subject: [PATCH 6/6] phy: qcom-qmp-combo: fix type-c switch registration Date: Sat, 17 Feb 2024 16:02:28 +0100 Message-ID: <20240217150228.5788-7-johan+linaro@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240217150228.5788-1-johan+linaro@kernel.org> References: <20240217150228.5788-1-johan+linaro@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791158909359629346 X-GMAIL-MSGID: 1791158909359629346 Due to a long-standing issue in driver core, drivers may not probe defer after having registered child devices to avoid triggering a probe deferral loop (see fbc35b45f9f6 ("Add documentation on meaning of -EPROBE_DEFER")). Move registration of the typec switch to after looking up clocks and other resources. Note that PHY creation can in theory also trigger a probe deferral when a 'phy' supply is used. This does not seem to affect the QMP PHY driver but the PHY subsystem should be reworked to address this (i.e. by separating initialisation and registration of the PHY). Fixes: 2851117f8f42 ("phy: qcom-qmp-combo: Introduce orientation switching") Cc: stable@vger.kernel.org # 6.5 Cc: Bjorn Andersson Signed-off-by: Johan Hovold Reviewed-by: Bjorn Andersson Reviewed-by: Dmitry Baryshkov Acked-by: Vinod Koul --- drivers/phy/qualcomm/phy-qcom-qmp-combo.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-combo.c b/drivers/phy/qualcomm/phy-qcom-qmp-combo.c index e19d6a084f10..17c4ad7553a5 100644 --- a/drivers/phy/qualcomm/phy-qcom-qmp-combo.c +++ b/drivers/phy/qualcomm/phy-qcom-qmp-combo.c @@ -3562,10 +3562,6 @@ static int qmp_combo_probe(struct platform_device *pdev) if (ret) return ret; - ret = qmp_combo_typec_switch_register(qmp); - if (ret) - return ret; - /* Check for legacy binding with child nodes. */ usb_np = of_get_child_by_name(dev->of_node, "usb3-phy"); if (usb_np) { @@ -3585,6 +3581,10 @@ static int qmp_combo_probe(struct platform_device *pdev) if (ret) goto err_node_put; + ret = qmp_combo_typec_switch_register(qmp); + if (ret) + goto err_node_put; + ret = drm_aux_bridge_register(dev); if (ret) goto err_node_put;