> From: Jason Gunthorpe <[email protected]>
> Sent: Friday, September 19, 2025 10:31 PM
> 
> On Fri, Sep 19, 2025 at 08:11:11AM +0000, Tian, Kevin wrote:
> > > Oh, pt_contig_count_lg2 didn't get kdocs because they are internal
> > > helpers to build other functions..
> > >
> > > Like this:
> > >
> > > /*
> > >  * If not supplied by the format then contiguous pages are not supported.
> > >  *
> > >  * If contiguous pages are supported then the format must also provide
> > >  * pt_contig_count_lg2() if it supports a single contiguous size per 
> > > level,
> > >  * or pt_possible_sizes() if it supports multiple sizes per level.
> >
> > could be simplified to require the format to always support
> pt_possible_sizes()
> > if contiguous sizes are supported, no matter being a single size or 
> > multiple.
> 
> I had that once, but it is a little more boiler plate/complex for the
> formats to write.
> 
> > hmm I didn't find ARM/RISCV defining pt_contig_count_lg2().
> 
> static inline unsigned short
> armv7s_pt_contig_count_lg2(const struct pt_state *pts)
> {
>       return ilog2(16);
> }
> #define pt_contig_count_lg2 armv7s_pt_contig_count_lg2
> 
> /* Number contigous entries that ARMV8PT_FMT_CONTIG will join at this
> level */
> static inline unsigned short
> armv8pt_contig_count_lg2(const struct pt_state *pts)
> {
>       if (PT_GRANULE_SIZE == SZ_4K)
>               return ilog2(16); /* 64KB, 32MB */
>       else if (PT_GRANULE_SIZE == SZ_16K && pts->level == 1)
>               return ilog2(32); /* 1GB */
>       else if (PT_GRANULE_SIZE == SZ_16K && pts->level == 0)
>               return ilog2(128); /* 2M */
>       else if (PT_GRANULE_SIZE == SZ_64K)
>               return ilog2(32); /* 2M, 16G */
>       return ilog2(1);
> }
> #define pt_contig_count_lg2 armv8pt_contig_count_lg2
> 
> And I missed switching riscv, fixed it into:
> 
> static inline unsigned short
> riscvpt_contig_count_lg2(const struct pt_state *pts)
> {
>       if (pts->level == 0 && pts_feature(pts,
> PT_FEAT_RSICV_SVNAPOT_64K))
>               return ilog2(16);
>       return ilog2(1);
> }
> #define pt_contig_count_lg2 riscvpt_contig_count_lg2
> 

oh, yes. I looked at the iommu_pt_vtd branch which doesn't
include all the bits.

Reply via email to