From: Matthew Rosato <mjrosato@linux.ibm.com>
To: Eric Farman <farman@linux.ibm.com>, Halil Pasic <pasic@linux.ibm.com>
Cc: Heiko Carstens <hca@linux.ibm.com>,
Vasily Gorbik <gor@linux.ibm.com>,
Alexander Gordeev <agordeev@linux.ibm.com>,
Christian Borntraeger <borntraeger@linux.ibm.com>,
Sven Schnelle <svens@linux.ibm.com>,
Vineeth Vijayan <vneethv@linux.ibm.com>,
Peter Oberparleiter <oberpar@linux.ibm.com>,
linux-s390@vger.kernel.org, kvm@vger.kernel.org
Subject: Re: [PATCH v1 06/16] vfio/ccw: simplify CCW chain fetch routines
Date: Thu, 15 Dec 2022 16:18:26 -0500 [thread overview]
Message-ID: <dd84e145-84ba-04d7-717f-d106d20d5bf7@linux.ibm.com> (raw)
In-Reply-To: <20221121214056.1187700-7-farman@linux.ibm.com>
On 11/21/22 4:40 PM, Eric Farman wrote:
> The act of processing a fetched CCW has two components:
>
> 1) Process a Transfer-in-channel (TIC) CCW
> 2) Process any other CCW
>
> The former needs to look at whether the TIC jumps backwards into
> the current channel program or forwards into a new one segment,
unnecessary word 'one'?
> while the latter just processes the CCW data address itself.
>
> Rather than passing the chain segment and index within it to the
> handlers for the above, and requiring each to calculate the
> elements it needs, simply pass the needed pointers directly.
>
> For the TIC, that means the CCW being processed and the location
> of the entire channel program which holds all segments. For the
> other CCWs, the page_array pointer is also needed to perform the
> page pinning, etc.
>
> While at it, rename ccwchain_fetch_direct to _ccw, to indicate
> what it is. The name "_direct" is historical, when it used to
> process a direct-addressed CCW, but IDAs are processed here too.
>
> Signed-off-by: Eric Farman <farman@linux.ibm.com>
Reviewed-by: Matthew Rosato <mjrosato@linux.ibm.com>
> ---
> drivers/s390/cio/vfio_ccw_cp.c | 33 +++++++++++++++------------------
> 1 file changed, 15 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/s390/cio/vfio_ccw_cp.c b/drivers/s390/cio/vfio_ccw_cp.c
> index 1eacbb8dc860..d41d94cecdf8 100644
> --- a/drivers/s390/cio/vfio_ccw_cp.c
> +++ b/drivers/s390/cio/vfio_ccw_cp.c
> @@ -482,11 +482,9 @@ static int ccwchain_loop_tic(struct ccwchain *chain, struct channel_program *cp)
> return 0;
> }
>
> -static int ccwchain_fetch_tic(struct ccwchain *chain,
> - int idx,
> +static int ccwchain_fetch_tic(struct ccw1 *ccw,
> struct channel_program *cp)
> {
> - struct ccw1 *ccw = chain->ch_ccw + idx;
> struct ccwchain *iter;
> u32 ccw_head;
>
> @@ -502,14 +500,12 @@ static int ccwchain_fetch_tic(struct ccwchain *chain,
> return -EFAULT;
> }
>
> -static int ccwchain_fetch_direct(struct ccwchain *chain,
> - int idx,
> - struct channel_program *cp)
> +static int ccwchain_fetch_ccw(struct ccw1 *ccw,
> + struct page_array *pa,
> + struct channel_program *cp)
> {
> struct vfio_device *vdev =
> &container_of(cp, struct vfio_ccw_private, cp)->vdev;
> - struct ccw1 *ccw;
> - struct page_array *pa;
> u64 iova;
> unsigned long *idaws;
> int ret;
> @@ -517,8 +513,6 @@ static int ccwchain_fetch_direct(struct ccwchain *chain,
> int idaw_nr, idal_len;
> int i;
>
> - ccw = chain->ch_ccw + idx;
> -
> if (ccw->count)
> bytes = ccw->count;
>
> @@ -548,7 +542,6 @@ static int ccwchain_fetch_direct(struct ccwchain *chain,
> * required for the data transfer, since we only only support
> * 4K IDAWs today.
> */
> - pa = chain->ch_pa + idx;
> ret = page_array_alloc(pa, iova, bytes);
> if (ret < 0)
> goto out_free_idaws;
> @@ -604,16 +597,15 @@ static int ccwchain_fetch_direct(struct ccwchain *chain,
> * and to get rid of the cda 2G limitiaion of ccw1, we'll translate
> * direct ccws to idal ccws.
> */
> -static int ccwchain_fetch_one(struct ccwchain *chain,
> - int idx,
> +static int ccwchain_fetch_one(struct ccw1 *ccw,
> + struct page_array *pa,
> struct channel_program *cp)
> -{
> - struct ccw1 *ccw = chain->ch_ccw + idx;
>
> +{
> if (ccw_is_tic(ccw))
> - return ccwchain_fetch_tic(chain, idx, cp);
> + return ccwchain_fetch_tic(ccw, cp);
>
> - return ccwchain_fetch_direct(chain, idx, cp);
> + return ccwchain_fetch_ccw(ccw, pa, cp);
> }
>
> /**
> @@ -736,6 +728,8 @@ void cp_free(struct channel_program *cp)
> int cp_prefetch(struct channel_program *cp)
> {
> struct ccwchain *chain;
> + struct ccw1 *ccw;
> + struct page_array *pa;
> int len, idx, ret;
>
> /* this is an error in the caller */
> @@ -745,7 +739,10 @@ int cp_prefetch(struct channel_program *cp)
> list_for_each_entry(chain, &cp->ccwchain_list, next) {
> len = chain->ch_len;
> for (idx = 0; idx < len; idx++) {
> - ret = ccwchain_fetch_one(chain, idx, cp);
> + ccw = chain->ch_ccw + idx;
> + pa = chain->ch_pa + idx;
> +
> + ret = ccwchain_fetch_one(ccw, pa, cp);
> if (ret)
> goto out_err;
> }
next prev parent reply other threads:[~2022-12-15 21:19 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-21 21:40 [PATCH v1 00/16] vfio/ccw: channel program cleanup Eric Farman
2022-11-21 21:40 ` [PATCH v1 01/16] vfio/ccw: cleanup some of the mdev commentary Eric Farman
2022-11-22 16:12 ` Matthew Rosato
2022-11-21 21:40 ` [PATCH v1 02/16] vfio/ccw: simplify the cp_get_orb interface Eric Farman
2022-11-22 16:13 ` Matthew Rosato
2022-11-21 21:40 ` [PATCH v1 03/16] vfio/ccw: allow non-zero storage keys Eric Farman
2022-12-15 20:55 ` Matthew Rosato
2022-11-21 21:40 ` [PATCH v1 04/16] vfio/ccw: move where IDA flag is set in ORB Eric Farman
2022-12-15 20:55 ` Matthew Rosato
2022-11-21 21:40 ` [PATCH v1 05/16] vfio/ccw: replace copy_from_iova with vfio_dma_rw Eric Farman
2022-11-22 1:41 ` Jason Gunthorpe
2022-12-15 20:59 ` Matthew Rosato
2022-11-21 21:40 ` [PATCH v1 06/16] vfio/ccw: simplify CCW chain fetch routines Eric Farman
2022-12-15 21:18 ` Matthew Rosato [this message]
2022-11-21 21:40 ` [PATCH v1 07/16] vfio/ccw: remove unnecessary malloc alignment Eric Farman
2022-12-16 20:10 ` Matthew Rosato
2022-12-19 16:22 ` Eric Farman
2022-11-21 21:40 ` [PATCH v1 08/16] vfio/ccw: pass page count to page_array struct Eric Farman
2022-12-16 19:59 ` Matthew Rosato
2022-12-19 16:22 ` Eric Farman
2022-11-21 21:40 ` [PATCH v1 09/16] vfio/ccw: populate page_array struct inline Eric Farman
2022-12-16 21:05 ` Matthew Rosato
2022-11-21 21:40 ` [PATCH v1 10/16] vfio/ccw: refactor the idaw counter Eric Farman
2022-12-19 19:16 ` Matthew Rosato
2022-12-19 19:31 ` Eric Farman
2022-12-19 19:40 ` Matthew Rosato
2022-11-21 21:40 ` [PATCH v1 11/16] vfio/ccw: discard second fmt-1 IDAW Eric Farman
2022-12-19 19:27 ` Matthew Rosato
2022-12-19 20:27 ` Eric Farman
2022-11-21 21:40 ` [PATCH v1 12/16] vfio/ccw: calculate number of IDAWs regardless of format Eric Farman
2022-12-19 19:49 ` Matthew Rosato
2022-11-21 21:40 ` [PATCH v1 13/16] vfio/ccw: allocate/populate the guest idal Eric Farman
2022-12-19 20:14 ` Matthew Rosato
2022-12-19 21:00 ` Eric Farman
2022-11-21 21:40 ` [PATCH v1 14/16] vfio/ccw: handle a guest Format-1 IDAL Eric Farman
2022-12-19 20:29 ` Matthew Rosato
2022-12-19 21:04 ` Eric Farman
2022-11-21 21:40 ` [PATCH v1 15/16] vfio/ccw: don't group contiguous pages on 2K IDAWs Eric Farman
2022-12-19 20:40 ` Matthew Rosato
2022-11-21 21:40 ` [PATCH v1 16/16] vfio/ccw: remove old IDA format restrictions Eric Farman
2022-12-19 20:44 ` Matthew Rosato
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=dd84e145-84ba-04d7-717f-d106d20d5bf7@linux.ibm.com \
--to=mjrosato@linux.ibm.com \
--cc=agordeev@linux.ibm.com \
--cc=borntraeger@linux.ibm.com \
--cc=farman@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=oberpar@linux.ibm.com \
--cc=pasic@linux.ibm.com \
--cc=svens@linux.ibm.com \
--cc=vneethv@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox