Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3286222ybb; Tue, 31 Mar 2020 02:07:14 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsN8uM++zhzgc75e81oqAaOKrFOl3A3wWyq9LzLjGLyoDtfyAAhux2JKKaVjqH6gTwEzO// X-Received: by 2002:a4a:c315:: with SMTP id c21mr3836606ooq.13.1585645634765; Tue, 31 Mar 2020 02:07:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585645634; cv=none; d=google.com; s=arc-20160816; b=eYALbY4Av7yVBPKsgQ7ohC3EUpercTyFN5dqyzXhIpbXwrHIiqSsDd/qfE1EmrIUk5 q/0Vdl9bM1cHdwC2AeXGqkfkDYpwFMhPaN6MF0QcrqT3CTLLWiMJDQ/JSlBrzBGxTXwu xeL1cNiMbzLFYQR6TIIkn0dmV6FHAitsyTkbrlbJLY+/p2eYxbwe39Y4Ss3VvYvXyyKV s344vc5Rg79uNITcW68Gmze7OEaNq4wRH80rMfS+2h0vV0nqwfhQbFBlzQXPvNYa/3Sl l7SQwfH24JtnG++qjzfCsvbHptP/MhoPTuuJOZPJ3D/V88nBbdTHh9H5WQYnBUnOb1Fx Vr3g== 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=Ooww4QU1iP+rkYR5XG2k2aX/kP3ngB9iAub2s3HHDC4=; b=I87FZJmp+7sMvFRzKKYz+bD36MnDCgEJUdF6SSjcCV9VYzWSZTrP+CncsnrEfMdjDT woDEYdalvylJrxSmPw6yK8Xnht/BR3stRTHUMihdkBIHV/9BCTts2Wxra5WgW5EZHIiD ZqnUEu2GnAC4BKgK0YLjdUwUswGwjFPcRMHHuHAa7qb0L8hFxvyKF6pHB46iHSCKYUPZ T08VTbJNHIwB81Rl4qNLCETRs7tKRU6kJb/r6iTueb+f2wcVRCmauN+9iC2cU6oxPhcW PJuyl5KYLoYKLv+BFePg1SCjKSsL4gDib3pH/6HKmo5CdAeBDwjaUWtM1Q88yYuHBKOY Deug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="i0rj/Zv0"; 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 s63si6837187oig.69.2020.03.31.02.07.02; Tue, 31 Mar 2020 02:07:14 -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="i0rj/Zv0"; 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 S1731182AbgCaJGr (ORCPT + 99 others); Tue, 31 Mar 2020 05:06:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:48256 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730763AbgCaJGp (ORCPT ); Tue, 31 Mar 2020 05:06:45 -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 AF35E20675; Tue, 31 Mar 2020 09:06:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1585645605; bh=q1Wq3oXTi7QJHrqZ3v5qjUsU0inZfTf2XVcsAVXiihY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=i0rj/Zv07Cdhs0yV1srYikjaM+w+C6q4Cb3z4Bk98qzuf8HFtJat42oxUDtJZ2niD 8S3BKvpBl92SQjbF14q9pGpE7PlXcCkKpSMyqC4dlK6IumFiPTLgkUakAizWPm+NjI P8QAETYEdKut9MYq7lvkK6p4xGanwzCNyTdN9Agc= 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 104/170] drm/amdgpu: fix scatter-gather mapping with user pages Date: Tue, 31 Mar 2020 10:58:38 +0200 Message-Id: <20200331085435.243545182@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 0199172f933342d8b1011aae2054a695c25726f4 upstream. Calls to dma_map_sg may return less segments / entries than requested if they fall on page bounderies. The old implementation did not support this use case. 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-3-bigbeeshane@gmail.com Cc: stable@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c @@ -973,7 +973,7 @@ static int amdgpu_ttm_tt_pin_userptr(str /* Map SG to device */ r = -ENOMEM; nents = dma_map_sg(adev->dev, ttm->sg->sgl, ttm->sg->nents, direction); - if (nents != ttm->sg->nents) + if (nents == 0) goto release_sg; /* convert SG to linear array of pages and dma addresses */