All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cornelia Huck <cohuck@redhat.com>
To: Pierre Morel <pmorel@linux.ibm.com>
Cc: kvm@vger.kernel.org, frankja@linux.ibm.com, david@redhat.com,
	thuth@redhat.com, imbrenda@linux.ibm.com
Subject: Re: [kvm-unit-tests PATCH v3 3/5] s390x: css: implementing Set CHannel Monitor
Date: Tue, 23 Feb 2021 14:22:19 +0100	[thread overview]
Message-ID: <20210223142219.0f42a303.cohuck@redhat.com> (raw)
In-Reply-To: <1613669204-6464-4-git-send-email-pmorel@linux.ibm.com>

On Thu, 18 Feb 2021 18:26:42 +0100
Pierre Morel <pmorel@linux.ibm.com> wrote:

> We implement the call of the Set CHannel Monitor instruction,
> starting the monitoring of the all Channel Sub System, and
> initializing channel subsystem monitoring.
> 
> Initial tests report the presence of the extended measurement block
> feature, and verify the error reporting of the hypervisor for SCHM.
> 
> Signed-off-by: Pierre Morel <pmorel@linux.ibm.com>
> ---
>  lib/s390x/css.h     |  21 +++++++++-
>  lib/s390x/css_lib.c | 100 ++++++++++++++++++++++++++++++++++++++++++++
>  s390x/css.c         |  35 ++++++++++++++++
>  3 files changed, 155 insertions(+), 1 deletion(-)

(...)

> diff --git a/lib/s390x/css_lib.c b/lib/s390x/css_lib.c
> index 65b58ff..4c8a6ae 100644
> --- a/lib/s390x/css_lib.c
> +++ b/lib/s390x/css_lib.c
> @@ -265,6 +265,106 @@ retry:
>  	return -1;
>  }
>  
> +/*
> + * schib_update_mb: update the subchannel Mesurement Block

s/Mesurement/Measurement/

I guess that one is hard to get out of one's fingers :)

> + * @schid: Subchannel Identifier
> + * @mb   : 64bit address of the measurement block
> + * @mbi : the measurement block offset
> + * @flags : PMCW_MBUE to enable measurement block update
> + *	    PMCW_DCTME to enable device connect time
> + *	    0 to disable measurement
> + * @format1: set if format 1 is to be used
> + */
> +static bool schib_update_mb(int schid, uint64_t mb, uint16_t mbi,
> +			    uint16_t flags, bool format1)
> +{
> +	struct pmcw *pmcw = &schib.pmcw;
> +	int cc;
> +
> +	/* Read the SCHIB for this subchannel */
> +	cc = stsch(schid, &schib);
> +	if (cc) {
> +		report_info("stsch: sch %08x failed with cc=%d", schid, cc);
> +		return false;
> +	}
> +
> +	/* Update the SCHIB to enable the measurement block */
> +	if (flags) {
> +		pmcw->flags |= flags;
> +
> +		if (format1)
> +			pmcw->flags2 |= PMCW_MBF1;
> +		else
> +			pmcw->flags2 &= ~PMCW_MBF1;
> +
> +		pmcw->mbi = mbi;
> +		schib.mbo = mb;
> +	} else {
> +		pmcw->flags &= ~(PMCW_MBUE | PMCW_DCTME);
> +	}
> +
> +	/* Tell the CSS we want to modify the subchannel */
> +	cc = msch(schid, &schib);
> +	if (cc) {
> +		/*
> +		 * If the subchannel is status pending or
> +		 * if a function is in progress,
> +		 * we consider both cases as errors.
> +		 */
> +		report_info("msch: sch %08x failed with cc=%d", schid, cc);
> +		return false;
> +	}
> +
> +	/*
> +	 * Read the SCHIB again
> +	 */
> +	cc = stsch(schid, &schib);
> +	if (cc) {
> +		report_info("stsch: updating sch %08x failed with cc=%d",
> +			    schid, cc);
> +		return false;
> +	}
> +
> +	return true;
> +}
> +
> +/*
> + * css_enable_mb: enable the subchannel Mesurement Block

s/Mesurement/Measurement/

> + * @schid: Subchannel Identifier
> + * @mb   : 64bit address of the measurement block
> + * @format1: set if format 1 is to be used
> + * @mbi : the measurement block offset
> + * @flags : PMCW_MBUE to enable measurement block update
> + *	    PMCW_DCTME to enable device connect time
> + */
> +bool css_enable_mb(int schid, uint64_t mb, uint16_t mbi, uint16_t flags,
> +		   bool format1)
> +{
> +	int retry_count = MAX_ENABLE_RETRIES;
> +	struct pmcw *pmcw = &schib.pmcw;
> +
> +	while (retry_count-- &&
> +	       !schib_update_mb(schid, mb, mbi, flags, format1))
> +		mdelay(10); /* the hardware was not ready, give it some time */
> +
> +	return schib.mbo == mb && pmcw->mbi == mbi;
> +}
> +
> +/*
> + * css_disable_mb: enable the subchannel Mesurement Block

s/enable/disable/
s/Mesurement/Measurement/

> + * @schid: Subchannel Identifier
> + */
> +bool css_disable_mb(int schid)
> +{
> +	int retry_count = MAX_ENABLE_RETRIES;
> +
> +	while (retry_count-- &&
> +	       !schib_update_mb(schid, 0, 0, 0, 0))
> +		mdelay(10); /* the hardware was not ready, give it some time */
> +
> +	return retry_count > 0;
> +}
> +
>  static struct irb irb;
>  
>  void css_irq_io(void)

(...)

I'd still have split out the subchannel-modifying functions into a
separate patch, but no strong opinion.

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


  reply	other threads:[~2021-02-23 13:24 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-18 17:26 [kvm-unit-tests PATCH v3 0/5] CSS Mesurement Block Pierre Morel
2021-02-18 17:26 ` [kvm-unit-tests PATCH v3 1/5] s390x: css: Store CSS Characteristics Pierre Morel
2021-02-26  9:50   ` Janosch Frank
2021-02-26 13:38     ` Pierre Morel
2021-02-18 17:26 ` [kvm-unit-tests PATCH v3 2/5] s390x: css: simplifications of the tests Pierre Morel
2021-02-18 17:26 ` [kvm-unit-tests PATCH v3 3/5] s390x: css: implementing Set CHannel Monitor Pierre Morel
2021-02-23 13:22   ` Cornelia Huck [this message]
2021-02-23 15:43     ` Pierre Morel
2021-02-18 17:26 ` [kvm-unit-tests PATCH v3 4/5] s390x: css: testing measurement block format 0 Pierre Morel
2021-02-23 13:27   ` Cornelia Huck
2021-02-23 15:49     ` Pierre Morel
2021-02-23 16:05       ` Cornelia Huck
2021-02-18 17:26 ` [kvm-unit-tests PATCH v3 5/5] s390x: css: testing measurement block format 1 Pierre Morel
2021-02-23 13:29   ` Cornelia Huck
2021-02-23 15:52     ` Pierre Morel
2021-02-26 10:02   ` Janosch Frank
2021-02-26 13:34     ` Pierre Morel

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=20210223142219.0f42a303.cohuck@redhat.com \
    --to=cohuck@redhat.com \
    --cc=david@redhat.com \
    --cc=frankja@linux.ibm.com \
    --cc=imbrenda@linux.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=pmorel@linux.ibm.com \
    --cc=thuth@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.