Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/1.2/patches/2225777/?format=api
{ "id": 2225777, "url": "http://patchwork.ozlabs.org/api/1.2/patches/2225777/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-pci/patch/20260421-io_projection-v2-1-4c251c692ef4@garyguo.net/", "project": { "id": 28, "url": "http://patchwork.ozlabs.org/api/1.2/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-1-4c251c692ef4@garyguo.net>", "list_archive_url": null, "date": "2026-04-21T14:56:12", "name": "[v2,01/11] rust: io: generalize `MmioRaw` to pointer to arbitrary type", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "016921a076cc833e87ab99e707ba8ff1627406c3", "submitter": { "id": 76823, "url": "http://patchwork.ozlabs.org/api/1.2/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-1-4c251c692ef4@garyguo.net/mbox/", "series": [ { "id": 500833, "url": "http://patchwork.ozlabs.org/api/1.2/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/2225777/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2225777/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "\n <linux-pci+bounces-52847-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=VqbSJBQI;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=2600:3c0a:e001:db::12fc:5321; helo=sea.lore.kernel.org;\n envelope-from=linux-pci+bounces-52847-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=\"VqbSJBQI\"", "smtp.subspace.kernel.org;\n arc=fail smtp.client-ip=52.101.196.82", "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 sea.lore.kernel.org (sea.lore.kernel.org\n [IPv6:2600:3c0a:e001:db::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 4g0Qd46DX9z1yGt\n\tfor <incoming@patchwork.ozlabs.org>; Wed, 22 Apr 2026 01:04:56 +1000 (AEST)", "from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sea.lore.kernel.org (Postfix) with ESMTP id 18C0430597B7\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 21 Apr 2026 14:57:47 +0000 (UTC)", "from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id B11FC3D9DCC;\n\tTue, 21 Apr 2026 14:56:42 +0000 (UTC)", "from LO3P265CU004.outbound.protection.outlook.com\n (mail-uksouthazon11020082.outbound.protection.outlook.com [52.101.196.82])\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 7DB4C3DB625;\n\tTue, 21 Apr 2026 14:56:40 +0000 (UTC)", "from LOVP265MB8871.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:488::16)\n by CWLP265MB5523.GBRP265.PROD.OUTLOOK.COM (2603:10a6:400:1b9::6) 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:27 +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:27 +0000" ], "ARC-Seal": [ "i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1776783402; cv=fail;\n b=GMUu7RER7ie5av4FjsPbnodKA+1jdDAC7iyLOD7zAeSgH+nYygxTQmhvNv8bVV4+WEeTQKUTwC6hsXccqOeP6z6SlUVsve08sUXhCKj7wITzyNC5C/jjrZVWBt9EsRIhp0m6nSWWwBR7Lnhk2NmGL+lWB1P1cjvAyGAJfbO4W3Q=", "i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none;\n b=ij/bqBuc40tPgaS6OszEXxbxBRww/YcKm6uJ1f6kYZQYW8H2TpWmOAuv3dUX7dRpGXPQSE1eoJay07h8q9clJ3NVdBBAvV3HjeHhYn5p4cmRBPbBxTdC84Gr/oAZn8Nph5IrgOH2h9ajr3BpiePN98VtI4jRxT3qpmfT2X0WWuym0iS5/clZ+KeuBUsTGWdCfBNwEQfVlbFIucntpRrlCE6ZnOJ/WmoUfyRw57UFgaHviFwMXEoNjBGbjqnrOTfF+7r63I5Hlnau3NOwPwNKr1H36AL9sA8wHT9EqqKCTxMpnhmjygaWSzaayD+rL/YCluIYUmY/yRUy0rAy1xpJwg==" ], "ARC-Message-Signature": [ "i=2; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1776783402; c=relaxed/simple;\n\tbh=nYKQK/f1KfskLdodznB/5NT4h/cZos/SolizpGrj0LE=;\n\th=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To:\n\t To:Cc:MIME-Version;\n b=lE3rHXKCrAvdEDWJWWAmfzL1jMk4lwi3IjNVClELcDDqcEyWkSoJpRm4nxn7200rIh/EpKWtBjQPoyXCjKl9E50ypc7r2LBEr3jzIVAgKj9P2C9rreFIBTfOdtmXclc6Lj8qAiHZ3/asiMqKsgZVJqS3/5DZlk7wwF/hcWAcaw4=", "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=KherrrE+rsrXm3BlkG4oiDUH5/nddaBLxhmqGt2+OeY=;\n b=acQCdL3MUP1VUWaAG4K/yX/7sUympzQHF9seVUbdmcx+jM/DjeEoJraZcdmtNELaqiTjPKqDcZv/EauBwKtjx+GYGYET73eDGpltpslrMii+g2daKmNLHamcrjFQbg+IbItIii5sc1IzLC67x6hY1w3PUKiZh5171Z7GeXtluzS0gcjmKd2C1UpWW0AvvDSLHnsg9794Doz2A7XZ9jk9m+Yg9eIXtNq/pQHDm8tY0cScM62FCkm2jwGu7mcbXw14Jn93GKuXANwo4FS8Fl8g/H+aEwGwRPioU3Jrfp7OVcUHtSkZbFcvykFlRHVeA3NtGgs7XYpocqroABmHhQLFmA==" ], "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=VqbSJBQI; arc=fail smtp.client-ip=52.101.196.82", "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=KherrrE+rsrXm3BlkG4oiDUH5/nddaBLxhmqGt2+OeY=;\n b=VqbSJBQI3SvwFDkI62FBhved/I9643ZWttr/MB6Kt9H1iG9pp5K2+JlYn2Cg/FpNPMvQdMCzz4c9Lahs1pSHkwaGRSsEIjpRiD8CwCSkJAtYgnSCPWoQQIcws0dFxiF49f+INdGpfIBeNUxhUi6iiptR/2sxAT+Ccw5oixcOPvs=", "From": "Gary Guo <gary@garyguo.net>", "Date": "Tue, 21 Apr 2026 15:56:12 +0100", "Subject": "[PATCH v2 01/11] rust: io: generalize `MmioRaw` to pointer to\n arbitrary type", "Content-Type": "text/plain; charset=\"utf-8\"", "Content-Transfer-Encoding": "7bit", "Message-Id": "<20260421-io_projection-v2-1-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=8434;\n i=gary@garyguo.net; s=20221204; h=from:subject:message-id;\n bh=nYKQK/f1KfskLdodznB/5NT4h/cZos/SolizpGrj0LE=;\n b=OaG5mFrZyUJqCnGEj3sHwSoJsPGCebrOKCATdGc3MWO9XHxsjhqyRuWhIIAwXdsQrGvIpbYtE\n KSXJicQWrJUAzNUDuroHrvxyA8+GIfotk7Sz5peuVeIJbWnKM5pqiER", "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_|CWLP265MB5523:EE_", "X-MS-Office365-Filtering-Correlation-Id": "4fe97c69-24bd-4ecd-b278-08de9fb62a24", "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\tqebbT1Q96VGI7ZSMcCimdrG9Fuy/tVc3tBIq2V0SvarRhDrIwjpd/CyachTAeM4lN8sD5u96/eZ3sFUVHoRbJ8JaFDbnXbIgLftRDEiUhEVyMYFbgBqwBkU4CMJnTqwSHSg3nMfi1sn0QNl7zJ2xN7LXoQCBUlIRZ7uz9kPFOftQagZoWY7lL48wP3BpmlSs2DlWgufaYz7ghI1+cbafFkTSPB/PhaEVzzT6Ex1MEEE1hp7f41D6M5LHorjjd3JXnTe7gXxtEQiDGzQsIGzVltxF02bYEvUlPmwOUxz4PVaGy7YrWlnJDvoFiAOnWvxjCUpctEsrvVau9Cc8bzqvEvaz9Ul6yn5AfVu6K5XID9t9Mp5k503sOWVIY+bTF8iREOmPYxMGu2RkzcZReg1lwPyiqspyY0BWSxKQFz/kjHEy6ee1mDcAfoqexXFgmkTrDnwbFqsc90bGaVC4bOX4SWI3k1KDn7rTfekGGqbAF1+5UocCKLH1laGHqGn6GIC+XHOEwlCPW1ecVHCW7HrwELCjw0eIeSwf1tjusa6YsfKyaIj6VPS46iU1RzKnjiV1SOvFxz/iX+eIvczsrWu5XbtFnpT51YaDUKEL/vjhm3ZIbNLE2c8a7wby8zbcPq3RGyVwkG59Qf4IgW0YXS/kAnK36jYK6ODCtEC2rFQsFiJWlz5yYrL1kNGPHYa28OCkaBs5XMf7lBmUH2MXhxAD82jS4fbqB2xgIwPiWnACLTqA7IduA15l8mUahRdh98CndMOVn04qBMIL2ZKiqmnTqQ==", "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?JdOpClWwpfwUkSJBO3Rrw3jLx4Ha?=\n\t=?utf-8?q?ROM8ZAlIDoo9Y+lmCiPxp5srnNtgKsbDmdnF6Q070nZI5pjbJz9/GGzqytTqlRpKO?=\n\t=?utf-8?q?PTwh78SGxfh2GoTjc+zzk/+zVcF2Y0ZiA8wJzWTvPdcMV3RbpC6e0gpICUkedD3bE?=\n\t=?utf-8?q?IAkFnS8GyVAzD0OHXa7RcMbqmYE5ek/imfiKvR2VyPYNgvwYmVOfxUYqllQVVqxRL?=\n\t=?utf-8?q?muz8YRbVXpa7MLKP9JnX8PbF0/mpBQEYhZxCRHQhi83jACVt7VurbFkZHpwuPGH6b?=\n\t=?utf-8?q?d8FqCqPq4uWIxq5hqKZo6h2j6gVzp6pVBGelEIR8A+z15saI4Ry7y9QQd/DdJHA4U?=\n\t=?utf-8?q?tlM0T13xqYS0xQR7ERYZ9LYkUjYIw5LC/Jd8dvF9G1Vd/vsrCotkp3Ud62NPq/W9+?=\n\t=?utf-8?q?aU5PWL+Y4Ufwura5PqVqkAgr3Wbt+CKdf8eW/KM+mP5pCLuaFPLT91B1bFFiSGZCF?=\n\t=?utf-8?q?dm0KtIDszHzuGTm+z52M/BDZ0tjwNpwJuTf3ccfQxn/DSJ4kOUdQgtAAt4atHFWVx?=\n\t=?utf-8?q?4Rt66fV2xwVxc+I8bmLD6SQyqac6z7LW6OnHRHp8qk7tC/ey15dWd7nxsTErOY8la?=\n\t=?utf-8?q?OH0H0h0raplVge1fFFHgTo4gIHHxmhk/JjDWXFN6pGPsx5PUNDVkDqPFhrHnz3DQX?=\n\t=?utf-8?q?1u3QTR1TyXqJUXUiT77ukVduQxgew4am/0G4DTZ1t7XRgjHPc8RAwfEyVTJZpJYwl?=\n\t=?utf-8?q?SWrDX2QWWizXsbi4S+/oASiQRjWCVUmIqstHlV47/tkTyK/zi8Fyzd4OG6htSPyeI?=\n\t=?utf-8?q?BeL61fMrq+uLmiYU2xG3e69WtUFOGnb1EONlwBel6/SIOepTxwJD4QyWN9rGH3NP6?=\n\t=?utf-8?q?8XJL8RYJvjW0iDzEAetwoVzmpA/n9jtTHqkVkBk8d7OlLRS/nIbafh/FlQ0cZ3lNM?=\n\t=?utf-8?q?XnA3W7RFtD7LsWHvHqjkvi4Q1FYuv5o3/tMwA3gMulzzGri3xdXnW4+miHIF16UFJ?=\n\t=?utf-8?q?XmRwGYsfGyxzmqRaBjhjtkxYkL21kaHHclTS3REI4h9wy8nJsAUOSyzvhcgF60OYC?=\n\t=?utf-8?q?VnNCduMqcQKZraoxSYsvmuiQ1aHVMS9zOcjjDkiFwcQmWWq6Lnl/N9rDRnprBJySY?=\n\t=?utf-8?q?oVqIfvp1cr757ZmcUHY7dp+dUjlQN+qJDK2q2q73tSOpmnLker79ZMpJtvD2uKgbG?=\n\t=?utf-8?q?vO6DI0XJYYHV0b1gy3lExfDypREgojls8tJ4XCaM1n6NfEMEOASwL3NIFbSDwNUqQ?=\n\t=?utf-8?q?MzxmrZ41xvEogpI+D0VIhVhBnD3TDpIwEijhefm9kyLMjKQ1scDWTZ2Z9gv1PBdIx?=\n\t=?utf-8?q?H9YgooPEQiAjyW2MDJqaTegoHtxkHqoef2ZvZ4ewnX654e917QdK6ZhtbIFtKSMZ1?=\n\t=?utf-8?q?ppFQfawrcNwkTy25BGPNxoxe73c/4ZNZSxU/Tl//3MgVeMf/UcvXRhG49Z6I7NOCg?=\n\t=?utf-8?q?nbdrgf3hTVw4fGQ3ajqbsr+5V2soUU5P3VwRDdwdwHgl947Slh94f3aI1AOhfJAwZ?=\n\t=?utf-8?q?ZXhztQh6JDy2IMc6jO9IAFI2OBsfFQDAADZRtuP6SmQ++aJVlOLDuzotw0sLyHrma?=\n\t=?utf-8?q?uUyXELEjgQfZnutbZuEGKfcKvqhJR13b6LAEfoLhpnwjIPuET6l3rURTZDJ8haE2Z?=\n\t=?utf-8?q?AE1scXlWoiSnAazZobVUOvhPqcOK0YmRdFg5LU2rFsgNMcqudVPEzunMgcQ5oSV68?=\n\t=?utf-8?q?a39P7bYX0ReAbmRazbEd7ncd+tYyWnsA=3D=3D?=", "X-OriginatorOrg": "garyguo.net", "X-MS-Exchange-CrossTenant-Network-Message-Id": "\n 4fe97c69-24bd-4ecd-b278-08de9fb62a24", "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:27.3841\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 VAOCeFOaBsvJtMWVG/hLi7gEv+m/cJdRJmxZ5chFbv59HHBvFBVRIM0U+nEraD/YAFLGMPADWMU5752fRcG6jA==", "X-MS-Exchange-Transport-CrossTenantHeadersStamped": "CWLP265MB5523" }, "content": "Conceptually, `MmioRaw` is just `__iomem *`, so it should work for any\ntypes. The existing use case where it represents a region of compile-time\nknown minimum size and run-time known actual size is moved to a custom\ndynamic-sized type `Region<SIZE>` instead. The `maxsize` method is also\nrenamed to `size` to reflect that it is the actual size (not a bound) of\nthe region.\n\nSigned-off-by: Gary Guo <gary@garyguo.net>\n---\n rust/kernel/devres.rs | 7 +++--\n rust/kernel/io.rs | 84 ++++++++++++++++++++++++++++++++++++++++-----------\n rust/kernel/io/mem.rs | 4 +--\n rust/kernel/pci/io.rs | 4 +--\n 4 files changed, 74 insertions(+), 25 deletions(-)", "diff": "diff --git a/rust/kernel/devres.rs b/rust/kernel/devres.rs\nindex 9e5f93aed20c..65a4082122af 100644\n--- a/rust/kernel/devres.rs\n+++ b/rust/kernel/devres.rs\n@@ -71,14 +71,15 @@ struct Inner<T> {\n /// IoKnownSize,\n /// Mmio,\n /// MmioRaw,\n-/// PhysAddr, //\n+/// PhysAddr,\n+/// Region, //\n /// },\n /// prelude::*,\n /// };\n /// use core::ops::Deref;\n ///\n /// // See also [`pci::Bar`] for a real example.\n-/// struct IoMem<const SIZE: usize>(MmioRaw<SIZE>);\n+/// struct IoMem<const SIZE: usize>(MmioRaw<Region<SIZE>>);\n ///\n /// impl<const SIZE: usize> IoMem<SIZE> {\n /// /// # Safety\n@@ -93,7 +94,7 @@ struct Inner<T> {\n /// return Err(ENOMEM);\n /// }\n ///\n-/// Ok(IoMem(MmioRaw::new(addr as usize, SIZE)?))\n+/// Ok(IoMem(MmioRaw::new_region(addr as usize, SIZE)?))\n /// }\n /// }\n ///\ndiff --git a/rust/kernel/io.rs b/rust/kernel/io.rs\nindex fcc7678fd9e3..d7f2145fa9b9 100644\n--- a/rust/kernel/io.rs\n+++ b/rust/kernel/io.rs\n@@ -6,7 +6,8 @@\n \n use crate::{\n bindings,\n- prelude::*, //\n+ prelude::*,\n+ ptr::KnownSize, //\n };\n \n pub mod mem;\n@@ -31,39 +32,85 @@\n /// `CONFIG_PHYS_ADDR_T_64BIT`, and it can be a u64 even on 32-bit architectures.\n pub type ResourceSize = bindings::resource_size_t;\n \n+/// Untyped I/O region.\n+///\n+/// This type can be used when an I/O region without known type information has a compile-time known\n+/// minimum size (and a runtime known actual size).\n+///\n+/// The `SIZE` generic parameter indicate the minimum size of the region.\n+#[repr(transparent)]\n+pub struct Region<const SIZE: usize = 0> {\n+ inner: [u8],\n+}\n+\n+impl<const SIZE: usize> KnownSize for Region<SIZE> {\n+ #[inline(always)]\n+ fn size(p: *const Self) -> usize {\n+ (p as *const [u8]).len()\n+ }\n+}\n+\n /// Raw representation of an MMIO region.\n ///\n+/// `MmioRaw<T>` is equivalent to `T __iomem *` in C.\n+///\n /// By itself, the existence of an instance of this structure does not provide any guarantees that\n /// the represented MMIO region does exist or is properly mapped.\n ///\n /// Instead, the bus specific MMIO implementation must convert this raw representation into an\n /// `Mmio` instance providing the actual memory accessors. Only by the conversion into an `Mmio`\n /// structure any guarantees are given.\n-pub struct MmioRaw<const SIZE: usize = 0> {\n- addr: usize,\n- maxsize: usize,\n+pub struct MmioRaw<T: ?Sized> {\n+ /// Pointer is in I/O address space.\n+ ///\n+ /// The provenance does not matter, only the address and metadata do.\n+ addr: *mut T,\n }\n \n-impl<const SIZE: usize> MmioRaw<SIZE> {\n- /// Returns a new `MmioRaw` instance on success, an error otherwise.\n- pub fn new(addr: usize, maxsize: usize) -> Result<Self> {\n- if maxsize < SIZE {\n+// SAFETY: `MmioRaw` is just an address, so is thread-safe.\n+unsafe impl<T: ?Sized> Send for MmioRaw<T> {}\n+// SAFETY: `MmioRaw` is just an address, so is thread-safe.\n+unsafe impl<T: ?Sized> Sync for MmioRaw<T> {}\n+\n+impl<T> MmioRaw<T> {\n+ /// Create a `MmioRaw` from address.\n+ #[inline]\n+ pub fn new(addr: usize) -> Self {\n+ Self {\n+ addr: core::ptr::without_provenance_mut(addr),\n+ }\n+ }\n+}\n+\n+impl<const SIZE: usize> MmioRaw<Region<SIZE>> {\n+ /// Create a `MmioRaw` representing a I/O region with given size.\n+ ///\n+ /// The size is checked against the minimum size specified via const generics.\n+ #[inline]\n+ pub fn new_region(addr: usize, size: usize) -> Result<Self> {\n+ if size < SIZE {\n return Err(EINVAL);\n }\n \n- Ok(Self { addr, maxsize })\n+ let addr = core::ptr::slice_from_raw_parts_mut::<u8>(\n+ core::ptr::without_provenance_mut(addr),\n+ size,\n+ ) as *mut Region<SIZE>;\n+ Ok(Self { addr })\n }\n+}\n \n+impl<T: ?Sized + KnownSize> MmioRaw<T> {\n /// Returns the base address of the MMIO region.\n #[inline]\n pub fn addr(&self) -> usize {\n- self.addr\n+ self.addr.addr()\n }\n \n- /// Returns the maximum size of the MMIO region.\n+ /// Returns the size of the MMIO region.\n #[inline]\n- pub fn maxsize(&self) -> usize {\n- self.maxsize\n+ pub fn size(&self) -> usize {\n+ KnownSize::size(self.addr)\n }\n }\n \n@@ -89,12 +136,13 @@ pub fn maxsize(&self) -> usize {\n /// Mmio,\n /// MmioRaw,\n /// PhysAddr,\n+/// Region,\n /// },\n /// };\n /// use core::ops::Deref;\n ///\n /// // See also `pci::Bar` for a real example.\n-/// struct IoMem<const SIZE: usize>(MmioRaw<SIZE>);\n+/// struct IoMem<const SIZE: usize>(MmioRaw<Region<SIZE>>);\n ///\n /// impl<const SIZE: usize> IoMem<SIZE> {\n /// /// # Safety\n@@ -109,7 +157,7 @@ pub fn maxsize(&self) -> usize {\n /// return Err(ENOMEM);\n /// }\n ///\n-/// Ok(IoMem(MmioRaw::new(addr as usize, SIZE)?))\n+/// Ok(IoMem(MmioRaw::new_region(addr as usize, SIZE)?))\n /// }\n /// }\n ///\n@@ -139,7 +187,7 @@ pub fn maxsize(&self) -> usize {\n /// # }\n /// ```\n #[repr(transparent)]\n-pub struct Mmio<const SIZE: usize = 0>(MmioRaw<SIZE>);\n+pub struct Mmio<const SIZE: usize = 0>(MmioRaw<Region<SIZE>>);\n \n /// Checks whether an access of type `U` at the given `offset`\n /// is valid within this region.\n@@ -767,7 +815,7 @@ fn addr(&self) -> usize {\n /// Returns the maximum size of this mapping.\n #[inline]\n fn maxsize(&self) -> usize {\n- self.0.maxsize()\n+ self.0.size()\n }\n }\n \n@@ -782,7 +830,7 @@ impl<const SIZE: usize> Mmio<SIZE> {\n ///\n /// Callers must ensure that `addr` is the start of a valid I/O mapped memory region of size\n /// `maxsize`.\n- pub unsafe fn from_raw(raw: &MmioRaw<SIZE>) -> &Self {\n+ pub unsafe fn from_raw(raw: &MmioRaw<Region<SIZE>>) -> &Self {\n // SAFETY: `Mmio` is a transparent wrapper around `MmioRaw`.\n unsafe { &*core::ptr::from_ref(raw).cast() }\n }\ndiff --git a/rust/kernel/io/mem.rs b/rust/kernel/io/mem.rs\nindex 7dc78d547f7a..9117d417f99c 100644\n--- a/rust/kernel/io/mem.rs\n+++ b/rust/kernel/io/mem.rs\n@@ -231,7 +231,7 @@ fn deref(&self) -> &Self::Target {\n /// [`IoMem`] always holds an [`MmioRaw`] instance that holds a valid pointer to the\n /// start of the I/O memory mapped region.\n pub struct IoMem<const SIZE: usize = 0> {\n- io: MmioRaw<SIZE>,\n+ io: MmioRaw<super::Region<SIZE>>,\n }\n \n impl<const SIZE: usize> IoMem<SIZE> {\n@@ -266,7 +266,7 @@ fn ioremap(resource: &Resource) -> Result<Self> {\n return Err(ENOMEM);\n }\n \n- let io = MmioRaw::new(addr as usize, size)?;\n+ let io = MmioRaw::new_region(addr as usize, size)?;\n let io = IoMem { io };\n \n Ok(io)\ndiff --git a/rust/kernel/pci/io.rs b/rust/kernel/pci/io.rs\nindex ae78676c927f..0335b5068f69 100644\n--- a/rust/kernel/pci/io.rs\n+++ b/rust/kernel/pci/io.rs\n@@ -148,7 +148,7 @@ impl<'a, S: ConfigSpaceKind> IoKnownSize for ConfigSpace<'a, S> {\n /// memory mapped PCI BAR and its size.\n pub struct Bar<const SIZE: usize = 0> {\n pdev: ARef<Device>,\n- io: MmioRaw<SIZE>,\n+ io: MmioRaw<crate::io::Region<SIZE>>,\n num: i32,\n }\n \n@@ -184,7 +184,7 @@ pub(super) fn new(pdev: &Device, num: u32, name: &CStr) -> Result<Self> {\n return Err(ENOMEM);\n }\n \n- let io = match MmioRaw::new(ioptr, len as usize) {\n+ let io = match MmioRaw::new_region(ioptr, len as usize) {\n Ok(io) => io,\n Err(err) => {\n // SAFETY:\n", "prefixes": [ "v2", "01/11" ] }