Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1917486pxb; Thu, 16 Sep 2021 20:12:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzfzzw5bKuM0viwAicwfYXrXtcH51cdA5AOwl6PaIixc9bcL2OdWy2cMz5MukK4El6uupQQ X-Received: by 2002:a17:906:a3d9:: with SMTP id ca25mr9715790ejb.306.1631848323594; Thu, 16 Sep 2021 20:12:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631848323; cv=none; d=google.com; s=arc-20160816; b=ilDpJd8usRLzBF6iEHYY0mQP5UA++j+oY8bmxoXu3xwb0WAlc8tcX2xahac5NUf/+u mPfB1Nh7aQ3m99iBtvM8J7tnAoye+rgPyvbpZxH9tld0C4ZWhLBV5NY7g73FFKYLWMuh l0a2CEKIcyKnJLPwLCUAHVmB6CHf9fff0KR1oc5+GsSVrEVAOyKH6sqD1vLtNLMJ37qH +mPJ/E5DuFgENruJqIHkOGvNaR4vPZPHtRM+E7zhYxDnhNdAyAj+rIa+MXLpDcSkrCgq Q2+Nq2Yjt7disub9haq0BkQDiHqVxvbVBZsAH4isDlSQ+O5Bdhb55c5SuiSp/Gddly1k tyWA== 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=tsRo/2KzU6oZfDqSK1J0EX1IqhWOUQ1XRr/GuVkFP3U=; b=bZsRLZ6P3HhtbVMc67Aa0Ee7aipzxS4bFOK8gTDhlAHruyDgciWMrfCWOkG3iA4fJo 32rtXo/2gyZF7/zp2BHEr4tDtsmF3Oj9+yUEtmNlESc8SGN9zO/mP/UDtxDNXzyDoiMX It6J8bEwvK1n/w92cvP5RZ6ISLN2n2vxsUl9UBpwgTpoYSjT149t74VS9o2It9wq4F+/ U17z4IV+U3GkE3KXrDjaB6IzbfhLK9yBxrNMjz+Qql5nsDJ6ykI4gjjHRHVmbSxsrGSg dWDSRrDy/gVNWE12JWsgsAJSUo0O0sqg2MTW/A70Ktkw1hxdRtHekS+yO6sv/q9+qfNo Ct/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=uqIA3jnJ; 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 bz6si5624096ejc.374.2021.09.16.20.11.39; Thu, 16 Sep 2021 20:12:03 -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=uqIA3jnJ; 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 S1353034AbhIPR3w (ORCPT + 99 others); Thu, 16 Sep 2021 13:29:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:43648 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351986AbhIPRUI (ORCPT ); Thu, 16 Sep 2021 13:20:08 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2261C61BB2; Thu, 16 Sep 2021 16:42:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631810523; bh=lZPFsafQ4x9ZhcGx2SHXD6JQ8EyomNZhe2cZ6YQnL5I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uqIA3jnJTXtIqDpFFKVaxXUtzmPiBD/ykaJqazZQoEqRBGA+CeNcRFeOgxBHvcj6J Rvrc4+HopMc0Kd6MEvPnIm+Qnrzlt8r74Vkzc4dHLHvHa36U77R2nyoS4h79v9lK+Z 9lkmv+M6/f/8znpaR3lQDutMzg+YEo6OGI4OOggs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Thomas Zimmermann , Melissa Wen , Sasha Levin Subject: [PATCH 5.14 173/432] drm/vkms: Let shadow-plane helpers prepare the planes FB Date: Thu, 16 Sep 2021 17:58:42 +0200 Message-Id: <20210916155816.607392338@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210916155810.813340753@linuxfoundation.org> References: <20210916155810.813340753@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: Thomas Zimmermann [ Upstream commit b43e2ec03b0de040d536591713ea9c875ff34ba9 ] Replace vkms' prepare_fb and cleanup_fb functions with the generic code for shadow-buffered planes. No functional changes. This change also fixes a problem where IGT kms_flip tests would create a segmentation fault within vkms. The driver's prepare_fb function did not report an error if a BO's vmap operation failed. The kernel later tried to operate on the non-mapped memory areas. The shared shadow-plane helpers handle errors correctly, so that the driver now avoids the segmantation fault. v2: * include paragraph about IGT tests in commit message (Melissa) Signed-off-by: Thomas Zimmermann Reviewed-by: Melissa Wen Link: https://patchwork.freedesktop.org/patch/msgid/20210705074633.9425-4-tzimmermann@suse.de Signed-off-by: Sasha Levin --- drivers/gpu/drm/vkms/vkms_plane.c | 38 +------------------------------ 1 file changed, 1 insertion(+), 37 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_plane.c b/drivers/gpu/drm/vkms/vkms_plane.c index 107521ace597..092514a2155f 100644 --- a/drivers/gpu/drm/vkms/vkms_plane.c +++ b/drivers/gpu/drm/vkms/vkms_plane.c @@ -8,7 +8,6 @@ #include #include #include -#include #include "vkms_drv.h" @@ -150,45 +149,10 @@ static int vkms_plane_atomic_check(struct drm_plane *plane, return 0; } -static int vkms_prepare_fb(struct drm_plane *plane, - struct drm_plane_state *state) -{ - struct drm_gem_object *gem_obj; - struct dma_buf_map map; - int ret; - - if (!state->fb) - return 0; - - gem_obj = drm_gem_fb_get_obj(state->fb, 0); - ret = drm_gem_shmem_vmap(gem_obj, &map); - if (ret) - DRM_ERROR("vmap failed: %d\n", ret); - - return drm_gem_plane_helper_prepare_fb(plane, state); -} - -static void vkms_cleanup_fb(struct drm_plane *plane, - struct drm_plane_state *old_state) -{ - struct drm_gem_object *gem_obj; - struct drm_gem_shmem_object *shmem_obj; - struct dma_buf_map map; - - if (!old_state->fb) - return; - - gem_obj = drm_gem_fb_get_obj(old_state->fb, 0); - shmem_obj = to_drm_gem_shmem_obj(drm_gem_fb_get_obj(old_state->fb, 0)); - dma_buf_map_set_vaddr(&map, shmem_obj->vaddr); - drm_gem_shmem_vunmap(gem_obj, &map); -} - static const struct drm_plane_helper_funcs vkms_primary_helper_funcs = { .atomic_update = vkms_plane_atomic_update, .atomic_check = vkms_plane_atomic_check, - .prepare_fb = vkms_prepare_fb, - .cleanup_fb = vkms_cleanup_fb, + DRM_GEM_SHADOW_PLANE_HELPER_FUNCS, }; struct vkms_plane *vkms_plane_init(struct vkms_device *vkmsdev, -- 2.30.2