drivers/gpu/drm/xe/xe_sriov_pf_migration.c

Source file repositories/reference/linux-study-clean/drivers/gpu/drm/xe/xe_sriov_pf_migration.c

File Facts

System
Linux kernel
Corpus path
drivers/gpu/drm/xe/xe_sriov_pf_migration.c
Extension
.c
Size
9221 bytes
Lines
367
Domain
Driver Families
Bucket
drivers/gpu
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

while (consumed < len) {
			ret = xe_sriov_packet_read_single(xe, vfid, buf, len - consumed);
			if (ret == -ENODATA)
				break;
			if (ret < 0)
				return ret;

			consumed += ret;
			buf += ret;
		}
	}

	return consumed;
}

/**
 * xe_sriov_pf_migration_write() - Write migration data to the device.
 * @xe: the &xe_device
 * @vfid: the VF identifier
 * @buf: start address of userspace buffer
 * @len: requested write size from userspace
 *
 * Return: number of bytes that has been successfully written,
 *	   -errno on failure.
 */
ssize_t xe_sriov_pf_migration_write(struct xe_device *xe, unsigned int vfid,
				    const char __user *buf, size_t len)
{
	struct xe_sriov_migration_state *migration = pf_pick_migration(xe, vfid);
	ssize_t ret, produced = 0;

	xe_assert(xe, IS_SRIOV_PF(xe));

	scoped_cond_guard(mutex_intr, return -EINTR, &migration->lock) {
		while (produced < len) {
			ret = xe_sriov_packet_write_single(xe, vfid, buf, len - produced);
			if (ret < 0)
				return ret;

			produced += ret;
			buf += ret;
		}
	}

	return produced;
}

/**
 * xe_sriov_pf_migration_size() - Total size of migration data from all components within a device
 * @xe: the &xe_device
 * @vfid: the VF identifier (can't be 0)
 *
 * This function is for PF only.
 *
 * Return: total migration data size in bytes or a negative error code on failure.
 */
ssize_t xe_sriov_pf_migration_size(struct xe_device *xe, unsigned int vfid)
{
	size_t size = 0;
	struct xe_gt *gt;
	ssize_t ret;
	u8 gt_id;

	xe_assert(xe, IS_SRIOV_PF(xe));
	xe_assert(xe, vfid);

	for_each_gt(gt, xe, gt_id) {
		ret = xe_gt_sriov_pf_migration_size(gt, vfid);
		if (ret < 0)
			return ret;

		size += ret;
	}

	return size;
}

Annotation

Implementation Notes