Lines Matching defs:context
211 static inline void context_clear_pasid_enable(struct context_entry *context)
213 context->lo &= ~(1ULL << 11);
216 static inline bool context_pasid_enabled(struct context_entry *context)
218 return !!(context->lo & (1ULL << 11));
221 static inline void context_set_copied(struct context_entry *context)
223 context->hi |= (1ull << 3);
226 static inline bool context_copied(struct context_entry *context)
228 return !!(context->hi & (1ULL << 3));
231 static inline bool __context_present(struct context_entry *context)
233 return (context->lo & 1);
236 bool context_present(struct context_entry *context)
238 return context_pasid_enabled(context) ?
239 __context_present(context) :
240 __context_present(context) && !context_copied(context);
243 static inline void context_set_present(struct context_entry *context)
245 context->lo |= 1;
248 static inline void context_set_fault_enable(struct context_entry *context)
250 context->lo &= (((u64)-1) << 2) | 1;
253 static inline void context_set_translation_type(struct context_entry *context,
256 context->lo &= (((u64)-1) << 4) | 3;
257 context->lo |= (value & 3) << 2;
260 static inline void context_set_address_root(struct context_entry *context,
263 context->lo &= ~VTD_PAGE_MASK;
264 context->lo |= value & VTD_PAGE_MASK;
267 static inline void context_set_address_width(struct context_entry *context,
270 context->hi |= value & 7;
273 static inline void context_set_domain_id(struct context_entry *context,
276 context->hi |= (value & ((1 << 16) - 1)) << 8;
284 static inline void context_clear_entry(struct context_entry *context)
286 context->lo = 0;
287 context->hi = 0;
789 struct context_entry *context;
801 context = phys_to_virt(*entry & VTD_PAGE_MASK);
807 context = alloc_pgtable_page(iommu->node);
808 if (!context)
811 __iommu_flush_cache(iommu, (void *)context, CONTEXT_SIZE);
812 phy_addr = virt_to_phys((void *)context);
816 return &context[devfn];
977 struct context_entry *context;
982 context = iommu_context_addr(iommu, bus, devfn, 0);
983 if (context)
984 ret = context_present(context);
993 struct context_entry *context;
1000 context = iommu_context_addr(iommu, i, 0, 0);
1001 if (context)
1002 free_pgtable_page(context);
1007 context = iommu_context_addr(iommu, i, 0x80, 0);
1008 if (context)
1009 free_pgtable_page(context);
1898 /* free context mapping */
2092 * Get the PASID directory size for scalable mode context entry.
2093 * Value of X in the PDTS field of a scalable mode context entry
2109 * Set the RID_PASID field of a scalable mode context entry. The
2114 context_set_sm_rid2pasid(struct context_entry *context, unsigned long pasid)
2116 context->hi |= pasid & ((1 << 20) - 1);
2120 * Set the DTE(Device-TLB Enable) field of a scalable mode context
2123 static inline void context_set_sm_dte(struct context_entry *context)
2125 context->lo |= (1 << 2);
2129 * Set the PRE(Page Request Enable) field of a scalable mode context
2132 static inline void context_set_sm_pre(struct context_entry *context)
2134 context->lo |= (1 << 4);
2137 /* Convert value to context PASID directory size field coding. */
2148 struct context_entry *context;
2157 pr_debug("Set context mapping for %02x:%02x.%d\n",
2166 context = iommu_context_addr(iommu, bus, devfn, 1);
2167 if (!context)
2171 if (context_present(context))
2183 if (context_copied(context)) {
2184 u16 did_old = context_domain_id(context);
2196 context_clear_entry(context);
2205 context->lo = (u64)virt_to_phys(table->table) |
2209 context_set_sm_rid2pasid(context, PASID_RID2PASID);
2217 context_set_sm_dte(context);
2219 context_set_sm_pre(context);
2224 context_set_domain_id(context, did);
2244 context_set_address_root(context, virt_to_phys(pgd));
2245 context_set_address_width(context, agaw);
2252 context_set_address_width(context, iommu->msagaw);
2255 context_set_translation_type(context, translation);
2258 context_set_fault_enable(context);
2259 context_set_present(context);
2261 clflush_cache_range(context, sizeof(*context));
2554 struct context_entry *context;
2561 context = iommu_context_addr(iommu, bus, devfn, 0);
2562 if (!context) {
2566 did_old = context_domain_id(context);
2567 context_clear_entry(context);
2568 __iommu_flush_cache(iommu, context, sizeof(*context));
2812 dev_err(dev, "Domain context map failed\n");
3119 /* Now copy the context entry */
3130 * We need a marker for copied context entries. This
3132 * for extended context entries.
3134 * Bit 67 of the context entry is used. In the old
3205 pr_err("%s: Failed to copy context table for bus %d\n",
3397 * we could share the same root & context tables
3467 * global invalidate context cache
5915 struct context_entry *context;
5933 context = iommu_context_addr(iommu, info->bus, info->devfn, 0);
5934 if (WARN_ON(!context))
5937 ctx_lo = context[0].lo;
5941 context[0].lo = ctx_lo;