From patchwork Thu Aug 6 17:00:28 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcin Wojtas X-Patchwork-Id: 6961481 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 204DCC05AC for ; Thu, 6 Aug 2015 17:03:35 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 847072070D for ; Thu, 6 Aug 2015 17:03:29 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9002720708 for ; Thu, 6 Aug 2015 17:03:28 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZNOXx-0006xG-4z; Thu, 06 Aug 2015 17:01:37 +0000 Received: from mail-la0-f43.google.com ([209.85.215.43]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZNOXY-0006dk-TW for linux-arm-kernel@lists.infradead.org; Thu, 06 Aug 2015 17:01:14 +0000 Received: by labow3 with SMTP id ow3so53181297lab.1 for ; Thu, 06 Aug 2015 10:00:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=2FsPy/2eA/d0lVWA1WOeS4Y/uUAD8O8qkOKFzc5Bg3E=; b=UefLAyB7CI80eG96hDwG/GylM/kt7VXXigKve0wrj0XxH97Uo8w4tJ6pOtgRRV5c30 ZOpIqP5mITKFXbeVySNtabE5vB8g2t4brLet8NaryRB95tMJi9GDpDATlYB+ssXE/aYq Nq3rI4yziDhFOXyE8ZMMWgKi7K3TPjeopr39prKEHCgG/Ec2OIOhl0KWU7NHR/W9elMO ADx6nRTBfp2LqtIdrRHop4tJ4iM1d0YlP0Kf93BcE57OqjbBKqMvoIQpX2IwR7ZfCHWS yxj3Fr+QWdEcw7/sGs16D0UVaN5vtgIjJ6/ks7ahS9ZKoiw30IrW7bw2b4Ca3AzR0vK+ aOUQ== X-Gm-Message-State: ALoCoQkHlRZI0KfboUsW5kdYfajSvNIaIiQD9Xa0ZzKpsuQNE8eX/3a7fqGqQuGTfUxcCDKxECTL X-Received: by 10.152.25.169 with SMTP id d9mr3394286lag.80.1438880450871; Thu, 06 Aug 2015 10:00:50 -0700 (PDT) Received: from mw-VirtualBox.semihalf.com ([80.82.22.190]) by smtp.gmail.com with ESMTPSA id v8sm1506147lbo.43.2015.08.06.10.00.48 (version=TLSv1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 06 Aug 2015 10:00:49 -0700 (PDT) From: Marcin Wojtas To: linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org Subject: [PATCH 1/3] net: mvpp2: remove excessive spinlocks from driver initialization Date: Thu, 6 Aug 2015 19:00:28 +0200 Message-Id: <1438880430-5480-2-git-send-email-mw@semihalf.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1438880430-5480-1-git-send-email-mw@semihalf.com> References: <1438880430-5480-1-git-send-email-mw@semihalf.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150806_100113_140743_68966440 X-CRM114-Status: GOOD ( 13.26 ) X-Spam-Score: -2.6 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: thomas.petazzoni@free-electrons.com, alior@marvell.com, jason@lakedaemon.net, jaz@semihalf.com, ezequiel.garcia@free-electrons.com, gregory.clement@free-electrons.com, Marcin Wojtas , davem@davemloft.net MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Using spinlocks protection during one-time driver initialization is not necessary. Moreover it resulted in invalid GFP_KERNEL allocation under the lock. This commit removes redundant spinlocks from buffer manager part of mvpp2 initialization. Signed-off-by: Marcin Wojtas Reported-by: Alexandre Fournier --- drivers/net/ethernet/marvell/mvpp2.c | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/drivers/net/ethernet/marvell/mvpp2.c b/drivers/net/ethernet/marvell/mvpp2.c index 3e8b1bf..f94bd12 100644 --- a/drivers/net/ethernet/marvell/mvpp2.c +++ b/drivers/net/ethernet/marvell/mvpp2.c @@ -913,8 +913,6 @@ struct mvpp2_bm_pool { /* Occupied buffers indicator */ atomic_t in_use; int in_use_thresh; - - spinlock_t lock; }; struct mvpp2_buff_hdr { @@ -3376,7 +3374,6 @@ static int mvpp2_bm_pool_create(struct platform_device *pdev, bm_pool->pkt_size = 0; bm_pool->buf_num = 0; atomic_set(&bm_pool->in_use, 0); - spin_lock_init(&bm_pool->lock); return 0; } @@ -3647,7 +3644,6 @@ static struct mvpp2_bm_pool * mvpp2_bm_pool_use(struct mvpp2_port *port, int pool, enum mvpp2_bm_type type, int pkt_size) { - unsigned long flags = 0; struct mvpp2_bm_pool *new_pool = &port->priv->bm_pools[pool]; int num; @@ -3656,8 +3652,6 @@ mvpp2_bm_pool_use(struct mvpp2_port *port, int pool, enum mvpp2_bm_type type, return NULL; } - spin_lock_irqsave(&new_pool->lock, flags); - if (new_pool->type == MVPP2_BM_FREE) new_pool->type = type; @@ -3686,8 +3680,6 @@ mvpp2_bm_pool_use(struct mvpp2_port *port, int pool, enum mvpp2_bm_type type, if (num != pkts_num) { WARN(1, "pool %d: %d of %d allocated\n", new_pool->id, num, pkts_num); - /* We need to undo the bufs_add() allocations */ - spin_unlock_irqrestore(&new_pool->lock, flags); return NULL; } } @@ -3695,15 +3687,12 @@ mvpp2_bm_pool_use(struct mvpp2_port *port, int pool, enum mvpp2_bm_type type, mvpp2_bm_pool_bufsize_set(port->priv, new_pool, MVPP2_RX_BUF_SIZE(new_pool->pkt_size)); - spin_unlock_irqrestore(&new_pool->lock, flags); - return new_pool; } /* Initialize pools for swf */ static int mvpp2_swf_bm_pool_init(struct mvpp2_port *port) { - unsigned long flags = 0; int rxq; if (!port->pool_long) { @@ -3714,9 +3703,7 @@ static int mvpp2_swf_bm_pool_init(struct mvpp2_port *port) if (!port->pool_long) return -ENOMEM; - spin_lock_irqsave(&port->pool_long->lock, flags); port->pool_long->port_map |= (1 << port->id); - spin_unlock_irqrestore(&port->pool_long->lock, flags); for (rxq = 0; rxq < rxq_number; rxq++) mvpp2_rxq_long_pool_set(port, rxq, port->pool_long->id); @@ -3730,9 +3717,7 @@ static int mvpp2_swf_bm_pool_init(struct mvpp2_port *port) if (!port->pool_short) return -ENOMEM; - spin_lock_irqsave(&port->pool_short->lock, flags); port->pool_short->port_map |= (1 << port->id); - spin_unlock_irqrestore(&port->pool_short->lock, flags); for (rxq = 0; rxq < rxq_number; rxq++) mvpp2_rxq_short_pool_set(port, rxq,