From patchwork Fri Mar 26 00:08:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Popple X-Patchwork-Id: 12165247 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6DD64C433E6 for ; Fri, 26 Mar 2021 00:08:47 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 111ED619A3 for ; Fri, 26 Mar 2021 00:08:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 111ED619A3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=nvidia.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id E775F6B0087; Thu, 25 Mar 2021 20:08:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E10A36B0088; Thu, 25 Mar 2021 20:08:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C2B896B0089; Thu, 25 Mar 2021 20:08:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0069.hostedemail.com [216.40.44.69]) by kanga.kvack.org (Postfix) with ESMTP id AA6126B0087 for ; Thu, 25 Mar 2021 20:08:45 -0400 (EDT) Received: from smtpin21.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 72838180226DE for ; Fri, 26 Mar 2021 00:08:45 +0000 (UTC) X-FDA: 77960089410.21.D120F2F Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2067.outbound.protection.outlook.com [40.107.223.67]) by imf21.hostedemail.com (Postfix) with ESMTP id D60DCE0011C0 for ; Fri, 26 Mar 2021 00:08:43 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kaVM2qFTO+ULqi3zRqwyPVvUkVZtAQ3sRQzyAzE2CJ0EHIGDO38txvoV5Q0i4i0LFdm4Y8N6836ozF/pywfrj/jVjzTN/X86FEX+ejNdCISYNRC4Y6jxkzK/yJdqL10J4eeYxjZsVpjTSP9690yANFmZZfJ3wykxSGD+T50dpHQzYqkru4gW/53qAsDaA56LNvPiY4PYnUuoaz/CgAW5TocufOS9pHY4UfQbPnnGVqwJwc831wauvI3iXwc1Czdx41HNIjDu20eOQknYF+BqS4ruUPrw5aIv9l9BW030RzFA2PgZTLI3X60MrrXHZ49EMd5PRFRpQIyZG+KzG/okDg== 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=4c9870s3/fS3cTF+SLC8wpSfZhem4zErBulvbvUfaA4=; b=mhsg+Mz05ckdEK9aZANLb09YKNFGRIsJVJJ/KVNp1wQ6is6pCZOopRAJ/aARKw1IqEIvV1P8r3afwUKra3QZ9FkNIefJrihnzcBAk4X9KWFVTjj3FnoZU3PqHUaS6oZkYAtPAuovdahgcpglbuE3BUaXeJF/qwklPoaM9rchbLm+ZpYp5Pb9fBSbp7uK4nb3gqoMsYCDWjy2QJXSBwZOodatA/B4K9dGnvHOtAe4Nr3g2jYxZCmS91Rgp2dY5GmqNEMbsjiHBc/u8q8qf+7GtRiNc+rJ1UXAZIk6XCrrcxN8eD0QkTHSkC2Mlh4xUqJqXKzL4Dlsl0vvI0i0Id3jpA== 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=4c9870s3/fS3cTF+SLC8wpSfZhem4zErBulvbvUfaA4=; b=PMQizhB1xfyE8/Vv+y0NRLMIXm3O9SSRQnHahDXoaplB+IE5Y5315PNppzMYzRRcJFt6FqpsWe7W8iaoxgAD3Ic48OmvzrB8rML1Oa8B5WxivpZg/WzTHPfJ9L8LtIqTffYzJYkiAkPx9e/QGw9PofC7p6oLriGsaqYIBvBN1AHVCxnT5Hp1slGpwdpUnFxfu271hnzc5AyUAQILGwrXRQPxcBviwMD4jN6LljrrbsyYzsCHJuK4d6LwthtyjT5booDQAP94RGFiiyWDuW83/5eAX2je2eyUcsrU3nUtBHIxjKIjeDBZKusDPz2T8sJSSr08I3a2ubKneX7CIsrBHQ== Received: from MWHPR15CA0041.namprd15.prod.outlook.com (2603:10b6:300:ad::27) by DM6PR12MB2699.namprd12.prod.outlook.com (2603:10b6:5:4a::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.25; Fri, 26 Mar 2021 00:08:42 +0000 Received: from CO1NAM11FT047.eop-nam11.prod.protection.outlook.com (2603:10b6:300:ad:cafe::a0) by MWHPR15CA0041.outlook.office365.com (2603:10b6:300:ad::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3977.24 via Frontend Transport; Fri, 26 Mar 2021 00:08:42 +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 CO1NAM11FT047.mail.protection.outlook.com (10.13.174.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.3955.18 via Frontend Transport; Fri, 26 Mar 2021 00:08:42 +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; Fri, 26 Mar 2021 00:08:41 +0000 From: Alistair Popple To: , , , CC: , , , , , , , , , , , Alistair Popple Subject: [PATCH v7 7/8] nouveau/svm: Refactor nouveau_range_fault Date: Fri, 26 Mar 2021 11:08:04 +1100 Message-ID: <20210326000805.2518-8-apopple@nvidia.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210326000805.2518-1-apopple@nvidia.com> References: <20210326000805.2518-1-apopple@nvidia.com> MIME-Version: 1.0 X-Originating-IP: [172.20.145.6] X-ClientProxiedBy: HQMAIL105.nvidia.com (172.20.187.12) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 516ebe24-adfd-4481-a155-08d8efeb50d5 X-MS-TrafficTypeDiagnostic: DM6PR12MB2699: 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: w9iWpNqRptymgHYpmVTXacomaKaB8XPmWIGh1IdDGscPh/iyUZRqBAV2cJix7IC7bG9mNtG+CO836C0NCXK3HrQyRKOeqE98X/vH3svpV38l0xJ+HJoP15OS5VSgyuST34yBu7FetcvzCALUmj+MzuN6L3SKGP0KtaVqXNTaF2N3g0NQdWHo97Ar5j1tPUu91Dzz34XRGsWOkYAW99p8aqmy6g4/1wIOIijyNabcYm3j1gpbko1+krvdSu1NRA0GGUTX179FvhmR96WBbHq7m6HIKkG8RUHL9DiO21zh8TQcJ/HzjxSfWHohh+1BC6FWqKH91Z3T21uN8BrwTW5gEed6xXNs+mt+Re3ox8EHVlKryDnM5A9yMCSNJwJodpMpmiyYjvSKpeHlNpDwc9wCWWISN9uWGvd3oOKvjfCC8Pab4wTa3SoTeQFj4MsChTFdDWTjvuYgi6YkfGg4W65c6f2t6evHlu/2TSvLquy23o/yh23l1JIuQ+2HxLtjAoN+D62fewrktSbnPOYJDjluY0IrSwUgz1sr7kVWIyHTszpk4XdQ5LEZL2133euHyepoNuUFohfzv6vQwoowHWxd/tnimkYzVvcOevPQlBGPpJ0hEFN0Z8t0zKoVJQukYs8Odu6isEskwzxTWd+Z9CqNHqoTznZHGk6KkS0H8iSRJI0= 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)(396003)(376002)(346002)(39860400002)(46966006)(36840700001)(2616005)(5660300002)(54906003)(26005)(426003)(83380400001)(36756003)(8676002)(16526019)(478600001)(316002)(7416002)(4326008)(36906005)(8936002)(86362001)(82740400003)(110136005)(82310400003)(7636003)(186003)(6666004)(70206006)(1076003)(70586007)(47076005)(356005)(2906002)(336012)(107886003)(36860700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Mar 2021 00:08:42.1917 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 516ebe24-adfd-4481-a155-08d8efeb50d5 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: CO1NAM11FT047.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB2699 X-Stat-Signature: ye8jgjq1ek86ac4fneqbwkwbhe78js5k X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: D60DCE0011C0 Received-SPF: none (nvidia.com>: No applicable sender policy available) receiver=imf21; identity=mailfrom; envelope-from=""; helo=NAM11-DM6-obe.outbound.protection.outlook.com; client-ip=40.107.223.67 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1616717323-187149 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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 --- 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;