From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 82D0F179958 for ; Tue, 18 Jun 2024 23:40:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718754048; cv=none; b=oH0ZxS8lksl0i/OL2H72dlFLDoG++mngbxlEaFtOraWaxbxKPnRU8SFaD7Fde9cAv4KO1HjvOiMou5cjP+OTeMAqeet2ZvhbZaKgWzOiqqIdBhjdDlviv+o4sdxUeyYi00LUy2aN12jlO5yeDW1HLcqAUSd63JzA7RIEMNqgcQw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718754048; c=relaxed/simple; bh=+Xk39ZwrIE1KGhHA9AKUZiS/VoU2xqjKZp1A3FfM24w=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=HWorSVlLTFu3E0Yn0Te4a3pvgrCf91lzJevqT0hPs4MBNnTF/emK5mFTyeSMwEOIpIz/Cqe9rMting9Xcqux1WOYGS2Jk9ahSO4qyjVocxYTZBcFXGGvaYPv3rOSG3BcyyMJHUmHvyYrvFU8vqygZ5cSr8gQn4S9tLKjHVpizBc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Q7mbTErG; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Q7mbTErG" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718754045; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=q6H9H1SHefxyue1HrWMST8kDKDco4keX1wncuBDxteE=; b=Q7mbTErGYuemzt5qHo4l+O0JgVfOzchNi+uEA43Vg0RBnOSb1rImA+qyftuwmZelUDgkZR c/5IgE/CySph/uPY39DSJVuQIkf9nadbcRfazO6d6PbiRAcLy2HQE0io8An3NCXFykXI98 9jv81qVuxY6r5TVe1MydwElKzIp77ec= Received: from mail-lf1-f71.google.com (mail-lf1-f71.google.com [209.85.167.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-561-9dBGi5uDOVeMCj7Fkq2aQw-1; Tue, 18 Jun 2024 19:40:43 -0400 X-MC-Unique: 9dBGi5uDOVeMCj7Fkq2aQw-1 Received: by mail-lf1-f71.google.com with SMTP id 2adb3069b0e04-52c8a4ef5e5so4638391e87.1 for ; Tue, 18 Jun 2024 16:40:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718754042; x=1719358842; 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=q6H9H1SHefxyue1HrWMST8kDKDco4keX1wncuBDxteE=; b=p2QqCqWh8+FbUfJC/KQOxVnEKg5R0Pe2zFP+3on72T1njK+3LbSl7PTVdEVS8m/ypT QA3evgNWyF/vdo+e4gZU+CZfcaizaNR1tIx0yh26c+8Ry5iRfxqu9bmGSEc8tzY3l8pl 3rjd9tnmcjoz+MviChjVvFvS1IB6cBFCqqoI3ZejpUp2r0WnzIUuec87UWyFMu5bqZGF WRHvH9hDlF13fYzRiXoBNVJjbcF553nkc9FDSZvmKp01FBJ5iwtVzbX8wTI0vqLodyNy XomkKGsrgW9E9wEP2DwCX3aOPXnOV+GNYy5rSHttPj47rhVoXOKGZvj7WzUI7HUvkSFz mB/Q== X-Gm-Message-State: AOJu0YwufLQ2mTNDuoHxv/iMTBSpaafzh9X3usjsCct3MJEnqBMTIqUI 94RFayCMfs7REH00+PEsrCtmIOiGllytJJkSRP/+SgCnX+zCxRqX4J+3OpOiXS0x9GH2/zuDba+ bwmW4W9sCxNcBrprk5ShpND0PI/FrL+fe9Y6oNnI8eIOSibPbhylB44sAWLyFjhaK X-Received: by 2002:a05:6512:3151:b0:52c:897b:4c5a with SMTP id 2adb3069b0e04-52ccaa6595fmr408371e87.34.1718754042399; Tue, 18 Jun 2024 16:40:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFmDtDAFR8V+id/nUJyFRf/A1MigXS0y4xOPObqrZY1ZBL1uSWuEi4ubFGyiuxHcNDLrMrT8w== X-Received: by 2002:a05:6512:3151:b0:52c:897b:4c5a with SMTP id 2adb3069b0e04-52ccaa6595fmr408353e87.34.1718754041929; Tue, 18 Jun 2024 16:40:41 -0700 (PDT) Received: from cassiopeiae.. ([2a02:810d:4b3f:ee94:642:1aff:fe31:a19f]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3609aa60a59sm4760760f8f.84.2024.06.18.16.40.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Jun 2024 16:40:41 -0700 (PDT) From: Danilo Krummrich To: gregkh@linuxfoundation.org, rafael@kernel.org, bhelgaas@google.com, ojeda@kernel.org, alex.gaynor@gmail.com, wedsonaf@gmail.com, boqun.feng@gmail.com, gary@garyguo.net, bjorn3_gh@protonmail.com, benno.lossin@proton.me, a.hindborg@samsung.com, aliceryhl@google.com, airlied@gmail.com, fujita.tomonori@gmail.com, lina@asahilina.net, pstanner@redhat.com, ajanulgu@redhat.com, lyude@redhat.com, robh@kernel.org, daniel.almeida@collabora.com Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, Danilo Krummrich Subject: [PATCH v2 00/10] Device / Driver and PCI Rust abstractions Date: Wed, 19 Jun 2024 01:39:46 +0200 Message-ID: <20240618234025.15036-1-dakr@redhat.com> X-Mailer: git-send-email 2.45.1 Precedence: bulk X-Mailing-List: rust-for-linux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true This patch series implements basic device / driver, PCI and devres Rust abstractions. This patch series is sent in the context of [1], and the corresponding patch series [2], which contains some basic DRM Rust abstractions and a stub implementation of the Nova GPU driver. Nova is intended to be developed upstream, starting out with just a stub driver to lift some initial required infrastructure upstream. A more detailed explanation can be found in [1]. As mentioned above, a driver serving as example on how these abstractions are used within a (DRM) driver can be found in [2]. Additionally, the device / driver bits can also be found in [3], all abstractions required for Nova in [4] and Nova in [5]. This patch series is based on [6] (which has been merged in the driver-core tree already), as well as two more patches: - "rust: init: introduce Opaque::try_ffi_init" [7] - "rust: introduce InPlaceModule" [8] @Wedson, please let me know if you want to send the two separately or if you want me to pick them up for this series. Changes in v2: ============== - statically initialize driver structures (Greg) - move base device ID abstractions to a separate source file (Greg) - remove `DeviceRemoval` trait in favor of using a `Devres` callback to unregister drivers - remove `device::Data`, we don't need this abstraction anymore now that we `Devres` to revoke resources and registrations - pass the module name to `Module::init` and `InPlaceModule::init` in a separate patch - rework of `Io` including compile time boundary checks (Miguel, Wedson) - adjust PCI abstractions accordingly and implement a `module_pci_driver!` macro - rework `pci::Bar` to support a const SIZE - increase the total amount of Documentation, rephrase some safety comments and commit messages for less ambiguity - fix compilation issues with some documentation examples [1] https://lore.kernel.org/dri-devel/Zfsj0_tb-0-tNrJy@cassiopeiae/T/#u [2] https://lore.kernel.org/dri-devel/20240618233324.14217-1-dakr@redhat.com/ [3] https://github.com/Rust-for-Linux/linux/tree/staging/rust-device [4] https://github.com/Rust-for-Linux/linux/tree/staging/dev [5] https://gitlab.freedesktop.org/drm/nova/-/tree/nova-next [6] https://lore.kernel.org/rust-for-linux/20240618154841.6716-1-dakr@redhat.com/ [7] https://github.com/Rust-for-Linux/linux/commit/9c49161db95f4eb4e55e62873b835fb6c1a0bb39 [8] https://github.com/Rust-for-Linux/linux/commit/e74d5d33dd2b9361e8cebae77227e3f924b50034 Danilo Krummrich (6): rust: pass module name to `Module::init` rust: implement generic driver registration rust: add `io::Io` base type rust: add devres abstraction rust: pci: add basic PCI device / driver abstractions rust: pci: implement I/O mappable `pci::Bar` Wedson Almeida Filho (4): rust: implement `IdArray`, `IdTable` and `RawDeviceId` rust: add rcu abstraction rust: add `Revocable` type rust: add `dev_*` print macros. rust/bindings/bindings_helper.h | 1 + rust/helpers.c | 145 ++++++++++ rust/kernel/device.rs | 319 +++++++++++++++++++++- rust/kernel/device_id.rs | 336 +++++++++++++++++++++++ rust/kernel/devres.rs | 168 ++++++++++++ rust/kernel/driver.rs | 128 +++++++++ rust/kernel/io.rs | 219 +++++++++++++++ rust/kernel/lib.rs | 22 +- rust/kernel/net/phy.rs | 2 +- rust/kernel/pci.rs | 467 ++++++++++++++++++++++++++++++++ rust/kernel/prelude.rs | 2 + rust/kernel/revocable.rs | 209 ++++++++++++++ rust/kernel/sync.rs | 1 + rust/kernel/sync/rcu.rs | 52 ++++ rust/macros/module.rs | 3 +- samples/rust/rust_minimal.rs | 2 +- samples/rust/rust_print.rs | 2 +- 17 files changed, 2069 insertions(+), 9 deletions(-) create mode 100644 rust/kernel/device_id.rs create mode 100644 rust/kernel/devres.rs create mode 100644 rust/kernel/driver.rs create mode 100644 rust/kernel/io.rs create mode 100644 rust/kernel/pci.rs create mode 100644 rust/kernel/revocable.rs create mode 100644 rust/kernel/sync/rcu.rs base-commit: e74d5d33dd2b9361e8cebae77227e3f924b50034 -- 2.45.1