On 1/13/26 5:43 AM, Gary Guo wrote:
> On Wed Dec 3, 2025 at 5:58 AM GMT, John Hubbard wrote:
...
>> +impl Architecture {
>> + /// Returns the number of DMA address bits supported by this
>> architecture.
>> + ///
>> + /// Hopper and Blackwell support 52-bit DMA addresses, while earlier
>> architectures
>> + /// (Turing, Ampere, Ada) support 47-bit DMA addresses.
>> + pub(crate) const fn dma_addr_bits(&self) -> u32 {
>
> How about just return `DmaMask` from here? This get rids of the fallible
> constructor call of `DmaMask`.
Yes, that's a nice touch, I'll do that.
>
>> + match self {
>> + Self::Turing | Self::Ampere | Self::Ada => 47,
>> + Self::Hopper | Self::Blackwell => 52,
>> + }
>> + }
>> +}
>> +
>> impl TryFrom<u8> for Architecture {
>> type Error = Error;
>>
>> @@ -203,6 +216,20 @@ pub(crate) struct Spec {
>> revision: Revision,
>> }
>>
>> +/// Reads the GPU architecture from BAR0 registers.
>> +///
>> +/// This is a lightweight check used early in probe to determine the
>> correct DMA address width
>> +/// before the full [`Spec`] is constructed.
>> +pub(crate) fn read_architecture(bar: &Bar0) -> Result<Architecture> {
>> + let boot0 = regs::NV_PMC_BOOT_0::read(bar);
>> +
>> + if boot0.is_older_than_fermi() {
>> + return Err(ENODEV);
>> + }
>> +
>> + regs::NV_PMC_BOOT_42::read(bar).architecture()
>
> Can this just be `Spec::new`?
Yes it can. I've fixed it locally, to do Spec::new() early and pass
the Spec into Gpu::new(), and it does result in less code here. Good.
thanks,
--
John Hubbard