From patchwork Thu Jan 27 03:09:45 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: 12726204 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 6A3DCC433EF for ; Thu, 27 Jan 2022 03:10:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5A2A16B007E; Wed, 26 Jan 2022 22:10:10 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4D89B6B0088; Wed, 26 Jan 2022 22:10:10 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 21C316B0081; Wed, 26 Jan 2022 22:10:10 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0250.hostedemail.com [216.40.44.250]) by kanga.kvack.org (Postfix) with ESMTP id D623A6B0088 for ; Wed, 26 Jan 2022 22:10:09 -0500 (EST) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 8BEF48248D52 for ; Thu, 27 Jan 2022 03:10:09 +0000 (UTC) X-FDA: 79074588138.29.2E540F1 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2064.outbound.protection.outlook.com [40.107.236.64]) by imf03.hostedemail.com (Postfix) with ESMTP id 11FE92001D for ; Thu, 27 Jan 2022 03:10:08 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dZHyVm1ZKvTSvBB9UZIaQgSpOPA0VkxDIJ04TjLalAwdBBhjH9f9joWM8xbKrqtj33rmqxrxkTfARMxnyBPXLN5qJdyv+G1sP5iG9g07fwDF+9K+lLNZFjv6ZfzQntqEg2vlqG9qjzNJjrX2bMDwdsTktx+hDDXk95Gks0mGEz7M2nMy4zp98PJJbP62LJkuXqQrq0p9JXssgAZK77MF4FMz+NATcCmbt283BrwCP+DZmOJbSXi7dHMe7vfey7tSul1zhQNdL80LUWlXcHWAX8WNsjJyIFa/RR7aYsuDHw06whnoF27VpNdLEj/dJNfSp7IMv17/L9/mGI9/Ya+Gnw== 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=w4Gx4O56pz11w33yhsqgpm264AySA+e5Qi1ku8UkUqI=; b=kPzq+TYwM+FFpZi6lqOUd0cbbrf6kGPXIwpfjTK/41xIjNnp6OBvDGt6YEwPbQHRfKjsFg5k6wH89OIhBmuuThFdqXpinWl+ZHchE08Vw+hzNBDWQfBZ+swCupah5oYCZSmzPAsnCCj6d3xk5wSMP7JUxVmpYjh+otj8dyh2GLkKHb4S2akD1moboPtDna1UVDeetr+QRxKtOxRAZjerRItgc9KzHJJXBi89TiqF1B+99rcdq2CPJqbyzBURklvvhjZIIs8jkQYFLolXtMF62k4tBmzVwd7iTBE9aUrZekbW3ZUabLMe4iGvC4NU87O5f8EqVgsIjvwxFCqR164HIA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=linux-foundation.org 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=w4Gx4O56pz11w33yhsqgpm264AySA+e5Qi1ku8UkUqI=; b=jrnIxJhE5IXiqEAh3Z+6KHvDXzUNpWiB42oDgORewwnCmEtBCTiPXHoLOyo7wXlTc069jQ12NqTFACQfl4omBejzBN0c3HR7vSwnIk2/jejwtkdTKSyHFWxZlFq8YgEiEuQzTgp986J/ejY3E9Hg5lTVmfHxwN+rrZ4bWRO+qsg= Received: from CO2PR05CA0104.namprd05.prod.outlook.com (2603:10b6:104:1::30) by BL0PR12MB5555.namprd12.prod.outlook.com (2603:10b6:208:1c2::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15; Thu, 27 Jan 2022 03:10:07 +0000 Received: from CO1NAM11FT066.eop-nam11.prod.protection.outlook.com (2603:10b6:104:1:cafe::23) by CO2PR05CA0104.outlook.office365.com (2603:10b6:104:1::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4930.15 via Frontend Transport; Thu, 27 Jan 2022 03:10:07 +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.4930.15 via Frontend Transport; Thu, 27 Jan 2022 03:10:06 +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.18; Wed, 26 Jan 2022 21:10:03 -0600 From: Alex Sierra To: , , , , , CC: , , , , , , Subject: [PATCH v4 06/10] lib: test_hmm add ioctl to get zone device type Date: Wed, 26 Jan 2022 21:09:45 -0600 Message-ID: <20220127030949.19396-7-alex.sierra@amd.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220127030949.19396-1-alex.sierra@amd.com> References: <20220127030949.19396-1-alex.sierra@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a1d93e32-8eab-42ae-55c6-08d9e142855c X-MS-TrafficTypeDiagnostic: BL0PR12MB5555:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4303; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LgLPRb1Q5leI1mGEwMAXiP64r1MD9uGPRdsg9kNjiLePxrlTBwG6J4gDlDe/QcVRmtM8JF9uIBYFij0BPQ5PcC8xGuauV6L0hckEE5CjUalQDQfcMOwRFS+nZyAzTxvudmQF2LiqlM7MFN87G9kPM2eU1hiYRTrq/XVH4gyZ+hs+GUJcUVO4WYHQixsE9wChJDdKwltR577gOF2kbQmnAz6/W36uNWyL9tasXd7bU071FqshdhqU3CZDCeE/Uzp0latAwhqsa3ug4wExjuDLH7T80qdDBbTrb9a7ePlseovC+u6mtGMtrpt7mG983KvldwplIm7U+iMQUuRX+g3HG+tYJrsudAr8m2TeTsV8+l46IDW3/wzw4uollgaheSVK3imlyVifQcb01RFi0Alg8BYyzMl5aXHNokKkMLtD7EGZqwttKDs5vnHw7nFAyTzg6IKgwEsLC7gkmNsC3IvFfCW5PTQtvcDnYg0X+PFCJkiWW+enghmyjgxOujC1B4UNU9fTUNuhaqyaoe+ogFr8abO9moDEBtv1V3YzkT2MzqYDR+EB9fieLu9w6Fb+pazXd2PiMyLa9Hswo2y7SfLtzPfAtM/5Xw9OuLFgHXua0xlNv/yy1bMtn66369f8rctLdxo8GVpA7KY9DqpjXUT1VhIL/R4ue6biLNbUwHmDyKNDaWiNjEK9onzvCOJ0ltCzm9kMSwFrEJ3gjk9LVb8mfg== 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)(36840700001)(46966006)(40470700004)(6666004)(44832011)(7416002)(86362001)(4326008)(81166007)(5660300002)(7696005)(82310400004)(508600001)(70586007)(70206006)(83380400001)(36860700001)(8936002)(8676002)(356005)(36756003)(316002)(26005)(1076003)(47076005)(110136005)(54906003)(40460700003)(2906002)(2616005)(16526019)(426003)(186003)(336012)(36900700001)(20210929001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Jan 2022 03:10:06.9273 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a1d93e32-8eab-42ae-55c6-08d9e142855c 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: BL0PR12MB5555 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 11FE92001D X-Stat-Signature: w1n7azpdphidqhgwt3spjxbdkuc3rtnx X-Rspam-User: nil Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=jrnIxJhE; spf=pass (imf03.hostedemail.com: domain of Alex.Sierra@amd.com designates 40.107.236.64 as permitted sender) smtp.mailfrom=Alex.Sierra@amd.com; dmarc=pass (policy=quarantine) header.from=amd.com X-HE-Tag: 1643253008-819417 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 Reviewed-by: Alistair Popple --- 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 c259842f6d44..fb1fa7c6fa98 100644 --- a/lib/test_hmm.c +++ b/lib/test_hmm.c @@ -84,6 +84,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; @@ -1025,6 +1026,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) @@ -1075,6 +1085,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; } @@ -1235,14 +1248,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 */