linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/6] IB/ehca: Serialize hypervisor calls in ehca_register_mr()
@ 2007-05-09 11:47 Joachim Fenkes
  2007-05-10  3:03 ` Roland Dreier
  2007-05-10  8:55 ` Joachim Fenkes
  0 siblings, 2 replies; 3+ messages in thread
From: Joachim Fenkes @ 2007-05-09 11:47 UTC (permalink / raw)
  To: LinuxPPC-Dev, LKML, OF-General, Roland Dreier
  Cc: Stefan Roscher, Christoph Raisch

From: Stefan Roscher <stefan.roscher@de.ibm.com>

Some pSeries hypervisor versions show a race condition in the allocate MR hCall.
Serialize this call per adapter to circumvent this problem.

Signed-off-by: Joachim Fenkes <fenkes@de.ibm.com>
---
 drivers/infiniband/hw/ehca/ehca_classes.h |    1 +
 drivers/infiniband/hw/ehca/ehca_main.c    |    2 ++
 drivers/infiniband/hw/ehca/hcp_if.c       |   14 ++++++++++++--
 3 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/drivers/infiniband/hw/ehca/ehca_classes.h b/drivers/infiniband/hw/ehca/ehca_classes.h
index 10fb8fb..4bc5cb3 100644
--- a/drivers/infiniband/hw/ehca/ehca_classes.h
+++ b/drivers/infiniband/hw/ehca/ehca_classes.h
@@ -276,6 +276,7 @@ void ehca_cleanup_mrmw_cache(void);
 
 extern spinlock_t ehca_qp_idr_lock;
 extern spinlock_t ehca_cq_idr_lock;
+extern spinlock_t hcall_lock;
 extern struct idr ehca_qp_idr;
 extern struct idr ehca_cq_idr;
 
diff --git a/drivers/infiniband/hw/ehca/ehca_main.c b/drivers/infiniband/hw/ehca/ehca_main.c
index 2d37054..2e27e68 100644
--- a/drivers/infiniband/hw/ehca/ehca_main.c
+++ b/drivers/infiniband/hw/ehca/ehca_main.c
@@ -98,6 +98,7 @@ MODULE_PARM_DESC(scaling_code,
 
 spinlock_t ehca_qp_idr_lock;
 spinlock_t ehca_cq_idr_lock;
+spinlock_t hcall_lock;
 DEFINE_IDR(ehca_qp_idr);
 DEFINE_IDR(ehca_cq_idr);
 
@@ -817,6 +818,7 @@ int __init ehca_module_init(void)
 	idr_init(&ehca_cq_idr);
 	spin_lock_init(&ehca_qp_idr_lock);
 	spin_lock_init(&ehca_cq_idr_lock);
+	spin_lock_init(&hcall_lock);
 
 	INIT_LIST_HEAD(&shca_list);
 	spin_lock_init(&shca_list_lock);
diff --git a/drivers/infiniband/hw/ehca/hcp_if.c b/drivers/infiniband/hw/ehca/hcp_if.c
index b564fcd..bb76134 100644
--- a/drivers/infiniband/hw/ehca/hcp_if.c
+++ b/drivers/infiniband/hw/ehca/hcp_if.c
@@ -154,7 +154,9 @@ static long ehca_plpar_hcall9(unsigned l
 			      unsigned long arg9)
 {
 	long ret;
-	int i, sleep_msecs;
+	int i, sleep_msecs, lock_is_set = 0;
+	unsigned long flags;
+
 
 	ehca_gen_dbg("opcode=%lx arg1=%lx arg2=%lx arg3=%lx arg4=%lx "
 		     "arg5=%lx arg6=%lx arg7=%lx arg8=%lx arg9=%lx",
@@ -162,10 +164,18 @@ static long ehca_plpar_hcall9(unsigned l
 		     arg8, arg9);
 
 	for (i = 0; i < 5; i++) {
+		if ((opcode == H_ALLOC_RESOURCE) && (arg2 == 5)) {
+			spin_lock_irqsave(&hcall_lock, flags);
+			lock_is_set = 1;
+		}
+
 		ret = plpar_hcall9(opcode, outs,
 				   arg1, arg2, arg3, arg4, arg5,
 				   arg6, arg7, arg8, arg9);
 
+		if (lock_is_set)
+			spin_unlock_irqrestore(&hcall_lock, flags);
+
 		if (H_IS_LONG_BUSY(ret)) {
 			sleep_msecs = get_longbusy_msecs(ret);
 			msleep_interruptible(sleep_msecs);
@@ -193,11 +203,11 @@ static long ehca_plpar_hcall9(unsigned l
 			     opcode, ret, outs[0], outs[1], outs[2], outs[3],
 			     outs[4], outs[5], outs[6], outs[7], outs[8]);
 		return ret;
-
 	}
 
 	return H_BUSY;
 }
+
 u64 hipz_h_alloc_resource_eq(const struct ipz_adapter_handle adapter_handle,
 			     struct ehca_pfeq *pfeq,
 			     const u32 neq_control,
-- 
1.4.2.1

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

* Re: [PATCH 1/6] IB/ehca: Serialize hypervisor calls in ehca_register_mr()
  2007-05-09 11:47 [PATCH 1/6] IB/ehca: Serialize hypervisor calls in ehca_register_mr() Joachim Fenkes
@ 2007-05-10  3:03 ` Roland Dreier
  2007-05-10  8:55 ` Joachim Fenkes
  1 sibling, 0 replies; 3+ messages in thread
From: Roland Dreier @ 2007-05-10  3:03 UTC (permalink / raw)
  To: Joachim Fenkes
  Cc: LKML, LinuxPPC-Dev, Christoph Raisch, OF-General, Stefan Roscher

thanks, it all looks fine... I'll apply when I'm back from my trip on Monday.

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

* Re: [PATCH 1/6] IB/ehca: Serialize hypervisor calls in ehca_register_mr()
  2007-05-09 11:47 [PATCH 1/6] IB/ehca: Serialize hypervisor calls in ehca_register_mr() Joachim Fenkes
  2007-05-10  3:03 ` Roland Dreier
@ 2007-05-10  8:55 ` Joachim Fenkes
  1 sibling, 0 replies; 3+ messages in thread
From: Joachim Fenkes @ 2007-05-10  8:55 UTC (permalink / raw)
  To: LinuxPPC-Dev; +Cc: LKML, Christoph Raisch, OF-General, Stefan Roscher

On Wednesday 09 May 2007 13:47, Joachim Fenkes wrote:

> --- a/drivers/infiniband/hw/ehca/hcp_if.c
> +++ b/drivers/infiniband/hw/ehca/hcp_if.c
> @@ -154,7 +154,9 @@ static long ehca_plpar_hcall9(unsigned l
>  			      unsigned long arg9)
>  {
>  	long ret;
> -	int i, sleep_msecs;
> +	int i, sleep_msecs, lock_is_set =3D 0;
> +	unsigned long flags;
> +
> =20
>  	ehca_gen_dbg("opcode=3D%lx arg1=3D%lx arg2=3D%lx arg3=3D%lx arg4=3D%lx "
>  		     "arg5=3D%lx arg6=3D%lx arg7=3D%lx arg8=3D%lx arg9=3D%lx",
> @@ -162,10 +164,18 @@ static long ehca_plpar_hcall9(unsigned l

Whoops, that's one too many empty line...
Roland, when you apply this patch, could you apply the following patch on t=
op:

=2D-- a/drivers/infiniband/hw/ehca/hcp_if.c
+++ b/drivers/infiniband/hw/ehca/hcp_if.c
@@ -157,7 +157,6 @@ static long ehca_plpar_hcall9(unsigned l
        int i, sleep_msecs, lock_is_set =3D 0;
        unsigned long flags;

=2D
        ehca_gen_dbg("opcode=3D%lx arg1=3D%lx arg2=3D%lx arg3=3D%lx arg4=3D=
%lx "
                     "arg5=3D%lx arg6=3D%lx arg7=3D%lx arg8=3D%lx arg9=3D%l=
x",
                     opcode, arg1, arg2, arg3, arg4, arg5, arg6, arg7,


Thanks!
  Joachim

=2D-=20
Joachim Fenkes =A0-- =A0eHCA Linux Driver Developer and Hardware Tamer
IBM Deutschland Entwicklung GmbH =A0-- =A0Dept. 3627 (I/O Firmware Dev. 2)
Schoenaicher Strasse 220 =A0-- =A071032 Boeblingen =A0-- =A0Germany
eMail: fenkes@de.ibm.com =A0-- =A0Phone: +49 7031 16 1239

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

end of thread, other threads:[~2007-05-10  8:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-05-09 11:47 [PATCH 1/6] IB/ehca: Serialize hypervisor calls in ehca_register_mr() Joachim Fenkes
2007-05-10  3:03 ` Roland Dreier
2007-05-10  8:55 ` Joachim Fenkes

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).