Re: [PATCH v2 5/9] vfio-ccw: Rearrange pfn_array and pfn_array_table arrays

Cornelia Huck
2019-06-13T16:02:36Z

On Thu, 6 Jun 2019 22:28:27 +0200
Eric Farman <farman@linux.ibm.com> wrote:

> While processing a channel program, we currently have two nested
> arrays that carry a slightly different structure. The direct CCW
> path creates this:
>
> ccwchain->pfn_array_table[1]->pfn_array[#pages]
>
> while an IDA CCW creates:
>
> ccwchain->pfn_array_table[#idaws]->pfn_array[1]
>
> The distinction appears to state that each pfn_array_table entry
> points to an array of contiguous pages, represented by a pfn_array,
> um, array. Since the direct-addressed scenario can ONLY represent
> contiguous pages, it makes the intermediate array necessary but
> difficult to recognize. Meanwhile, since an IDAL can contain
> non-contiguous pages and there is no logic in vfio-ccw to detect
> adjacent IDAWs, it is the second array that is necessary but appearing
> to be superfluous.
>
> I am not aware of any documentation that states the pfn_array[] needs
> to be of contiguous pages; it is just what the code does today.
> I don't see any reason for this either, let's just flip the IDA
> codepath around so that it generates:
>
> ch_pat->pfn_array_table[1]->pfn_array[#idaws]
>
> This will bring it in line with the direct-addressed codepath,
> so that we can understand the behavior of this memory regardless
> of what type of CCW is being processed. And it means the casual
> observer does not need to know/care whether the pfn_array[]
> represents contiguous pages or not.
>
> NB: The existing vfio-ccw code only supports 4K-block Format-2 IDAs,
> so that "#pages" == "#idaws" in this area. This means that we will
> have difficulty with this overlap in terminology if support for
> Format-1 or 2K-block Format-2 IDAs is ever added. I don't think that
> this patch changes our ability to make that distinction.

I agree; and knowing that later patches will simplify things further, I
think it will even be easier to do than on the current code base.

>
> Signed-off-by: Eric Farman <farman@linux.ibm.com>
> ---
> drivers/s390/cio/vfio_ccw_cp.c | 26 +++++++++++---------------
> 1 file changed, 11 insertions(+), 15 deletions(-)

Reviewed-by: Cornelia Huck <cohuck@redhat.com>