All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] tests/vpci: fix unit tests after locking change
@ 2024-02-27 14:57 Stewart Hildebrand
  2024-02-27 16:24 ` Roger Pau Monné
  0 siblings, 1 reply; 2+ messages in thread
From: Stewart Hildebrand @ 2024-02-27 14:57 UTC (permalink / raw)
  To: xen-devel
  Cc: Stewart Hildebrand, Roger Pau Monné, Wei Liu, Anthony PERARD,
	Andrew Cooper

The recent vPCI locking broke the vPCI unit tests. Fix it to unblock CI.

Fixes: 4f78438b45e2 ("vpci: use per-domain PCI lock to protect vpci structure")
Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Stewart Hildebrand <stewart.hildebrand@amd.com>
---
 tools/tests/vpci/emul.h | 9 ++++++++-
 tools/tests/vpci/main.c | 2 +-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/tools/tests/vpci/emul.h b/tools/tests/vpci/emul.h
index 3c2f66a18f13..da446bba86b4 100644
--- a/tools/tests/vpci/emul.h
+++ b/tools/tests/vpci/emul.h
@@ -37,7 +37,10 @@
 
 #include "list.h"
 
+typedef bool rwlock_t;
+
 struct domain {
+    rwlock_t pci_lock;
 };
 
 struct pci_dev {
@@ -46,7 +49,7 @@ struct pci_dev {
 
 struct vcpu
 {
-    const struct domain *domain;
+    struct domain *domain;
 };
 
 extern const struct vcpu *current;
@@ -56,6 +59,10 @@ typedef bool spinlock_t;
 #define spin_lock_init(l) (*(l) = false)
 #define spin_lock(l) (*(l) = true)
 #define spin_unlock(l) (*(l) = false)
+#define read_lock(l) (*(l) = true)
+#define read_unlock(l) (*(l) = false)
+#define write_lock(l) (*(l) = true)
+#define write_unlock(l) (*(l) = false)
 
 typedef union {
     uint32_t sbdf;
diff --git a/tools/tests/vpci/main.c b/tools/tests/vpci/main.c
index 64d4552936c7..33223db3eb77 100644
--- a/tools/tests/vpci/main.c
+++ b/tools/tests/vpci/main.c
@@ -21,7 +21,7 @@
 /* Single vcpu (current), and single domain with a single PCI device. */
 static struct vpci vpci;
 
-const static struct domain d;
+static struct domain d;
 
 const struct pci_dev test_pdev = {
     .vpci = &vpci,

base-commit: 576528a2a742069af203e90c613c5c93e23c9755
-- 
2.43.2



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

* Re: [PATCH] tests/vpci: fix unit tests after locking change
  2024-02-27 14:57 [PATCH] tests/vpci: fix unit tests after locking change Stewart Hildebrand
@ 2024-02-27 16:24 ` Roger Pau Monné
  0 siblings, 0 replies; 2+ messages in thread
From: Roger Pau Monné @ 2024-02-27 16:24 UTC (permalink / raw)
  To: Stewart Hildebrand; +Cc: xen-devel, Wei Liu, Anthony PERARD, Andrew Cooper

On Tue, Feb 27, 2024 at 09:57:43AM -0500, Stewart Hildebrand wrote:
> The recent vPCI locking broke the vPCI unit tests. Fix it to unblock CI.
> 
> Fixes: 4f78438b45e2 ("vpci: use per-domain PCI lock to protect vpci structure")
> Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
> Signed-off-by: Stewart Hildebrand <stewart.hildebrand@amd.com>
> ---
>  tools/tests/vpci/emul.h | 9 ++++++++-
>  tools/tests/vpci/main.c | 2 +-
>  2 files changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/tests/vpci/emul.h b/tools/tests/vpci/emul.h
> index 3c2f66a18f13..da446bba86b4 100644
> --- a/tools/tests/vpci/emul.h
> +++ b/tools/tests/vpci/emul.h
> @@ -37,7 +37,10 @@
>  
>  #include "list.h"
>  
> +typedef bool rwlock_t;
> +
>  struct domain {
> +    rwlock_t pci_lock;
>  };
>  
>  struct pci_dev {
> @@ -46,7 +49,7 @@ struct pci_dev {
>  
>  struct vcpu
>  {
> -    const struct domain *domain;
> +    struct domain *domain;
>  };
>  
>  extern const struct vcpu *current;
> @@ -56,6 +59,10 @@ typedef bool spinlock_t;
>  #define spin_lock_init(l) (*(l) = false)
>  #define spin_lock(l) (*(l) = true)
>  #define spin_unlock(l) (*(l) = false)
> +#define read_lock(l) (*(l) = true)
> +#define read_unlock(l) (*(l) = false)
> +#define write_lock(l) (*(l) = true)
> +#define write_unlock(l) (*(l) = false)

I now realize the spinlock handlers are pointless to set a boolean,
and the same applies to the rwlocks, but anyway, it's not going to
affect the testing.

Acked-by: Roger Pau Monné <roger.pau@citrix.com>

Thanks, Roger.


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

end of thread, other threads:[~2024-02-27 16:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-27 14:57 [PATCH] tests/vpci: fix unit tests after locking change Stewart Hildebrand
2024-02-27 16:24 ` Roger Pau Monné

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.