Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3425127pxj; Mon, 24 May 2021 06:32:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzaNTgfVuI2RhHXGuZ/o2knCiB29Z9Gwjuy53CZYhXzRHGv/VEfbRPGSCrZhXcz+TQzAwkh X-Received: by 2002:a05:6402:3551:: with SMTP id f17mr4050712edd.313.1621863142756; Mon, 24 May 2021 06:32:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1621863142; cv=pass; d=google.com; s=arc-20160816; b=pY19FiZx0/DLR5usFH2UWVLPMMpSCdDdmriihsIIYCcu+4K/StT34rM6u/Dpo4yUO1 WgMhUMJkFWf1gTAoCEdhOidUgtY5iC8Cbhjd0B9Gy8kKdYoJ09owP5QMJH5t6azbLQJj Sgo5tWKg45+m+x5Y2vO4FzZlOhSFCRkHWo+pOvUB6yhsNzcG8Sqf1DqH+5hjMHd4a3xD Z75jSC3nWPzUpIWp1qRr1Arm7AhNZmvQlA54AX+52O48wvDgBOgThryzOtYYNwvRBmcL 8FezGQRe7PtX65abfMBITN9UqFvj47vA8X7n/l/uSrRdkX90l9WOMr09czuf0vTiF+fc yAug== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=rD3uyMV2vClc/Wdfm27HpRUHNcfDummDwIQJycXPjFo=; b=o6urhOJIYBsSpP5/D68q1UhzoD7Q1TA/tphkXMPIIBcBorb0S3lOBJzQTzcLfhl7KG geO2H78d3QWuli5FjT3SqGLbXktYhEw5ozIN+cgrD81D60xVHNUpUtoVfTrmK7ymTBv7 dyRTD/BPNiFm9ngBSqIQarthYr61MymmlLa4lDK6n6appzETU1DL9Ej6oEiLZllKBILO dgQf0tvKzfBjKtUGg5/s6Nk/PIKl9OiBHZyUR26pbjDJzUsa4EYRrv11hQOjj91yYv2W ZLKCeSS5/irGyviWJioqOyzs8f697U9vcNJP3aWcU4gth9hvJOP981mpNT6KiTUBztpx m6xg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=hNbPITK2; arc=pass (i=1 spf=pass spfdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); 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=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i9si11554683edb.271.2021.05.24.06.31.59; Mon, 24 May 2021 06:32:22 -0700 (PDT) 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=@Nvidia.com header.s=selector2 header.b=hNbPITK2; arc=pass (i=1 spf=pass spfdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); 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=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233061AbhEXNa6 (ORCPT + 99 others); Mon, 24 May 2021 09:30:58 -0400 Received: from mail-bn8nam08on2051.outbound.protection.outlook.com ([40.107.100.51]:39520 "EHLO NAM04-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S232944AbhEXNae (ORCPT ); Mon, 24 May 2021 09:30:34 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cnsfUqIbmKE5u1YGw6n9R9cZUEf6SRVz5O/UwjDr6oUSMSjH5VpiSeJqyEU/f36dK7ap+uI7+qZLClteo9myh7nX1eCTPK+sxv+AeXRTw3pVs9NabGnywPCwDqETUjyPboxHniwy65xhU17Jvgjf9xy0mMTG/xLfTvV74Cbxf+JQY8rXKtmznn4LoeZTihNSweZW7NZA8/5fXVeX5ATwZh5/wdtCiQ21uHs9Lr2B3X7jijOGM9ujlqfxXcCq7eemXlaXLfgrjE4+XFCc0EAKJOclWNpNUxXQZXa3yHf7ztp3AkLWWgq+bwCctJHdeXxXmsaelHMEnSv8zESeVS3HZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rD3uyMV2vClc/Wdfm27HpRUHNcfDummDwIQJycXPjFo=; b=aX53YfrOoHXOQKAXNXee1jrKfgBPyXMFRyWMzuZ8BcYzCAHPTX0X3DQqZS9qiTRLx9+/azgWL/hK7j+CyhT+nrj7615RjTWO0tuZqTTJ2FkEYRFa7c259eMLmLcx+/+kQFagZNEYFzsl80urPDdYom6ruesYKgbkq7uIuDZ3jJjyzcMxzsJ7KwbrzyrBQGZoO9OIjBkbpIgtR+DbxSDyOvYoUQXToxLXe4T3Xm8eM9Rj9/xkVF6BMkLjRmnE+0oD82WkJnR0f/4OELjG+FXDHswxjtP2Gs097iChZUYBJ5K3Nrjphj0PuCPPO6MDGJbEGw1qFAw6UzNJFaFRf5mK6w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=redhat.com smtp.mailfrom=nvidia.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rD3uyMV2vClc/Wdfm27HpRUHNcfDummDwIQJycXPjFo=; b=hNbPITK2kbWDRbZVahFPxbzX/sWjX0USAIo0KBhZwfNuj8pqOPJPdlRiOdyU2UJPqJWeJ6WOFcXikS1ZmYEGK7DeX6M2mKv6ql/JXv6R5OXhLa34UXbvNFw+5TH1+/MS3tq9fa8WDf2YSEgVfxMtzcL4cuBayjbGiBs+RzcWXJdvtLYX3FtyVlrjhSZfht+LoYyVDGomjCOrrGVg6UY3HFYIKP8m/+T+kwzU11vLJt/HUevf2ARyJkgawCI38Jgc6KDgIdFjgUFYIsCBy0w+vprWyco0JtP6VJqJjprRbmJKiyuIN87SxYH1Z5vEdoH90y1fA+6CyfzZArRzzM852A== Received: from MWHPR18CA0042.namprd18.prod.outlook.com (2603:10b6:320:31::28) by DM5PR12MB1706.namprd12.prod.outlook.com (2603:10b6:3:10f::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.23; Mon, 24 May 2021 13:29:04 +0000 Received: from CO1NAM11FT011.eop-nam11.prod.protection.outlook.com (2603:10b6:320:31:cafe::63) by MWHPR18CA0042.outlook.office365.com (2603:10b6:320:31::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.23 via Frontend Transport; Mon, 24 May 2021 13:29:04 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; redhat.com; dkim=none (message not signed) header.d=none;redhat.com; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by CO1NAM11FT011.mail.protection.outlook.com (10.13.175.186) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4129.25 via Frontend Transport; Mon, 24 May 2021 13:29:04 +0000 Received: from localhost (172.20.145.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 24 May 2021 13:29:02 +0000 From: Alistair Popple To: , CC: , , , , , , , , , , , , , , Alistair Popple Subject: [PATCH v9 09/10] nouveau/svm: Refactor nouveau_range_fault Date: Mon, 24 May 2021 23:27:24 +1000 Message-ID: <20210524132725.12697-10-apopple@nvidia.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210524132725.12697-1-apopple@nvidia.com> References: <20210524132725.12697-1-apopple@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.145.6] X-ClientProxiedBy: HQMAIL101.nvidia.com (172.20.187.10) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2205765b-eb8b-4c54-b717-08d91eb7e68c X-MS-TrafficTypeDiagnostic: DM5PR12MB1706: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6108; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rskvLXAdk0g+wIvlAKwtGRkUU29asrXzzcVy32niHUT0XosaXbZyZ/FsYSGIEWBX02sLAcTelxJs0HhdHKLhMMzamXDBJpYX+TAKKudGK61Tk0UJk+Sfnip1DmDkGIqQe8cBGecm+Sd1rpHB6GmBKodViUCsgRPtweI5ef4lJEj9R6lQDlElO0Uz+PHGv22XqYuR9CE06Q5XUA8r1XiUB3fbqZpc+Tt+VOlkQLMlWfrxiyRJRDaIAicYP40AN8LGcB2ou+xNbVXPy9ez9G+MZHp/T+30ipC15YPAamJ8/8JmMxyE9qj2qlYDTCWVPUw9aV35XRyeBCLnijpcKcx8ZMA6H7SrWGE2k74zDcl5vZ1egBKvOzRxcBBgJnfa+gW+3sZgNZgTahkwFSUHRhHhzwe/Yu7jviCfFLZvp2QcRGZtHvS4cnJ/4eameoaLUC5mufPqs+FVKDNbM0hjtEwjfca2GODr1u4OwiVf0U6QKZXxH//BBgnOIe6lG97m9auH+SZ0KiqmP8alIgv1pJXPoKr0V+P6s0ui2l+G0nH92x/RWuINuMlbEbYlg13CWcedNoObciq1VKRFd9z26tcaJqR9C5aX6yy8fe2anvdzTpBvEXT9FAhpmK52L0aLI2Li+DtoOIxB8N+bkacWhYatXXzGJd0aCm02AzMX5DVCooE= X-Forefront-Antispam-Report: CIP:216.228.112.34;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:schybrid03.nvidia.com;CAT:NONE;SFS:(4636009)(136003)(346002)(39860400002)(396003)(376002)(36840700001)(46966006)(8676002)(2616005)(426003)(26005)(7636003)(6666004)(8936002)(356005)(82310400003)(86362001)(336012)(83380400001)(107886003)(47076005)(36860700001)(54906003)(1076003)(36756003)(2906002)(5660300002)(478600001)(70206006)(316002)(36906005)(16526019)(7416002)(110136005)(186003)(70586007)(4326008)(82740400003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 May 2021 13:29:04.4496 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2205765b-eb8b-4c54-b717-08d91eb7e68c X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.112.34];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT011.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1706 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Call mmu_interval_notifier_insert() as part of nouveau_range_fault(). This doesn't introduce any functional change but makes it easier for a subsequent patch to alter the behaviour of nouveau_range_fault() to support GPU atomic operations. Signed-off-by: Alistair Popple Reviewed-by: Ben Skeggs --- v9: * Added Ben's Reviewed-By (thanks!) --- drivers/gpu/drm/nouveau/nouveau_svm.c | 34 ++++++++++++++++----------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_svm.c b/drivers/gpu/drm/nouveau/nouveau_svm.c index 94f841026c3b..a195e48c9aee 100644 --- a/drivers/gpu/drm/nouveau/nouveau_svm.c +++ b/drivers/gpu/drm/nouveau/nouveau_svm.c @@ -567,18 +567,27 @@ static int nouveau_range_fault(struct nouveau_svmm *svmm, unsigned long hmm_pfns[1]; struct hmm_range range = { .notifier = ¬ifier->notifier, - .start = notifier->notifier.interval_tree.start, - .end = notifier->notifier.interval_tree.last + 1, .default_flags = hmm_flags, .hmm_pfns = hmm_pfns, .dev_private_owner = drm->dev, }; - struct mm_struct *mm = notifier->notifier.mm; + struct mm_struct *mm = svmm->notifier.mm; int ret; + ret = mmu_interval_notifier_insert(¬ifier->notifier, mm, + args->p.addr, args->p.size, + &nouveau_svm_mni_ops); + if (ret) + return ret; + + range.start = notifier->notifier.interval_tree.start; + range.end = notifier->notifier.interval_tree.last + 1; + while (true) { - if (time_after(jiffies, timeout)) - return -EBUSY; + if (time_after(jiffies, timeout)) { + ret = -EBUSY; + goto out; + } range.notifier_seq = mmu_interval_read_begin(range.notifier); mmap_read_lock(mm); @@ -587,7 +596,7 @@ static int nouveau_range_fault(struct nouveau_svmm *svmm, if (ret) { if (ret == -EBUSY) continue; - return ret; + goto out; } mutex_lock(&svmm->mutex); @@ -606,6 +615,9 @@ static int nouveau_range_fault(struct nouveau_svmm *svmm, svmm->vmm->vmm.object.client->super = false; mutex_unlock(&svmm->mutex); +out: + mmu_interval_notifier_remove(¬ifier->notifier); + return ret; } @@ -727,14 +739,8 @@ nouveau_svm_fault(struct nvif_notify *notify) } notifier.svmm = svmm; - ret = mmu_interval_notifier_insert(¬ifier.notifier, mm, - args.i.p.addr, args.i.p.size, - &nouveau_svm_mni_ops); - if (!ret) { - ret = nouveau_range_fault(svmm, svm->drm, &args.i, - sizeof(args), hmm_flags, ¬ifier); - mmu_interval_notifier_remove(¬ifier.notifier); - } + ret = nouveau_range_fault(svmm, svm->drm, &args.i, + sizeof(args), hmm_flags, ¬ifier); mmput(mm); limit = args.i.p.addr + args.i.p.size; -- 2.20.1