Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp2143010iob; Thu, 5 May 2022 17:03:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzxu9EEK1UFpWt+UtC2TVF2d2wXZGyv/pL+CFdXIkRP432ifrivZo2Rr7DkhTkU2nFYFrq/ X-Received: by 2002:a05:6402:51d3:b0:428:4666:b389 with SMTP id r19-20020a05640251d300b004284666b389mr737774edd.345.1651795433820; Thu, 05 May 2022 17:03:53 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1651795433; cv=pass; d=google.com; s=arc-20160816; b=zDyUHDmviD8anQDQEXfMsWakSFZmPk3/8Mj5kexvrsy6PVOauN846gSTKVhJXeVNEC HNQoD45o0gMn6YdnmodtZcuXa5Whja1gcIGdmsW1WXfO/n8jB9C9ci8kauDm02mvCQfD oXwklMbBdChcQF0ZHO3HGaA+Wo1Hlyf3BSa27ydMHvx+IvwRXrkCJGRlk3cC9mxavGyl gzkbhOsvbyXLq6oaALFqoawQ6N5lf1WkpRAHIPP5KvUbPpu50yLa7cvkJpsxPCeq293t k4HGFXfsYqc504SWTuEjBaLdKg0L3hML19fucoJQvSL2Nf0sazOshTBTyOr02rIKd4UQ MODA== 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=BO1XgdLChGhcmXQYgQRlktGItGh1h3zZzS9U0EV0V6A=; b=mBswthUI1aOm6My6c5j9hNc94vqTf9PhSxbMdDbAFBlBJ1ohgZtqMg4u+Y1d7fko8q TqhN7UfbcputZw+3v0uaQN3N5ZRl7JbFBhjEx5Io5XwZjxnWbKd/7Xc5OsqRXTc8W1jD 2tkXgvWmSJYDXL0kGTbLoFSZ9aKyyfw8vDexUX2Z+S4Kn0CQk8z9hZnob6hv5Y8buB4c AasDxSDP0ilaXAaEeezMZQBZVOrljIkDiw8VVhyusmiR+S8452Z7lIkyj3tvmIGhglcy BsGoN0Y2NsgXP8NqTqVTaIpPZkH7JCtV4UI1Hw8foJksGiKl7rF8k2SmHNIGkzeOPuY3 n2oQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b="MF4/wnnS"; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e11-20020a170906504b00b006f407a163cesi3567389ejk.522.2022.05.05.17.03.24; Thu, 05 May 2022 17:03:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-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=@amd.com header.s=selector1 header.b="MF4/wnnS"; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378646AbiEEVjA (ORCPT + 99 others); Thu, 5 May 2022 17:39:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1385945AbiEEViu (ORCPT ); Thu, 5 May 2022 17:38:50 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2089.outbound.protection.outlook.com [40.107.94.89]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 29B595BD2B; Thu, 5 May 2022 14:35:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GW7YsxNmOUz9TiWECylOO8fpmWtvm9xOQaxllZz+QEMKC/CdPMU8Dc5AV7uQrOmV+q486Cp0X5R825wEBB1ElM+KJv59y4D5GwbPFLrx8qFCcEBrbDX6n9TTYcvKXgfUz01FPYXGhi3kD/svuz2/rvrgs8zIsbW77fwKRR+84qvGZ1i8nLtdnM9Qp8pablb80eoOg/7bpvN4svT310PZ4DzIh6sO/OFloiqaTgolD/egffV1CcB7UkY7h+MXoF9PakP4cxAl6RwMehGb18b5lPP9YO9Hu6zt0M8Af++WByZPHBX6M4+a1Ai7OdUy1HSqyPYtU3C3sPxmS/d2BTA0Ug== 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=BO1XgdLChGhcmXQYgQRlktGItGh1h3zZzS9U0EV0V6A=; b=jveCmmwU98/BwcfHTZwMGw9Jnk7LHVG4ddrz0BCVZkNBo1AX966VL73UFmd2ewID+Ya8YklqUDi1i/PrFx+uq6QmS4omKrnfusMEBbA1/vYDho859kSIxxzZQlXecRal+MKh6z3MfmeXRhIuxNgkR49qxwlm1Yw4IdZlsIUOUXEuc0i6lSXlJE3D6D+y3sWZVIpK7Iv1adR7jOPSyzCRE/MjguYX3f/no/hySL231vmt8Y8rfuajqa6s6EiB8SpPmiFXXKNuyZCmiLsCEIXvlOgIuTSSIQJwPU2m+1upoAJvgjGALJ/u/qy2a2CiHaP8Xxoq4hrFv3XQYqbrIhqzlQ== 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=BO1XgdLChGhcmXQYgQRlktGItGh1h3zZzS9U0EV0V6A=; b=MF4/wnnSR5PLjvJVzH+k1fbIisVhcsu5kmgbaug+7wtbr493PdT8/Wrx4fNg1LMbvsJl4ZqG+Maqk3WXu2Lu1diFVvUU6b7FSYtqbru+26DsQADLjBrHBL7pE6jzd0gTmYyM3p9VU4cHR81mlFIxWNzY7PPQGK8GwMoE+VMJilU= Received: from MW4P220CA0012.NAMP220.PROD.OUTLOOK.COM (2603:10b6:303:115::17) by DM5PR12MB1898.namprd12.prod.outlook.com (2603:10b6:3:10d::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5206.24; Thu, 5 May 2022 21:35:01 +0000 Received: from CO1NAM11FT066.eop-nam11.prod.protection.outlook.com (2603:10b6:303:115:cafe::3d) by MW4P220CA0012.outlook.office365.com (2603:10b6:303:115::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5206.13 via Frontend Transport; Thu, 5 May 2022 21:35:01 +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; Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT066.mail.protection.outlook.com (10.13.175.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5227.15 via Frontend Transport; Thu, 5 May 2022 21:35:01 +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.24; Thu, 5 May 2022 16:34:59 -0500 From: Alex Sierra To: CC: , , , , , , , , , , , , Subject: [PATCH v1 08/15] lib: test_hmm add ioctl to get zone device type Date: Thu, 5 May 2022 16:34:31 -0500 Message-ID: <20220505213438.25064-9-alex.sierra@amd.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220505213438.25064-1-alex.sierra@amd.com> References: <20220505213438.25064-1-alex.sierra@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain 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: 5659c407-724d-4e23-33d9-08da2edf1c46 X-MS-TrafficTypeDiagnostic: DM5PR12MB1898:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: sZ98FxZtIb07U5h0EdSiCjjL/h8Am1RwtH2k8xEcMwItPhN+5Y2KXyGi0fqUOuYLz1ITta0cfA6HIHDGHkpW50rJtLA2jZDk8e5EHm1m+Qqhv4lHGm0MQucbD+rdOz0ixkfM8ldaROX6b07bR97oYc2XsKXsGYlShrUZCP/pMA6J9b9TZKCHdtf0Rprg1ls20TtHtazoIOyKSVNZzGdJVxAOfjoWS+x/OvQssmpEkaWi2JVXqjpI+pDmZNi6NZ1EBfSnqfe10aZuDEXcZTiDrWyq98oN01sVvqs5L/CldA+QePLHYtaT7cgGnlWAwypmdPhT26dznsypdpgcHC7iNQqSMAxc4tE3oNELOH8f2XQw7ukhV7wTrZCuGZuesaej/vNNXz9FNqHzs2s87o6NP9QEOf5zS8A6LZS7vpxMIJNyULYHq8Rq/v6dANDEbuNcT21iV7RLwu4RzdiAVCCsIdtoYIiX2Odc68CG5oDizjHfu3YOlGQQdExRU1np6bnacP9oBxgJWom5XHkvxkLKNVoWdqLjdeUkIwFyr2bMc2Npmc26R4fUh3mdDDFGJX3sM6cO3/l6FJgXC/Eiu0AlWrsu+n1N75nwUbxHyR73JQm132Mzw4dVHJ8LfJsfN8S1kloRu/07YKQtmID9Tyc4RPmiAj29V/KlB1LcecXsYJgf0PHe+IdvEn3tBu7UOR7Ly/oUl2SBcvuksErt1jT/Tw== 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:(13230001)(4636009)(40470700004)(36840700001)(46966006)(86362001)(26005)(7696005)(6666004)(36860700001)(16526019)(186003)(426003)(81166007)(356005)(47076005)(336012)(40460700003)(1076003)(2616005)(5660300002)(83380400001)(70206006)(4326008)(70586007)(8676002)(316002)(82310400005)(36756003)(44832011)(7416002)(2906002)(8936002)(54906003)(6916009)(508600001)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 May 2022 21:35:01.1419 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5659c407-724d-4e23-33d9-08da2edf1c46 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: CO1NAM11FT066.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR12MB1898 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE 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-ext4@vger.kernel.org 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 | 23 +++++++++++++++++++++-- lib/test_hmm_uapi.h | 8 ++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/lib/test_hmm.c b/lib/test_hmm.c index cfe632047839..7a27584484ce 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; @@ -1026,6 +1027,15 @@ static int dmirror_snapshot(struct dmirror *dmirror, return ret; } +static int dmirror_get_device_type(struct dmirror *dmirror, + struct hmm_dmirror_cmd *cmd) +{ + mutex_lock(&dmirror->mutex); + cmd->zone_device_type = dmirror->mdevice->zone_device_type; + mutex_unlock(&dmirror->mutex); + + return 0; +} static long dmirror_fops_unlocked_ioctl(struct file *filp, unsigned int command, unsigned long arg) @@ -1076,6 +1086,9 @@ static long dmirror_fops_unlocked_ioctl(struct file *filp, ret = dmirror_snapshot(dmirror, &cmd); break; + case HMM_DMIRROR_GET_MEM_DEV_TYPE: + ret = dmirror_get_device_type(dmirror, &cmd); + break; default: return -EINVAL; } @@ -1260,14 +1273,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..17f842f1aa02 100644 --- a/lib/test_hmm_uapi.h +++ b/lib/test_hmm_uapi.h @@ -19,6 +19,7 @@ * @npages: (in) number of pages to read/write * @cpages: (out) number of pages copied * @faults: (out) number of device page faults seen + * @zone_device_type: (out) zone device memory type */ struct hmm_dmirror_cmd { __u64 addr; @@ -26,6 +27,7 @@ struct hmm_dmirror_cmd { __u64 npages; __u64 cpages; __u64 faults; + __u64 zone_device_type; }; /* Expose the address space of the calling process through hmm device file */ @@ -35,6 +37,7 @@ 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_GET_MEM_DEV_TYPE _IOWR('H', 0x06, struct hmm_dmirror_cmd) /* * Values returned in hmm_dmirror_cmd.ptr for HMM_DMIRROR_SNAPSHOT. @@ -62,4 +65,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 */ -- 2.32.0