Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2225769/?format=api
{ "id": 2225769, "url": "http://patchwork.ozlabs.org/api/patches/2225769/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-pci/patch/20260421-io_projection-v2-8-4c251c692ef4@garyguo.net/", "project": { "id": 28, "url": "http://patchwork.ozlabs.org/api/projects/28/?format=api", "name": "Linux PCI development", "link_name": "linux-pci", "list_id": "linux-pci.vger.kernel.org", "list_email": "linux-pci@vger.kernel.org", "web_url": null, "scm_url": null, "webscm_url": null, "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20260421-io_projection-v2-8-4c251c692ef4@garyguo.net>", "list_archive_url": null, "date": "2026-04-21T14:56:19", "name": "[v2,08/11] rust: io: add `read_val` and `write_val` function on I/O view", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "b1b47d907a62b7206d8c87b9c82df5dc0031ed75", "submitter": { "id": 76823, "url": "http://patchwork.ozlabs.org/api/people/76823/?format=api", "name": "Gary Guo", "email": "gary@garyguo.net" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/linux-pci/patch/20260421-io_projection-v2-8-4c251c692ef4@garyguo.net/mbox/", "series": [ { "id": 500833, "url": "http://patchwork.ozlabs.org/api/series/500833/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-pci/list/?series=500833", "date": "2026-04-21T14:56:19", "name": "rust: I/O type generalization and projection", "version": 2, "mbox": "http://patchwork.ozlabs.org/series/500833/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2225769/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2225769/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "\n <linux-pci+bounces-52843-incoming=patchwork.ozlabs.org@vger.kernel.org>", "X-Original-To": [ "incoming@patchwork.ozlabs.org", "linux-pci@vger.kernel.org" ], "Delivered-To": "patchwork-incoming@legolas.ozlabs.org", "Authentication-Results": [ "legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=garyguo.net header.i=@garyguo.net header.a=rsa-sha256\n header.s=selector1 header.b=hhhCA9/e;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=2600:3c09:e001:a7::12fc:5321; helo=sto.lore.kernel.org;\n envelope-from=linux-pci+bounces-52843-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)", "smtp.subspace.kernel.org;\n\tdkim=pass (1024-bit key) header.d=garyguo.net header.i=@garyguo.net\n header.b=\"hhhCA9/e\"", "smtp.subspace.kernel.org;\n arc=fail smtp.client-ip=52.101.196.131", "smtp.subspace.kernel.org;\n dmarc=pass (p=none dis=none) header.from=garyguo.net", "smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=garyguo.net", "dkim=none (message not signed)\n header.d=none;dmarc=none action=none header.from=garyguo.net;" ], "Received": [ "from sto.lore.kernel.org (sto.lore.kernel.org\n [IPv6:2600:3c09:e001:a7::12fc:5321])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4g0QSt6PdPz1yCv\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 22 Apr 2026 00:57:50 +1000 (AEST)", "from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sto.lore.kernel.org (Postfix) with ESMTP id 43EA0301BEBB\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 21 Apr 2026 14:57:14 +0000 (UTC)", "from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id B57543DA7DB;\n\tTue, 21 Apr 2026 14:56:39 +0000 (UTC)", "from LO3P265CU004.outbound.protection.outlook.com\n (mail-uksouthazon11020131.outbound.protection.outlook.com [52.101.196.131])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id 83F363D9DDF;\n\tTue, 21 Apr 2026 14:56:37 +0000 (UTC)", "from LOVP265MB8871.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:488::16)\n by CWLP265MB5674.GBRP265.PROD.OUTLOOK.COM (2603:10a6:400:1b0::13) with\n Microsoft SMTP Server (version=TLS1_2,\n cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9846.16; Tue, 21 Apr\n 2026 14:56:30 +0000", "from LOVP265MB8871.GBRP265.PROD.OUTLOOK.COM\n ([fe80::1c3:ceba:21b4:9986]) by LOVP265MB8871.GBRP265.PROD.OUTLOOK.COM\n ([fe80::1c3:ceba:21b4:9986%4]) with mapi id 15.20.9846.016; Tue, 21 Apr 2026\n 14:56:30 +0000" ], "ARC-Seal": [ "i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1776783399; cv=fail;\n b=DO+ulg20RBmdCnb3QuFex4boaqqFdzZmT5WS6aeHOl26wHb4mHRKx4ke4dE28DcHqsU0ssE0dmobv+jCFAFlawfIZDS2Kk6rdRdf1JWzNKTmEft78meOI2VWhh/+qdsdDTqvMshMTyNifxSfVlzKrR94svKCyK2xbb2gqfSdV2I=", "i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none;\n b=CA40ceVExwfC2a5hzRTrRuIv7zlYRc3s+bT29eoKQE4/JkNSTZEroMN+aZQZXY/8KVFYuaWdCbdPMuCw1kY1Xv0umJmoal4TVzdCZf68AMuwNoAVEktHd1QNKbzO35YUaZymwZ76CegTnUuuGgfe+YyhaQRjbUAbG0wRmyPOyPY5YuwOnV1lm3+v7z64i1vg+Wu6PPvfm79Eb+WRixJwoAbFd1e000OBWVNJ7C7i6GXz1n6T2OBVbxP50Ktl6OVAYYELlOxUI74fShu4l1jedQGL6pLcpG3EJawlnPwE0psKep25YQpiFFoYT8YzFJ5/FsdzPTYFxGLQeXA/Ann+2w==" ], "ARC-Message-Signature": [ "i=2; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1776783399; c=relaxed/simple;\n\tbh=d7D59E81y7GC3frEJZ83WlP+T/kdXpX9ZQKPVZqa7+k=;\n\th=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To:\n\t To:Cc:MIME-Version;\n b=X74EJ+Bv3s7DEcNVasivvIJG0CYB5WGzN5zJMawb+KBHcpOUreGAWQ1U4fkpOY1XH263xeHKx+R6dzPicC3vE0qqgo4tVffQvW8EAD89w37rV4Qa17TLPyz7ZeH/mEVio51B67/bQ/v8bHDV/MEb2PRFlYJuzJooTTr9YDpek/0=", "i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com;\n s=arcselector10001;\n 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;\n bh=1b5DdLMRYimSWgJfRYYszp83aLSNpWhflPrz3Msjbw0=;\n b=hpCp5b8vX7ahgq/LOBhGNQhead/98Lo6zxB4CgPEj3+E3sHbL3v7ZwVB3301PmKz/Q5vvYT1fugUqlORmmLvuOaeYmaajDyTrQWEbJp3aj6KuFSHpEjDJkuBVNsqNSVOHB7MtygGHpy3APC+m9VBFFQe45nnw2iq+lBJKGiONgjLta7CSYRI9cbr1yhNd6Olkn6C2r6IU8wk/kcgIktkxQmU2nysnkVbSdO7GeZKSPCnH0rUji7uAMrMNkFce+4CC3tEQRlHcZLW3zv4MD0qsHFyrDhtCE2sFnJcb+HVWzWizRvWa0huLzbonyXeTujRn/ur5GOka0g47d9nZiiRRQ==" ], "ARC-Authentication-Results": [ "i=2; smtp.subspace.kernel.org;\n dmarc=pass (p=none dis=none) header.from=garyguo.net;\n spf=pass smtp.mailfrom=garyguo.net;\n dkim=pass (1024-bit key) header.d=garyguo.net header.i=@garyguo.net\n header.b=hhhCA9/e; arc=fail smtp.client-ip=52.101.196.131", "i=1; mx.microsoft.com 1; spf=pass\n smtp.mailfrom=garyguo.net; dmarc=pass action=none header.from=garyguo.net;\n dkim=pass header.d=garyguo.net; arc=none" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=garyguo.net;\n s=selector1;\n h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck;\n bh=1b5DdLMRYimSWgJfRYYszp83aLSNpWhflPrz3Msjbw0=;\n b=hhhCA9/eaU+Y2JxIMiWifeyArKcf8914Y5HeeyehURYll+lka+wj/96SUr1/oaQjKdx+7d/hscyc95Vl88XYk5Y0IFxuAqf0y+ykY8Y5qsmpnpLkgn8/GIPzmtcGX2YglQRf0rM6qTHxVCSs7j9ocE/+LE3vEz0KXeO4nTTT01w=", "From": "Gary Guo <gary@garyguo.net>", "Date": "Tue, 21 Apr 2026 15:56:19 +0100", "Subject": "[PATCH v2 08/11] rust: io: add `read_val` and `write_val` function\n on I/O view", "Content-Type": "text/plain; charset=\"utf-8\"", "Content-Transfer-Encoding": "7bit", "Message-Id": "<20260421-io_projection-v2-8-4c251c692ef4@garyguo.net>", "References": "<20260421-io_projection-v2-0-4c251c692ef4@garyguo.net>", "In-Reply-To": "<20260421-io_projection-v2-0-4c251c692ef4@garyguo.net>", "To": "Greg Kroah-Hartman <gregkh@linuxfoundation.org>,\n \"Rafael J. Wysocki\" <rafael@kernel.org>, Danilo Krummrich <dakr@kernel.org>,\n Miguel Ojeda <ojeda@kernel.org>, Boqun Feng <boqun@kernel.org>,\n Gary Guo <gary@garyguo.net>,\n =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= <bjorn3_gh@protonmail.com>,\n Benno Lossin <lossin@kernel.org>, Andreas Hindborg <a.hindborg@kernel.org>,\n Alice Ryhl <aliceryhl@google.com>, Trevor Gross <tmgross@umich.edu>,\n Daniel Almeida <daniel.almeida@collabora.com>,\n Bjorn Helgaas <bhelgaas@google.com>,\n =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= <kwilczynski@kernel.org>,\n Abdiel Janulgue <abdiel.janulgue@gmail.com>,\n Robin Murphy <robin.murphy@arm.com>,\n Alexandre Courbot <acourbot@nvidia.com>, David Airlie <airlied@gmail.com>,\n Simona Vetter <simona@ffwll.ch>", "Cc": "driver-core@lists.linux.dev, rust-for-linux@vger.kernel.org,\n linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org,\n nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org", "X-Mailer": "b4 0.15.1", "X-Developer-Signature": "v=1; a=ed25519-sha256; t=1776783386; l=7273;\n i=gary@garyguo.net; s=20221204; h=from:subject:message-id;\n bh=d7D59E81y7GC3frEJZ83WlP+T/kdXpX9ZQKPVZqa7+k=;\n b=qF0wrVzmyz8fm5OQ/DwWboUlelLDg5mLGSN9s8IcpY5U5Exs6P6m21qpLlivvfZa17vP94do/\n kKKGzRhLwasA1tPQWtMdNqJP/9gWsCBFWZm5puOfvZYSBsBFUf0lnX3", "X-Developer-Key": "i=gary@garyguo.net; a=ed25519;\n pk=vB3uIX95SM4eVrIqo1DWNWKDKD2xzB+yLLLr0yOPYMo=", "X-ClientProxiedBy": "LO4P123CA0142.GBRP123.PROD.OUTLOOK.COM\n (2603:10a6:600:193::21) To LOVP265MB8871.GBRP265.PROD.OUTLOOK.COM\n (2603:10a6:600:488::16)", "Precedence": "bulk", "X-Mailing-List": "linux-pci@vger.kernel.org", "List-Id": "<linux-pci.vger.kernel.org>", "List-Subscribe": "<mailto:linux-pci+subscribe@vger.kernel.org>", "List-Unsubscribe": "<mailto:linux-pci+unsubscribe@vger.kernel.org>", "MIME-Version": "1.0", "X-MS-PublicTrafficType": "Email", "X-MS-TrafficTypeDiagnostic": "LOVP265MB8871:EE_|CWLP265MB5674:EE_", "X-MS-Office365-Filtering-Correlation-Id": "7dacd265-791f-4be1-e56b-08de9fb62bd3", "X-MS-Exchange-SenderADCheck": "1", "X-MS-Exchange-AntiSpam-Relay": "0", "X-Microsoft-Antispam": "\n\tBCL:0;ARA:13230040|1800799024|376014|7416014|10070799003|366016|921020|22082099003|18002099003|56012099003;", "X-Microsoft-Antispam-Message-Info": "\n\tmEroFlZL5aM9woDSdEslRumUUAayC5Bu9Vo1ZdLU++sa1r1zmKX40nBagHzx1YHvrkUKB0Pcv504JAyUIe9pWnXIA8kQECG2WeWO9dK9gv2HDCd1t0KdHb4Ys2klOoIHUFcmmp034PefU1+HwWowxxOqUs5/eH5DBaHd8ZpGieRpa6xc/Go6Ro3/+HK3X/i0LogvXzKZSwpIbQ5hImsHW0N2UGbMZb5sTD4VgrQEDUZ7+fcBTM/jdzAQcd6HewAYy8aSjkERcfKAKAmmBVFOM6F0Ibz31PCfN+aDjRXrV9LyVoeo1e0j2zi38rXQWqVkM494KSuSk6MZfevhqmxFJw5vQ5W4Wlnlgj6APhdxHv2RoRYE/dE9Ap6RhmY2zpoWsiwvzorRodt7uak25bcJ12jrYcKv3jmRyJ20SDrYhq1KuVKOh9FjFr3Y+u7Wqs6U2B+0l/GDViZcbq8lpaEJY2SCl0IzURkHgk8Dn/HnJkSWrzl5qYoQtJzhf8MZmE0Nxr0heaYlgYYPtIGmaD3yyzKmdybhZETbHgOk9BIR1gnAzIxMxrJbVjZ7KGAA87qrbOAotxPC14wUoDhoZ9iOO4v62XJ6QWEYdsm0Y+UjCcuxdV0RaxopFXuxFOhzjQUnXdcm0lEvvOY+os3AEKD00Cp4DOUc+adHEaXGVSpv6fQ1JnoEfx6KwjmhvxCyVZeL9H1h66onjEPyP8Toc5L2Q1Pgk45yu1cSN+RO0CqgkO8CcWWc3PTe+zCer3BPI+D1hf1IyHUHtx/sklf9iFcaZg==", "X-Forefront-Antispam-Report": "\n\tCIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:LOVP265MB8871.GBRP265.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(376014)(7416014)(10070799003)(366016)(921020)(22082099003)(18002099003)(56012099003);DIR:OUT;SFP:1102;", "X-MS-Exchange-AntiSpam-MessageData-ChunkCount": "1", "X-MS-Exchange-AntiSpam-MessageData-0": "=?utf-8?q?KSxZ+LlUJYZKRHUTl0jMg+jPjXGB?=\n\t=?utf-8?q?Rnnw/evCU9k4x0PZA0imRgVx3ZVqxRIBo+e9X8t69TSXRSPQFnuYT95w0LNlZ3QHE?=\n\t=?utf-8?q?KfMJTwZSuJEfJRxQ9LMFyAEVI3JdcnDTFp/8VvBYMatsVLvVD7nQlHGtb4oT+tZNH?=\n\t=?utf-8?q?awQCelDMqfwPjWaI21tXgxhvZ34b8lDmdG7w+fhtytoNUCt38FJTLfU25D3rxUSv7?=\n\t=?utf-8?q?TgvNDLezI7fSHRDqeC8qLHbiB/vQH1wigVVMGKNAsY8QLfZdeU6jeNRF60yXielRH?=\n\t=?utf-8?q?4rly6Nb+l9XTa+LBoMgYywkVujEZo+YzsR/AppRIzP78b6qstyFxaYt6LDSA6GoBW?=\n\t=?utf-8?q?sth0aZfLdtz5uHJWt1oq5I6ChFl/hgmczK6YKhYDKrObHVaqhrBvF3fUu4byPx4qv?=\n\t=?utf-8?q?AU5Q6iiAK+RYnzOCYsncLPK5KL1BQg0KwlDR164MjxC+bwtbnx/nDSjuzmKK+Rf0t?=\n\t=?utf-8?q?8s8yDnR89jFJ6RPgid1BBOfamXtgcyRDuXvguiErOi5Rwsn6vubxU9vaX5t6YAHnx?=\n\t=?utf-8?q?9Qsboj9YaPC9E1MmcDoMeW6LsziKwyPCmg0ChSwOjslVsoOTskBZZywhLk36MsuWB?=\n\t=?utf-8?q?Wn1DdOicZkdb1kJrvA1HO3kr66+UTXekD+vqfTuar/QbgX98UMBJkLvnTxSEgwkK6?=\n\t=?utf-8?q?gUufzt0R8lopvgCZoV/P/5Azz15Q/42rPHsopU58QWGzv3zOtI0eNPIkpzTDpmIZ+?=\n\t=?utf-8?q?1uGkpptPcA4JSTslvjjPB2A3eul/3BD2H4S3Pkaox6WYvWbPIw+by3KFH/lVwjT+z?=\n\t=?utf-8?q?v2xT4HKmI2nqS0u5Qxy4+DgBOhrRQQY3wEin4z5DinQn9iyHYjQnq5JSBELG0zxhO?=\n\t=?utf-8?q?0Q3j25A+Wl7HPTaWm8KruX16ZKuvBhR8sV5c1m2p2RyHElwEmWdXPt8/ou+xJkzRv?=\n\t=?utf-8?q?XAvhiQd4Y1zddhSEONImwjmbAcgid1emd+lo+2P2bnR5N0kIuUytToGXQ2WPgzIve?=\n\t=?utf-8?q?ZNBeyjLjKShNl6MyZmM+ox2nhduj2yZnWFTJp+kD9/GjQBmuL3Aj2Zjz3WDn8HlQM?=\n\t=?utf-8?q?kZ2TaO4KND+bEHXrsVTe6kKnp+8/Pb9+UyVjM1A8doX7/DiMEsp/LYbU+8Psl48HX?=\n\t=?utf-8?q?07WhECLLYLI0riXHfghUwizKvtNQtSu9Yf0d74c51rCbDM8p0Se9k8I77+RilKXIl?=\n\t=?utf-8?q?+IxW/29BpdtBSaWs7G2Oso6gJOin/itgH7NNWLz9FpjQAqGa2sfpJt+nri53hVx9y?=\n\t=?utf-8?q?boqgKggFQ5IfpbHQwOMpDLliZxXUe5zkI2222NUB7huGPgvFirhLtn7yGbGpqt7d4?=\n\t=?utf-8?q?nxtOu5EZ6rPU420kQqtGeHTjoWlxYd9VEazwdkOXcogUQPoHXKb269ctTYQfd8wRR?=\n\t=?utf-8?q?plmpcnSp+tSQmaqzPNj3DcbZLipYEDUmEXMDbhQdWG90o1idmLUnXNJQxBLuBstPF?=\n\t=?utf-8?q?75+Qs5CsBycYDgN+DvGJK28IvDoaSTNUl0nrY8OSSmhMpH4lFzG1vK8Lm0EmwZJYg?=\n\t=?utf-8?q?v73xXVg/hj5hPSf1a7/hAS/xNVI+mkP7ApHqnVjQKww5uWD6Tbi4Om/mCWTyJVbjD?=\n\t=?utf-8?q?XFdtJ/OYETzvQGUE/CwXigpvnjXTqJc5z5MyQmH083yHGhj9jQJ6YjcQLluWJsnlY?=\n\t=?utf-8?q?pN75LXzuxfRRwiFFdYGBAVAEDSZRlbfIQTb0rr9g52nt7ywKRnwKt78T+EYFJ6N93?=\n\t=?utf-8?q?k42nuLl/TCqpOxd5ylqrQgN7woO1hyqA=3D=3D?=", "X-OriginatorOrg": "garyguo.net", "X-MS-Exchange-CrossTenant-Network-Message-Id": "\n 7dacd265-791f-4be1-e56b-08de9fb62bd3", "X-MS-Exchange-CrossTenant-AuthSource": "LOVP265MB8871.GBRP265.PROD.OUTLOOK.COM", "X-MS-Exchange-CrossTenant-AuthAs": "Internal", "X-MS-Exchange-CrossTenant-OriginalArrivalTime": "21 Apr 2026 14:56:30.2277\n (UTC)", "X-MS-Exchange-CrossTenant-FromEntityHeader": "Hosted", "X-MS-Exchange-CrossTenant-Id": "bbc898ad-b10f-4e10-8552-d9377b823d45", "X-MS-Exchange-CrossTenant-MailboxType": "HOSTED", "X-MS-Exchange-CrossTenant-UserPrincipalName": "\n ISszC/OuJXGoejoTIkDqA75bB+4zlB5iF2c/EtxVc0MCBWv6JnbBpS/kqiLo0XBdl+hH1exf32UQzDD8aGH2Gg==", "X-MS-Exchange-Transport-CrossTenantHeadersStamped": "CWLP265MB5674" }, "content": "When a view is narrowed to just a primitive, these functions provide a way\nto access them using the `IoCapable` trait. This is used to provide\n`io_read!` and `io_write!` macros, which are generalized version of current\n`dma_read!` and `dma_write!` macro (that works on `Coherent` only, but not\nsubview of them, or other I/O backends).\n\nFor DMA coherent objects, `IoCapable` is only implemented for atomically\naccessible primitives; this is because `read_volatile`/`write_volatile` can\nbehave undesirably for aggregates; LLVM may turn them to multiple\ninstructions to access parts and assemble, or could combine them to a\nsingle instruction.\n\nThe ability to read/write aggregates (when atomicity is of no concern),\ncould be implemented with copying primitives (e.g. memcpy_{from,to}io) in\nthe future.\n\nSigned-off-by: Gary Guo <gary@garyguo.net>\n---\n rust/kernel/dma.rs | 46 ++++++++++++++++++++++++++-\n rust/kernel/io.rs | 92 ++++++++++++++++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 137 insertions(+), 1 deletion(-)", "diff": "diff --git a/rust/kernel/dma.rs b/rust/kernel/dma.rs\nindex 92db0e58f364..d0b86aeebfe2 100644\n--- a/rust/kernel/dma.rs\n+++ b/rust/kernel/dma.rs\n@@ -14,7 +14,10 @@\n },\n error::to_result,\n fs::file,\n- io::Io,\n+ io::{\n+ Io,\n+ IoCapable, //\n+ },\n prelude::*,\n ptr::KnownSize,\n sync::aref::ARef,\n@@ -999,6 +1002,47 @@ fn as_ptr(&self) -> *mut Self::Type {\n }\n }\n \n+/// Implements [`IoCapable`] on `Coherent` for `$ty` using `read_volatile` and `write_volatile`.\n+macro_rules! impl_coherent_io_capable {\n+ ($(#[$attr:meta])* $ty:ty) => {\n+ $(#[$attr])*\n+ impl<T: ?Sized + KnownSize> IoCapable<$ty> for Coherent<T> {\n+ #[inline]\n+ unsafe fn io_read(&self, address: *mut $ty) -> $ty {\n+ // SAFETY:\n+ // - By the safety precondition, the address is within bounds of the allocation and\n+ // aligned.\n+ // - Using read_volatile() here so that race with hardware is well-defined.\n+ // - Using read_volatile() here is not sound if it races with other CPU per Rust\n+ // rules, but this is allowed per LKMM.\n+ // - The macro is only used on primitives so all bit patterns are valid.\n+ unsafe { address.read_volatile() }\n+ }\n+\n+ #[inline]\n+ unsafe fn io_write(&self, value: $ty, address: *mut $ty) {\n+ // SAFETY:\n+ // - By the safety precondition, the address is within bounds of the allocation and\n+ // aligned.\n+ // - Using write_volatile() here so that race with hardware is well-defined.\n+ // - Using write_volatile() here is not sound if it races with other CPU per Rust\n+ // rules, but this is allowed per LKMM.\n+ unsafe { address.write_volatile(value) }\n+ }\n+ }\n+ };\n+}\n+\n+// DMA regions support atomic 8, 16, and 32-bit accesses.\n+impl_coherent_io_capable!(u8);\n+impl_coherent_io_capable!(u16);\n+impl_coherent_io_capable!(u32);\n+// DMA regions on 64-bit systems also support atomic 64-bit accesses.\n+impl_coherent_io_capable!(\n+ #[cfg(CONFIG_64BIT)]\n+ u64\n+);\n+\n impl<'a, B: ?Sized + KnownSize, T: ?Sized> crate::io::View<'a, Coherent<B>, T> {\n /// Returns a DMA handle which may be given to the device as the DMA address base of\n /// the region.\ndiff --git a/rust/kernel/io.rs b/rust/kernel/io.rs\nindex 869071d47a13..efcd7e6741d7 100644\n--- a/rust/kernel/io.rs\n+++ b/rust/kernel/io.rs\n@@ -1009,6 +1009,26 @@ pub fn try_cast<U>(self) -> Result<View<'a, IO, U>>\n }\n }\n \n+impl<T, IO: ?Sized + Io + IoCapable<T>> View<'_, IO, T> {\n+ /// Read from I/O memory.\n+ ///\n+ /// This is only supported on types that is directly supported by `IO` with [`IoCapable`].\n+ #[inline]\n+ pub fn read_val(&self) -> T {\n+ // SAFETY: Per type invariant.\n+ unsafe { self.io.io_read(self.ptr) }\n+ }\n+\n+ /// Write to I/O memory.\n+ ///\n+ /// This is only supported on types that is directly supported by `IO` with [`IoCapable`].\n+ #[inline]\n+ pub fn write_val(&self, value: T) {\n+ // SAFETY: Per type invariant.\n+ unsafe { self.io.io_write(value, self.ptr) }\n+ }\n+}\n+\n /// Project an I/O type to a subview of it.\n ///\n /// The syntax is of form `io_project!(io, proj)` where `io` is an expression to a type that\n@@ -1057,3 +1077,75 @@ macro_rules! io_project {\n \n #[doc(inline)]\n pub use crate::io_project;\n+\n+/// Read from I/O memory.\n+///\n+/// The syntax is of form `io_read!(io, proj)` where `io` is an expression to a type that\n+/// implements [`Io`] and `proj` is a [projection specification](kernel::ptr::project!).\n+///\n+/// # Examples\n+///\n+/// ```\n+/// # use kernel::io::View;\n+/// struct MyStruct { field: u32, }\n+///\n+/// // SAFETY: All bit patterns are acceptable values for `MyStruct`.\n+/// unsafe impl kernel::transmute::FromBytes for MyStruct{};\n+/// // SAFETY: Instances of `MyStruct` have no uninitialized portions.\n+/// unsafe impl kernel::transmute::AsBytes for MyStruct{};\n+///\n+/// # fn test(mmio: &kernel::io::Mmio<[MyStruct]>) -> Result {\n+/// // let mmio: Mmio<[MyStruct]>;\n+/// let field: u32 = kernel::io::io_read!(mmio, [try: 2].field);\n+/// # Ok::<(), Error>(()) }\n+#[macro_export]\n+#[doc(hidden)]\n+macro_rules! io_read {\n+ ($io:expr, $($proj:tt)*) => {\n+ $crate::io_project!($io, $($proj)*).read_val()\n+ };\n+}\n+\n+#[doc(inline)]\n+pub use crate::io_read;\n+\n+/// Writes to I/O memory.\n+///\n+/// The syntax is of form `io_write!(io, proj, val)` where `io` is an expression to a type that\n+/// implements [`Io`] and `proj` is a [projection specification](kernel::ptr::project!),\n+/// and `val` is the value to be written to the projected location.\n+///\n+/// # Examples\n+///\n+/// ```\n+/// # use kernel::io::View;\n+/// struct MyStruct { field: u32, }\n+///\n+/// // SAFETY: All bit patterns are acceptable values for `MyStruct`.\n+/// unsafe impl kernel::transmute::FromBytes for MyStruct{};\n+/// // SAFETY: Instances of `MyStruct` have no uninitialized portions.\n+/// unsafe impl kernel::transmute::AsBytes for MyStruct{};\n+///\n+/// # fn test(mmio: &kernel::io::Mmio<[MyStruct]>) -> Result {\n+/// // let mmio: Mmio<[MyStruct]>;\n+/// kernel::io::io_write!(mmio, [try: 2].field, 10);\n+/// # Ok::<(), Error>(()) }\n+#[macro_export]\n+#[doc(hidden)]\n+macro_rules! io_write {\n+ (@parse [$io:expr] [$($proj:tt)*] [, $val:expr]) => {\n+ $crate::io_project!($io, $($proj)*).write_val($val)\n+ };\n+ (@parse [$io:expr] [$($proj:tt)*] [.$field:tt $($rest:tt)*]) => {\n+ $crate::io_write!(@parse [$io] [$($proj)* .$field] [$($rest)*])\n+ };\n+ (@parse [$io:expr] [$($proj:tt)*] [[$flavor:ident: $index:expr] $($rest:tt)*]) => {\n+ $crate::io_write!(@parse [$io] [$($proj)* [$flavor: $index]] [$($rest)*])\n+ };\n+ ($io:expr, $($rest:tt)*) => {\n+ $crate::io_write!(@parse [$io] [] [$($rest)*])\n+ };\n+}\n+\n+#[doc(inline)]\n+pub use crate::io_write;\n", "prefixes": [ "v2", "08/11" ] }