Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp446318pxb; Thu, 9 Sep 2021 04:47:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxqbxO4zAeICLxrXC63q6FCKOHCT1S1JlpAQ+6jdxZhJQsVx9lVHLBnRDZo2bmLLoSOKfts X-Received: by 2002:a05:6402:493:: with SMTP id k19mr2832632edv.386.1631188049982; Thu, 09 Sep 2021 04:47:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631188049; cv=none; d=google.com; s=arc-20160816; b=iwkIpTaVbnQ4iAICCX/V+Bp8WE5B7Jvhgugeox6HcDHDAELZfwpgUqSaSlFfAzl5Bt zhsw7chmWChzmJNE3tKrxleez73IIkCI8+COEtta2XT6/3DhkU38bfmVHAqHoqpMOHlM g9NQgqS7oTs9SFwLIDlS3AJeneHvCdcnIjM/5sWKiZyTuKAVwP3SHd45hT3yN7V7eVby u1Q31rE8iQ0uiO7ZZ130zS4qzCopD2kUIVPA8jXQniJAk74PnpoJZwM/XRzyySPC2eOY boRD448j2F8lhF2cVZtPU+zSyx1pav7qtHl9bafaIz5gU5e8SoknwzduqjMoKyk4ArNl NjmQ== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=tsRo/2KzU6oZfDqSK1J0EX1IqhWOUQ1XRr/GuVkFP3U=; b=GBWiYvXiOLCQZWcUV3cU1tzMvpnOOYRZt0Bp2qMsAH/YqR93BCC0YAdfmd+ErFE5sU yMWS8N8m53qtmWE5jcfHtxFHWO0b+t5TspapIj1W0OrEiZp68z/Zo/RqdKacCmBSwAMs obyJc4n2EcIJM+Kd/H80kHfDCwjA1Yd+PJ11U0MV2ILmS3oSBwe7BEIAXqDRnIPhImJA Ife3kqkEf8zKhTwG9cV6s7aceZ5YDnhxaezWS3E0aEchGgjdUyujdpwpm88P704RDpP3 Tm9rS9JkIRDxO8MZ8nkAtXeuWJpEEtPT2HnSLyXcAmKbdGd8aHoHGal5K3z8ADLMB20o nvnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=AN0DcgNT; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l9si1675070edq.493.2021.09.09.04.47.06; Thu, 09 Sep 2021 04:47:29 -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=@kernel.org header.s=k20201202 header.b=AN0DcgNT; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237234AbhIILni (ORCPT + 99 others); Thu, 9 Sep 2021 07:43:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:45698 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235980AbhIILmk (ORCPT ); Thu, 9 Sep 2021 07:42:40 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0CBE2611AF; Thu, 9 Sep 2021 11:41:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1631187690; bh=lZPFsafQ4x9ZhcGx2SHXD6JQ8EyomNZhe2cZ6YQnL5I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AN0DcgNTGF9usL6YT3HZ5+zoQTVHAXwQ1ltJKsOgEJXyWGJI+cr1uaM1UhC6f0OFk x/tKntb3IIk0VDeHtw2GI4d5I6BJJZYupZKYyI4AN53LYl6Cpvo2Ia0x6MnOx/REQ2 eRqeOD374GNFpndrp7EJ5GL4rH5lCP+I7bY7JEn34XDGLtQ1eK9E7CVNC2wRpIWjtd DkIdwdX7SkDUfw0iZKlpk5ei24Nulv9tUOMOCaJN/kUI1JnyUfYbu1eTjEUDRwoDJo 0gZSKOCQ3wMynJwApSiH3UXpHVgjMX788L96JktzMUiFB9yAGfX4B/w5sg0KRUtgUG 0v2ZaBkSxa66w== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Thomas Zimmermann , Melissa Wen , Sasha Levin , dri-devel@lists.freedesktop.org Subject: [PATCH AUTOSEL 5.14 018/252] drm/vkms: Let shadow-plane helpers prepare the plane's FB Date: Thu, 9 Sep 2021 07:37:12 -0400 Message-Id: <20210909114106.141462-18-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210909114106.141462-1-sashal@kernel.org> References: <20210909114106.141462-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore 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