[ewg] Re: [ofa-general] [PATCH ofed-1.3.1 2/2] IB/ehca: Wait for async events to finish before destroying QP

Vladimir Sokolovsky vlad at dev.mellanox.co.il
Wed May 21 06:28:36 PDT 2008


Stefan Roscher wrote:
> Signed-off-by: Stefan Roscher <stefan.roscher at de.ibm.com>
> ---
> ehca_0042_Count_async_events_for_EQs.patch |   55 +++++++++++++++++++++++++++++
> 1 file changed, 55 insertions(+)
> 
> diff -Nurp ofa_kernel-1.3_old/kernel_patches/fixes/ehca_0042_Count_async_events_for_EQs.patch ofa_kernel-1.3_new/kernel_patches/fixes/ehca_0042_Count_async_events_for_EQs.patch
> --- ofa_kernel-1.3_old/kernel_patches/fixes/ehca_0042_Count_async_events_for_EQs.patch	1970-01-01 01:00:00.000000000 +0100
> +++ ofa_kernel-1.3_new/kernel_patches/fixes/ehca_0042_Count_async_events_for_EQs.patch	2008-05-21 14:41:20.000000000 +0200
> @@ -0,0 +1,55 @@
> +diff -Nurp a/drivers/infiniband/hw/ehca/ehca_classes.h b/drivers/infiniband/hw/ehca/ehca_classes.h
> +--- a/drivers/infiniband/hw/ehca/ehca_classes.h	2008-05-21 13:54:31.000000000 +0200
> ++++ b/drivers/infiniband/hw/ehca/ehca_classes.h	2008-05-21 14:35:25.000000000 +0200
> +@@ -192,6 +192,8 @@ struct ehca_qp {
> + 	int mtu_shift;
> + 	u32 message_count;
> + 	u32 packet_count;
> ++	atomic_t nr_events; /* events seen */
> ++	wait_queue_head_t wait_completion;
> + };
> + 
> + #define IS_SRQ(qp) (qp->ext_type == EQPT_SRQ)
> +diff -Nurp a/drivers/infiniband/hw/ehca/ehca_irq.c b/drivers/infiniband/hw/ehca/ehca_irq.c
> +--- a/drivers/infiniband/hw/ehca/ehca_irq.c	2008-05-21 13:54:31.000000000 +0200
> ++++ b/drivers/infiniband/hw/ehca/ehca_irq.c	2008-05-21 14:35:25.000000000 +0200
> +@@ -204,6 +204,8 @@ static void qp_event_callback(struct ehc
> + 
> + 	read_lock(&ehca_qp_idr_lock);
> + 	qp = idr_find(&ehca_qp_idr, token);
> ++	if (qp)
> ++		atomic_inc(&qp->nr_events);
> + 	read_unlock(&ehca_qp_idr_lock);
> + 
> + 	if (!qp)
> +@@ -223,6 +225,8 @@ static void qp_event_callback(struct ehc
> + 	if (fatal && qp->ext_type == EQPT_SRQBASE)
> + 		dispatch_qp_event(shca, qp, IB_EVENT_QP_LAST_WQE_REACHED);
> + 
> ++	if (atomic_dec_and_test(&qp->nr_events))
> ++		wake_up(&qp->wait_completion);
> + 	return;
> + }
> + 
> +diff -Nurp a/drivers/infiniband/hw/ehca/ehca_qp.c b/drivers/infiniband/hw/ehca/ehca_qp.c
> +--- a/drivers/infiniband/hw/ehca/ehca_qp.c	2008-05-21 13:54:31.000000000 +0200
> ++++ b/drivers/infiniband/hw/ehca/ehca_qp.c	2008-05-21 14:35:25.000000000 +0200
> +@@ -561,6 +566,8 @@ static struct ehca_qp *internal_create_q
> + 		return ERR_PTR(-ENOMEM);
> + 	}
> + 
> ++	atomic_set(&my_qp->nr_events, 0);
> ++	init_waitqueue_head(&my_qp->wait_completion);
> + 	spin_lock_init(&my_qp->spinlock_s);
> + 	spin_lock_init(&my_qp->spinlock_r);
> + 	my_qp->qp_type = qp_type;
> +@@ -1929,6 +1936,9 @@ static int internal_destroy_qp(struct ib
> + 	idr_remove(&ehca_qp_idr, my_qp->token);
> + 	write_unlock_irqrestore(&ehca_qp_idr_lock, flags);
> + 
> ++	/* now wait until all pending events have completed */
> ++	wait_event(my_qp->wait_completion, !atomic_read(&my_qp->nr_events));
> ++
> + 	h_ret = hipz_h_destroy_qp(shca->ipz_hca_handle, my_qp);
> + 	if (h_ret != H_SUCCESS) {
> + 		ehca_err(dev, "hipz_h_destroy_qp() failed h_ret=%li "

Applied,

Regards,
Vladimir



More information about the ewg mailing list