diff mbox series

[v3,2/4] s390x/css: Split out the IRB sense data

Message ID 20210616014749.2460133-3-farman@linux.ibm.com
State New
Headers show
Series s390x: Fix IRB sense data | expand

Commit Message

Eric Farman June 16, 2021, 1:47 a.m. UTC
Let's move this logic into its own routine,
so it can be reused later.

Signed-off-by: Eric Farman <farman@linux.ibm.com>
---
 hw/s390x/css.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

Comments

Thomas Huth June 17, 2021, 5:05 a.m. UTC | #1
On 16/06/2021 03.47, Eric Farman wrote:
> Let's move this logic into its own routine,
> so it can be reused later.
> 
> Signed-off-by: Eric Farman <farman@linux.ibm.com>
> ---
>   hw/s390x/css.c | 19 ++++++++++++-------
>   1 file changed, 12 insertions(+), 7 deletions(-)
> 
> diff --git a/hw/s390x/css.c b/hw/s390x/css.c
> index 8be21efb13..554c9083fd 100644
> --- a/hw/s390x/css.c
> +++ b/hw/s390x/css.c
> @@ -1639,6 +1639,17 @@ static void copy_irb_to_guest(IRB *dest, const IRB *src, const PMCW *pmcw,
>       *irb_len = sizeof(*dest);
>   }
>   
> +static void build_irb_sense_data(SubchDev *sch, IRB *irb)
> +{
> +    int i;
> +
> +    /* Attention: sense_data is already BE! */
> +    memcpy(irb->ecw, sch->sense_data, sizeof(sch->sense_data));
> +    for (i = 0; i < ARRAY_SIZE(irb->ecw); i++) {
> +        irb->ecw[i] = be32_to_cpu(irb->ecw[i]);
> +    }
> +}
> +
>   int css_do_tsch_get_irb(SubchDev *sch, IRB *target_irb, int *irb_len)
>   {
>       SCHIB *schib = &sch->curr_status;
> @@ -1669,14 +1680,8 @@ int css_do_tsch_get_irb(SubchDev *sch, IRB *target_irb, int *irb_len)
>           /* If a unit check is pending, copy sense data. */
>           if ((schib->scsw.dstat & SCSW_DSTAT_UNIT_CHECK) &&
>               (schib->pmcw.chars & PMCW_CHARS_MASK_CSENSE)) {
> -            int i;
> -
>               irb.scsw.flags |= SCSW_FLAGS_MASK_ESWF | SCSW_FLAGS_MASK_ECTL;
> -            /* Attention: sense_data is already BE! */
> -            memcpy(irb.ecw, sch->sense_data, sizeof(sch->sense_data));
> -            for (i = 0; i < ARRAY_SIZE(irb.ecw); i++) {
> -                irb.ecw[i] = be32_to_cpu(irb.ecw[i]);
> -            }
> +            build_irb_sense_data(sch, &irb);
>               irb.esw.erw = ESW_ERW_SENSE | (sizeof(sch->sense_data) << 8);
>           }
>       }
> 

Reviewed-by: Thomas Huth <thuth@redhat.com>
diff mbox series

Patch

diff --git a/hw/s390x/css.c b/hw/s390x/css.c
index 8be21efb13..554c9083fd 100644
--- a/hw/s390x/css.c
+++ b/hw/s390x/css.c
@@ -1639,6 +1639,17 @@  static void copy_irb_to_guest(IRB *dest, const IRB *src, const PMCW *pmcw,
     *irb_len = sizeof(*dest);
 }
 
+static void build_irb_sense_data(SubchDev *sch, IRB *irb)
+{
+    int i;
+
+    /* Attention: sense_data is already BE! */
+    memcpy(irb->ecw, sch->sense_data, sizeof(sch->sense_data));
+    for (i = 0; i < ARRAY_SIZE(irb->ecw); i++) {
+        irb->ecw[i] = be32_to_cpu(irb->ecw[i]);
+    }
+}
+
 int css_do_tsch_get_irb(SubchDev *sch, IRB *target_irb, int *irb_len)
 {
     SCHIB *schib = &sch->curr_status;
@@ -1669,14 +1680,8 @@  int css_do_tsch_get_irb(SubchDev *sch, IRB *target_irb, int *irb_len)
         /* If a unit check is pending, copy sense data. */
         if ((schib->scsw.dstat & SCSW_DSTAT_UNIT_CHECK) &&
             (schib->pmcw.chars & PMCW_CHARS_MASK_CSENSE)) {
-            int i;
-
             irb.scsw.flags |= SCSW_FLAGS_MASK_ESWF | SCSW_FLAGS_MASK_ECTL;
-            /* Attention: sense_data is already BE! */
-            memcpy(irb.ecw, sch->sense_data, sizeof(sch->sense_data));
-            for (i = 0; i < ARRAY_SIZE(irb.ecw); i++) {
-                irb.ecw[i] = be32_to_cpu(irb.ecw[i]);
-            }
+            build_irb_sense_data(sch, &irb);
             irb.esw.erw = ESW_ERW_SENSE | (sizeof(sch->sense_data) << 8);
         }
     }