From patchwork Thu Jun 5 16:19:56 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Korotin X-Patchwork-Id: 894215 Received: from mail-wm1-f68.google.com (mail-wm1-f68.google.com [209.85.128.68]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 41F3B1E5B7D; Thu, 5 Jun 2025 16:22:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.68 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749140535; cv=none; b=pC7RZktvfJA64yT93katQ5qDdLg0/O4B7M8FqgcFM5xOP4wX/8Oap4ikmPkBgXsaCsb0lZUPdPV6U0/5Kbmtz84J3vg6a1gkk4lVYu/9RNiwuGT1BYQkTiGVe4kHMPhZlT+kB4Db8qUHO4iVNIHsIppkEjKNRpxlA89V37MQwoo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1749140535; c=relaxed/simple; bh=WOEAx/OuSA6ujJIrMf+xRi70l3LrT+6XGNIYC00yoYI=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Q7imois8n1J0DFacpqVS3rwSTNIhHbPZuUwpyHyuuvONlDQARPQ+A6kZkGGJxoQ8sl7aQPsM38o8KoLmy7zJIIuQDblUo4du5xtEnna50///+1UkBrpn6GWGlY3aFTXhUjvewMGvrIK+5eSxZqnzKejx+1kbmUANph7yYfjNvZA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=HKRjHVlX; arc=none smtp.client-ip=209.85.128.68 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HKRjHVlX" Received: by mail-wm1-f68.google.com with SMTP id 5b1f17b1804b1-451d3f72391so14480955e9.3; Thu, 05 Jun 2025 09:22:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1749140531; x=1749745331; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=LY3Zmm9CwcbsqE728Ul4F6AXczl5eGOeRnNMCNxXAoY=; b=HKRjHVlX0FJ2S65FHKl6MC/HmxSipJZoyPSPTAfZds4XrLNBLqhslT/MkeWYzmRyMx 7QFkuW8WLQvV9kzpFZ8x5Bm3V+SiUa4D4EiqBaMx7TSarCquZI/W+8hQ1fvjPhZAOEGp ZG0wK9sVule0sVJreWgXJWvNlO2bK/jPkN+mnZv2C1eynWBtPrzLbrCSOWloqKrhMLCO Heeq+4F9b/c95eCCMI89eUMgHnNqIBVK98jUqYOomm9RF1cyczTfp0j3CjLiCi562YQ2 ji4RM45UIeBrM+9SBuSA1H7mvMu6JdWu/rvOW5iB1eMXeykqVy5QGxH/k1B/vHArA/de aKQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1749140531; x=1749745331; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=LY3Zmm9CwcbsqE728Ul4F6AXczl5eGOeRnNMCNxXAoY=; b=ikbqEaatKC6ovS7iwJze+IOPLOApmLSOxC0COTrzBu2SWPEdQXIWeqK//P+dTpbyV3 emvfwlyh4XkOYL42YOJOY8GBVQcgc7n8J3gBLCUZ7usVGwW2VmXc5LnVmCO8Yv4OHPXY TWkGtN7acmkIjG4y3W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G/6u4AQM5gkIe4ms4BiQRY7r+cBwxy2JLfG vEnGd+JSfTIIW X-Google-Smtp-Source: AGHT+IE4y9d8vikxgvAwpXIodBENHW2PgVwG5bQuSLsdfkNT1qH9L0nf9UIIGAtpDXr/v+6N33XcPA== X-Received: by 2002:a05:600c:348e:b0:44a:b7a3:b95f with SMTP id 5b1f17b1804b1-451f0b249a2mr77239945e9.25.1749140531225; Thu, 05 Jun 2025 09:22:11 -0700 (PDT) Received: from igor-korotin-Precision-Tower-3620.. ([188.39.32.4]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-451f990cf14sm30010615e9.25.2025.06.05.09.22.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Jun 2025 09:22:10 -0700 (PDT) From: Igor Korotin To: Miguel Ojeda , Alex Gaynor , Rob Herring , Saravana Kannan , "Rafael J . Wysocki" , Greg Kroah-Hartman , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, devicetree@vger.kernel.org Cc: Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Danilo Krummrich , Len Brown , Viresh Kumar , Wedson Almeida Filho , Alex Hung , Tamir Duberstein , FUJITA Tomonori , Xiangfei Ding , Igor Korotin Subject: [PATCH v2 0/5] rust: Add ACPI match table support for Rust drivers Date: Thu, 5 Jun 2025 17:19:56 +0100 Message-ID: <20250605161956.3658374-1-igor.korotin.linux@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-acpi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This patch series introduces support for ACPI match tables in Rust drivers. Currently, Rust abstractions support only Open Firmware (OF) device matching. This series extends the driver model to support ACPI-based matching, enabling Rust drivers to bind to ACPI-described devices. Changes include: - A new `acpi::DeviceId` abstraction for working with `struct acpi_device_id`. - A helper function `is_of_node()` for determining fwnode types. - Updates to the core `Adapter` trait and `platform::Driver` to support optional ACPI ID tables. - A sample implementation in the Rust platform driver, demonstrating multi-bus matching. This is especially useful for writing drivers that work across platforms using both OF and ACPI. Tested using QEMU with a custom SSDT that creates an ACPI device matching the sample Rust platform driver. Igor Korotin (5): rust: acpi: add `acpi::DeviceId` abstraction rust: helpers: Add `is_of_node` helper function rust: driver: Add ACPI id table support to Adapter trait rust: platform: Add ACPI match table support to `Driver` trait samples: rust: add ACPI match table example to platform driver Changelog --------- v2: - Removed misleading comment in `acpi::DeviceID` implementation. - Removed unnecessary casting in `acpi::DeviceID::new`. - Moved `pub mod acpi` to correct alphabetical position in `rust/kernel/lib.rs`. - Link to v1: https://lore.kernel.org/rust-for-linux/20250530123815.1766726-1-igor.korotin.linux@gmail.com/ MAINTAINERS | 2 + rust/bindings/bindings_helper.h | 1 + rust/helpers/helpers.c | 1 + rust/helpers/of.c | 6 +++ rust/kernel/acpi.rs | 62 ++++++++++++++++++++++++++++ rust/kernel/driver.rs | 58 ++++++++++++++++++++++++-- rust/kernel/lib.rs | 1 + rust/kernel/platform.rs | 17 +++++++- samples/rust/rust_driver_platform.rs | 41 +++++++++++++++++- 9 files changed, 183 insertions(+), 6 deletions(-) create mode 100644 rust/helpers/of.c create mode 100644 rust/kernel/acpi.rs