Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3202534pxb; Mon, 9 Nov 2020 05:30:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJzvtJqs8bb6HLa4j9FQsIwobQKB/nVA8MVEKOyfJIz7sZb1NHig8TvB+ufCMvNwZH6PDxKY X-Received: by 2002:a17:906:f752:: with SMTP id jp18mr14306153ejb.331.1604928622399; Mon, 09 Nov 2020 05:30:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604928622; cv=none; d=google.com; s=arc-20160816; b=UbUHDq0m/opXtRDdEkSYk6wIfL8pKVugLxbt7PV5pNO4Dv5l3ZxZXvKlGbUZ9M90It 3jXb7YPXF3iQJLh7PUS5KaITZu5o3rAeQeSDfplnYgo43RGvvnUCayp6e/s9RmzES0LI 0mn/4hEoJ2WvHWsg6XrxM6ivnou3Vl23N6TK5ekOqYSfyA4RuMwB+bPQf4bsfmWR6K1l wHjwuJ5+K9rfz0jMNZ2nHu2RXNslYFfMLTFjwztPTeIFbD5tPMvXn9HoorBzn/QegpHZ Fs4PbSNp2Q8s1VEuaRztguuvm5xHvnDfPBqEJpc+uEqRsLMv/W5UULfz678WOAL6BjSr eDNQ== 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=9a8HBsvHdxEWJtidTnwZPhbZOYgzNtk9H01b+JELbDw=; b=ePmUeAVZNKz6EaAq69Qc6pgdYmlS+iBsD20gX7XedCj/Ci6xemw1+4zdJ4nE1h1IRu 1AZmPAQGL0ZRP/2nw6JY/99pNDweyLy4wUniZp+YPGPien1M8AFhn/RB9fouSHkyQWZB HNOd4zbwol2sVCEyqoYFCJnmuPIOc667TFXNuJHUDyFBZ4/5t8LxSiSPaEx9a+qqD+wy sRBf94bnubwBHJtkZdf6dc8gNOwcXm2Y0I9dVdnAukSCKln6mhgYncFLzzzIK3SF52QK r6UXHj5RSxfsp7BPa1rbw7N2mCxJ7Ltl32+b1D4G5kCzpP2B0xfBwEZjidLKegt0F+Yg wLhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=KCITwdcm; 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=fail (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 62si7439149edc.231.2020.11.09.05.29.59; Mon, 09 Nov 2020 05:30:22 -0800 (PST) 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=default header.b=KCITwdcm; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387492AbgKIN0n (ORCPT + 99 others); Mon, 9 Nov 2020 08:26:43 -0500 Received: from mail.kernel.org ([198.145.29.99]:42634 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732918AbgKINPr (ORCPT ); Mon, 9 Nov 2020 08:15:47 -0500 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 01F8620789; Mon, 9 Nov 2020 13:15:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604927746; bh=LElm6Zafo7BTS/lgiCEqVaMi8wJy5DkDg9vX2n7H3tQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KCITwdcmKiYgbzbPk1i0tjExGMdbOAYTHc5JzcHB8apkEVKR5DXATq8cAROLjPEoO 8ZoEdlvGuz/1da0PYOR1vB6nu8m75/hkhdFzp6CtM1f9joJAXCL62BaWf2KAQw0ht3 2Nnu/D6uxDoP+mecLaTjem3VUfmCn4vGiGOnZjNg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ralph Campbell , Ben Skeggs , Sasha Levin Subject: [PATCH 5.4 60/85] drm/nouveau/nouveau: fix the start/end range for migration Date: Mon, 9 Nov 2020 13:55:57 +0100 Message-Id: <20201109125025.446308429@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201109125022.614792961@linuxfoundation.org> References: <20201109125022.614792961@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: Ralph Campbell [ Upstream commit cfa736f5a6f31ca8a05459b5720aac030247ad1b ] The user level OpenCL code shouldn't have to align start and end addresses to a page boundary. That is better handled in the nouveau driver. The npages field is also redundant since it can be computed from the start and end addresses. Signed-off-by: Ralph Campbell Signed-off-by: Ben Skeggs Signed-off-by: Sasha Levin --- drivers/gpu/drm/nouveau/nouveau_svm.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_svm.c b/drivers/gpu/drm/nouveau/nouveau_svm.c index 824654742a604..0be4668c780bf 100644 --- a/drivers/gpu/drm/nouveau/nouveau_svm.c +++ b/drivers/gpu/drm/nouveau/nouveau_svm.c @@ -112,11 +112,11 @@ nouveau_svmm_bind(struct drm_device *dev, void *data, struct nouveau_cli *cli = nouveau_cli(file_priv); struct drm_nouveau_svm_bind *args = data; unsigned target, cmd, priority; - unsigned long addr, end, size; + unsigned long addr, end; struct mm_struct *mm; args->va_start &= PAGE_MASK; - args->va_end &= PAGE_MASK; + args->va_end = ALIGN(args->va_end, PAGE_SIZE); /* Sanity check arguments */ if (args->reserved0 || args->reserved1) @@ -125,8 +125,6 @@ nouveau_svmm_bind(struct drm_device *dev, void *data, return -EINVAL; if (args->va_start >= args->va_end) return -EINVAL; - if (!args->npages) - return -EINVAL; cmd = args->header >> NOUVEAU_SVM_BIND_COMMAND_SHIFT; cmd &= NOUVEAU_SVM_BIND_COMMAND_MASK; @@ -158,12 +156,6 @@ nouveau_svmm_bind(struct drm_device *dev, void *data, if (args->stride) return -EINVAL; - size = ((unsigned long)args->npages) << PAGE_SHIFT; - if ((args->va_start + size) <= args->va_start) - return -EINVAL; - if ((args->va_start + size) > args->va_end) - return -EINVAL; - /* * Ok we are ask to do something sane, for now we only support migrate * commands but we will add things like memory policy (what to do on @@ -178,7 +170,7 @@ nouveau_svmm_bind(struct drm_device *dev, void *data, return -EINVAL; } - for (addr = args->va_start, end = args->va_start + size; addr < end;) { + for (addr = args->va_start, end = args->va_end; addr < end;) { struct vm_area_struct *vma; unsigned long next; -- 2.27.0