Re: [RFC] media: atomisp: change copy_from_compatible to iov_iter

From: Andy Shevchenko

Date: Wed Apr 08 2026 - 10:33:38 EST


On Wed, Apr 08, 2026 at 05:25:39PM +0300, Andy Shevchenko wrote:
> On Wed, Apr 08, 2026 at 01:46:11PM +0000, Joshua Crofts wrote:
> > Since the atomisp driver concerns transferring video
> > data, it would probably be better to use an iov_iter
> > than copy_to_user calls (scatter-gather i/o and better
> > pointer safety). Per yesterday's emails, I'm sending an
> > an example of a function in atomisp_cmd.c where I've
> > implemented iov_iter usage.
> >
> > Note, this isn't a patch, more of a question whether this
> > style of changing the copy_to_user calls is valid (or if
> > I'm writing garbage code). I'd rather get your opinion
> > than submitting a patch first.

Sure, see below.

...

> > - ret = copy_to_user(config->data, asd->params.s3a_user_stat->data,
> > - asd->params.s3a_output_bytes);
> > - if (ret) {
> > - dev_err(isp->dev, "copy to user failed: copied %lu bytes\n",
> > - ret);
> > + ret = import_ubuf(ITER_DEST, (void __user *)config->data, asd->params.s3a_output_bytes, &iter);
> > + if (ret)
> > + return ret;
> > +
> > + if (copy_to_iter(asd->params.s3a_user_stat->data, asd->params.s3a_output_bytes, &iter) != asd->params.s3a_output_bytes)
> > return -EFAULT;
> > - }
>
> It doesn't change any architectural decision here. Basically you need to have
> s3a_output_bytes to be already iov_iter at this point. So, import_ubuf() has to
> happen somewhere else.

Brief grepping shows this

/*
* Intermediate buffers used to communicate data between
* CSS and user space.
*/
struct ia_css_3a_statistics *s3a_user_stat;

which suggests that iov_iter should be somewhere here, in the struct
atomisp_subdev_params. But you need to read much more code and get familiar
with this. I wouldn't expect any meaningful change by a few days, maybe by
a few weeks as this driver is quite complicated.

In any case, thanks into trying with this, will be very appreciated
when the task is logically finished.

--
With Best Regards,
Andy Shevchenko