linux/drivers/gpu/drm/xe/xe_pt_walk.h

/* SPDX-License-Identifier: GPL-2.0-only */
/*
 * Copyright © 2022 Intel Corporation
 */
#ifndef __XE_PT_WALK__
#define __XE_PT_WALK__

#include <linux/pagewalk.h>
#include <linux/types.h>

/**
 * struct xe_ptw - base class for driver pagetable subclassing.
 * @children: Pointer to an array of children if any.
 *
 * Drivers could subclass this, and if it's a page-directory, typically
 * embed an array of xe_ptw pointers.
 */
struct xe_ptw {};

/**
 * struct xe_pt_walk - Embeddable struct for walk parameters
 */
struct xe_pt_walk {};

/**
 * typedef xe_pt_entry_fn - gpu page-table-walk callback-function
 * @parent: The parent page.table.
 * @offset: The offset (number of entries) into the page table.
 * @level: The level of @parent.
 * @addr: The virtual address.
 * @next: The virtual address for the next call, or end address.
 * @child: Pointer to pointer to child page-table at this @offset. The
 * function may modify the value pointed to if, for example, allocating a
 * child page table.
 * @action: The walk action to take upon return. See <linux/pagewalk.h>.
 * @walk: The walk parameters.
 */
xe_pt_entry_fn;

/**
 * struct xe_pt_walk_ops - Walk callbacks.
 */
struct xe_pt_walk_ops {};

int xe_pt_walk_range(struct xe_ptw *parent, unsigned int level,
		     u64 addr, u64 end, struct xe_pt_walk *walk);

int xe_pt_walk_shared(struct xe_ptw *parent, unsigned int level,
		      u64 addr, u64 end, struct xe_pt_walk *walk);

/**
 * xe_pt_covers - Whether the address range covers an entire entry in @level
 * @addr: Start of the range.
 * @end: End of range + 1.
 * @level: Page table level.
 * @walk: Page table walk info.
 *
 * This function is a helper to aid in determining whether a leaf page table
 * entry can be inserted at this @level.
 *
 * Return: Whether the range provided covers exactly an entry at this level.
 */
static inline bool xe_pt_covers(u64 addr, u64 end, unsigned int level,
				const struct xe_pt_walk *walk)
{}

/**
 * xe_pt_num_entries: Number of page-table entries of a given range at this
 * level
 * @addr: Start address.
 * @end: End address.
 * @level: Page table level.
 * @walk: Walk info.
 *
 * Return: The number of page table entries at this level between @start and
 * @end.
 */
static inline pgoff_t
xe_pt_num_entries(u64 addr, u64 end, unsigned int level,
		  const struct xe_pt_walk *walk)
{}

/**
 * xe_pt_offset: Offset of the page-table entry for a given address.
 * @addr: The address.
 * @level: Page table level.
 * @walk: Walk info.
 *
 * Return: The page table entry offset for the given address in a
 * page table with size indicated by @level.
 */
static inline pgoff_t
xe_pt_offset(u64 addr, unsigned int level, const struct xe_pt_walk *walk)
{}

#endif