From patchwork Thu Jul 7 19:03:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Sierra Guiza, Alejandro (Alex)" X-Patchwork-Id: 12910095 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 78B9FCCA47F for ; Thu, 7 Jul 2022 19:04:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C0F9E6B0081; Thu, 7 Jul 2022 15:04:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B69FC900002; Thu, 7 Jul 2022 15:04:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9969A6B0083; Thu, 7 Jul 2022 15:04:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 885236B0081 for ; Thu, 7 Jul 2022 15:04:20 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay12.hostedemail.com (Postfix) with ESMTP id 67A1B1211BD for ; Thu, 7 Jul 2022 19:04:20 +0000 (UTC) X-FDA: 79661229480.11.E771872 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2050.outbound.protection.outlook.com [40.107.244.50]) by imf17.hostedemail.com (Postfix) with ESMTP id EB4E24000F for ; Thu, 7 Jul 2022 19:04:19 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=P1eg5sb3RsxmEkUoMcUflE9w117N5qm9v3B043A20uv78eB0XkhgaNULeYxUXTXrbIve7K6Vj+Co3hl+RErkCjyjVtf0PwLHZoUBWmQVeCh1nfHneP0lZa5dDoETs5oXnxXFP63Dh4ob1P8wRZlNs+UdcxDNjYsD5yaHYlDsRoylDeb/gBClfxLUQxLk4Kf5kKur9bgsuFXaEwdq7xWHSFuObC4xPh3bmMK42jXj2NwCYqfKYKGCK9TuTDYnBEDhMbuaH33qskN237zHc7LYF5S9L2nkejP1/XQitOmLg+pjFlGZdMgr2svh23LvnDSMxPgH6oq3p7krQKEW/+ejWw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=F8lzcu9Uc51zZ3prS+uZltVgKEco8VgkJ2E7O9HgaPo=; b=HGr6USIUC8TxnSK6qqyATto0pDG5R7lnaRMJdXh1mJmlRs3tn4Gp9rtj0CfzKWLEKTwgCyh93Pq4GgoBmZCCYO3Yeze6EJ/0f06BhFxQTYxkq7/4Lhdmu7OrQSD8e6ECuhVI7Iqvc1O+yBHWTWBm4bH4lENNsLARsBx3kibBHue8UjNW9bjDGGPR4Qk1oB5D6Yz1Nsq4TAXiBbmgzERx6AeTYM9tAVKXOPJcTsXXaFVGJ4agDaaGlz/qZluoM3f0WryeXtQ9dsnO9CsIWKu0MlMz5A9Es5m4MmvwBtEatgmu+/wxFkNMdah7mPQwKTKFtjoPa83jHROgX/lXt5LzLg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=nvidia.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=F8lzcu9Uc51zZ3prS+uZltVgKEco8VgkJ2E7O9HgaPo=; b=Oq5UgM0UVg//qPrCuXW6L5+QzVD8fkxjXU5cODoetHBDAX0ez/htCjPN9TBDPlik78gictQZqthUIGJbyjkdHiKbo21IU1NRkyLQfmDzvkV1TJlMWU83N0ETPvoyfwqGWQ8sY1t34jN1AWyN/ev97hUzSpy2pf9VDo6gR46v3nw= Received: from BN0PR04CA0167.namprd04.prod.outlook.com (2603:10b6:408:eb::22) by MW3PR12MB4539.namprd12.prod.outlook.com (2603:10b6:303:59::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5395.15; Thu, 7 Jul 2022 19:04:17 +0000 Received: from BN8NAM11FT049.eop-nam11.prod.protection.outlook.com (2603:10b6:408:eb:cafe::93) by BN0PR04CA0167.outlook.office365.com (2603:10b6:408:eb::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5395.15 via Frontend Transport; Thu, 7 Jul 2022 19:04:16 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT049.mail.protection.outlook.com (10.13.177.157) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5417.15 via Frontend Transport; Thu, 7 Jul 2022 19:04:16 +0000 Received: from alex-MS-7B09.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Thu, 7 Jul 2022 14:04:15 -0500 From: Alex Sierra To: CC: , , , , , , , , , , , , Subject: [PATCH v8 09/15] lib: test_hmm add ioctl to get zone device type Date: Thu, 7 Jul 2022 14:03:43 -0500 Message-ID: <20220707190349.9778-10-alex.sierra@amd.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220707190349.9778-1-alex.sierra@amd.com> References: <20220707190349.9778-1-alex.sierra@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2f0d7cf5-fe09-4b22-28b6-08da604b7d45 X-MS-TrafficTypeDiagnostic: MW3PR12MB4539:EE_ X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: d35OzaCwYVJLsXaiQZm4pUjbcnNLS7CW3VnvjpyEpD0bghLr0vd98fh38vzroDfajH7ORwQWdPn0VL2qRNpEHA6nY0hN3M/4o8nG4Or+23rvTkJS6kviD1mfJzde42TNsCKbGjoafCYYy8EFO1WTSYM4B4Kl1NaG3EQqTb15VY2FLann/i1XgcX90vK0PKv7I5RouhVcm00pinR8xV2wD467tMKeXUxXAT8XJFHU5kEcybkDR13CsQD/kQX9f16tpQWSO0HuWtAHxL8l5bqZHzpPrm6qY2UCRJRUUq6jLfZcsE+DmW4baUY2JANBBuLG88X8Q2Lx7sQfk1sJBej5bzloIlU31A+mc3/4cXTd1YxEtcxKfMIyiAH4sJdnW65AhmCmNL9IHnfNZlGvdb9eaYGRn0w9wRDvs5KsyHMUTDdy8TbvHRzVZ9F/uGlQhBQ4JGnlggkiVGtKEd4fDVLJedgK0b0bj7YLqmfM6pteEENLbdzRlswRUGX2KTXaCRgbmfTQDhctys5RBhC6kUsPe+/WW1NJKEcNlOWJtroUdNrVomf2tDLX7RY9KFtn6wquUM+FHzohdnSoPBHCCv5tysUe2IxuMzKpGeYVTB6pMfdk7M7GAZ793g2l1cjGHw/rXqoxVGtglByiW9ChXzF0Nf5iKIvg+Cn9gcgujnhIYe0/l1AZD5g8Uj5H5hJ2smqqEwDhwDlzv9sLqIdv5tyYg+huksirMQkCnACUQGrwIuCXSBwyB93bY1oYhE/2QJjOgf7WT0hGm4ORuLUBS+gGspb9+E3ZcBzGq8iFDdvqYQEss4ix2GNDftcqNF+NXB+45HWQERCiiaDz7tyoa3Ft5bPn21M6QI6tssxieY9iOEjYdVbA/3kDB59blf+2Tved X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230016)(4636009)(136003)(39860400002)(376002)(396003)(346002)(46966006)(36840700001)(40470700004)(1076003)(86362001)(70586007)(81166007)(4326008)(7416002)(478600001)(70206006)(7696005)(2906002)(8676002)(5660300002)(356005)(2616005)(82740400003)(8936002)(41300700001)(6666004)(40480700001)(44832011)(426003)(82310400005)(54906003)(6916009)(40460700003)(36860700001)(316002)(34020700004)(83380400001)(16526019)(336012)(186003)(36756003)(26005)(47076005)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jul 2022 19:04:16.6219 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2f0d7cf5-fe09-4b22-28b6-08da604b7d45 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT049.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4539 ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1657220660; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=F8lzcu9Uc51zZ3prS+uZltVgKEco8VgkJ2E7O9HgaPo=; b=ZwlxkuAA9fmdpvVr75+E7z1riz4vGKhvaDWSIMD/gSCSYwtFc1Nk7ovbGNo9HTf2vh4B4i Y6HtnuCFHbtvTlXhLF5P/9NpQfzEMB1y2HdbHH+DlLprDHBMLzaN/Nx6Z56TNd4QQKoKLW ROsWZmRcE6LcsUKafV4XZtEThQGYteo= ARC-Authentication-Results: i=2; imf17.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=Oq5UgM0U; arc=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=pass (policy=quarantine) header.from=amd.com; spf=pass (imf17.hostedemail.com: domain of Alex.Sierra@amd.com designates 40.107.244.50 as permitted sender) smtp.mailfrom=Alex.Sierra@amd.com ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1657220660; a=rsa-sha256; cv=pass; b=lG7QCD53IWOYR/PZH1fpiBG4h6mqKqApNXg6dGu9FLjP5b7cwp2yLIPF/L2t5j6G63vP5h oih/Y0rVq0DU7Al+oquaQ0gyd8eCBCQjmYipJKmKURIMZJD3eKc/oKoqSn7u2O5KoUEvaK 4uCkBjzmWgeLQdbhAkW+xLbPxTwT5Ss= X-Rspamd-Server: rspam11 X-Rspam-User: X-Stat-Signature: hbjoy1gzwyin6ifompko47iefuhjfrxb X-Rspamd-Queue-Id: EB4E24000F Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=Oq5UgM0U; arc=pass ("microsoft.com:s=arcselector9901:i=1"); dmarc=pass (policy=quarantine) header.from=amd.com; spf=pass (imf17.hostedemail.com: domain of Alex.Sierra@amd.com designates 40.107.244.50 as permitted sender) smtp.mailfrom=Alex.Sierra@amd.com X-HE-Tag: 1657220659-21958 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: new ioctl cmd added to query zone device type. This will be used once the test_hmm adds zone device coherent type. Signed-off-by: Alex Sierra Acked-by: Felix Kuehling Reviewed-by: Alistair Poppple Signed-off-by: Christoph Hellwig --- lib/test_hmm.c | 11 +++++++++-- lib/test_hmm_uapi.h | 14 ++++++++++---- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/lib/test_hmm.c b/lib/test_hmm.c index cfe632047839..915ef6b5b0d4 100644 --- a/lib/test_hmm.c +++ b/lib/test_hmm.c @@ -87,6 +87,7 @@ struct dmirror_chunk { struct dmirror_device { struct cdev cdevice; struct hmm_devmem *devmem; + unsigned int zone_device_type; unsigned int devmem_capacity; unsigned int devmem_count; @@ -1260,14 +1261,20 @@ static void dmirror_device_remove(struct dmirror_device *mdevice) static int __init hmm_dmirror_init(void) { int ret; - int id; + int id = 0; + int ndevices = 0; ret = alloc_chrdev_region(&dmirror_dev, 0, DMIRROR_NDEVICES, "HMM_DMIRROR"); if (ret) goto err_unreg; - for (id = 0; id < DMIRROR_NDEVICES; id++) { + memset(dmirror_devices, 0, DMIRROR_NDEVICES * sizeof(dmirror_devices[0])); + dmirror_devices[ndevices++].zone_device_type = + HMM_DMIRROR_MEMORY_DEVICE_PRIVATE; + dmirror_devices[ndevices++].zone_device_type = + HMM_DMIRROR_MEMORY_DEVICE_PRIVATE; + for (id = 0; id < ndevices; id++) { ret = dmirror_device_init(dmirror_devices + id, id); if (ret) goto err_chrdev; diff --git a/lib/test_hmm_uapi.h b/lib/test_hmm_uapi.h index f14dea5dcd06..0511af7464ee 100644 --- a/lib/test_hmm_uapi.h +++ b/lib/test_hmm_uapi.h @@ -31,10 +31,11 @@ struct hmm_dmirror_cmd { /* Expose the address space of the calling process through hmm device file */ #define HMM_DMIRROR_READ _IOWR('H', 0x00, struct hmm_dmirror_cmd) #define HMM_DMIRROR_WRITE _IOWR('H', 0x01, struct hmm_dmirror_cmd) -#define HMM_DMIRROR_MIGRATE _IOWR('H', 0x02, struct hmm_dmirror_cmd) -#define HMM_DMIRROR_SNAPSHOT _IOWR('H', 0x03, struct hmm_dmirror_cmd) -#define HMM_DMIRROR_EXCLUSIVE _IOWR('H', 0x04, struct hmm_dmirror_cmd) -#define HMM_DMIRROR_CHECK_EXCLUSIVE _IOWR('H', 0x05, struct hmm_dmirror_cmd) +#define HMM_DMIRROR_MIGRATE_TO_DEV _IOWR('H', 0x02, struct hmm_dmirror_cmd) +#define HMM_DMIRROR_MIGRATE_TO_SYS _IOWR('H', 0x03, struct hmm_dmirror_cmd) +#define HMM_DMIRROR_SNAPSHOT _IOWR('H', 0x04, struct hmm_dmirror_cmd) +#define HMM_DMIRROR_EXCLUSIVE _IOWR('H', 0x05, struct hmm_dmirror_cmd) +#define HMM_DMIRROR_CHECK_EXCLUSIVE _IOWR('H', 0x06, struct hmm_dmirror_cmd) /* * Values returned in hmm_dmirror_cmd.ptr for HMM_DMIRROR_SNAPSHOT. @@ -62,4 +63,9 @@ enum { HMM_DMIRROR_PROT_DEV_PRIVATE_REMOTE = 0x30, }; +enum { + /* 0 is reserved to catch uninitialized type fields */ + HMM_DMIRROR_MEMORY_DEVICE_PRIVATE = 1, +}; + #endif /* _LIB_TEST_HMM_UAPI_H */