From patchwork Mon Jun 4 12:30:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roman Pen X-Patchwork-Id: 10446513 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 802FF6054D for ; Mon, 4 Jun 2018 12:30:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5D9FB28E7F for ; Mon, 4 Jun 2018 12:30:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5BF7328E77; Mon, 4 Jun 2018 12:30:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E8BC828ED0 for ; Mon, 4 Jun 2018 12:30:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752675AbeFDMaZ (ORCPT ); Mon, 4 Jun 2018 08:30:25 -0400 Received: from mail-wr0-f195.google.com ([209.85.128.195]:43462 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751769AbeFDMaX (ORCPT ); Mon, 4 Jun 2018 08:30:23 -0400 Received: by mail-wr0-f195.google.com with SMTP id d2-v6so27609480wrm.10 for ; Mon, 04 Jun 2018 05:30:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=profitbricks-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=qURUI2rbvSxPWUtXgIznk7Eal3MMAaS0f4YvwQ5Mw9I=; b=XS64D1J1mZQ1adNB6OQgXe0kCN3sjZcQ75J8933HuI6qmM8ntWbQtwg4OFtDlt4+3g PoyvKyxhiW/ilWCCKutowsQzEJPAjEH2a4/2gEamEWEo1onwCvnb8Rz4kFtPOklCeUsC DE5WNowP4+/tGTTC3zzRSFhFpjCegSMkJfy51qgluVs7XpbzQ3xx8i5eZ/zel/ajfZN4 2X5gMkiebrrOyhVgvOK2AwkjvbjoOHJkrpLyzSXZW/kg3ezGoGsBAvpZFWHVfsAwGJGN 5sBze0dw9Z0TjUXUujCMUpWWgpdhu34aiTovWoG4CczqkYdG3Ou9BxKZRKiWYZossOK8 knEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=qURUI2rbvSxPWUtXgIznk7Eal3MMAaS0f4YvwQ5Mw9I=; b=jFFZJonJ+AqShPzWabOsPqBQ/FND2WOgUwLvyo3gkJqa25i80Pdfsp2TyJxjRbOTge +ufzvavX6qMIlDvgaFGLVNikTZv3A5y1tnesuzjEL2kLNoIeDXfvSv4O+8Efrbx0V0ZZ cp+z6hi7zz8e13qsx3PsVO5R3JFXe5wvHKYf/MRW/GAC+denqH8RUnwDtv9lKplpiDnd nVBtWdGRjyYvHD8NjJQhePFDNocYDzuzEugaehJ11QW6bjQQ9LMSuqvwuTtOOMTjvH42 ELI5pV8rQwiduMFsFtOvP++J1xOz1cu/tR5Efrpc0iwwmxxj7MLiaitsyAHROXPIxUhh GiNw== X-Gm-Message-State: ALKqPwdxXtGogy3OK2t4oyMG6PqFadwNgZVb8p8fUwqRCyz7IWyqUnkg HncUGkF644FxN4X1oYOQn0eUlg== X-Google-Smtp-Source: ADUXVKIohhcB9GGwP73CIcWZUDhqGYVh/RMqbXLnDj2jNW54XMw9DwW9we9spb2oh3ttqxIga3fGKQ== X-Received: by 2002:adf:9950:: with SMTP id x74-v6mr15147878wrb.135.1528115422791; Mon, 04 Jun 2018 05:30:22 -0700 (PDT) Received: from pb.pb.local ([62.217.45.26]) by smtp.gmail.com with ESMTPSA id s9-v6sm70578wmc.34.2018.06.04.05.30.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Jun 2018 05:30:22 -0700 (PDT) From: Roman Pen To: linux-rdma@vger.kernel.org Cc: Roman Pen , Roman Pen , Christoph Hellwig , Steve Wise , Bart Van Assche , Doug Ledford , target-devel@vger.kernel.org Subject: [PATCH v2 6/8] IB/isert: embed mutex inside isert_device structure Date: Mon, 4 Jun 2018 14:30:01 +0200 Message-Id: <20180604123003.24748-7-roman.penyaev@profitbricks.com> X-Mailer: git-send-email 2.13.1 In-Reply-To: <20180604123003.24748-1-roman.penyaev@profitbricks.com> References: <20180604123003.24748-1-roman.penyaev@profitbricks.com> Sender: target-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP do not abuse device_list_mutex. In the next patch device_list_mutex will be removed. Signed-off-by: Roman Pen Cc: Christoph Hellwig Cc: Steve Wise Cc: Bart Van Assche Reviewed-by: Sagi Grimberg Cc: Doug Ledford Cc: target-devel@vger.kernel.org --- drivers/infiniband/ulp/isert/ib_isert.c | 11 +++++++---- drivers/infiniband/ulp/isert/ib_isert.h | 1 + 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/infiniband/ulp/isert/ib_isert.c b/drivers/infiniband/ulp/isert/ib_isert.c index fff40b097947..b7da1a6ea32c 100644 --- a/drivers/infiniband/ulp/isert/ib_isert.c +++ b/drivers/infiniband/ulp/isert/ib_isert.c @@ -96,14 +96,14 @@ isert_comp_get(struct isert_conn *isert_conn) struct isert_comp *comp; int i, min = 0; - mutex_lock(&device_list_mutex); + mutex_lock(&device->comp_mutex); for (i = 0; i < device->comps_used; i++) if (device->comps[i].active_qps < device->comps[min].active_qps) min = i; comp = &device->comps[min]; comp->active_qps++; - mutex_unlock(&device_list_mutex); + mutex_unlock(&device->comp_mutex); isert_info("conn %p, using comp %p min_index: %d\n", isert_conn, comp, min); @@ -114,9 +114,11 @@ isert_comp_get(struct isert_conn *isert_conn) static void isert_comp_put(struct isert_comp *comp) { - mutex_lock(&device_list_mutex); + struct isert_device *device = comp->device; + + mutex_lock(&device->comp_mutex); comp->active_qps--; - mutex_unlock(&device_list_mutex); + mutex_unlock(&device->comp_mutex); } static struct ib_qp * @@ -374,6 +376,7 @@ isert_device_get(struct rdma_cm_id *cma_id) } INIT_LIST_HEAD(&device->dev_node); + mutex_init(&device->comp_mutex); device->ib_device = cma_id->device; ret = isert_create_device_ib_res(device); diff --git a/drivers/infiniband/ulp/isert/ib_isert.h b/drivers/infiniband/ulp/isert/ib_isert.h index 3b296bac4f60..9f0b0a6d87cf 100644 --- a/drivers/infiniband/ulp/isert/ib_isert.h +++ b/drivers/infiniband/ulp/isert/ib_isert.h @@ -184,6 +184,7 @@ struct isert_comp { struct isert_device { bool pi_capable; int refcount; + struct mutex comp_mutex; struct ib_device *ib_device; struct ib_pd *pd; struct isert_comp *comps;