Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1124411pxb; Thu, 4 Mar 2021 04:04:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJz6PzKbX4rFNLJ2cbxq+kz/mupY38x0ZLhvfLFct46fH+wpDla4HsA8K0LQ1t/fzW3v80jh X-Received: by 2002:a17:906:1182:: with SMTP id n2mr3912401eja.234.1614859493606; Thu, 04 Mar 2021 04:04:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614859493; cv=none; d=google.com; s=arc-20160816; b=xsVibnsVGS8AIDS5XrLbm5qKnX+GgU6g1HbtYs9Qe4d0Dsl4xlP9Ay8aOuhp5bhcsY T3oyN0LNlAdrKcrg8w6YeaCI1oTdU0IcDXK/D+ZX0CZY7pm1ncjYvF7Nm9VM9ScZKPtW x1TCWVGE60sxvf/PENliEt/DU8fHTy7RcRRmG/qjVvTe5J2t6piGu5fCXaJkcJX6pTWt oE1uPLmDrKX6K631aKsP0MjfwqI7iLdA2h4bNhUNK4wD1ddwtUfFZaokPGGQrUB2aI4y I0r2OnU6Pd5nO4fcMxYAAQFChgIjnRqKQdxdD52cDIy993ckNekwSFlNH2iLmEolQLU8 CSAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:message-id:user-agent:cc:to:references :in-reply-to:from:subject:content-transfer-encoding:mime-version :dmarc-filter:sender:dkim-signature; bh=63uD1rKESWU1WACrRV+OsLIaFjlY+XnAo1HvrwgjRqY=; b=kjxdGWOOlr6T0wMlMt/ClsWSBVcqCOnziOsYHzFxAKCXACt7duIp0vH7u1jRQ2S5Qf LxS3G7xAvkZk9lQKgMDcFoGdFSmn9orHYtSrvPuCS7DIvgmTTgGKIMtc3DN2El8171XM G1qcB2AG0MCvBiQflTWRf0MwmoNqg4ISVFvub3JIIP3e2uaq4/jVlIpYNBZGisgzUKzB +Z4mrfiUDOAxrN6wyratS4XmK/6szg7UL0/TQcxGtpkC7t1GvJ23mnoiJW8cJGhuehf8 Y16bo1reH5EAExHnYR8yDoZwUsFYFj8MRPUJu7TYOhL9EjE61txpDbE/q/SlQgijzYjc fz/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=stC6+EqP; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bx25si6910886edb.242.2021.03.04.04.04.30; Thu, 04 Mar 2021 04:04:53 -0800 (PST) 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=@mg.codeaurora.org header.s=smtp header.b=stC6+EqP; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1578230AbhCCSQx (ORCPT + 99 others); Wed, 3 Mar 2021 13:16:53 -0500 Received: from m42-2.mailgun.net ([69.72.42.2]:47255 "EHLO m42-2.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233516AbhCCQAu (ORCPT ); Wed, 3 Mar 2021 11:00:50 -0500 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1614787217; h=Date: Message-Id: Cc: To: References: In-Reply-To: From: Subject: Content-Transfer-Encoding: MIME-Version: Content-Type: Sender; bh=63uD1rKESWU1WACrRV+OsLIaFjlY+XnAo1HvrwgjRqY=; b=stC6+EqPPZgy0JQCGKMf2HP1vRE1qG4J4l5NjbMa5xluO8jX5ccI2uq8OveIt6TE/a6rhL0z AdT50/2cMEq6UQzVhh1Mr0nyrjUKvXznhqPSA3CS3jt+yYK2GT4HTZgZYcrLW0sukH2Y/1Jb wkKoYwj5gB626bbm5BaR1MecpW8= X-Mailgun-Sending-Ip: 69.72.42.2 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n01.prod.us-east-1.postgun.com with SMTP id 603fb26d1a5c93533fec4c0d (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Wed, 03 Mar 2021 15:59:41 GMT Sender: kvalo=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id C0819C433ED; Wed, 3 Mar 2021 15:59:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=ALL_TRUSTED,BAYES_00, MISSING_DATE,MISSING_MID,SPF_FAIL,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from potku.adurom.net (88-114-240-156.elisa-laajakaista.fi [88.114.240.156]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: kvalo) by smtp.codeaurora.org (Postfix) with ESMTPSA id C1A31C433CA; Wed, 3 Mar 2021 15:59:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org C1A31C433CA Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=fail smtp.mailfrom=kvalo@codeaurora.org Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: Re: [PATCH v2] iwlwifi: don't call netif_napi_add() with rxq->lock held (was Re: Lockdep warning in iwl_pcie_rx_handle()) From: Kalle Valo In-Reply-To: References: To: Jiri Kosina Cc: Johannes Berg , Luca Coelho , Heiner Kallweit , linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org User-Agent: pwcli/0.1.0-git (https://github.com/kvalo/pwcli/) Python/3.5.2 Message-Id: <20210303155940.C0819C433ED@smtp.codeaurora.org> Date: Wed, 3 Mar 2021 15:59:40 +0000 (UTC) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Jiri Kosina wrote: > From: Jiri Kosina > > We can't call netif_napi_add() with rxq-lock held, as there is a potential > for deadlock as spotted by lockdep (see below). rxq->lock is not > protecting anything over the netif_napi_add() codepath anyway, so let's > drop it just before calling into NAPI. > > ======================================================== > WARNING: possible irq lock inversion dependency detected > 5.12.0-rc1-00002-gbada49429032 #5 Not tainted > -------------------------------------------------------- > irq/136-iwlwifi/565 just changed the state of lock: > ffff89f28433b0b0 (&rxq->lock){+.-.}-{2:2}, at: iwl_pcie_rx_handle+0x7f/0x960 [iwlwifi] > but this lock took another, SOFTIRQ-unsafe lock in the past: > (napi_hash_lock){+.+.}-{2:2} > > and interrupts could create inverse lock ordering between them. > > other info that might help us debug this: > Possible interrupt unsafe locking scenario: > > CPU0 CPU1 > ---- ---- > lock(napi_hash_lock); > local_irq_disable(); > lock(&rxq->lock); > lock(napi_hash_lock); > > lock(&rxq->lock); > > *** DEADLOCK *** > > 1 lock held by irq/136-iwlwifi/565: > #0: ffff89f2b1440170 (sync_cmd_lockdep_map){+.+.}-{0:0}, at: iwl_pcie_irq_handler+0x5/0xb30 > > the shortest dependencies between 2nd lock and 1st lock: > -> (napi_hash_lock){+.+.}-{2:2} { > HARDIRQ-ON-W at: > lock_acquire+0x277/0x3d0 > _raw_spin_lock+0x2c/0x40 > netif_napi_add+0x14b/0x270 > e1000_probe+0x2fe/0xee0 [e1000e] > local_pci_probe+0x42/0x90 > pci_device_probe+0x10b/0x1c0 > really_probe+0xef/0x4b0 > driver_probe_device+0xde/0x150 > device_driver_attach+0x4f/0x60 > __driver_attach+0x9c/0x140 > bus_for_each_dev+0x79/0xc0 > bus_add_driver+0x18d/0x220 > driver_register+0x5b/0xf0 > do_one_initcall+0x5b/0x300 > do_init_module+0x5b/0x21c > load_module+0x1dae/0x22c0 > __do_sys_finit_module+0xad/0x110 > do_syscall_64+0x33/0x80 > entry_SYSCALL_64_after_hwframe+0x44/0xae > SOFTIRQ-ON-W at: > lock_acquire+0x277/0x3d0 > _raw_spin_lock+0x2c/0x40 > netif_napi_add+0x14b/0x270 > e1000_probe+0x2fe/0xee0 [e1000e] > local_pci_probe+0x42/0x90 > pci_device_probe+0x10b/0x1c0 > really_probe+0xef/0x4b0 > driver_probe_device+0xde/0x150 > device_driver_attach+0x4f/0x60 > __driver_attach+0x9c/0x140 > bus_for_each_dev+0x79/0xc0 > bus_add_driver+0x18d/0x220 > driver_register+0x5b/0xf0 > do_one_initcall+0x5b/0x300 > do_init_module+0x5b/0x21c > load_module+0x1dae/0x22c0 > __do_sys_finit_module+0xad/0x110 > do_syscall_64+0x33/0x80 > entry_SYSCALL_64_after_hwframe+0x44/0xae > INITIAL USE at: > lock_acquire+0x277/0x3d0 > _raw_spin_lock+0x2c/0x40 > netif_napi_add+0x14b/0x270 > e1000_probe+0x2fe/0xee0 [e1000e] > local_pci_probe+0x42/0x90 > pci_device_probe+0x10b/0x1c0 > really_probe+0xef/0x4b0 > driver_probe_device+0xde/0x150 > device_driver_attach+0x4f/0x60 > __driver_attach+0x9c/0x140 > bus_for_each_dev+0x79/0xc0 > bus_add_driver+0x18d/0x220 > driver_register+0x5b/0xf0 > do_one_initcall+0x5b/0x300 > do_init_module+0x5b/0x21c > load_module+0x1dae/0x22c0 > __do_sys_finit_module+0xad/0x110 > do_syscall_64+0x33/0x80 > entry_SYSCALL_64_after_hwframe+0x44/0xae > } > ... key at: [] napi_hash_lock+0x18/0x40 > ... acquired at: > _raw_spin_lock+0x2c/0x40 > netif_napi_add+0x14b/0x270 > _iwl_pcie_rx_init+0x1f4/0x710 [iwlwifi] > iwl_pcie_rx_init+0x1b/0x3b0 [iwlwifi] > iwl_trans_pcie_start_fw+0x2ac/0x6a0 [iwlwifi] > iwl_mvm_load_ucode_wait_alive+0x116/0x460 [iwlmvm] > iwl_run_init_mvm_ucode+0xa4/0x3a0 [iwlmvm] > iwl_op_mode_mvm_start+0x9ed/0xbf0 [iwlmvm] > _iwl_op_mode_start.isra.4+0x42/0x80 [iwlwifi] > iwl_opmode_register+0x71/0xe0 [iwlwifi] > iwl_mvm_init+0x34/0x1000 [iwlmvm] > do_one_initcall+0x5b/0x300 > do_init_module+0x5b/0x21c > load_module+0x1dae/0x22c0 > __do_sys_finit_module+0xad/0x110 > do_syscall_64+0x33/0x80 > entry_SYSCALL_64_after_hwframe+0x44/0xae > > [ ... lockdep output trimmed .... ] > > Fixes: 25edc8f259c7106 ("iwlwifi: pcie: properly implement NAPI") > Signed-off-by: Jiri Kosina > Acked-by: Luca Coelho Patch applied to wireless-drivers.git, thanks. 295d4cd82b01 iwlwifi: don't call netif_napi_add() with rxq->lock held (was Re: Lockdep warning in iwl_pcie_rx_handle()) -- https://patchwork.kernel.org/project/linux-wireless/patch/nycvar.YFH.7.76.2103021134060.12405@cbobk.fhfr.pm/ https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches