/* * On multi-tile devices, partition the BAR space for MMIO on each tile, * possibly accounting for register override on the number of tiles available. * tile_mmio_size contains both the tile's 4MB register space, as well as * additional space for the GTT and other (possibly unused) regions). * Resulting memory layout is like below: * * .----------------------. <- tile_count * tile_mmio_size * | .... | * |----------------------| <- 2 * tile_mmio_size * | tile1 GTT + other | * |----------------------| <- 1 * tile_mmio_size + 4MB * | tile1->mmio.regs | * |----------------------| <- 1 * tile_mmio_size * | tile0 GTT + other | * |----------------------| <- 4MB * | tile0->mmio.regs | * '----------------------' <- 0MB
*/ staticvoid mmio_multi_tile_setup(struct xe_device *xe, size_t tile_mmio_size)
{ struct xe_tile *tile; struct xe_gt *gt;
u8 id;
/* * Nothing to be done as tile 0 has already been setup earlier with the * entire BAR mapped - see xe_mmio_probe_early()
*/ if (xe->info.tile_count == 1) return;
/* Possibly override number of tile based on configuration register */ if (!xe->info.skip_mtcfg) { struct xe_mmio *mmio = xe_root_tile_mmio(xe);
u8 tile_count, gt_count;
u32 mtcfg;
/* * Although the per-tile mmio regs are not yet initialized, this * is fine as it's going to the root tile's mmio, that's * guaranteed to be initialized earlier in xe_mmio_probe_early()
*/
mtcfg = xe_mmio_read32(mmio, XEHP_MTCFG_ADDR);
tile_count = REG_FIELD_GET(TILE_COUNT, mtcfg) + 1;
/* * We've already setup gt_count according to the full * tile count. Re-calculate it to only include the GTs * that belong to the remaining tile(s).
*/
gt_count = 0;
for_each_gt(gt, xe, id) if (gt->info.id < tile_count * xe->info.max_gt_per_tile)
gt_count++;
xe->info.gt_count = gt_count;
}
}
/* * Map the entire BAR. * The first 16MB of the BAR, belong to the root tile, and include: * registers (0-4MB), reserved space (4MB-8MB) and GGTT (8MB-16MB).
*/
xe->mmio.size = pci_resource_len(pdev, GTTMMADR_BAR);
xe->mmio.regs = pci_iomap(pdev, GTTMMADR_BAR, 0); if (!xe->mmio.regs) {
drm_err(&xe->drm, "failed to map registers\n"); return -EIO;
}
/* Setup first tile; other tiles (if present) will be setup later. */
xe_mmio_init(&root_tile->mmio, root_tile, xe->mmio.regs, SZ_4M);
/** * xe_mmio_init() - Initialize an MMIO instance * @mmio: Pointer to the MMIO instance to initialize * @tile: The tile to which the MMIO region belongs * @ptr: Pointer to the start of the MMIO region * @size: The size of the MMIO region in bytes * * This is a convenience function for minimal initialization of struct xe_mmio.
*/ void xe_mmio_init(struct xe_mmio *mmio, struct xe_tile *tile, void __iomem *ptr, u32 size)
{
xe_tile_assert(tile, size <= XE_REG_ADDR_MAX);
/** * xe_mmio_read64_2x32() - Read a 64-bit register as two 32-bit reads * @mmio: MMIO target * @reg: register to read value from * * Although Intel GPUs have some 64-bit registers, the hardware officially * only supports GTTMMADR register reads of 32 bits or smaller. Even if * a readq operation may return a reasonable value, that violation of the * spec shouldn't be relied upon and all 64-bit register reads should be * performed as two 32-bit reads of the upper and lower dwords. * * When reading registers that may be changing (such as * counters), a rollover of the lower dword between the two 32-bit reads * can be problematic. This function attempts to ensure the upper dword has * stabilized before returning the 64-bit value. * * Note that because this function may re-read the register multiple times * while waiting for the value to stabilize it should not be used to read * any registers where read operations have side effects. * * Returns the value of the 64-bit register.
*/
u64 xe_mmio_read64_2x32(struct xe_mmio *mmio, struct xe_reg reg)
{ struct xe_reg reg_udw = { .addr = reg.addr + 0x4 };
u32 ldw, udw, oldudw, retries;
/** * xe_mmio_wait32() - Wait for a register to match the desired masked value * @mmio: MMIO target * @reg: register to read value from * @mask: mask to be applied to the value read from the register * @val: desired value after applying the mask * @timeout_us: time out after this period of time. Wait logic tries to be * smart, applying an exponential backoff until @timeout_us is reached. * @out_val: if not NULL, points where to store the last unmasked value * @atomic: needs to be true if calling from an atomic context * * This function polls for the desired masked value and returns zero on success * or -ETIMEDOUT if timed out. * * Note that @timeout_us represents the minimum amount of time to wait before * giving up. The actual time taken by this function can be a little more than * @timeout_us for different reasons, specially in non-atomic contexts. Thus, * it is possible that this function succeeds even after @timeout_us has passed.
*/ int xe_mmio_wait32(struct xe_mmio *mmio, struct xe_reg reg, u32 mask, u32 val, u32 timeout_us,
u32 *out_val, bool atomic)
{ return __xe_mmio_wait32(mmio, reg, mask, val, timeout_us, out_val, atomic, true);
}
/** * xe_mmio_wait32_not() - Wait for a register to return anything other than the given masked value * @mmio: MMIO target * @reg: register to read value from * @mask: mask to be applied to the value read from the register * @val: value not to be matched after applying the mask * @timeout_us: time out after this period of time * @out_val: if not NULL, points where to store the last unmasked value * @atomic: needs to be true if calling from an atomic context * * This function works exactly like xe_mmio_wait32() with the exception that * @val is expected not to be matched.
*/ int xe_mmio_wait32_not(struct xe_mmio *mmio, struct xe_reg reg, u32 mask, u32 val, u32 timeout_us,
u32 *out_val, bool atomic)
{ return __xe_mmio_wait32(mmio, reg, mask, val, timeout_us, out_val, atomic, false);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.