All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH rdma-next v1] irdma: Use list_last_entry/list_first_entry
@ 2021-06-08 21:14 Shiraz Saleem
  2021-06-08 23:04 ` Jason Gunthorpe
  2021-06-09  6:45 ` Dan Carpenter
  0 siblings, 2 replies; 5+ messages in thread
From: Shiraz Saleem @ 2021-06-08 21:14 UTC (permalink / raw)
  To: dledford, jgg; +Cc: linux-rdma, Shiraz Saleem, Dan Carpenter

Use list_last_entry and list_first_entry instead of using prev and next
pointers.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Shiraz Saleem <shiraz.saleem@intel.com>
---
v0->v1: create patch on more recent git version

 drivers/infiniband/hw/irdma/puda.c  | 2 +-
 drivers/infiniband/hw/irdma/utils.c | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/infiniband/hw/irdma/puda.c b/drivers/infiniband/hw/irdma/puda.c
index 18057139817d..e09d3be90771 100644
--- a/drivers/infiniband/hw/irdma/puda.c
+++ b/drivers/infiniband/hw/irdma/puda.c
@@ -1419,7 +1419,7 @@ irdma_ieq_handle_partial(struct irdma_puda_rsrc *ieq, struct irdma_pfpdu *pfpdu,
 
 error:
 	while (!list_empty(&pbufl)) {
-		buf = (struct irdma_puda_buf *)(pbufl.prev);
+		buf = list_last_entry(&pbufl, struct irdma_puda_buf, list);
 		list_del(&buf->list);
 		list_add(&buf->list, rxlist);
 	}
diff --git a/drivers/infiniband/hw/irdma/utils.c b/drivers/infiniband/hw/irdma/utils.c
index 8ce3535cdc21..81e590fb77b1 100644
--- a/drivers/infiniband/hw/irdma/utils.c
+++ b/drivers/infiniband/hw/irdma/utils.c
@@ -425,8 +425,8 @@ struct irdma_cqp_request *irdma_alloc_and_get_cqp_request(struct irdma_cqp *cqp,
 
 	spin_lock_irqsave(&cqp->req_lock, flags);
 	if (!list_empty(&cqp->cqp_avail_reqs)) {
-		cqp_request = list_entry(cqp->cqp_avail_reqs.next,
-					 struct irdma_cqp_request, list);
+		cqp_request = list_first_entry(&cqp->cqp_avail_reqs,
+					       struct irdma_cqp_request, list);
 		list_del_init(&cqp_request->list);
 	}
 	spin_unlock_irqrestore(&cqp->req_lock, flags);
-- 
2.27.0


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

* Re: [PATCH rdma-next v1] irdma: Use list_last_entry/list_first_entry
  2021-06-08 21:14 [PATCH rdma-next v1] irdma: Use list_last_entry/list_first_entry Shiraz Saleem
@ 2021-06-08 23:04 ` Jason Gunthorpe
  2021-06-08 23:19   ` Saleem, Shiraz
  2021-06-09  6:45 ` Dan Carpenter
  1 sibling, 1 reply; 5+ messages in thread
From: Jason Gunthorpe @ 2021-06-08 23:04 UTC (permalink / raw)
  To: Shiraz Saleem; +Cc: dledford, linux-rdma, Dan Carpenter

On Tue, Jun 08, 2021 at 04:14:16PM -0500, Shiraz Saleem wrote:
> Use list_last_entry and list_first_entry instead of using prev and next
> pointers.
> 
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Signed-off-by: Shiraz Saleem <shiraz.saleem@intel.com>
> ---
> v0->v1: create patch on more recent git version
> 
>  drivers/infiniband/hw/irdma/puda.c  | 2 +-
>  drivers/infiniband/hw/irdma/utils.c | 4 ++--
>  2 files changed, 3 insertions(+), 3 deletions(-)

This still doesn't apply to the rdma tree.. You need to use the exact
rdma tree, not wherever this came from.

Anyhow I fixed it up by hand.

Jason

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

* RE: [PATCH rdma-next v1] irdma: Use list_last_entry/list_first_entry
  2021-06-08 23:04 ` Jason Gunthorpe
@ 2021-06-08 23:19   ` Saleem, Shiraz
  2021-06-08 23:25     ` Jason Gunthorpe
  0 siblings, 1 reply; 5+ messages in thread
From: Saleem, Shiraz @ 2021-06-08 23:19 UTC (permalink / raw)
  To: Jason Gunthorpe; +Cc: dledford, linux-rdma, Dan Carpenter

> Subject: Re: [PATCH rdma-next v1] irdma: Use list_last_entry/list_first_entry
> 
> On Tue, Jun 08, 2021 at 04:14:16PM -0500, Shiraz Saleem wrote:
> > Use list_last_entry and list_first_entry instead of using prev and
> > next pointers.
> >
> > Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> > Signed-off-by: Shiraz Saleem <shiraz.saleem@intel.com>
> > ---
> > v0->v1: create patch on more recent git version
> >
> >  drivers/infiniband/hw/irdma/puda.c  | 2 +-
> > drivers/infiniband/hw/irdma/utils.c | 4 ++--
> >  2 files changed, 3 insertions(+), 3 deletions(-)
> 
> This still doesn't apply to the rdma tree.. You need to use the exact rdma tree, not
> wherever this came from.
> 
> Anyhow I fixed it up by hand.
> 

I am not really sure what is going on. This applies cleanly for me to the tip of for-next. Here is snippet of git log -p.

commit fc7f645ca3c1b7a7e9f8eabc83a6ee462b277194 (HEAD -> rdma-for-next)
Author: Shiraz Saleem <shiraz.saleem@intel.com>
Date:   Tue Jun 8 12:02:30 2021 -0500

    irdma: Use list_last_entry/list_first_entry
    
    Use list_last_entry and list_first_entry instead of using prev and next
    pointers.
    
    Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
    Signed-off-by: Shiraz Saleem <shiraz.saleem@intel.com>

diff --git a/drivers/infiniband/hw/irdma/puda.c b/drivers/infiniband/hw/irdma/puda.c
index 18057139817d..e09d3be90771 100644
--- a/drivers/infiniband/hw/irdma/puda.c
+++ b/drivers/infiniband/hw/irdma/puda.c
@@ -1419,7 +1419,7 @@ irdma_ieq_handle_partial(struct irdma_puda_rsrc *ieq, struct irdma_pfpdu *pfpdu,
 
 error:
        while (!list_empty(&pbufl)) {
-               buf = (struct irdma_puda_buf *)(pbufl.prev);
+               buf = list_last_entry(&pbufl, struct irdma_puda_buf, list);
                list_del(&buf->list);
                list_add(&buf->list, rxlist);
        }
diff --git a/drivers/infiniband/hw/irdma/utils.c b/drivers/infiniband/hw/irdma/utils.c
index 8f04347be52c..b4b91cb81cca 100644
--- a/drivers/infiniband/hw/irdma/utils.c
+++ b/drivers/infiniband/hw/irdma/utils.c
@@ -425,8 +425,8 @@ struct irdma_cqp_request *irdma_alloc_and_get_cqp_request(struct irdma_cqp *cqp,
 
        spin_lock_irqsave(&cqp->req_lock, flags);
        if (!list_empty(&cqp->cqp_avail_reqs)) {
-               cqp_request = list_entry(cqp->cqp_avail_reqs.next,
-                                        struct irdma_cqp_request, list);
+               cqp_request = list_first_entry(&cqp->cqp_avail_reqs,
+                                              struct irdma_cqp_request, list);
                list_del_init(&cqp_request->list);
        }
        spin_unlock_irqrestore(&cqp->req_lock, flags);

commit 61c7d826b81769ea57d094305c900f903768f322 (upstream_v2/for-next)
Author: Kamal Heib <kamalheib1@gmail.com>
Date:   Tue Jun 8 01:15:43 2021 +0300

    RDMA/irdma: Fix return error sign from irdma_modify_qp
    
    There is a typo in the returned error code sign from irdma_modify_qp()
    when the attr_mask is not supported - Fix it.

[....]

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

* Re: [PATCH rdma-next v1] irdma: Use list_last_entry/list_first_entry
  2021-06-08 23:19   ` Saleem, Shiraz
@ 2021-06-08 23:25     ` Jason Gunthorpe
  0 siblings, 0 replies; 5+ messages in thread
From: Jason Gunthorpe @ 2021-06-08 23:25 UTC (permalink / raw)
  To: Saleem, Shiraz; +Cc: dledford, linux-rdma, Dan Carpenter

On Tue, Jun 08, 2021 at 11:19:58PM +0000, Saleem, Shiraz wrote:
> > Subject: Re: [PATCH rdma-next v1] irdma: Use list_last_entry/list_first_entry
> > 
> > On Tue, Jun 08, 2021 at 04:14:16PM -0500, Shiraz Saleem wrote:
> > > Use list_last_entry and list_first_entry instead of using prev and
> > > next pointers.
> > >
> > > Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> > > Signed-off-by: Shiraz Saleem <shiraz.saleem@intel.com>
> > > v0->v1: create patch on more recent git version
> > >
> > >  drivers/infiniband/hw/irdma/puda.c  | 2 +-
> > > drivers/infiniband/hw/irdma/utils.c | 4 ++--
> > >  2 files changed, 3 insertions(+), 3 deletions(-)
> > 
> > This still doesn't apply to the rdma tree.. You need to use the exact rdma tree, not
> > wherever this came from.
> > 
> > Anyhow I fixed it up by hand.
> > 
> 
> I am not really sure what is going on. This applies cleanly for me
> to the tip of for-next.

It is git magic because you have the right blobs and I don't

> diff --git a/drivers/infiniband/hw/irdma/utils.c b/drivers/infiniband/hw/irdma/utils.c
> index 8f04347be52c..b4b91cb81cca 100644
        ^^^^^^^^^^^^

This is the right blob, but the v1 from before had this:

index 8ce3535cdc21..81e590fb77b1 100644

And I don't have 8ce3535cdc21 at all. So git gives up if things aren't
a perfect match.

You have 8ce3535cdc21 so when you tried to apply your own patch it
would have done a 3 way merge and fixed it.

This is why it is important to actually generate diffs against common
commits that other people have because it allows git magic to work
properly. Even if the diffs are nearly identical having the blob be
correct covers alot of sins.

What I tell other people to do is publish everything they send in a
branch in a git repo and I then just keep a local copy of it up to
date and get the needed stuff from there.

Jason

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

* Re: [PATCH rdma-next v1] irdma: Use list_last_entry/list_first_entry
  2021-06-08 21:14 [PATCH rdma-next v1] irdma: Use list_last_entry/list_first_entry Shiraz Saleem
  2021-06-08 23:04 ` Jason Gunthorpe
@ 2021-06-09  6:45 ` Dan Carpenter
  1 sibling, 0 replies; 5+ messages in thread
From: Dan Carpenter @ 2021-06-09  6:45 UTC (permalink / raw)
  To: Shiraz Saleem; +Cc: dledford, jgg, linux-rdma

On Tue, Jun 08, 2021 at 04:14:16PM -0500, Shiraz Saleem wrote:
> Use list_last_entry and list_first_entry instead of using prev and next
> pointers.
> 
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Signed-off-by: Shiraz Saleem <shiraz.saleem@intel.com>
> ---
> v0->v1: create patch on more recent git version
> 
>  drivers/infiniband/hw/irdma/puda.c  | 2 +-
>  drivers/infiniband/hw/irdma/utils.c | 4 ++--
>  2 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/infiniband/hw/irdma/puda.c b/drivers/infiniband/hw/irdma/puda.c
> index 18057139817d..e09d3be90771 100644
> --- a/drivers/infiniband/hw/irdma/puda.c
> +++ b/drivers/infiniband/hw/irdma/puda.c
> @@ -1419,7 +1419,7 @@ irdma_ieq_handle_partial(struct irdma_puda_rsrc *ieq, struct irdma_pfpdu *pfpdu,
>  
>  error:
>  	while (!list_empty(&pbufl)) {
> -		buf = (struct irdma_puda_buf *)(pbufl.prev);
> +		buf = list_last_entry(&pbufl, struct irdma_puda_buf, list);
>  		list_del(&buf->list);
>  		list_add(&buf->list, rxlist);
>  	}
> diff --git a/drivers/infiniband/hw/irdma/utils.c b/drivers/infiniband/hw/irdma/utils.c
> index 8ce3535cdc21..81e590fb77b1 100644
> --- a/drivers/infiniband/hw/irdma/utils.c
> +++ b/drivers/infiniband/hw/irdma/utils.c
> @@ -425,8 +425,8 @@ struct irdma_cqp_request *irdma_alloc_and_get_cqp_request(struct irdma_cqp *cqp,
>  
>  	spin_lock_irqsave(&cqp->req_lock, flags);
>  	if (!list_empty(&cqp->cqp_avail_reqs)) {
> -		cqp_request = list_entry(cqp->cqp_avail_reqs.next,
> -					 struct irdma_cqp_request, list);
> +		cqp_request = list_first_entry(&cqp->cqp_avail_reqs,
> +					       struct irdma_cqp_request, list);
>  		list_del_init(&cqp_request->list);

Thanks for doing this one too.  :)

regards,
dan carpenter


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

end of thread, other threads:[~2021-06-09  6:45 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-08 21:14 [PATCH rdma-next v1] irdma: Use list_last_entry/list_first_entry Shiraz Saleem
2021-06-08 23:04 ` Jason Gunthorpe
2021-06-08 23:19   ` Saleem, Shiraz
2021-06-08 23:25     ` Jason Gunthorpe
2021-06-09  6:45 ` Dan Carpenter

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.