From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) (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 BEF6A3451B2 for ; Fri, 20 Feb 2026 13:20:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771593640; cv=none; b=uHhf8zA7nQUCZNlxr/GhGYsxZjT4cTHT5Rte1P13TrnltbVlAgWOqekqirW+ktaZGzdeO6lEk/Q+S3bLL2wRXTW+R3UEnQ7xtXmzFcHr/qGqFLnxoVtNwqpalJV8MGgxIZygJo1lKdeMeJhIcBl8YXZDq6egkN2Qko2R3PH6XUA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771593640; c=relaxed/simple; bh=wuvRQXlCRLuwIsSmpqcRNATCL2TV0Dnk15w9Ychvgbs=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Z/UGCDkGSciKyETGtpW5SZ5pUM8jHB2m7eTOd0E8ZQ6DwNUozr/Pygpk/Ks7pAUJ+2AKYA06JTC0wb612tYqfijsIvR5bXNVMPiKj0ygdFhfErz51FER72RA99i8mukXi8hdGQqc5S9ZzGv9LAzAH0+BGAH9tJrqxmvGr4mzoV0= 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=nLOFozTw; arc=none smtp.client-ip=209.85.221.45 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="nLOFozTw" Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-4362507f396so2082334f8f.0 for ; Fri, 20 Feb 2026 05:20:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1771593637; x=1772198437; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=yisxG46a/j9NykTgwbDnRnNT6I9RQR5YNqufY/coaEE=; b=nLOFozTwMyShuy0rrOpCiAs1fhqIagmnGl8B60gLA0/gZZGiGIEZN6nsdxATCb1+kd NyiFkkWaYswVnwNw6ptYjiCwp4mIs+7IJ3cn3LLekiy6fu8okhgP0/y/F/NY4wTprjqJ 6pYo0SkGl0ddq10K3NOFhTi59uH2auQCGT0Ubz9cLbFxBFHLb7ZicrSlAiiCA/J65EAf 8CjVy9XuD6PWm05cEQRr958ohRWSen/tNbhlkInIyax2ux/vx0173BvvM9510OkccDap TBmm4p5J7ldtxRkPeNlpjRKLyQUwdKG23XaNbdo1U+NYAtYhYr/OYXW6iCgX5+F34wdU B9sQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771593637; x=1772198437; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=yisxG46a/j9NykTgwbDnRnNT6I9RQR5YNqufY/coaEE=; b=PHbV45YWQ8Bkq8HZJ8UNNN68+Qb9r+qmAyQHvxSxoSlIWEDU3o2CtaqkQOrkeIlRvV 1F68dXixWEqb9wcahnGkYGJ5lv/K5bON5h2y8+HjjBCE2eXUWwBK4esHECwOFgVoBOCg V+GLGlB9WIRFbjm7+D/r0kUybKCOzRc37YU728znHz5cIImFNOOZMj1aILftB69BUdmE Zesa6TaP2vxVWz/STMDI/8gyt/+dqn7ZcixBPwDc8rsTgweozhu74trq3i6jqMhRTnPE dIwcweRpYsKr59wOhhnG0LC3WyAV9SfqhVgoC89ZqoWvP+nYerDjBDdBDD7FtOWmN25R r9qg== X-Forwarded-Encrypted: i=1; AJvYcCW4rOLzeOqtyA8zrHpqdl9qdcD1jmp+oL7Pm+u0czElULXtsLdu+JWXXQHI6K6VZpriWiNhHVtGVsPl0JA=@vger.kernel.org X-Gm-Message-State: AOJu0YwaCKpM6TyEwwgfcYNTgbK7VnhNksjqz9XkNaNeymE0VssuItKC n716zly7b2nsO+a/k4/9Aiy5wG4m9T+cL49O0nw9Ih4a1cXOLgUvaHzY X-Gm-Gg: AZuq6aL03zVU1QbCBAbsm4Hd42+p0VuW9s7OZX/xE+j1jidSdzmuuXVsxQnSllUDe7f 1sUHEvX6cZFagTZMXMZnl2mK10qZlKM2aoDYDH47qmMOO26DniuTaGk4T3uVElJvalmmNFtWOKZ 6nIs534r2TAM7UdO+bv5DZn5K/1867I4FMlg+dNicsU0FlolmD01HVFjWnHLFXPKPyX4NQ9fbZA wSIxwXVWiBmwM28+uwhTJAW8OA8pmSqUGNshM1xOG99/K8tiVlXypCB3xKB2ANxWh6IHMDxFQFn urUmEBKag7M+cke07MYJphvVaZsOT8WbryQHFCJsL4olaevtZ8UNLT6LhbnCmO4c9aUaZymnzYW bsKEaIuIQpjQWJTQcsSm4prGMGWykbXmZr+GIlZfwCyPBNZsgxItBVz9HKjzpUTHOMTnALATZPc MFJ0L58Zle4FYLMEhkAgqFT18nE+VI6hYzurHEOXaejb4f67Jl3yGlgauH7R6HnktJImhwseTJk ey1cAesmBdOKjzuAEgmTasRtOrZQSuYWLPfi7Sx3nwj/0MCMinI+BSbSQ== X-Received: by 2002:a05:6000:400e:b0:435:9882:234e with SMTP id ffacd0b85a97d-43958e58315mr15302003f8f.59.1771593636717; Fri, 20 Feb 2026 05:20:36 -0800 (PST) Received: from ?IPV6:2003:df:bf29:9000:7fb1:1192:aeeb:ca3f? (p200300dfbf2990007fb11192aeebca3f.dip0.t-ipconnect.de. [2003:df:bf29:9000:7fb1:1192:aeeb:ca3f]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43796a5acaasm51063862f8f.6.2026.02.20.05.20.35 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 20 Feb 2026 05:20:36 -0800 (PST) Message-ID: Date: Fri, 20 Feb 2026 14:20:34 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v6 0/9] rust: add `register!` macro To: Alexandre Courbot , Danilo Krummrich , Alice Ryhl , Daniel Almeida , Miguel Ojeda , Gary Guo , =?UTF-8?Q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Trevor Gross , Boqun Feng Cc: Yury Norov , John Hubbard , Alistair Popple , Joel Fernandes , Timur Tabi , Edwin Peer , Eliot Courtney , Dirk Behme , Steven Price , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org References: <20260216-register-v6-0-eec9a4de9e9e@nvidia.com> Content-Language: de-AT-frami, en-US From: Dirk Behme In-Reply-To: <20260216-register-v6-0-eec9a4de9e9e@nvidia.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Hi Alexandre, On 16.02.26 09:04, Alexandre Courbot wrote: > This new revision took some time because it is (yet another) overhaul. > ^_^; > > Thanks to a breakthrough by Gary, we found a way to have the I/O type > perform the actual I/O instead of the register type, which moves us from > this access pattern: > > let boot0 = regs::NV_PMC_BOOT_0::read(bar); > > to this arguably more natural one: > > let boot0 = bar.read(regs::NV_PMC_BOOT_0); > > It also has the benefit of taking advantage of deref coercion for types > that wrap an `Io`, something the register-based methods couldn't do and > which would have required extra `AsRef` implementations just for this > purpose. > > Furthermore, this resolves the inconsistency of the former register API > that couldn't use the `try_` I/O accessors (and even had methods whose > names clashed with them). Now if `Io` supports it, it can be done on a > register. > > Another benefit is that there is less work done within macros, and more > in generic code, which is (generally) a win for readability. The > `register!` macro is considerably smaller and easier to work on, and now > mostly made up of the bitfield accessors that will eventually be moved > into another macro. > > I decided to remove a couple of tags because the code has changed quite > a bit since they were obtained. Last time I gave this a try was with v2. From my aarch64 simple timer test on that version I have [1] below. Could you give a hint how to convert this to v6? :) Many thanks! Dirk [1] register!(TCR(u16) @ 0x10 { 9:9 icpf; 8:8 unf; 7:6 icpe; 5:5 unie; 4:3 ckeg; 2:0 tpsc; }); impl TCR { fn handle_underflow(io: &T) where T: Deref>, { let tcr = Self::read(io); if tcr.unf().into() { tcr.set_unf(false).write(io); } } } ... // Reset the underflow flag TCR::handle_underflow(io);