lkml.org 
[lkml]   [2023]   [Dec]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH v2 1/6] iommu/vt-d: Setup scalable mode context entry in probe path
From
On 12/12/23 1:38 AM, Jason Gunthorpe wrote:
> On Tue, Dec 05, 2023 at 09:21:58AM +0800, Lu Baolu wrote:
>> +/*
>> + * Get the PASID directory size for scalable mode context entry.
>> + * Value of X in the PDTS field of a scalable mode context entry
>> + * indicates PASID directory with 2^(X + 7) entries.
>> + */
>> +static unsigned long context_get_sm_pds(struct pasid_table *table)
>> +{
>> + unsigned long pds, max_pde;
>> +
>> + max_pde = table->max_pasid >> PASID_PDE_SHIFT;
>> + pds = find_first_bit(&max_pde, MAX_NR_PASID_BITS);
>> + if (pds < 7)
>> + return 0;
>> +
>> + return pds - 7;
> This seems like a convoluted way to write
> max(ilog2(table-max_pasid) - 7,0)
>
> ?

Yes. :-)

Something like,

max(ilog2(table->max_pasid >> PASID_PDE_SHIFT) - 7, 0)

Best regards,
baolu

\
 
 \ /
  Last update: 2023-12-12 06:39    [W:0.142 / U:1.664 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site