summaryrefslogtreecommitdiffstats
path: root/drivers/android/binder/debug.rs
diff options
context:
space:
mode:
authorNiklas Cassel <cassel@kernel.org>2026-09-16 15:00:32 +0200
committerNiklas Cassel <cassel@kernel.org>2026-09-16 16:18:00 +0200
commit8d836581f9b1f57ceaa2b47654754ef1260b410b (patch)
tree1dbd4d0dfb99c2e238356cbe947e5b0be3e3a571 /drivers/android/binder/debug.rs
downloadlinux-stable-8d836581f9b1f57ceaa2b47654754ef1260b410b.tar.gz
linux-stable-8d836581f9b1f57ceaa2b47654754ef1260b410b.zip
ata: libata-scsi: fix ata_dsm_trim_pages() kernel-docgrafted
make htmldocs fails with: Documentation/driver-api/libata:604: ./drivers/ata/libata-scsi.c:2301: ERROR: Unexpected indentation. [docutils] The Return: section of ata_dsm_trim_pages() ends its first sentence with a colon and continues with an indented bullet list. reStructuredText requires a blank line before an indented block, so docutils chokes on the list. Simply adding the missing blank line does not work either: Return: is a kernel-doc "special section", which is terminated by the first blank line, so the bullet list would end up in the Description section, detached from the sentence introducing it. Spell the two bounds out as prose instead, so that the Return: section stays self-contained. Documentation-only change. Fixes: e64e6b5dc867 ("ata: libata-scsi: scale DSM TRIM payload by MAX PAGES PER DSM COMMAND") Reported-by: Thomas Huth <thuth@redhat.com> Closes: https://lore.kernel.org/linux-ide/b0a0b8e8-cc4f-4c7b-8bc5-fee0712d405a@redhat.com/ Reviewed-by: Damien Le Moal <dlemoal@kernel.org> Reviewed-by: Thomas Huth <thuth@redhat.com> Link: https://lore.kernel.org/r/20260916130031.29990-2-cassel@kernel.org Signed-off-by: Niklas Cassel <cassel@kernel.org>
Diffstat (limited to 'drivers/android/binder/debug.rs')
-rw-r--r--drivers/android/binder/debug.rs76
1 files changed, 76 insertions, 0 deletions
diff --git a/drivers/android/binder/debug.rs b/drivers/android/binder/debug.rs
new file mode 100644
index 000000000..824b10c00
--- /dev/null
+++ b/drivers/android/binder/debug.rs
@@ -0,0 +1,76 @@
+// SPDX-License-Identifier: GPL-2.0
+// Copyright (C) 2026 Google LLC.
+
+//! Binder debugging helpers.
+
+#![allow(dead_code)]
+
+use kernel::bits::bit_u32;
+use kernel::sync::atomic::Atomic;
+
+kernel::impl_flags!(
+ /// Represents multiple debug mask flags.
+ #[derive(Debug, Clone, Default, Copy, PartialEq, Eq)]
+ pub struct DebugMasks(u32);
+
+ /// Represents a single debug mask category.
+ #[derive(Debug, Clone, Copy, PartialEq, Eq)]
+ pub enum DebugMask {
+ UserError = bit_u32(0),
+ FailedTransaction = bit_u32(1),
+ DeadTransaction = bit_u32(2),
+ OpenClose = bit_u32(3),
+ DeadBinder = bit_u32(4),
+ DeathNotification = bit_u32(5),
+ ReadWrite = bit_u32(6),
+ UserRefs = bit_u32(7),
+ Threads = bit_u32(8),
+ Transaction = bit_u32(9),
+ TransactionComplete = bit_u32(10),
+ FreeBuffer = bit_u32(11),
+ InternalRefs = bit_u32(12),
+ PriorityCap = bit_u32(13),
+ Spinlocks = bit_u32(14),
+ }
+);
+
+#[no_mangle]
+pub(crate) static rust_binder_debug_mask: Atomic<u32> = Atomic::new(
+ (DebugMask::UserError as u32)
+ | (DebugMask::FailedTransaction as u32)
+ | (DebugMask::DeadTransaction as u32),
+);
+
+/// Checks if the given debug logging category is enabled in the mask.
+pub(crate) fn debug_mask_enabled(mask: DebugMask) -> bool {
+ let current_mask = rust_binder_debug_mask.load(kernel::sync::atomic::Relaxed);
+ DebugMasks(current_mask).contains(mask)
+}
+
+/// Prints a debug log if the specified mask category is enabled.
+#[macro_export]
+macro_rules! binder_debug {
+ // Rule to explicitly specify a PID (used in kworkers).
+ (pid=$pid:expr, $mask:ident, $($arg:tt)*) => {
+ if $crate::debug::debug_mask_enabled($crate::debug::DebugMask::$mask) {
+ kernel::pr_info!(
+ "{}: {}\n",
+ $pid,
+ kernel::prelude::fmt!($($arg)*)
+ );
+ }
+ };
+
+ // Default rule (automatically prepends "PID:TID" of the current calling thread).
+ ($mask:ident, $($arg:tt)*) => {
+ if $crate::debug::debug_mask_enabled($crate::debug::DebugMask::$mask) {
+ let thread = kernel::current!();
+ kernel::pr_info!(
+ "{}:{} {}\n",
+ thread.tgid(),
+ thread.pid(),
+ kernel::prelude::fmt!($($arg)*)
+ );
+ }
+ };
+}