[PATCH 1/4] iov_iter: Provide copy_iomem_to|from_iter()

Matthew Wilcox willy at infradead.org
Thu Nov 7 20:13:55 UTC 2024


On Thu, Nov 07, 2024 at 05:34:45PM +0100, Michal Wajdeczko wrote:
> +size_t copy_iomem_to_iter(const void __iomem *from, size_t offset,
> +			  size_t bytes, struct iov_iter *i)
> +{
> +	unsigned char buf[SMP_CACHE_BYTES];
> +	size_t progress = 0, copied, len;
> +
> +	from += offset;
> +	while (bytes) {
> +		len = min(bytes, sizeof(buf));
> +		memcpy_fromio(buf, from + progress, len);
> +		copied = _copy_to_iter(buf, len, i);
> +		if (!copied)
> +			break;
> +		bytes -= copied;
> +		progress += copied;
> +	}

This seems like a rather sad implementation.  Why not:

	if (WARN_ON_ONCE(i->data_source))
		return 0;
	if (user_backed_iter(i))
		might_fault();
	return iterate_and_advance(i, bytes, (void *)addr,
			copy_iomem_to_iter, memcpy_iomem_to_iter);

along with

size_t memcpy_iomem_to_iter()
{
	memcpy_fromio(iter_to, from + progress, len);
	return 0;
}`


More information about the Intel-xe mailing list