From patchwork Tue Mar 9 22:38:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Popple X-Patchwork-Id: 12126663 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,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 A4A83C433E0 for ; Tue, 9 Mar 2021 22:38:43 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 17F8964F48 for ; Tue, 9 Mar 2021 22:38:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 17F8964F48 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 720DE8D0153; Tue, 9 Mar 2021 17:38:42 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 6CFE58D0148; Tue, 9 Mar 2021 17:38:42 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4FCDD8D0153; Tue, 9 Mar 2021 17:38:42 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0043.hostedemail.com [216.40.44.43]) by kanga.kvack.org (Postfix) with ESMTP id 30CB98D0148 for ; Tue, 9 Mar 2021 17:38:42 -0500 (EST) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id E0A4D6C36 for ; Tue, 9 Mar 2021 22:38:41 +0000 (UTC) X-FDA: 77901801642.06.7D6D6FE Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2064.outbound.protection.outlook.com [40.107.237.64]) by imf14.hostedemail.com (Postfix) with ESMTP id 9EA92C0007CF for ; Tue, 9 Mar 2021 22:38:36 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Uu5np9HMa+aeEQOhJ4LUVL3v/X7YAYiazWTOSgMzbGNm7L19ywU4wSDqNOzPCTBun2Z13up3QVXfu6Hb08/5qHPGAVGGDvGfnTLsmeDBNEv59XbIPMj2jVIn2Y1YKKIknMv8C44E21ukjUMHSYzBgZYwXDcR47ksytbbzoceaHZc6RImHEYSzyCsL7lq/Zpu/EOJfzg4MIkHAkCV4uRgcSl65nWXmp6iGuVs2yaLDE5amWiWayuiinaHDqaGnXL8VWcbfmSBwLkDRohv5QQ6c6mV6KMB1mDnb6/qXppQoDyM+Ya9CxLqL22hITCss6VoU8XgwU8TJTmPe8pU6r8QIA== 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=vjmm3izY2BFjD/mNXDCW0CyvtiJ9fItFsvR23ZEDbHc=; b=mjQK8PSwm3EY9TXhVZPyoOvEj/qLaDqyFeRyXloiphuqrxu34X4IQW3OU9eOs4k+QjQpVF95+Gtb2vHwMXjkyWB+Y2LZKKjPlRK3/X1MgREYr0ZxuAprTmi0/QefUiogGiMEIfhcheo4USV8hvDXIYqXcqchbaRncpW8KhSLOi22zAb17E7PiDahYv7r7xzcGeWSP++5rXJP3lYPKakogI2gQM+c0MNRi31tCxx+MxOUBfL6GD2zsdhhamT+TVnbDZ7Am0ovXNVZsa2oIP4uKD8XBFqjqLyj2MeyTjA51nznZU+zP+3Co3qWBUWMOJ1XJlhjv5kzmEwx+dxpgntUAw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=vger.kernel.org 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=vjmm3izY2BFjD/mNXDCW0CyvtiJ9fItFsvR23ZEDbHc=; b=Q/JZ+bZUBlRSbPJwSACjXqK/zvloxfyAKgCBwaZJtJ6AqVu3GfXBEloo19RkZou5egC6RM8DSXApIVFt46Md1y6p0QRzKW8A44dUB/XvCKdnzzipMYRh6d7XaMqFUKEwNKpLfvviLCPE56ZmJQbKIVLz/4cO7D1l+qu1M9RXZdCpe8gntiqV6NRWUTvvvEJbaI8bbBPAZ5+ZaIUayhyqpziSJ+v88fizisBIUhrGHfBBHchNPoUr0e+bPJjzbUeSH4lDkUOb5DIrfS+4WlJd2pnKl+oxW5gax9Jhz3tGhGE9mRx5WTF2IrPist3drgWBgGkatM+XSzwU4fTPf/gkQg== Received: from DM5PR19CA0013.namprd19.prod.outlook.com (2603:10b6:3:151::23) by DM5PR1201MB0218.namprd12.prod.outlook.com (2603:10b6:4:4d::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3890.19; Tue, 9 Mar 2021 22:38:39 +0000 Received: from DM6NAM11FT040.eop-nam11.prod.protection.outlook.com (2603:10b6:3:151:cafe::5f) by DM5PR19CA0013.outlook.office365.com (2603:10b6:3:151::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3912.17 via Frontend Transport; Tue, 9 Mar 2021 22:38:39 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; 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 DM6NAM11FT040.mail.protection.outlook.com (10.13.173.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.3912.17 via Frontend Transport; Tue, 9 Mar 2021 22:38:39 +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; Tue, 9 Mar 2021 22:38:38 +0000 From: Alistair Popple To: , , , CC: , , , , , , , "Alistair Popple" Subject: [PATCH v5 7/8] nouveau/svm: Refactor nouveau_range_fault Date: Wed, 10 Mar 2021 09:38:27 +1100 Message-ID: <20210309223827.24541-1-apopple@nvidia.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210309121505.23608-1-apopple@nvidia.com> References: <20210309121505.23608-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: 287d2c0d-a50b-41ba-6c6b-08d8e34c15e4 X-MS-TrafficTypeDiagnostic: DM5PR1201MB0218: 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: 2T/1RBuiaFZGRwn2pe+47qfpbmm1GceaTlvwFE/xNXvq1Yq7Kpo/HpDmXAwnkMKVbYE3Lxi2gFjIceXlyFd07hFV5iedmz3cSPnbpXB/MTD4l2Iivycc2/MXpWF/UnHcb6l477+IR5gYco+FHUKooCsoGxS48CUoE9qvtSuW+C/Qco5got5bd1SdwiM5+0jOR/v3NOEezpKN3QKkvW5G8+DxjLZUuDYQ6PNcoThevvizOUKitDWe1hDAtm+RHhKlwjumy7bcUBiXslHRiZpZCxvsI20Nll1qPmoS8S+9dr5ojjXhpHFJKtS5zp7RlFKeT4tgNcq9cHKLy/dIJCAPdToyYHQSrfu0ZQ1nvDb5mWZJ+3SX0lk7c680QLaJSjvERnYnjACFB6O+hF4zryfEfILQsGbSd0S3P+kYD8OHfMMnwrCPj/bu95crw+6eKO0V9IpeIdPr/gDw85dluhx/6vMFIHuiULHk8nvoLdL225ld9BVfOTHJid1RjqMtdsIIspopytHpsMFi0wRpQ9hOf+sMTRDMk6Hdk2U/N+Hw7I1elMrvDr5q8cK+FBmngYP/lcR2cAjJRd4R5nazjIaQnRSab5kqPXL8pOkagh2EcAufEagqZAuMXrORhV2Qz+Q8CtNzt79WTe8U1CQUHm5jM2Eh86PDuaxm/yqLjU89dXOM0+zGlqRmMrPMEh8Br7uX 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)(346002)(39860400002)(376002)(36840700001)(46966006)(36756003)(8936002)(2906002)(110136005)(316002)(356005)(7636003)(4326008)(54906003)(426003)(83380400001)(107886003)(82740400003)(8676002)(2616005)(82310400003)(36906005)(70586007)(5660300002)(336012)(478600001)(70206006)(36860700001)(186003)(6666004)(1076003)(47076005)(26005)(86362001)(34020700004)(16526019);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Mar 2021 22:38:39.6077 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 287d2c0d-a50b-41ba-6c6b-08d8e34c15e4 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: DM6NAM11FT040.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR1201MB0218 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 9EA92C0007CF X-Stat-Signature: kkc96c5igzq7555yzccgdh9i4d6scyyo Received-SPF: none (nvidia.com>: No applicable sender policy available) receiver=imf14; identity=mailfrom; envelope-from=""; helo=NAM12-BN8-obe.outbound.protection.outlook.com; client-ip=40.107.237.64 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1615329516-389879 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 f18bd53da052..cd7b47c946cf 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;