Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2264208iof; Wed, 8 Jun 2022 00:50:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzwrYoVbp2F2LOhyDc1jpqa6wEXXNEnLHFT/CrE6ryeP4lbKJjgynruZ4SRu+USwQlRReyO X-Received: by 2002:a17:902:7b8f:b0:162:467:db7c with SMTP id w15-20020a1709027b8f00b001620467db7cmr31795166pll.140.1654674615835; Wed, 08 Jun 2022 00:50:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654674615; cv=none; d=google.com; s=arc-20160816; b=vRYm0/mFYGaZ1nemGQQCl1SjzIskp18jCeWFl4MEBR61ZsWlaJZSO8f1b9OZj6u10I BPMPp91ZvflCggJSZE1auY5Gwuhczd5WbCL0NoyAtj96n1Wm2N8v+FKiY2K4wX7t6/nz 7QYSDAmFYR98rNjhq5t0e9UUbcoHQdb4OzeNvH6WxJAA/YheZfpOOFFaRmxm1Go8R0dS kZTQOP7PCuTJO+EweKPJky4bDYyWfh5utMETniEYVZ/AiVccgsjNYE3lAL51HvFtN+5H 9rVZOJWAtrGp9RYTURGGHvgj7eY+OyOxwtgehh4f7eC9D7GcSdLDX0ISQpdJGq7Uw9iX 57sg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=qYnWuWZqsjR3ev4Pdfi8otBXKZA0lpzWhfadAqA+NJQ=; b=AjyqccnP+stWIYHT13rqiULnJgoD4EMMpKOxKbWemHhl+lL/TaPHegryhqNGtJsIyS 0tBtVgyqzlb6DFII9NcfPfSFrGU0UsBAjTweuRmdgu3bhoJ8zqh6OIOZ27PpL+g5Xpqe y6x3n6mU+5QM4Er7vujfiDPgdCGxBdtiR4TLt9w08dJorhcX7wbTjI3Ygt3COO1P6vrY xpyPuWBL/B4U72RA04Bi+TdHkWnzl+k2vBqNzVmLHf0GeoinNkUgNMRMZ55zbU4NadgR 8dWSnrUduKwQWnJ8Fdyz84ebjqU4eC3JpbC3gePOg/do0oX3B3pMrE7BCoOb/6ORBQco iXAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zODXs2Kp; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 85-20020a630358000000b003f8a48ed403si26711042pgd.580.2022.06.08.00.50.03; Wed, 08 Jun 2022 00:50:15 -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=@linuxfoundation.org header.s=korg header.b=zODXs2Kp; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1382102AbiFGWnp (ORCPT + 99 others); Tue, 7 Jun 2022 18:43:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1381041AbiFGVbe (ORCPT ); Tue, 7 Jun 2022 17:31:34 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8FAF822CBCA; Tue, 7 Jun 2022 12:03:58 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id B9A8D617CC; Tue, 7 Jun 2022 19:03:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BFF07C385A2; Tue, 7 Jun 2022 19:03:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654628637; bh=TQ3Y3rgG9grSoqcDMuYepeiWXwXwF02pRKQIscNhIF0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zODXs2KpLCbt9UfK4A+R8cHAWgVDFMafSseHPfOC3kyZLUBKFhI1muoZgvGJR3v2U 3IPtj/yYsizw8tebm2lQm5S95yvtuo8duqxWxycDMViaTr4bde3ORgXHdXFFOWr2BC /z3XywpZDydLN6e2iUT4sR2eRvweGltCWvXsP8ew= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tomeu Vizoso , Jessica Zhang , Rob Clark , Dmitry Baryshkov , Sasha Levin Subject: [PATCH 5.18 400/879] drm/msm/mdp5: Return error code in mdp5_mixer_release when deadlock is detected Date: Tue, 7 Jun 2022 18:58:38 +0200 Message-Id: <20220607165014.473515299@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607165002.659942637@linuxfoundation.org> References: <20220607165002.659942637@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 From: Jessica Zhang [ Upstream commit ca75f6f7c6f89365e40f10f641b15981b1f07c31 ] There is a possibility for mdp5_get_global_state to return -EDEADLK when acquiring the modeset lock, but currently global_state in mdp5_mixer_release doesn't check for if an error is returned. To avoid a NULL dereference error, let's have mdp5_mixer_release check if an error is returned and propagate that error. Reported-by: Tomeu Vizoso Signed-off-by: Jessica Zhang Fixes: 7907a0d77cb4 ("drm/msm/mdp5: Use the new private_obj state") Reviewed-by: Rob Clark Reviewed-by: Dmitry Baryshkov Patchwork: https://patchwork.freedesktop.org/patch/485181/ Link: https://lore.kernel.org/r/20220505214051.155-2-quic_jesszhan@quicinc.com Signed-off-by: Dmitry Baryshkov Signed-off-by: Sasha Levin --- drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c | 10 ++++++++-- drivers/gpu/drm/msm/disp/mdp5/mdp5_mixer.c | 15 +++++++++++---- drivers/gpu/drm/msm/disp/mdp5/mdp5_mixer.h | 4 ++-- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c b/drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c index b966cd69f99d..fe2922c8d21b 100644 --- a/drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c +++ b/drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c @@ -612,9 +612,15 @@ static int mdp5_crtc_setup_pipeline(struct drm_crtc *crtc, if (ret) return ret; - mdp5_mixer_release(new_crtc_state->state, old_mixer); + ret = mdp5_mixer_release(new_crtc_state->state, old_mixer); + if (ret) + return ret; + if (old_r_mixer) { - mdp5_mixer_release(new_crtc_state->state, old_r_mixer); + ret = mdp5_mixer_release(new_crtc_state->state, old_r_mixer); + if (ret) + return ret; + if (!need_right_mixer) pipeline->r_mixer = NULL; } diff --git a/drivers/gpu/drm/msm/disp/mdp5/mdp5_mixer.c b/drivers/gpu/drm/msm/disp/mdp5/mdp5_mixer.c index 954db683ae44..2536def2a000 100644 --- a/drivers/gpu/drm/msm/disp/mdp5/mdp5_mixer.c +++ b/drivers/gpu/drm/msm/disp/mdp5/mdp5_mixer.c @@ -116,21 +116,28 @@ int mdp5_mixer_assign(struct drm_atomic_state *s, struct drm_crtc *crtc, return 0; } -void mdp5_mixer_release(struct drm_atomic_state *s, struct mdp5_hw_mixer *mixer) +int mdp5_mixer_release(struct drm_atomic_state *s, struct mdp5_hw_mixer *mixer) { struct mdp5_global_state *global_state = mdp5_get_global_state(s); - struct mdp5_hw_mixer_state *new_state = &global_state->hwmixer; + struct mdp5_hw_mixer_state *new_state; if (!mixer) - return; + return 0; + + if (IS_ERR(global_state)) + return PTR_ERR(global_state); + + new_state = &global_state->hwmixer; if (WARN_ON(!new_state->hwmixer_to_crtc[mixer->idx])) - return; + return -EINVAL; DBG("%s: release from crtc %s", mixer->name, new_state->hwmixer_to_crtc[mixer->idx]->name); new_state->hwmixer_to_crtc[mixer->idx] = NULL; + + return 0; } void mdp5_mixer_destroy(struct mdp5_hw_mixer *mixer) diff --git a/drivers/gpu/drm/msm/disp/mdp5/mdp5_mixer.h b/drivers/gpu/drm/msm/disp/mdp5/mdp5_mixer.h index 43c9ba43ce18..545ee223b9d7 100644 --- a/drivers/gpu/drm/msm/disp/mdp5/mdp5_mixer.h +++ b/drivers/gpu/drm/msm/disp/mdp5/mdp5_mixer.h @@ -30,7 +30,7 @@ void mdp5_mixer_destroy(struct mdp5_hw_mixer *lm); int mdp5_mixer_assign(struct drm_atomic_state *s, struct drm_crtc *crtc, uint32_t caps, struct mdp5_hw_mixer **mixer, struct mdp5_hw_mixer **r_mixer); -void mdp5_mixer_release(struct drm_atomic_state *s, - struct mdp5_hw_mixer *mixer); +int mdp5_mixer_release(struct drm_atomic_state *s, + struct mdp5_hw_mixer *mixer); #endif /* __MDP5_LM_H__ */ -- 2.35.1