Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3286380ybb; Tue, 31 Mar 2020 02:07:26 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuBm7e8xA1FYBpypUty/drAQG1U1CzoVRZBUaQkqC9VZmc6DjcH9izsolUFccGeA9YDJelA X-Received: by 2002:aca:7512:: with SMTP id q18mr1370616oic.71.1585645646120; Tue, 31 Mar 2020 02:07:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585645646; cv=none; d=google.com; s=arc-20160816; b=fy5ygmHvoX5PRJSwc28C790UN4hIVgyk43Q4ScZQ2uGyM0VgFMkIgn2SnyrqBhE0Ih VxWpx/pRMfTv++UTmaghaIW8KvtCzaY5RJmdHnPuDj9wOuLIy3wKHf/fZ95ABxwLpalb Y7LhtdIEmKHd/h/tazdJtRy3Z7QFdH1fc5dRq1gAdFmmX03Jw3H1tY3/rBEzraIkmwdg 3Jr+kglFmA5a2pcx4r6x6djfjaAItasoF09U++D5j5bMuiLdJ9zgok604a2JIwwjjJA4 D+RzNRZIm7pzDSBeMvoz+Q4A8MQaDyqVXqntAw34GHNOvzDweUY1Aihg+eWYSgRtP2YD yXTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=cy56NM9a+vqowTOwmzBxvYW1LT3BP+9pxCW7c+ui+OA=; b=AlNZqB1El3CluiU9uTrvOpZTS76a9JOIXK0wQrs4nkdJwcjs6KxAlkvh3174cWNPbQ PIidxJZt8uIYBrx+Kl6cUe+rzIGgkGEUYRiw+KimXlZSP9tQk4S1hHhEV9FT9FR+Fn3c IrrowQhQuBvmZCDCIbKvHLnm7OYX7UBpuvoxuHXKkW9QNvPCwX/JAT36i4DlyfqyX4r6 tQMtT2upsJudxmZzCa20xIF1nT3RTHNHPKFA+DaUNkypEMYcG8GlYEm1vC/NOskDzthL Pt6c39DlaSQWQb0Zn9Qj3gop1MVxlDUuWrUG2dbmDknyk4lDNG7TzCW8IVfN4uBjdFMG AA8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ZpWqrsQn; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m18si6925719otn.322.2020.03.31.02.07.13; Tue, 31 Mar 2020 02:07:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=ZpWqrsQn; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731076AbgCaJGx (ORCPT + 99 others); Tue, 31 Mar 2020 05:06:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:48222 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731055AbgCaJGn (ORCPT ); Tue, 31 Mar 2020 05:06:43 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 16A6320675; Tue, 31 Mar 2020 09:06:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1585645602; bh=CzooAaftlavTbOqyUjLGDWwIFSY/farNaexwMre5f40=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZpWqrsQnrZCRtcflrKH7DqW27mw7LLkEyAOULFmtaz3jGau7WP6gNPe5u5jd/8LvG rj7NsRLtY5/UoH0XgVWWQ5BqJhvnV/5BCq173UZk+TPO8pez4sOH0YF6q7dHSXOK2t r2PtZRw9qdQ+x0fGgQQWoustMA1unm/TdqFa54lU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Shane Francis , "Michael J. Ruhl" , Alex Deucher Subject: [PATCH 5.5 103/170] drm/prime: use dma length macro when mapping sg Date: Tue, 31 Mar 2020 10:58:37 +0200 Message-Id: <20200331085435.153059838@linuxfoundation.org> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200331085423.990189598@linuxfoundation.org> References: <20200331085423.990189598@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Shane Francis commit 42e67b479eab6d26459b80b4867298232b0435e7 upstream. As dma_map_sg can reorganize scatter-gather lists in a way that can cause some later segments to be empty we should always use the sg_dma_len macro to fetch the actual length. This could now be 0 and not need to be mapped to a page or address array Fixes: be62dbf554c5 ("iommu/amd: Convert AMD iommu driver to the dma-iommu api") Bug: https://bugzilla.kernel.org/show_bug.cgi?id=206461 Bug: https://bugzilla.kernel.org/show_bug.cgi?id=206895 Bug: https://gitlab.freedesktop.org/drm/amd/issues/1056 Signed-off-by: Shane Francis Reviewed-by: Michael J. Ruhl Signed-off-by: Alex Deucher Link: https://patchwork.freedesktop.org/patch/msgid/20200325090741.21957-2-bigbeeshane@gmail.com Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/drm_prime.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/gpu/drm/drm_prime.c +++ b/drivers/gpu/drm/drm_prime.c @@ -964,7 +964,7 @@ int drm_prime_sg_to_page_addr_arrays(str index = 0; for_each_sg(sgt->sgl, sg, sgt->nents, count) { - len = sg->length; + len = sg_dma_len(sg); page = sg_page(sg); addr = sg_dma_address(sg);