lkml.org 
[lkml]   [2016]   [Jun]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 08/12] infiniband: Employ atomic_fetch_inc()
    Date
    Now that we have fetch_inc() we can stop using inc_return() - 1.

    These are very similar to the existing OP-RETURN primitives we already
    have, except they return the value of the atomic variable _before_
    modification.

    Cc: Doug Ledford <dledford@redhat.com>
    Cc: Sean Hefty <sean.hefty@intel.com>
    Cc: Hal Rosenstock <hal.rosenstock@gmail.com>
    Signed-off-by: Davidlohr Bueso <dbueso@suse.de>
    ---
    drivers/infiniband/hw/cxgb4/device.c | 3 +--
    drivers/infiniband/hw/hfi1/verbs.c | 3 +--
    2 files changed, 2 insertions(+), 4 deletions(-)

    diff --git a/drivers/infiniband/hw/cxgb4/device.c b/drivers/infiniband/hw/cxgb4/device.c
    index ae2e8b23d2dd..a32959fa2c82 100644
    --- a/drivers/infiniband/hw/cxgb4/device.c
    +++ b/drivers/infiniband/hw/cxgb4/device.c
    @@ -111,8 +111,7 @@ void c4iw_log_wr_stats(struct t4_wq *wq, struct t4_cqe *cqe)
    if (!wq->rdev->wr_log)
    return;

    - idx = (atomic_inc_return(&wq->rdev->wr_log_idx) - 1) &
    - (wq->rdev->wr_log_size - 1);
    + idx = atomic_fetch_inc(&wq->rdev->wr_log_idx) & (wq->rdev->wr_log_size - 1);
    le.poll_sge_ts = cxgb4_read_sge_timestamp(wq->rdev->lldi.ports[0]);
    getnstimeofday(&le.poll_host_ts);
    le.valid = 1;
    diff --git a/drivers/infiniband/hw/hfi1/verbs.c b/drivers/infiniband/hw/hfi1/verbs.c
    index 849c4b9399d4..9ba311b53085 100644
    --- a/drivers/infiniband/hw/hfi1/verbs.c
    +++ b/drivers/infiniband/hw/hfi1/verbs.c
    @@ -261,8 +261,7 @@ static void wss_advance_clean_counter(void)
    * wss.clean_entry. The table size, wss.num_entries,
    * is always a power-of-2.
    */
    - entry = (atomic_inc_return(&wss.clean_entry) - 1)
    - & (wss.num_entries - 1);
    + entry = atomic_fetch_inc(&wss.clean_entry) & (wss.num_entries - 1);

    /* clear the entry and count the bits */
    bits = xchg(&wss.entries[entry], 0);
    --
    2.6.6
    \
     
     \ /
      Last update: 2016-06-20 22:41    [W:4.539 / U:0.744 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site