Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp1026307ybx; Thu, 7 Nov 2019 06:14:35 -0800 (PST) X-Google-Smtp-Source: APXvYqySSylQZw2k3G41WgnZPwGCavtonkpj1xCtJv4t1f7wHrSHakJzcpw9UZWQNUJ+bKVaIM6W X-Received: by 2002:a17:906:6813:: with SMTP id k19mr3309020ejr.34.1573136075113; Thu, 07 Nov 2019 06:14:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573136075; cv=none; d=google.com; s=arc-20160816; b=jLR8vKB67EOl8nibvkeA3XjCJf/HZApoFDW0gkPIL4MUdjxFfR4yfXHBJ2hOcDv8H+ UW5B7iNHas0zhKz8LBOm840/vez1jimy9S5MZ5R3BXtQj4T6oiqLsVX1S/tbU/wrYrP1 TcFEa5e8a8WbWTRjRmQkIA2HXCFKX53YKUawpO+oSrVUJwBbPj5/q7Q7WBGbvfwpN0GV yOFzE4OSydZtmybVPyQfOCj2uWjprY5CBUpgcWlPatpL90lOgC30wT8O0SEri+ozSkG0 /ODx22J/MEaF+1/HXvaJrcZy0k51jMvE7wRiHgG1xb5CZCP5b73yncA8ZvxgfaOHnAWp Q6Xg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:message-id:references :in-reply-to:cc:from:date:content-transfer-encoding:mime-version :subject:to; bh=BCFll7re4xNad0P3oyKpPT05qhBpl/ozUhh9vqoj+l4=; b=Mbll1JoA+rrX4ntNvJWef9XlOVIDHfhDdWNuwNgXGPJg0EC6J9CU9fhcOLpRBeZfhJ HlVFeOsA6KurCPTP8eKmdJ6Cb8ULNFRCKMPEQRMwxOCG9zlTUoG9VLv8hx6y92buH6+u 1NkI3pjJN9uPaPS9teg87oB1eJOZ6hSm78K6yZthseBBo+/7Jg6a6QVqPIN7pkjCbXSo DR+CXcbkxHXl1AOIIRydox9ClQVxN5eYs8perMQUW37xc/8IF6m56LH37m04EFRNvo0f ARRydPME92rW/GlXfTM3VmvbPldQz4pcDr46cY2UBurvm3nz0twE56L1Vc6WB1oozU3T BDkQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n2si1453061ejy.60.2019.11.07.06.14.10; Thu, 07 Nov 2019 06:14:35 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389154AbfKGOMX (ORCPT + 99 others); Thu, 7 Nov 2019 09:12:23 -0500 Received: from inca-roads.misterjones.org ([213.251.177.50]:46356 "EHLO inca-roads.misterjones.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729162AbfKGOMX (ORCPT ); Thu, 7 Nov 2019 09:12:23 -0500 Received: from www-data by cheepnis.misterjones.org with local (Exim 4.80) (envelope-from ) id 1iSiWG-0006fb-WE; Thu, 07 Nov 2019 15:12:17 +0100 To: Salil Mehta Subject: Re: [PATCH net] net: hns: Fix the stray netpoll locks causing deadlock in NAPI path X-PHP-Originating-Script: 0:main.inc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Date: Thu, 07 Nov 2019 15:21:37 +0109 From: Marc Zyngier Cc: , , , , , , , In-Reply-To: <20191106185405.23112-1-salil.mehta@huawei.com> References: <20191106185405.23112-1-salil.mehta@huawei.com> Message-ID: X-Sender: maz@kernel.org User-Agent: Roundcube Webmail/0.7.2 X-SA-Exim-Connect-IP: X-SA-Exim-Rcpt-To: salil.mehta@huawei.com, davem@davemloft.net, edumazet@google.com, yisen.zhuang@huawei.com, lipeng321@huawei.com, mehta.salil@opnsrc.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linuxarm@huawei.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on cheepnis.misterjones.org); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Salil, On 2019-11-06 20:03, Salil Mehta wrote: > This patch fixes the problem of the spin locks, originally > meant for the netpoll path of hns driver, causing deadlock in > the normal NAPI poll path. The issue happened due presence of > the stray leftover spin lock code related to the netpoll, > whose support was earlier removed from the HNS[1], got activated > due to enabling of NET_POLL_CONTROLLER switch. > > Earlier background: > The netpoll handling code originally had this bug(as identified > by Marc Zyngier[2]) of wrong spin lock API being used which did > not disable the interrupts and hence could cause locking issues. > i.e. if the lock were first acquired in context to thread like > 'ip' util and this lock if ever got later acquired again in > context to the interrupt context like TX/RX (Interrupts could > always pre-empt the lock holding task and acquire the lock again) > and hence could cause deadlock. > > Proposed Solution: > 1. If the netpoll was enabled in the HNS driver, which is not > right now, we could have simply used spin_[un]lock_irqsave() > 2. But as netpoll is disabled, therefore, it is best to get rid > of the existing locks and stray code for now. This should > solve the problem reported by Marc. > > @Marc, > Could you please test this patch and confirm if the problem is > fixed at your end? Yes, this fixes it, although you may want to fully get rid of the now useless lock: diff --git a/drivers/net/ethernet/hisilicon/hns/hnae.c b/drivers/net/ethernet/hisilicon/hns/hnae.c index 6d0457eb4faa..08339278c722 100644 --- a/drivers/net/ethernet/hisilicon/hns/hnae.c +++ b/drivers/net/ethernet/hisilicon/hns/hnae.c @@ -199,7 +199,6 @@ hnae_init_ring(struct hnae_queue *q, struct hnae_ring *ring, int flags) ring->q = q; ring->flags = flags; - spin_lock_init(&ring->lock); ring->coal_param = q->handle->coal_param; assert(!ring->desc && !ring->desc_cb && !ring->desc_dma_addr); diff --git a/drivers/net/ethernet/hisilicon/hns/hnae.h b/drivers/net/ethernet/hisilicon/hns/hnae.h index e9c67c06bfd2..6ab9458302e1 100644 --- a/drivers/net/ethernet/hisilicon/hns/hnae.h +++ b/drivers/net/ethernet/hisilicon/hns/hnae.h @@ -274,9 +274,6 @@ struct hnae_ring { /* statistic */ struct ring_stats stats; - /* ring lock for poll one */ - spinlock_t lock; - dma_addr_t desc_dma_addr; u32 buf_size; /* size for hnae_desc->addr, preset by AE */ u16 desc_num; /* total number of desc */ With that: Acked-by: Marc Zyngier Tested-by: Marc Zyngier Thanks, M. -- Jazz is not dead. It just smells funny...