Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp5267587rwr; Mon, 24 Apr 2023 01:11:56 -0700 (PDT) X-Google-Smtp-Source: AKy350bQq0ByuykZb5gEAaJmrRCAePzcFsDPUzsOixVpUf6KlP4zdfiMNkidtW5uXv1LnoleuB6i X-Received: by 2002:a05:6a20:7485:b0:f4:c0d6:87e with SMTP id p5-20020a056a20748500b000f4c0d6087emr4341641pzd.1.1682323915990; Mon, 24 Apr 2023 01:11:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682323915; cv=none; d=google.com; s=arc-20160816; b=R36t5/52yFG0quWPpeE9wSEkXBkOy+VyCo6izytr24WAx9WN0FkTC95aFMTYdoNEq6 OuLRMJRAPHyt+LN6pscVWujVWAhmuqIhQwZwgw+awSYcR4AZ+rdNvoZax0LliilXrVCk Vg0zr2Cy1paBflUB9/1O/78p/YB8QtxshQRSgXL2pGdRwSR5kx10hGs0aG1EAEMCoKQR zt4rHuVpjjc0P5/8lZvxtCOId3InGzUmURv6of/RIbaePCaA9x+zyZDLUPJ5IitrryyP qvGhsZSQSDPenMuEZScktwHF8GHZp9mKsZdyB8wraZDbPeBGH/gOiFxGq3TfxOg33lp9 jlMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=VyUAwVndLKyz2OuOwFAyDEBY/0Eoo2W/05HV1tDiLOk=; b=MCvbl7mqfuyqwZ0qQD1e404MNwaC15HQMXqm81pGl3fvj/MAjSD11flrDUHNBXfC9E gTM4fmhOo1xIkPm7EL+BZBUAobQ5yvQAz2znOHBKHM9uGy2r0sPlW9GzMTDb10VGxCmJ wkRCNdoqfbsKWHWs5M6lBC1ycmBMMHEWMnpdGrtTB6eTELMyU6XKCMqHyaWtitUUBc32 TvERJjAF5NSWLJbWIepSZ9qwW1y9X4WQhIb0x6P8YdRzb0EF2ubXNHTPNVGPyNfd73vH AHdR0NAEO9xovy1Aa8rSSWOzueuhXn9Ss3um8bTUkfVSGbU0cSJaLg3DwOKrTpgVEdLd aJFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=MnGUwRkr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q9-20020a632a09000000b00524f1f0d020si5867019pgq.465.2023.04.24.01.11.42; Mon, 24 Apr 2023 01:11:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=MnGUwRkr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231474AbjDXIHW (ORCPT + 99 others); Mon, 24 Apr 2023 04:07:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231394AbjDXIHU (ORCPT ); Mon, 24 Apr 2023 04:07:20 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 68229E4F; Mon, 24 Apr 2023 01:07:13 -0700 (PDT) Received: from [IPV6:2001:b07:2ed:14ed:c5f8:7372:f042:90a2] (unknown [IPv6:2001:b07:2ed:14ed:c5f8:7372:f042:90a2]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: kholk11) by madras.collabora.co.uk (Postfix) with ESMTPSA id BF3F066031C8; Mon, 24 Apr 2023 09:07:09 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1682323631; bh=fk2JF4cqUutVFMf5ReNQ5Z96Nq9fCMd68NIqprhYP4I=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=MnGUwRkrnSGoo5I2HpQ1KCjotEMOiHWLBKexRH7q759Dy2mH4gixRn5awN7Gi/NZu dD6TwzsjthF4hzHgSj2Y3IjJ6qT7th+XS4dCDBJHzFjX26vEOdpi48GcGSGQzU7GOy keTScAocTMzmC7GznLLAcu+31IA5HZ+FxSkS4XFUslc1ZE6CjaHV5hdWvRWzHRcXkH o3KdMzNRNiKVkICdhKOX/zTVmQZcU7DR2j0gk8riSVQde61lz+TgJYY8ytdxSQ/fGf BDfVSjES2saNVdhBQKoiienboJ8tM0eDhKUvd4PSPmeqFdCXbRKaACkzWr6+GW598X JxqlYseu52+lA== Message-ID: Date: Mon, 24 Apr 2023 10:07:07 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: [PATCH v3 1/1] scsi: ufs: core: Fix &hwq->cq_lock deadlock issue Content-Language: en-US To: Alice Chao , Alim Akhtar , Avri Altman , Bart Van Assche , "James E.J. Bottomley" , "Martin K. Petersen" , Matthias Brugger , Can Guo , Asutosh Das , Stanley Chu , Manivannan Sadhasivam Cc: peter.wang@mediatek.com, chun-hung.wu@mediatek.com, powen.kao@mediatek.com, naomi.chu@mediatek.com, cc.chou@mediatek.com, chaotian.jing@mediatek.com, jiajie.hao@mediatek.com, tun-yu.yu@mediatek.com, eddie.huang@mediatek.com, wsd_upstream@mediatek.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org References: <20230424080400.8955-1-alice.chao@mediatek.com> From: AngeloGioacchino Del Regno In-Reply-To: <20230424080400.8955-1-alice.chao@mediatek.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Il 24/04/23 10:03, Alice Chao ha scritto: > [name:lockdep&]WARNING: inconsistent lock state > [name:lockdep&]-------------------------------- > [name:lockdep&]inconsistent {IN-HARDIRQ-W} -> {HARDIRQ-ON-W} usage. > [name:lockdep&]kworker/u16:4/260 [HC0[0]:SC0[0]:HE1:SE1] takes: > ffffff8028444600 (&hwq->cq_lock){?.-.}-{2:2}, at: > ufshcd_mcq_poll_cqe_lock+0x30/0xe0 > [name:lockdep&]{IN-HARDIRQ-W} state was registered at: > lock_acquire+0x17c/0x33c > _raw_spin_lock+0x5c/0x7c > ufshcd_mcq_poll_cqe_lock+0x30/0xe0 > ufs_mtk_mcq_intr+0x60/0x1bc [ufs_mediatek_mod] > __handle_irq_event_percpu+0x140/0x3ec > handle_irq_event+0x50/0xd8 > handle_fasteoi_irq+0x148/0x2b0 > generic_handle_domain_irq+0x4c/0x6c > gic_handle_irq+0x58/0x134 > call_on_irq_stack+0x40/0x74 > do_interrupt_handler+0x84/0xe4 > el1_interrupt+0x3c/0x78 > > > Possible unsafe locking scenario: > CPU0 > ---- > lock(&hwq->cq_lock); > > lock(&hwq->cq_lock); > *** DEADLOCK *** > 2 locks held by kworker/u16:4/260: > > [name:lockdep&] > stack backtrace: > CPU: 7 PID: 260 Comm: kworker/u16:4 Tainted: G S W OE > 6.1.17-mainline-android14-2-g277223301adb #1 > Workqueue: ufs_eh_wq_0 ufshcd_err_handler > > Call trace: > dump_backtrace+0x10c/0x160 > show_stack+0x20/0x30 > dump_stack_lvl+0x98/0xd8 > dump_stack+0x20/0x60 > print_usage_bug+0x584/0x76c > mark_lock_irq+0x488/0x510 > mark_lock+0x1ec/0x25c > __lock_acquire+0x4d8/0xffc > lock_acquire+0x17c/0x33c > _raw_spin_lock+0x5c/0x7c > ufshcd_mcq_poll_cqe_lock+0x30/0xe0 > ufshcd_poll+0x68/0x1b0 > ufshcd_transfer_req_compl+0x9c/0xc8 > ufshcd_err_handler+0x3bc/0xea0 > process_one_work+0x2f4/0x7e8 > worker_thread+0x234/0x450 > kthread+0x110/0x134 > ret_from_fork+0x10/0x20 > > ufs_mtk_mcq_intr() could refer to > https://lore.kernel.org/all/20230328103423.10970-3-powen.kao@mediatek.com/ > > When ufshcd_err_handler() is executed, CQ event interrupt can enter > waiting for the same lock. It could happened in upstream code path > ufshcd_handle_mcq_cq_events() and also in ufs_mtk_mcq_intr(). This > warning message will be generated when &hwq->cq_lock is used in IRQ > context with IRQ enabled. Use ufshcd_mcq_poll_cqe_lock() with > spin_lock_irqsave instead of spin_lock to resolve the deadlock issue. > > Fixes: ed975065c31c ("scsi: ufs: core: mcq: Add completion support in poll") > Reviewed-by: Can Guo > Reviewed-by: Stanley Chu > Signed-off-by: Alice Chao For readability purposes only - next time please put the actual description at the beginning and the log at the end. Anyway, Reviewed-by: AngeloGioacchino Del Regno