Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp5231151ybl; Tue, 27 Aug 2019 01:12:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqwqNp/7/nXHuP16wP/MoQTXM6VHcLo34v9JC57GrBHF70Iz5wjeK/T0y83nMx/+rpSm3wUA X-Received: by 2002:a62:ce0e:: with SMTP id y14mr24971655pfg.73.1566893552322; Tue, 27 Aug 2019 01:12:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566893552; cv=none; d=google.com; s=arc-20160816; b=B/izfKU4AUpooIsDMhtnwUMXFHSHlHua3+kLJV3e5iZ/7rAypRTO57WZO7P5SWlt0m VHJu0VkmYWz6sthp429Jd7cN3HK9iR3mQxMHnR5S4JycrThuJdIpUlPkBnl+Y1c8lQZf /NGJxbfpiP1pZWFISc4ymoywFkVhMf+8BakmblH4FX1fCcz9qg1+4U300xFgmNfwlAP6 tkivVjrFm/5+8m5I/eFDmbReLtqRkr91qxHtkFYlLWWkkrTXpk6lIO0kaBuyrXe+mDVS oUpc5wdGYX9d07LZtbTTiSVcfgk/ML2qz1De50v29QKfY3HXfjRDiUUQuZZl2/Cx32NG AqzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=w8PEMGdeXz8UqFxhmt6TbKk/5AGxf9jAiUhgsOP7iO4=; b=J7ETQ8BhwcHWWFZ75f1JBJN6gSuErOfjrxcXzcjj31VDxLuFzNd4HHch5O/4o9YahJ 81Q+9YAJBH4+FB15B1LqI55IA8y6hVDPFYXmsDj+r6HOhgfk+Y6bDO8Mt6YNOn5XXWEA LP+cflJx4P9Xnmvk4Si3Zpb3CbrbcDG3DkZnMnN0KiNONTv3kq4J7D0FoHvqBgxj28cb TAX068gzZEqzrnWTjfU4xpPLW648d5o91N+nyFTsq3zpz8t1olgJ6yDpORY8yN1Knwoz qdVgz0oLa4WEh3IdH/Qw3kZGGsD5XwAti0Qy4941xLrX6atYyd6fLNWVwib3AonBtd2V Fweg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="UFC/nAT9"; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p13si11986423plo.267.2019.08.27.01.12.16; Tue, 27 Aug 2019 01:12:32 -0700 (PDT) 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; dkim=pass header.i=@kernel.org header.s=default header.b="UFC/nAT9"; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731862AbfH0IDt (ORCPT + 99 others); Tue, 27 Aug 2019 04:03:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:32992 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731819AbfH0IDp (ORCPT ); Tue, 27 Aug 2019 04:03:45 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CFEC92186A; Tue, 27 Aug 2019 08:03:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1566893024; bh=x7amhHgdlrtU/F6wMRhW7EnLYizycQjfpOYD5xmaHX8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UFC/nAT9dvsruOqDzUGE3gFFzbQPocdSD+8ek13ktUQ5QNQQxx0I12mZAQOKrEwVo 5XaDxPi4QhOmGRp4ZPDwtYQdkjtMJ6uMkJLuoOW8acGBaKmDXbVkgxQq0M8rySs0i5 OSKo838sNKhh6c4Zem9Q0iCKcvDXidt7tLWRFz7c= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jiangfeng Xiao , "David S. Miller" , Sasha Levin Subject: [PATCH 5.2 093/162] net: hisilicon: make hip04_tx_reclaim non-reentrant Date: Tue, 27 Aug 2019 09:50:21 +0200 Message-Id: <20190827072741.428735732@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190827072738.093683223@linuxfoundation.org> References: <20190827072738.093683223@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit 1a2c070ae805910a853b4a14818481ed2e17c727 ] If hip04_tx_reclaim is interrupted while it is running and then __napi_schedule continues to execute hip04_rx_poll->hip04_tx_reclaim, reentrancy occurs and oops is generated. So you need to mask the interrupt during the hip04_tx_reclaim run. The kernel oops exception stack is as follows: Unable to handle kernel NULL pointer dereference at virtual address 00000050 pgd = c0003000 [00000050] *pgd=80000000a04003, *pmd=00000000 Internal error: Oops: 206 [#1] SMP ARM Modules linked in: hip04_eth mtdblock mtd_blkdevs mtd ohci_platform ehci_platform ohci_hcd ehci_hcd vfat fat sd_mod usb_storage scsi_mod usbcore usb_common CPU: 0 PID: 0 Comm: swapper/0 Tainted: G O 4.4.185 #1 Hardware name: Hisilicon A15 task: c0a250e0 task.stack: c0a00000 PC is at hip04_tx_reclaim+0xe0/0x17c [hip04_eth] LR is at hip04_tx_reclaim+0x30/0x17c [hip04_eth] pc : [] lr : [] psr: 600e0313 sp : c0a01d88 ip : 00000000 fp : c0601f9c r10: 00000000 r9 : c3482380 r8 : 00000001 r7 : 00000000 r6 : 000000e1 r5 : c3482000 r4 : 0000000c r3 : f2209800 r2 : 00000000 r1 : 00000000 r0 : 00000000 Flags: nZCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment kernel Control: 32c5387d Table: 03d28c80 DAC: 55555555 Process swapper/0 (pid: 0, stack limit = 0xc0a00190) Stack: (0xc0a01d88 to 0xc0a02000) [] (hip04_tx_reclaim [hip04_eth]) from [] (hip04_rx_poll+0x88/0x368 [hip04_eth]) [] (hip04_rx_poll [hip04_eth]) from [] (net_rx_action+0x114/0x34c) [] (net_rx_action) from [] (__do_softirq+0x218/0x318) [] (__do_softirq) from [] (irq_exit+0x88/0xac) [] (irq_exit) from [] (msa_irq_exit+0x11c/0x1d4) [] (msa_irq_exit) from [] (__handle_domain_irq+0x110/0x148) [] (__handle_domain_irq) from [] (gic_handle_irq+0xd4/0x118) [] (gic_handle_irq) from [] (__irq_svc+0x40/0x58) Exception stack(0xc0a01f30 to 0xc0a01f78) 1f20: c0ae8b40 00000000 00000000 00000000 1f40: 00000002 ffffe000 c0601f9c 00000000 ffffffff c0a2257c c0a22440 c0831a38 1f60: c0a01ec4 c0a01f80 c0203714 c0203718 600e0213 ffffffff [] (__irq_svc) from [] (arch_cpu_idle+0x20/0x3c) [] (arch_cpu_idle) from [] (cpu_startup_entry+0x244/0x29c) [] (cpu_startup_entry) from [] (rest_init+0xc8/0x10c) [] (rest_init) from [] (start_kernel+0x468/0x514) Code: a40599e5 016086e2 018088e2 7660efe6 (503090e5) ---[ end trace 1db21d6d09c49d74 ]--- Kernel panic - not syncing: Fatal exception in interrupt CPU3: stopping CPU: 3 PID: 0 Comm: swapper/3 Tainted: G D O 4.4.185 #1 Signed-off-by: Jiangfeng Xiao Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/hisilicon/hip04_eth.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hip04_eth.c b/drivers/net/ethernet/hisilicon/hip04_eth.c index e1f2978506fd3..5abe88dfe6abf 100644 --- a/drivers/net/ethernet/hisilicon/hip04_eth.c +++ b/drivers/net/ethernet/hisilicon/hip04_eth.c @@ -494,6 +494,9 @@ static int hip04_rx_poll(struct napi_struct *napi, int budget) u16 len; u32 err; + /* clean up tx descriptors */ + tx_remaining = hip04_tx_reclaim(ndev, false); + while (cnt && !last) { buf = priv->rx_buf[priv->rx_head]; skb = build_skb(buf, priv->rx_buf_size); @@ -554,8 +557,7 @@ refill: } napi_complete_done(napi, rx); done: - /* clean up tx descriptors and start a new timer if necessary */ - tx_remaining = hip04_tx_reclaim(ndev, false); + /* start a new timer if necessary */ if (rx < budget && tx_remaining) hip04_start_tx_timer(priv); -- 2.20.1