On Fri, Mar 09, 2018 at 11:20:53AM +0100, Jean Delvare wrote:
> > +   else if (size & 0x8000)
> > +           bytes = (u64)(size & 0x7fff) << 10;
> > +   else if (size != 0x7fff)
> > +           bytes = (u64)size << 20;
> > +   else
> > +           bytes = (u64)get_unaligned((u32 *)&d[0x1C]) << 20;
> > +
> > +   dmi_memdev[nr].size = bytes;
> 
> I'm curious, do you really need to know the amount of memory to the
> byte? The SMBIOS specification itself does not support granularity
> under 1 kB. I would be very surprised if any machine running Linux
> today has memory modules under 1 MB. If storing in MB you wouldn't need
> a u64...

I got side-tracked reading the standard with the ancient ways
used to report size back in the day when kilobytes was a
plausible unit. So I wrote code that covers all the crazy
cases.  Persistant DIMMs have sizes measured in gigabytes.
I should stop worrying about "0" vs. "fffffff" and just treat
the old cases as errors and simplify the code to be:

        u32 mbytes;

        if (size == 0 || (size & 0x8000))
                mbytes = 0;
        if (size != 0x7fff)
                mbytes = size;
        else
                mbytes = get_unaligned((u32 *)&d[0x1C]);

Then I can use 32-bit throughout this and patch 5.

Thanks for the review.

-Tony
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm

Reply via email to