Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2632410pxj; Mon, 14 Jun 2021 03:34:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz+7bE9c6evqgTeR5WDvVCI98lTclkE7LgpW6PVxYjbKnNYBERRgXfhBPIfiWCrukh043bP X-Received: by 2002:a05:6402:3513:: with SMTP id b19mr1345545edd.148.1623666844557; Mon, 14 Jun 2021 03:34:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623666844; cv=none; d=google.com; s=arc-20160816; b=CsucPldJsuAPdA0T0UbKR45khbVF2prn0xt6Dhw4Hqfe+YyMuKPResVyHef3p1/a5R gd22Btcjxlz6xJ/qvIWyavzx8HySbtkOfMXK47+xZOZomaqBLquYm8W1mGtly4ZyJTgX FiEBNS4QReDkV5Be5uNj05zZGLMWwk53ICooxklwWqG0fpPzQ2ziQHd0TwZA2kbJ05M5 MesQt/2ZaSvSAXH1qL7X3eBBKgw0/jJrK7C2eH8dZsOGIGWMpgLejKBO3NC9MKk317K3 p5Y24EpoScWQf4OSzqqugbY1VMUejBsx+Ux+pdMHLF+vE/GaV/qyx1b0dhyZy8incScM W3OQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=/xBOyldB66+snQ4bxj1YYdtgpbQYyvH7+cVyos0kXLc=; b=i6tjEEdoINQNR+7/OItxTQ/Zx8EciOUgAckIRIAGIIXjs0tHBj1k96XjVmrmvRPBD9 q+yRZxrw8idRTVnMLT6FB82AdjUdSej0LrE9Z0PZrib2fn1kCj63fsYIYtiFEyylKC2c 6dyQO/sSK/YZYnYXOaoL2kDIFsoV6OghG+IiHUriyNLbSTJfQoMQu1TUHMmh7qGcwIV1 Y3LbmgQ+u01AbEZ2azC70jV+XEtWxKhCFWck8C/ChT/04LBbH8ujsbJBBmb21wCwpsCJ PSn5k9c65y0zQIGL4btiyQQ+9sWnl6KgLJa4gHONEGxpikqGCyGO8yn7u/Ft4/JEoUuz hH3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Tdr7tY+z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c27si539150ejj.287.2021.06.14.03.33.41; Mon, 14 Jun 2021 03:34:04 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Tdr7tY+z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232983AbhFNKcM (ORCPT + 99 others); Mon, 14 Jun 2021 06:32:12 -0400 Received: from mail.kernel.org ([198.145.29.99]:37922 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232902AbhFNKbV (ORCPT ); Mon, 14 Jun 2021 06:31:21 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B5ABA611C1; Mon, 14 Jun 2021 10:29:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1623666546; bh=cX1osIjjG/EbNn6Zaz+wRjRZVJLIF7EUhPAuqw/oQEY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Tdr7tY+z8EEuvXbT/3Gb0dXmC0evqGLnMcokkfS5ELgFDD1u5LvIjzZWQ3PG5OB2Q txPAOnhOTHr6F/SWEdW5GCiwcyoQWzJjjpBG0FiAdDD2yBCz2yVAtXT51Z9cP+eMSr FS+s0HP2YxJtxNS5TEuKay9H3kNlYbBkCF7Vrq1s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zheyu Ma , "David S. Miller" , Sasha Levin Subject: [PATCH 4.4 08/34] net/qla3xxx: fix schedule while atomic in ql_sem_spinlock Date: Mon, 14 Jun 2021 12:26:59 +0200 Message-Id: <20210614102641.866568060@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210614102641.582612289@linuxfoundation.org> References: <20210614102641.582612289@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Zheyu Ma [ Upstream commit 13a6f3153922391e90036ba2267d34eed63196fc ] When calling the 'ql_sem_spinlock', the driver has already acquired the spin lock, so the driver should not call 'ssleep' in atomic context. This bug can be fixed by using 'mdelay' instead of 'ssleep'. The KASAN's log reveals it: [ 3.238124 ] BUG: scheduling while atomic: swapper/0/1/0x00000002 [ 3.238748 ] 2 locks held by swapper/0/1: [ 3.239151 ] #0: ffff88810177b240 (&dev->mutex){....}-{3:3}, at: __device_driver_lock+0x41/0x60 [ 3.240026 ] #1: ffff888107c60e28 (&qdev->hw_lock){....}-{2:2}, at: ql3xxx_probe+0x2aa/0xea0 [ 3.240873 ] Modules linked in: [ 3.241187 ] irq event stamp: 460854 [ 3.241541 ] hardirqs last enabled at (460853): [] _raw_spin_unlock_irqrestore+0x4f/0x70 [ 3.242245 ] hardirqs last disabled at (460854): [] _raw_spin_lock_irqsave+0x2a/0x70 [ 3.242245 ] softirqs last enabled at (446076): [] __do_softirq+0x2e4/0x4b1 [ 3.242245 ] softirqs last disabled at (446069): [] irq_exit_rcu+0x100/0x110 [ 3.242245 ] Preemption disabled at: [ 3.242245 ] [] ql3xxx_probe+0x2aa/0xea0 [ 3.242245 ] Kernel panic - not syncing: scheduling while atomic [ 3.242245 ] CPU: 2 PID: 1 Comm: swapper/0 Not tainted 5.13.0-rc1-00145 -gee7dc339169-dirty #16 [ 3.242245 ] Call Trace: [ 3.242245 ] dump_stack+0xba/0xf5 [ 3.242245 ] ? ql3xxx_probe+0x1f0/0xea0 [ 3.242245 ] panic+0x15a/0x3f2 [ 3.242245 ] ? vprintk+0x76/0x150 [ 3.242245 ] ? ql3xxx_probe+0x2aa/0xea0 [ 3.242245 ] __schedule_bug+0xae/0xe0 [ 3.242245 ] __schedule+0x72e/0xa00 [ 3.242245 ] schedule+0x43/0xf0 [ 3.242245 ] schedule_timeout+0x28b/0x500 [ 3.242245 ] ? del_timer_sync+0xf0/0xf0 [ 3.242245 ] ? msleep+0x2f/0x70 [ 3.242245 ] msleep+0x59/0x70 [ 3.242245 ] ql3xxx_probe+0x307/0xea0 [ 3.242245 ] ? _raw_spin_unlock_irqrestore+0x3a/0x70 [ 3.242245 ] ? pci_device_remove+0x110/0x110 [ 3.242245 ] local_pci_probe+0x45/0xa0 [ 3.242245 ] pci_device_probe+0x12b/0x1d0 [ 3.242245 ] really_probe+0x2a9/0x610 [ 3.242245 ] driver_probe_device+0x90/0x1d0 [ 3.242245 ] ? mutex_lock_nested+0x1b/0x20 [ 3.242245 ] device_driver_attach+0x68/0x70 [ 3.242245 ] __driver_attach+0x124/0x1b0 [ 3.242245 ] ? device_driver_attach+0x70/0x70 [ 3.242245 ] bus_for_each_dev+0xbb/0x110 [ 3.242245 ] ? rdinit_setup+0x45/0x45 [ 3.242245 ] driver_attach+0x27/0x30 [ 3.242245 ] bus_add_driver+0x1eb/0x2a0 [ 3.242245 ] driver_register+0xa9/0x180 [ 3.242245 ] __pci_register_driver+0x82/0x90 [ 3.242245 ] ? yellowfin_init+0x25/0x25 [ 3.242245 ] ql3xxx_driver_init+0x23/0x25 [ 3.242245 ] do_one_initcall+0x7f/0x3d0 [ 3.242245 ] ? rdinit_setup+0x45/0x45 [ 3.242245 ] ? rcu_read_lock_sched_held+0x4f/0x80 [ 3.242245 ] kernel_init_freeable+0x2aa/0x301 [ 3.242245 ] ? rest_init+0x2c0/0x2c0 [ 3.242245 ] kernel_init+0x18/0x190 [ 3.242245 ] ? rest_init+0x2c0/0x2c0 [ 3.242245 ] ? rest_init+0x2c0/0x2c0 [ 3.242245 ] ret_from_fork+0x1f/0x30 [ 3.242245 ] Dumping ftrace buffer: [ 3.242245 ] (ftrace buffer empty) [ 3.242245 ] Kernel Offset: disabled [ 3.242245 ] Rebooting in 1 seconds. Reported-by: Zheyu Ma Signed-off-by: Zheyu Ma Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/qlogic/qla3xxx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/qlogic/qla3xxx.c b/drivers/net/ethernet/qlogic/qla3xxx.c index f2cb77c3b199..192950a112c9 100644 --- a/drivers/net/ethernet/qlogic/qla3xxx.c +++ b/drivers/net/ethernet/qlogic/qla3xxx.c @@ -115,7 +115,7 @@ static int ql_sem_spinlock(struct ql3_adapter *qdev, value = readl(&port_regs->CommonRegs.semaphoreReg); if ((value & (sem_mask >> 16)) == sem_bits) return 0; - ssleep(1); + mdelay(1000); } while (--seconds); return -1; } -- 2.30.2