Messages in this thread | | | Date | Mon, 27 Apr 2020 15:18:25 -0700 | From | Fenghua Yu <> | Subject | Re: [PATCH 5/7] x86/mmu: Allocate/free PASID |
| |
On Sun, Apr 26, 2020 at 04:55:25PM +0200, Thomas Gleixner wrote: > Fenghua Yu <fenghua.yu@intel.com> writes: > > +++ b/arch/x86/include/asm/mmu.h @@ -50,6 +50,10 @@ typedef struct { > > u16 pkey_allocation_map; s16 execute_only_pkey; > > #endif > > + +#ifdef CONFIG_INTEL_IOMMU_SVM + int pasid; > > int? It's a value which gets programmed into the MSR along with the valid > bit (bit 31) set.
The pasid is defined as "int" in struct intel_svm and in intel_svm_bind_mm() and intel_svm_unbind_mm(). So the pasid defined in this patch follows the same type defined in those places.
But as you pointed out below, ioasid_t is defined as "unsigned int".
> > > extern void switch_mm(struct mm_struct *prev, struct mm_struct *next, > > diff --git a/drivers/iommu/intel-svm.c b/drivers/iommu/intel-svm.c > > index d7f2a5358900..da718a49e91e 100644 --- a/drivers/iommu/intel-svm.c > > +++ b/drivers/iommu/intel-svm.c @@ -226,6 +226,45 @@ static > > LIST_HEAD(global_svm_list); > > list_for_each_entry((sdev), &(svm)->devs, list) \ > > if ((d) != (sdev)->dev) {} else > > > > +/* + * If this mm already has a PASID we can use it. Otherwise > > allocate a new one. + * Let the caller know if we did an allocation via > > 'new_pasid'. + */ +static int alloc_pasid(struct intel_svm *svm, struct > > mm_struct *mm, + int pasid_max, bool *new_pasid, int flags) > > Again, data types please. flags are generally unsigned and not plain int. > Also pasid_max is certainly not plain int either.
The caller defines pasid_max and flags as "int". This function just follows the caller's definitions.
But I will change their definitions to "unsigned int" here.
> > > + *new_pasid = false; + + return mm->context.pasid; + } + + /* + * > > Allocate a new pasid. Do not use PASID 0, reserved for RID to + * > > PASID. + */ + pasid = ioasid_alloc(NULL, PASID_MIN, pasid_max - 1, > > svm); > > ioasid_alloc() uses ioasid_t which is > > typedef unsigned int ioasid_t; > > Can we please have consistent types and behaviour all over the place?
Should I just define "pasid", "pasid_max", "flags" as "unsigned int" for the new functions/code?
Or should I also change their types to "unsigned int" in the original svm code (struct intel_svm, ...bind_mm(), etc)? I'm afraid that will be a lot of changes and should be in a separate preparation patch.
Thanks.
-Fenghua
| |