From patchwork Wed Jan 11 17:50:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Zack Rusin X-Patchwork-Id: 13097070 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D1C35C46467 for ; Wed, 11 Jan 2023 17:50:30 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3E5FC10E7D1; Wed, 11 Jan 2023 17:50:29 +0000 (UTC) Received: from letterbox.kde.org (letterbox.kde.org [46.43.1.242]) by gabe.freedesktop.org (Postfix) with ESMTPS id 9AE4C10E7D1 for ; Wed, 11 Jan 2023 17:50:26 +0000 (UTC) Received: from vertex.vmware.com (pool-173-49-113-140.phlapa.fios.verizon.net [173.49.113.140]) (Authenticated sender: zack) by letterbox.kde.org (Postfix) with ESMTPSA id 308AD33F326; Wed, 11 Jan 2023 17:50:24 +0000 (GMT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kde.org; s=users; t=1673459424; bh=aK5KJQ9Nw7v7qyH659mF6AvhUERGuDuiygjbdOXDmJs=; h=From:To:Cc:Subject:Date:From; b=E6mhfvfQw6MCN0L0EmrVeLbH7MAApriDF5mfZCMcr/E4xhZvDRw+8vgmqSRIj4noT 1VmHHSR0mvx3X8EEVOjw5tgEt7EZKXAZxkS5AFwP5U6IXk2BZtVY8q/EqJYcj9WjhC D5dS5wSXTHcupGRDfQ8D7PYpMGqKXOwMDtDKDxME+emm1R5+mrR5yfAByq25PB/8+S AqjXNcphU1St4ceAdf3y8wdkQ0B8B6xrQlcvY00iM1U1PCDeseWokoI9gswjzC0bcw wj4L9bxfrte50Yrz4EOzt6Ro7+hKX2lzahJgJuBIatuoQO0UtKlNzxIevj2i0f4tH3 PCwDtnfZXl1NQ== From: Zack Rusin To: dri-devel@lists.freedesktop.org Subject: [PATCH] drm/ttm: Fix a regression causing kernel oops'es Date: Wed, 11 Jan 2023 12:50:15 -0500 Message-Id: <20230111175015.1134923-1-zack@kde.org> X-Mailer: git-send-email 2.37.2 MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Zack Rusin Cc: Somalapuram Amaranath , banackm@vmware.com, krastevm@vmware.com, =?utf-8?q?Christian_K=C3=B6nig?= , mombasawalam@vmware.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Zack Rusin The branch is explicitly taken if ttm == NULL which means that to avoid a null pointer reference the ttm object can not be used inside. Switch back to dst_mem to avoid kernel oops'es. This fixes kernel oops'es with any buffer objects which don't have ttm_tt, e.g. with vram based screen objects on vmwgfx. Signed-off-by: Zack Rusin Fixes: e3c92eb4a84f ("drm/ttm: rework on ttm_resource to use size_t type") Cc: Somalapuram Amaranath Cc: Christian König Reviewed-by: Martin Krastev Reviewed-by: Christian König --- drivers/gpu/drm/ttm/ttm_bo_util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c index fee7c20775c0..12017ec24d9f 100644 --- a/drivers/gpu/drm/ttm/ttm_bo_util.c +++ b/drivers/gpu/drm/ttm/ttm_bo_util.c @@ -183,7 +183,7 @@ int ttm_bo_move_memcpy(struct ttm_buffer_object *bo, clear = src_iter->ops->maps_tt && (!ttm || !ttm_tt_is_populated(ttm)); if (!(clear && ttm && !(ttm->page_flags & TTM_TT_FLAG_ZERO_ALLOC))) - ttm_move_memcpy(clear, ttm->num_pages, dst_iter, src_iter); + ttm_move_memcpy(clear, PFN_UP(dst_mem->size), dst_iter, src_iter); if (!src_iter->ops->maps_tt) ttm_kmap_iter_linear_io_fini(&_src_iter.io, bdev, src_mem);