On Tue, Nov 09, 2021 at 10:51:33AM -0800, matthew.gerlach@xxxxxxxxxxxxxxx wrote: > > > On Tue, 9 Nov 2021, Tom Rix wrote: > > > > > On 11/9/21 10:05 AM, Andy Shevchenko wrote: > > > On Tue, Nov 09, 2021 at 07:55:43AM -0800, Tom Rix wrote: > > > > On 11/9/21 7:41 AM, Andy Shevchenko wrote: > > > > > Currently the find_dfls_by_vsec() opens code pci_find_vsec_capability(). > > > > > Refactor the former to use the latter. No functional change intended. > > > Thanks for review, my answers below. > > > > > > ... > > > > > > > > + u16 voff; > > > > The later use of voff in pci_read_config_dword is of type 'int', it may be > > > > better to keep voff as an int. > > > I don't think so. The rule of thumb that the types should match the > > > value they > > > got in the first place. In this case it's u16. Compiler will > > > implicitly cast it > > > to whatever is needed as long as the type is good for integer promotion. > > > > > I think u16 is more precise than int, but I think it'll get promoted to an > int anywhen when used with calls to pci_read_config_dword(). Was this I agree u16 is OK. A minor concern, is it better we also change the dfl_res_off to u16? dfl_res_off & voff are the same type of variables needed on positioning the DFL, so I'd like them listed together. > change tested on real or emulated HW? > > > > ... > > > > > > > > + voff = pci_find_vsec_capability(dev, PCI_VENDOR_ID_INTEL, > > > > > PCI_VSEC_ID_INTEL_DFLS); > > > > This may be a weakness in the origin code, but intel isn't the exclusive > > > > user of DFL. > > > This does not change the original code. If you think so, this can be > > > extended > > > later on. > > > > I would rather see this fixed now or explained why this isn't a problem. > > I agree that a single Vendor/VSEC id being supported is a problem, but I > think fixing it should be a separate patch. Do we need to change this a I agree. The vendor_id should be checked before VSEC ID is meaningful, and now this Vendor/VSEC pair is the only supported one, so this piece of code is good to me. > table lookup of Vendor/VSEC id's, or do we need to reserve a more generic > Vendor/VSEC pair? A generic Vendor/VSEC pair means all vendors must use the unified vendor_id if they want to use DFL. I'm not sure if this is proper. Thanks, Yilun > > > > > Tom > > > > > > > > > > if (!voff) { > > > > > dev_dbg(&pcidev->dev, "%s no DFL VSEC found\n", __func__); > > > > > return -ENODEV; > > > >