Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2836244pxv; Mon, 12 Jul 2021 03:08:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxqn0pq2CF0uBJfAnPBtBSMiffBIwA/aCO4NMBiqCRyc3CBmBhYX6CpRHsh3tJkxtVZT9mi X-Received: by 2002:a05:6638:100b:: with SMTP id r11mr13570739jab.85.1626084444386; Mon, 12 Jul 2021 03:07:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626084444; cv=none; d=google.com; s=arc-20160816; b=akbbyTpEtqpyuLctIWJpPU2oSdYlFx572wW/9HWL2jmCKvsrC2SwVlZ17PGDXGYQ9S 1+yrL4SQ6p+/5z5nDKdUZ/BsVtxGoJ6+AbviYfuR06NTjvvBTOWzuTasPJy1Ioi/U9MP HdGL5bIn0bP/PcAXXwXIcFXcc5cqySKpsp4swGfJZnEhOY1dTiIJlc/A/WU6EYnK7bjA nQZZvb2P7/lqpGdkndVzlVX2WWqR9MDX0dVV3xtVkELJ+g1jljGbBCYwNddAvGSQ/msR rC8IW0M7iQOQlTGLr1Tf2nXMpc4KKwlTVbe7lzeIaZNNiVbHYzqzy5/uQJCkUmnzhSEz F0BQ== 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=rQzbSK4dhwQ9Wfl0kzZjIE4cBJ7BH/J0d04mkoDq1eY=; b=TVO/3LloHBX9nmbHZ54M0GnigzhH0EBoIZBeyCxYNUpdrZN+ikRacMDMMLgacntSUl ImuUigyJ46jGiWB73JTI9e1Xw9rCOfqZ3YNxhyPSglUg6WNLCGPD2ZVS7nMl3vZ+1X1S nV+TRJMYAZ3FgcxVb23sSdEBsJdg6W/27dJIIywEaq37maHY+1yEzOKu3WP1M1K9fLf8 e6FWZ5gP6yclPwBlKlgNYG+ZojAJaiZ7zb61gzETLG2QeFAM7SQ7qsSYJvhdTZdWtvIN lAWUCzgbkibJwbl6AUFlbkxdSVKDyzMkaYCnJLSbAjpbxfJ9ItvtUu/UvobJLZaP2gd6 futg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MWyDZeem; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q185si19314732iof.55.2021.07.12.03.07.12; Mon, 12 Jul 2021 03:07:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MWyDZeem; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1349967AbhGLHpG (ORCPT + 99 others); Mon, 12 Jul 2021 03:45:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:47232 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241946AbhGLHM2 (ORCPT ); Mon, 12 Jul 2021 03:12:28 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4C8F1610D1; Mon, 12 Jul 2021 07:09:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626073779; bh=j7z8Yc+lgjfOdQQig3VLMguQL2lfa3TQ/zG18pUkpSo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MWyDZeeme/LV0MuC3s9azmS6vy5O/6r8ND/Z1XJiGbsXkkaL66DbTkXQqBWOhUjgg oBMmR0lGfUh5OHtn02hyHTYs98s2VwKHA9/MBpuY5zAt0fcC6o5c/kWuKMnSHWJJNy tE4IQVvpmtVciug6sbx4+cTMhCDZnChXdFCSS8CE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lucas Stach , Philipp Zabel , Sasha Levin Subject: [PATCH 5.12 358/700] drm/imx: ipuv3-plane: fix PRG modifiers after drm managed resource conversion Date: Mon, 12 Jul 2021 08:07:21 +0200 Message-Id: <20210712061014.432461059@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210712060924.797321836@linuxfoundation.org> References: <20210712060924.797321836@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lucas Stach [ Upstream commit 17b9a94656fe19aef3647c4f93d93be51697ceb1 ] The conversion to drm managed resources introduced two bugs: the plane is now always initialized with the linear-only list, while the list with the Vivante GPU modifiers should have been used when the PRG/PRE engines are present. This masked another issue, as ipu_plane_format_mod_supported() is now called before the private plane data is set up, so if a non-linear modifier is supplied in the plane modifier list, we run into a NULL pointer dereference checking for the PRG presence. To fix this just remove the check from this function, as we know that it will only be called with a non-linear modifier, if the plane init code has already determined that the PRG/PRE is present. Fixes: 699e7e543f1a ("drm/imx: ipuv3-plane: use drm managed resources") Signed-off-by: Lucas Stach Link: https://lore.kernel.org/r/20210510145927.988661-1-l.stach@pengutronix.de Signed-off-by: Philipp Zabel Signed-off-by: Sasha Levin --- drivers/gpu/drm/imx/ipuv3-plane.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/imx/ipuv3-plane.c b/drivers/gpu/drm/imx/ipuv3-plane.c index c5ff966e2ceb..8c08c8b36074 100644 --- a/drivers/gpu/drm/imx/ipuv3-plane.c +++ b/drivers/gpu/drm/imx/ipuv3-plane.c @@ -345,10 +345,11 @@ static bool ipu_plane_format_mod_supported(struct drm_plane *plane, if (modifier == DRM_FORMAT_MOD_LINEAR) return true; - /* without a PRG there are no supported modifiers */ - if (!ipu_prg_present(ipu)) - return false; - + /* + * Without a PRG the possible modifiers list only includes the linear + * modifier, so we always take the early return from this function and + * only end up here if the PRG is present. + */ return ipu_prg_format_supported(ipu, format, modifier); } @@ -861,6 +862,10 @@ struct ipu_plane *ipu_plane_init(struct drm_device *dev, struct ipu_soc *ipu, formats = ipu_plane_rgb_formats; format_count = ARRAY_SIZE(ipu_plane_rgb_formats); } + + if (ipu_prg_present(ipu)) + modifiers = pre_format_modifiers; + ipu_plane = drmm_universal_plane_alloc(dev, struct ipu_plane, base, possible_crtcs, &ipu_plane_funcs, formats, format_count, modifiers, @@ -875,9 +880,6 @@ struct ipu_plane *ipu_plane_init(struct drm_device *dev, struct ipu_soc *ipu, ipu_plane->dma = dma; ipu_plane->dp_flow = dp; - if (ipu_prg_present(ipu)) - modifiers = pre_format_modifiers; - drm_plane_helper_add(&ipu_plane->base, &ipu_plane_helper_funcs); if (dp == IPU_DP_FLOW_SYNC_BG || dp == IPU_DP_FLOW_SYNC_FG) -- 2.30.2