From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) (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 28C0E47DD56 for ; Wed, 17 Jun 2026 15:02:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781708565; cv=none; b=R1J6mCDLdLkK2MwmJJqN5TgxeDpz+flx+EPUGM6oVtkv5PUnWMQu/5f5qdzukcF/rXgngiN5ZRhtTRWzsWFybKu0i/+Wp+OD4dhbIjkiw+txTn4igmorRI3hNcp+rkpWa2uLIl+ybyGb9Aw4utFNwZ/5F36IPT6fHZY8hPtYUPY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781708565; c=relaxed/simple; bh=UOoq7WuK2vbwwp69eAKcDwyrIb9HS49cy3U+9QHjj1g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=O1r97KgN/TbPeWwVyCI9WBdDACO12v4hwGq2Y8dgLqUZCcVfte2msvjgJg+IA4SfX7vUiJ049FbkxBYW9Q0rVtFbm3NLGgs3b9/R3BFHPn3ilsUqHwWbqRd+eg1/mokRKjfIQtMjut+txWQC41RHQzc+r0g5b17hbTaOq88IDYs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=fireburn.co.uk; spf=none smtp.mailfrom=fireburn.co.uk; dkim=pass (2048-bit key) header.d=fireburn-co-uk.20251104.gappssmtp.com header.i=@fireburn-co-uk.20251104.gappssmtp.com header.b=Z6DKWsoj; arc=none smtp.client-ip=209.85.221.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=fireburn.co.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=fireburn.co.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=fireburn-co-uk.20251104.gappssmtp.com header.i=@fireburn-co-uk.20251104.gappssmtp.com header.b="Z6DKWsoj" Received: by mail-wr1-f54.google.com with SMTP id ffacd0b85a97d-4624a44e152so923038f8f.2 for ; Wed, 17 Jun 2026 08:02:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fireburn-co-uk.20251104.gappssmtp.com; s=20251104; t=1781708563; x=1782313363; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=K+7QC6LAPQa8dQnEwdpFa6EKhfpyuQLPCL3jRYAOfa4=; b=Z6DKWsojwTbQ/C7278kq89emWqz4nC1qYVr++tUe5Gasw1G5pZGlWOhdk/qW4ImTpU /N5PVDRMYyjdQwyI7xVW/rFuquHTkp9J+Ss0A+eQgKS25zBzO9HTTGIQZbPUCpa3RaBH ng67Tyt0RmMmYAFVaUdbsYkLvmoSncUPrsAJzCJoCHu4JnuYork6WQYq22Ke6x7Lw5pN lEuxxgc9Vgu17Ymq2bIJYY//don6gCj+9ktHYKbAPlC8cng6RZmlkJgyUunRY5BOVJeO QCU0DvHDO91Snt1A34TBhyY0IkNqnZAOKkySDnBd6ZSuEZDypXEmX46sEulaZjKH615f P4cA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781708563; x=1782313363; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=K+7QC6LAPQa8dQnEwdpFa6EKhfpyuQLPCL3jRYAOfa4=; b=VPSH3LxpUbVqwBbA5kyMpfzdv604IfZr4dFvXIT8Bri1pkzPF05yYx3jLD6/kPSk6+ 9m7HoHX08ITleawpH4esAiG6D9aMweVyE3gzr4A75PHKsYD5kxF74xt5dcd2Ihmv3cse RvVUIHCeM8/cVNTNvvfNb/Jk7JCh4dDhG96ijug5ySpdWaGFtA5rQoKOSKIwomiIFdkJ EBXeF0RN9l+M6lKCYvKfqA/w0obvY4E4REPEPyr0RCJGNr+ltrdZz03md00UzfwhElap 4WJJCIoYLWZI4GsYh4nDDBNMFoyrWPd61OmSe3Tezu2CJ9S2VL1PnP8QT2+Qtei989pb gamQ== X-Forwarded-Encrypted: i=1; AFNElJ8FiZ43wIiL/b23v0bNjadTrLDcdavgHhsKTowXwaIhYPl0qxGGOU/kRHIVO0CEdcGjCiG+lbd9NFIlpeA=@vger.kernel.org X-Gm-Message-State: AOJu0YxvAmZwspuru0k8OZJQVSiHPNIdL71Nw6HJk8q0BtU+0e5N6tNx xSVuO9fVuzN6+EtYNyqpf9khCh0v0GeBtb0oqAw0FHL6ZZ5lfUc/leYsOU4BnbVr4A== X-Gm-Gg: AfdE7ckP66OHIzpJSPHzU92ua1Q+ytpVE/K8UclWJ4eOISkt/pXuZ2mxhwt6HSKGD+w JDCSiHBI7KW5kIkUKRS9lwOvVyJRRI4T+sBQQ5iCiznuhnADGJy4PBTdhi73pxoeO3c8GPTap+K /Pn0qrJqo1GOypLTlqETWDyvv7SNCL7XZPk7rTAi6pMVCDFDjFPQq2cCUBJ7ZIafsXKLJBVKCgR 2Y55oZf7YZNu24ReMaolPqy7dXDZyG+6jiRW1F7wOoZIeZVC9NNatsJnl3HqpXDbSzYBchomrFz E07CqBxUmnqQgsVHdS9e00ohSphdhNULG+nJDCgt3cZKztcyVN093essNxdF/EQOSjGaGBeEZKE TqthAM5u6REf6+M6jwHPbV04IR1+qEoEqMwDDMqis3/oY4H8Lq46xN+iLzLf6dN+PZjYa6e+rhU dGbBtXx9osQ+4RmT7VitbS4mmfIQrsGKxFjL06cZaQMWgKpPWB8bX70BEO X-Received: by 2002:adf:ef8d:0:b0:460:1f32:628d with SMTP id ffacd0b85a97d-4623683a4bdmr5928828f8f.11.1781708562488; Wed, 17 Jun 2026 08:02:42 -0700 (PDT) Received: from axion.fireburn.co.uk ([137.220.119.72]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4606f26f1cdsm57264311f8f.11.2026.06.17.08.02.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jun 2026 08:02:41 -0700 (PDT) From: Mike Lothian To: dri-devel@lists.freedesktop.org Cc: Mike Lothian , rust-for-linux@vger.kernel.org, Miguel Ojeda , Boqun Feng , Gary Guo , =?UTF-8?q?Bj=C3=B6rn=20Roy=20Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross , Danilo Krummrich , David Airlie , Simona Vetter , Daniel Almeida , Greg Kroah-Hartman , Alexandre Courbot , Asahi Lina , Lorenzo Stoakes , Joel Fernandes , linux-kernel@vger.kernel.org Subject: [RFC PATCH 3/4] rust: drm: expose drm::Device::as_raw() Date: Wed, 17 Jun 2026 16:02:25 +0100 Message-ID: <20260617150232.2210-4-mike@fireburn.co.uk> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260617150232.2210-1-mike@fireburn.co.uk> References: <20260617150232.2210-1-mike@fireburn.co.uk> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A KMS driver built on the minimal bindings added earlier in this series needs the raw `struct drm_device` pointer to hand to the C KMS helpers (drm_simple_display_pipe_init, drm_connector_init, the drm_atomic_helper_* family, …) until safe Rust KMS abstractions cover them. Make drm::Device::as_raw() pub, documented as a temporary escape hatch with the caller's locking/lifetime obligations spelled out. This is the part of the KMS work most likely to draw objections, so it is split into its own patch: it can be dropped or reworked (e.g. replaced by narrow safe wrappers, or kept pub(crate) behind per-helper methods) without disturbing the feature flags and header bindings, which are useful on their own. Signed-off-by: Mike Lothian Assisted-by: Claude:claude-opus-4-8 [Claude-Code] --- rust/kernel/drm/device.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/rust/kernel/drm/device.rs b/rust/kernel/drm/device.rs index 1d3319b713e2..c89c947b399a 100644 --- a/rust/kernel/drm/device.rs +++ b/rust/kernel/drm/device.rs @@ -296,7 +296,15 @@ pub struct Device { } impl Device { - pub(crate) fn as_raw(&self) -> *mut bindings::drm_device { + /// Returns a raw pointer to the underlying `struct drm_device`. + /// + /// This is a temporary escape hatch for drivers that need to call C KMS helpers + /// not yet covered by safe Rust abstractions; it is expected to be removed (or + /// narrowed to `pub(crate)`) once the in-progress safe KMS layer can express + /// those operations. The returned pointer is valid for as long as `self` is + /// borrowed; the caller must uphold the locking and lifetime rules of every C + /// function it is passed to. + pub fn as_raw(&self) -> *mut bindings::drm_device { self.dev.get() } -- 2.54.0