From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=3.0 tests=BUG6152_INVALID_DATE_TZ_ABSURD,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,INCLUDES_PATCH,INVALID_DATE_TZ_ABSURD,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C5FDAC5DF60 for ; Thu, 7 Nov 2019 14:12:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 980612178F for ; Thu, 7 Nov 2019 14:12:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573135944; bh=iGJ5B0qOz2lHUMNcg/EIgSWI4BQHNlzJUaoQBEBpOJM=; h=To:Subject:Date:From:Cc:In-Reply-To:References:List-ID:From; b=1WPGwULIJO9pD/ZkJ0UyBYGPrJgFRJQu1QxLdWf2Xx0MXWWmixOdAgKfGwTxTx2s2 rA5iBkIKysq75xZ6qMs+Uj2CRkbblob4SV9NsPgG94ha9su3+bxnBTFzSKdb+q9sl/ mdTr/Qa3N96Nss0CloTiKUVFzLbUr7q1IVs9S5Z8= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389170AbfKGOMX (ORCPT ); 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...