Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp1958302imn; Mon, 1 Aug 2022 06:18:55 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uJsqGveWwHWo/SJusA+SwHHbho6pwpz88NqbmoJ8HuBYKaaXRhVkAWfuUseWq0MSTXCnav X-Received: by 2002:a17:907:d92:b0:72e:e968:7fa1 with SMTP id go18-20020a1709070d9200b0072ee9687fa1mr13004468ejc.731.1659359934703; Mon, 01 Aug 2022 06:18:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659359934; cv=none; d=google.com; s=arc-20160816; b=ENDzZRMLA9r9LulCgtwzGW3Lw3hb6qELIdbsv8wEurWNvV5byEkhcdiyqvh3aOXoCA fePyAS4PE1mSB5ijOZ/KpOIrjM+7brm/XOnb9C9amzQDVVgrNaEYH21Z1W2iWU16L0Sn lJDE5ozW4ywRfGt2zX6VJFVEBKG+7FpjUdKXPLn+vBG34z9wQd6FvOv9yjxD02Z2flCu bNf23doJpzyeH0SlvSjeSGnZWX2kaho11e+EOg42zLlfF8FU+55slxP32kUdFn1KwGah 93AiT4NP7p1baMcawuZfRc4ZhibBfAWkfjW0ukT7H4TWItchvRXLETI1QdOLmpXtXmoQ rM4w== 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=CT/tWCu65esCoBSBIKjoVU12b7C9jOSSRqUCBPGXjz0=; b=skv2r4WXZLMffd5sEOVXdQVBRXzNvBa+tmutaoPjmyZfGrr3Y34M8EEhkFV7vnDPQF fecq5WQbSjuIuFL7RsSmX7y424NqgoKZDxHESK61EyzMaGwIT5PWZCBJ/lBLCr8LLhLK umybSFecIZ0qxktX3IVDt+oWhP+FdJqcLLTd3rISET/aSU+K0MseNA6fprqSwXn8444G BkrVQxa0Ojeih9Ihrw6O4fMW9tnRCgCmwDdxI0osPKRD3dOQnAYwiNhu/Nj1Ewk2RZg3 uklySsF9mZ3CDswEdv7qq3oMPMm/9YArijWeWChDXWwOM7C17Wm1cUeaGzE2jpmmrEuC kstw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lKlgbjWx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z22-20020a05640235d600b0043d9a57098asi3503425edc.184.2022.08.01.06.18.10; Mon, 01 Aug 2022 06:18:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=lKlgbjWx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231553AbiHALzC (ORCPT + 99 others); Mon, 1 Aug 2022 07:55:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232135AbiHALyc (ORCPT ); Mon, 1 Aug 2022 07:54:32 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92C093DF13; Mon, 1 Aug 2022 04:50:43 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 23BB3B8116B; Mon, 1 Aug 2022 11:50:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 76CBBC433C1; Mon, 1 Aug 2022 11:50:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1659354640; bh=F9pxzWaFExZc72a2VmO0mWpFCFZ99faa32kDZsNKF9k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lKlgbjWxGzHyqv6H+4LAiNCSqFF0+PssKM8tcsivq8jnzOMmeNiqO/u+VLEVp3Ed6 2JBEGbkX3IhLUOUvOT3a+WVkmGfVh1nM1eQtZ7RQ5nJ0T6F5OXplw5rkLkUdzhWfNy kGVBddpnIMaQfO6xCc/VefxUEKDI0MYJZGCrE6AA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alistair Popple , Ralph Campbell , Lyude Paul Subject: [PATCH 5.10 05/65] nouveau/svm: Fix to migrate all requested pages Date: Mon, 1 Aug 2022 13:46:22 +0200 Message-Id: <20220801114133.880205502@linuxfoundation.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20220801114133.641770326@linuxfoundation.org> References: <20220801114133.641770326@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Alistair Popple commit 66cee9097e2b74ff3c8cc040ce5717c521a0c3fa upstream. Users may request that pages from an OpenCL SVM allocation be migrated to the GPU with clEnqueueSVMMigrateMem(). In Nouveau this will call into nouveau_dmem_migrate_vma() to do the migration. If the total range to be migrated exceeds SG_MAX_SINGLE_ALLOC the pages will be migrated in chunks of size SG_MAX_SINGLE_ALLOC. However a typo in updating the starting address means that only the first chunk will get migrated. Fix the calculation so that the entire range will get migrated if possible. Signed-off-by: Alistair Popple Fixes: e3d8b0890469 ("drm/nouveau/svm: map pages after migration") Reviewed-by: Ralph Campbell Reviewed-by: Lyude Paul Signed-off-by: Lyude Paul Link: https://patchwork.freedesktop.org/patch/msgid/20220720062745.960701-1-apopple@nvidia.com Cc: # v5.8+ Signed-off-by: Greg Kroah-Hartman --- drivers/gpu/drm/nouveau/nouveau_dmem.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) --- a/drivers/gpu/drm/nouveau/nouveau_dmem.c +++ b/drivers/gpu/drm/nouveau/nouveau_dmem.c @@ -679,7 +679,11 @@ nouveau_dmem_migrate_vma(struct nouveau_ goto out_free_dma; for (i = 0; i < npages; i += max) { - args.end = start + (max << PAGE_SHIFT); + if (args.start + (max << PAGE_SHIFT) > end) + args.end = end; + else + args.end = args.start + (max << PAGE_SHIFT); + ret = migrate_vma_setup(&args); if (ret) goto out_free_pfns;