All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/4] s390x/pci: some small fixes
@ 2021-12-03 12:32 Matthew Rosato
  2021-12-03 12:32 ` [PATCH v2 1/4] s390x/pci: use a reserved ID for the default PCI group Matthew Rosato
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Matthew Rosato @ 2021-12-03 12:32 UTC (permalink / raw)
  To: thuth, qemu-s390x, qemu-devel
  Cc: farman, pmorel, david, cohuck, richard.henderson, pasic, borntraeger

A collection of small fixes for s390x PCI (not urgent).  The first 3 are
fixes related to always using the host-provided CLP value when provided
vs a hard-coded value.  The last patch adds logic for QEMU to report a
proper DTSM clp response rather than just 0s (guest linux doesn't look
at this field today).

Changes for v2:
- Add review tags (thanks!)
- Fix patch 4 (copy into guest payload)
- Small change to commit message for patches 1 & 4 (Pierre)

Matthew Rosato (4):
  s390x/pci: use a reserved ID for the default PCI group
  s390x/pci: don't use hard-coded dma range in reg_ioat
  s390x/pci: use the passthrough measurement update interval
  s390x/pci: add supported DT information to clp response

 hw/s390x/s390-pci-bus.c         |  1 +
 hw/s390x/s390-pci-inst.c        | 15 +++++++++------
 hw/s390x/s390-pci-vfio.c        |  1 +
 include/hw/s390x/s390-pci-bus.h |  3 ++-
 include/hw/s390x/s390-pci-clp.h |  3 ++-
 5 files changed, 15 insertions(+), 8 deletions(-)

-- 
2.27.0



^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH v2 1/4] s390x/pci: use a reserved ID for the default PCI group
  2021-12-03 12:32 [PATCH v2 0/4] s390x/pci: some small fixes Matthew Rosato
@ 2021-12-03 12:32 ` Matthew Rosato
  2021-12-03 12:32 ` [PATCH v2 2/4] s390x/pci: don't use hard-coded dma range in reg_ioat Matthew Rosato
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Matthew Rosato @ 2021-12-03 12:32 UTC (permalink / raw)
  To: thuth, qemu-s390x, qemu-devel
  Cc: farman, pmorel, david, cohuck, richard.henderson, pasic, borntraeger

The current default PCI group being used can technically collide with a
real group ID passed from a hostdev.  Let's instead use a group ID that
comes from a special pool (0xF0-0xFF) that is architected to be reserved
for simulated devices.

Fixes: 28dc86a072 ("s390x/pci: use a PCI Group structure")
Reviewed-by: Eric Farman <farman@linux.ibm.com>
Reviewed-by: Pierre Morel <pmorel@linux.ibm.com>
Signed-off-by: Matthew Rosato <mjrosato@linux.ibm.com>
---
 include/hw/s390x/s390-pci-bus.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/hw/s390x/s390-pci-bus.h b/include/hw/s390x/s390-pci-bus.h
index aa891c178d..2727e7bdef 100644
--- a/include/hw/s390x/s390-pci-bus.h
+++ b/include/hw/s390x/s390-pci-bus.h
@@ -313,7 +313,7 @@ typedef struct ZpciFmb {
 } ZpciFmb;
 QEMU_BUILD_BUG_MSG(offsetof(ZpciFmb, fmt0) != 48, "padding in ZpciFmb");
 
-#define ZPCI_DEFAULT_FN_GRP 0x20
+#define ZPCI_DEFAULT_FN_GRP 0xFF
 typedef struct S390PCIGroup {
     ClpRspQueryPciGrp zpci_group;
     int id;
-- 
2.27.0



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2 2/4] s390x/pci: don't use hard-coded dma range in reg_ioat
  2021-12-03 12:32 [PATCH v2 0/4] s390x/pci: some small fixes Matthew Rosato
  2021-12-03 12:32 ` [PATCH v2 1/4] s390x/pci: use a reserved ID for the default PCI group Matthew Rosato
@ 2021-12-03 12:32 ` Matthew Rosato
  2021-12-03 12:32 ` [PATCH v2 3/4] s390x/pci: use the passthrough measurement update interval Matthew Rosato
  2021-12-03 12:32 ` [PATCH v2 4/4] s390x/pci: add supported DT information to clp response Matthew Rosato
  3 siblings, 0 replies; 7+ messages in thread
From: Matthew Rosato @ 2021-12-03 12:32 UTC (permalink / raw)
  To: thuth, qemu-s390x, qemu-devel
  Cc: farman, pmorel, david, cohuck, richard.henderson, pasic, borntraeger

Instead use the values from clp info, they will either be the hard-coded
values or what came from the host driver via vfio.

Fixes: 9670ee752727 ("s390x/pci: use a PCI Function structure")
Reviewed-by: Eric Farman <farman@linux.ibm.com>
Reviewed-by: Pierre Morel <pmorel@linux.ibm.com>
Signed-off-by: Matthew Rosato <mjrosato@linux.ibm.com>
---
 hw/s390x/s390-pci-inst.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/hw/s390x/s390-pci-inst.c b/hw/s390x/s390-pci-inst.c
index 1c8ad91175..11b7f6bfa1 100644
--- a/hw/s390x/s390-pci-inst.c
+++ b/hw/s390x/s390-pci-inst.c
@@ -916,9 +916,10 @@ int pci_dereg_irqs(S390PCIBusDevice *pbdev)
     return 0;
 }
 
-static int reg_ioat(CPUS390XState *env, S390PCIIOMMU *iommu, ZpciFib fib,
+static int reg_ioat(CPUS390XState *env, S390PCIBusDevice *pbdev, ZpciFib fib,
                     uintptr_t ra)
 {
+    S390PCIIOMMU *iommu = pbdev->iommu;
     uint64_t pba = ldq_p(&fib.pba);
     uint64_t pal = ldq_p(&fib.pal);
     uint64_t g_iota = ldq_p(&fib.iota);
@@ -927,7 +928,7 @@ static int reg_ioat(CPUS390XState *env, S390PCIIOMMU *iommu, ZpciFib fib,
 
     pba &= ~0xfff;
     pal |= 0xfff;
-    if (pba > pal || pba < ZPCI_SDMA_ADDR || pal > ZPCI_EDMA_ADDR) {
+    if (pba > pal || pba < pbdev->zpci_fn.sdma || pal > pbdev->zpci_fn.edma) {
         s390_program_interrupt(env, PGM_OPERAND, ra);
         return -EINVAL;
     }
@@ -1125,7 +1126,7 @@ int mpcifc_service_call(S390CPU *cpu, uint8_t r1, uint64_t fiba, uint8_t ar,
         } else if (pbdev->iommu->enabled) {
             cc = ZPCI_PCI_LS_ERR;
             s390_set_status_code(env, r1, ZPCI_MOD_ST_SEQUENCE);
-        } else if (reg_ioat(env, pbdev->iommu, fib, ra)) {
+        } else if (reg_ioat(env, pbdev, fib, ra)) {
             cc = ZPCI_PCI_LS_ERR;
             s390_set_status_code(env, r1, ZPCI_MOD_ST_INSUF_RES);
         }
@@ -1150,7 +1151,7 @@ int mpcifc_service_call(S390CPU *cpu, uint8_t r1, uint64_t fiba, uint8_t ar,
             s390_set_status_code(env, r1, ZPCI_MOD_ST_SEQUENCE);
         } else {
             pci_dereg_ioat(pbdev->iommu);
-            if (reg_ioat(env, pbdev->iommu, fib, ra)) {
+            if (reg_ioat(env, pbdev, fib, ra)) {
                 cc = ZPCI_PCI_LS_ERR;
                 s390_set_status_code(env, r1, ZPCI_MOD_ST_INSUF_RES);
             }
-- 
2.27.0



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2 3/4] s390x/pci: use the passthrough measurement update interval
  2021-12-03 12:32 [PATCH v2 0/4] s390x/pci: some small fixes Matthew Rosato
  2021-12-03 12:32 ` [PATCH v2 1/4] s390x/pci: use a reserved ID for the default PCI group Matthew Rosato
  2021-12-03 12:32 ` [PATCH v2 2/4] s390x/pci: don't use hard-coded dma range in reg_ioat Matthew Rosato
@ 2021-12-03 12:32 ` Matthew Rosato
  2021-12-03 12:32 ` [PATCH v2 4/4] s390x/pci: add supported DT information to clp response Matthew Rosato
  3 siblings, 0 replies; 7+ messages in thread
From: Matthew Rosato @ 2021-12-03 12:32 UTC (permalink / raw)
  To: thuth, qemu-s390x, qemu-devel
  Cc: farman, pmorel, david, cohuck, richard.henderson, pasic, borntraeger

We may have gotten a measurement update interval from the underlying host
via vfio -- Use it to set the interval via which we update the function
measurement block.

Fixes: 28dc86a072 ("s390x/pci: use a PCI Group structure")
Reviewed-by: Eric Farman <farman@linux.ibm.com>
Reviewed-by: Pierre Morel <pmorel@linux.ibm.com>
Signed-off-by: Matthew Rosato <mjrosato@linux.ibm.com>
---
 hw/s390x/s390-pci-inst.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/hw/s390x/s390-pci-inst.c b/hw/s390x/s390-pci-inst.c
index 11b7f6bfa1..07bab85ce5 100644
--- a/hw/s390x/s390-pci-inst.c
+++ b/hw/s390x/s390-pci-inst.c
@@ -1046,7 +1046,7 @@ static void fmb_update(void *opaque)
                       sizeof(pbdev->fmb.last_update))) {
         return;
     }
-    timer_mod(pbdev->fmb_timer, t + DEFAULT_MUI);
+    timer_mod(pbdev->fmb_timer, t + pbdev->pci_group->zpci_group.mui);
 }
 
 int mpcifc_service_call(S390CPU *cpu, uint8_t r1, uint64_t fiba, uint8_t ar,
@@ -1204,7 +1204,8 @@ int mpcifc_service_call(S390CPU *cpu, uint8_t r1, uint64_t fiba, uint8_t ar,
         }
         pbdev->fmb_addr = fmb_addr;
         timer_mod(pbdev->fmb_timer,
-                  qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) + DEFAULT_MUI);
+                  qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) +
+                                    pbdev->pci_group->zpci_group.mui);
         break;
     }
     default:
-- 
2.27.0



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH v2 4/4] s390x/pci: add supported DT information to clp response
  2021-12-03 12:32 [PATCH v2 0/4] s390x/pci: some small fixes Matthew Rosato
                   ` (2 preceding siblings ...)
  2021-12-03 12:32 ` [PATCH v2 3/4] s390x/pci: use the passthrough measurement update interval Matthew Rosato
@ 2021-12-03 12:32 ` Matthew Rosato
  2021-12-03 12:48   ` Pierre Morel
  3 siblings, 1 reply; 7+ messages in thread
From: Matthew Rosato @ 2021-12-03 12:32 UTC (permalink / raw)
  To: thuth, qemu-s390x, qemu-devel
  Cc: farman, pmorel, david, cohuck, richard.henderson, pasic, borntraeger

The DTSM is a mask that specifies which I/O Address Translation designation
types are supported.  Today QEMU only supports DT=1.

Signed-off-by: Matthew Rosato <mjrosato@linux.ibm.com>
---
 hw/s390x/s390-pci-bus.c         | 1 +
 hw/s390x/s390-pci-inst.c        | 1 +
 hw/s390x/s390-pci-vfio.c        | 1 +
 include/hw/s390x/s390-pci-bus.h | 1 +
 include/hw/s390x/s390-pci-clp.h | 3 ++-
 5 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c
index 1b51a72838..01b58ebc70 100644
--- a/hw/s390x/s390-pci-bus.c
+++ b/hw/s390x/s390-pci-bus.c
@@ -782,6 +782,7 @@ static void s390_pci_init_default_group(void)
     resgrp->i = 128;
     resgrp->maxstbl = 128;
     resgrp->version = 0;
+    resgrp->dtsm = ZPCI_DTSM;
 }
 
 static void set_pbdev_info(S390PCIBusDevice *pbdev)
diff --git a/hw/s390x/s390-pci-inst.c b/hw/s390x/s390-pci-inst.c
index 07bab85ce5..f3feba5d74 100644
--- a/hw/s390x/s390-pci-inst.c
+++ b/hw/s390x/s390-pci-inst.c
@@ -329,6 +329,7 @@ int clp_service_call(S390CPU *cpu, uint8_t r2, uintptr_t ra)
         stw_p(&resgrp->i, group->zpci_group.i);
         stw_p(&resgrp->maxstbl, group->zpci_group.maxstbl);
         resgrp->version = group->zpci_group.version;
+        resgrp->version = group->zpci_group.dtsm;
         stw_p(&resgrp->hdr.rsp, CLP_RC_OK);
         break;
     }
diff --git a/hw/s390x/s390-pci-vfio.c b/hw/s390x/s390-pci-vfio.c
index 2a153fa8c9..6f80a47e29 100644
--- a/hw/s390x/s390-pci-vfio.c
+++ b/hw/s390x/s390-pci-vfio.c
@@ -160,6 +160,7 @@ static void s390_pci_read_group(S390PCIBusDevice *pbdev,
         resgrp->i = cap->noi;
         resgrp->maxstbl = cap->maxstbl;
         resgrp->version = cap->version;
+        resgrp->dtsm = ZPCI_DTSM;
     }
 }
 
diff --git a/include/hw/s390x/s390-pci-bus.h b/include/hw/s390x/s390-pci-bus.h
index 2727e7bdef..da3cde2bb4 100644
--- a/include/hw/s390x/s390-pci-bus.h
+++ b/include/hw/s390x/s390-pci-bus.h
@@ -37,6 +37,7 @@
 #define ZPCI_MAX_UID 0xffff
 #define UID_UNDEFINED 0
 #define UID_CHECKING_ENABLED 0x01
+#define ZPCI_DTSM 0x40
 
 OBJECT_DECLARE_SIMPLE_TYPE(S390pciState, S390_PCI_HOST_BRIDGE)
 OBJECT_DECLARE_SIMPLE_TYPE(S390PCIBus, S390_PCI_BUS)
diff --git a/include/hw/s390x/s390-pci-clp.h b/include/hw/s390x/s390-pci-clp.h
index 96b8e3f133..cc8c8662b8 100644
--- a/include/hw/s390x/s390-pci-clp.h
+++ b/include/hw/s390x/s390-pci-clp.h
@@ -163,7 +163,8 @@ typedef struct ClpRspQueryPciGrp {
     uint8_t fr;
     uint16_t maxstbl;
     uint16_t mui;
-    uint64_t reserved3;
+    uint8_t dtsm;
+    uint8_t reserved3[7];
     uint64_t dasm; /* dma address space mask */
     uint64_t msia; /* MSI address */
     uint64_t reserved4;
-- 
2.27.0



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 4/4] s390x/pci: add supported DT information to clp response
  2021-12-03 12:32 ` [PATCH v2 4/4] s390x/pci: add supported DT information to clp response Matthew Rosato
@ 2021-12-03 12:48   ` Pierre Morel
  2021-12-03 12:48     ` Matthew Rosato
  0 siblings, 1 reply; 7+ messages in thread
From: Pierre Morel @ 2021-12-03 12:48 UTC (permalink / raw)
  To: Matthew Rosato, thuth, qemu-s390x, qemu-devel
  Cc: farman, david, cohuck, richard.henderson, pasic, borntraeger



On 12/3/21 13:32, Matthew Rosato wrote:
> The DTSM is a mask that specifies which I/O Address Translation designation
> types are supported.  Today QEMU only supports DT=1.
> 
> Signed-off-by: Matthew Rosato <mjrosato@linux.ibm.com>
> ---
>   hw/s390x/s390-pci-bus.c         | 1 +
>   hw/s390x/s390-pci-inst.c        | 1 +
>   hw/s390x/s390-pci-vfio.c        | 1 +
>   include/hw/s390x/s390-pci-bus.h | 1 +
>   include/hw/s390x/s390-pci-clp.h | 3 ++-
>   5 files changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c
> index 1b51a72838..01b58ebc70 100644
> --- a/hw/s390x/s390-pci-bus.c
> +++ b/hw/s390x/s390-pci-bus.c
> @@ -782,6 +782,7 @@ static void s390_pci_init_default_group(void)
>       resgrp->i = 128;
>       resgrp->maxstbl = 128;
>       resgrp->version = 0;
> +    resgrp->dtsm = ZPCI_DTSM;
>   }
>   
>   static void set_pbdev_info(S390PCIBusDevice *pbdev)
> diff --git a/hw/s390x/s390-pci-inst.c b/hw/s390x/s390-pci-inst.c
> index 07bab85ce5..f3feba5d74 100644
> --- a/hw/s390x/s390-pci-inst.c
> +++ b/hw/s390x/s390-pci-inst.c
> @@ -329,6 +329,7 @@ int clp_service_call(S390CPU *cpu, uint8_t r2, uintptr_t ra)
>           stw_p(&resgrp->i, group->zpci_group.i);
>           stw_p(&resgrp->maxstbl, group->zpci_group.maxstbl);
>           resgrp->version = group->zpci_group.version;
> +        resgrp->version = group->zpci_group.dtsm;

;) cut and past error

...snip...

-- 
Pierre Morel
IBM Lab Boeblingen


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2 4/4] s390x/pci: add supported DT information to clp response
  2021-12-03 12:48   ` Pierre Morel
@ 2021-12-03 12:48     ` Matthew Rosato
  0 siblings, 0 replies; 7+ messages in thread
From: Matthew Rosato @ 2021-12-03 12:48 UTC (permalink / raw)
  To: Pierre Morel, thuth, qemu-s390x, qemu-devel
  Cc: farman, david, cohuck, richard.henderson, pasic, borntraeger

On 12/3/21 7:48 AM, Pierre Morel wrote:
> 
> 
> On 12/3/21 13:32, Matthew Rosato wrote:
>> The DTSM is a mask that specifies which I/O Address Translation 
>> designation
>> types are supported.  Today QEMU only supports DT=1.
>>
>> Signed-off-by: Matthew Rosato <mjrosato@linux.ibm.com>
>> ---
>>   hw/s390x/s390-pci-bus.c         | 1 +
>>   hw/s390x/s390-pci-inst.c        | 1 +
>>   hw/s390x/s390-pci-vfio.c        | 1 +
>>   include/hw/s390x/s390-pci-bus.h | 1 +
>>   include/hw/s390x/s390-pci-clp.h | 3 ++-
>>   5 files changed, 6 insertions(+), 1 deletion(-)
>>
>> diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c
>> index 1b51a72838..01b58ebc70 100644
>> --- a/hw/s390x/s390-pci-bus.c
>> +++ b/hw/s390x/s390-pci-bus.c
>> @@ -782,6 +782,7 @@ static void s390_pci_init_default_group(void)
>>       resgrp->i = 128;
>>       resgrp->maxstbl = 128;
>>       resgrp->version = 0;
>> +    resgrp->dtsm = ZPCI_DTSM;
>>   }
>>   static void set_pbdev_info(S390PCIBusDevice *pbdev)
>> diff --git a/hw/s390x/s390-pci-inst.c b/hw/s390x/s390-pci-inst.c
>> index 07bab85ce5..f3feba5d74 100644
>> --- a/hw/s390x/s390-pci-inst.c
>> +++ b/hw/s390x/s390-pci-inst.c
>> @@ -329,6 +329,7 @@ int clp_service_call(S390CPU *cpu, uint8_t r2, 
>> uintptr_t ra)
>>           stw_p(&resgrp->i, group->zpci_group.i);
>>           stw_p(&resgrp->maxstbl, group->zpci_group.maxstbl);
>>           resgrp->version = group->zpci_group.version;
>> +        resgrp->version = group->zpci_group.dtsm;
> 
> ;) cut and past error
> 
> ...snip...
> 

... And this is why I should not write code first thing in the morning!

Thanks, will send a v3 in a bit.



^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-12-03 12:50 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-03 12:32 [PATCH v2 0/4] s390x/pci: some small fixes Matthew Rosato
2021-12-03 12:32 ` [PATCH v2 1/4] s390x/pci: use a reserved ID for the default PCI group Matthew Rosato
2021-12-03 12:32 ` [PATCH v2 2/4] s390x/pci: don't use hard-coded dma range in reg_ioat Matthew Rosato
2021-12-03 12:32 ` [PATCH v2 3/4] s390x/pci: use the passthrough measurement update interval Matthew Rosato
2021-12-03 12:32 ` [PATCH v2 4/4] s390x/pci: add supported DT information to clp response Matthew Rosato
2021-12-03 12:48   ` Pierre Morel
2021-12-03 12:48     ` Matthew Rosato

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.