On 2022-12-09 at 13:45:22 -0800, matthew.gerlach@xxxxxxxxxxxxxxx wrote: > From: Matthew Gerlach <matthew.gerlach@xxxxxxxxxxxxxxx> [...] > /* > * when create sub feature instances, for private features, it doesn't need > * to provide resource size and feature id as they could be read from DFH > @@ -1023,39 +1125,69 @@ static int > create_feature_instance(struct build_feature_devs_info *binfo, > resource_size_t ofst, resource_size_t size, u16 fid) > { > - unsigned int irq_base, nr_irqs; > struct dfl_feature_info *finfo; > + resource_size_t start, end; > + int dfh_psize = 0; > u8 revision = 0; > + u64 v, addr_off; > + u8 dfh_ver = 0; > int ret; > - u64 v; > > if (fid != FEATURE_ID_AFU) { > v = readq(binfo->ioaddr + ofst); > revision = FIELD_GET(DFH_REVISION, v); > - > + dfh_ver = FIELD_GET(DFH_VERSION, v); > /* read feature size and id if inputs are invalid */ > size = size ? size : feature_size(v); > fid = fid ? fid : feature_id(v); > + if (dfh_ver == 1) { > + dfh_psize = dfh_get_psize(binfo->ioaddr + ofst, size); > + if (dfh_psize < 0) { > + dev_err(binfo->dev, > + "failed to read size of DFHv1 parameters %d\n", > + dfh_psize); > + return dfh_psize; > + } > + dev_dbg(binfo->dev, "dfhv1_psize %d\n", dfh_psize); > + } > } > > if (binfo->len - ofst < size) > return -EINVAL; > > - ret = parse_feature_irqs(binfo, ofst, fid, &irq_base, &nr_irqs); > - if (ret) > - return ret; > - > - finfo = kzalloc(sizeof(*finfo), GFP_KERNEL); > + finfo = kzalloc(sizeof(*finfo) + dfh_psize, GFP_KERNEL); Please use size_add(). See Documentation/process/deprecated.rst for details. Others look good to me. Yilun