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 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 07E1DC433EF for ; Wed, 20 Oct 2021 01:44:45 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BD5AB610D0 for ; Wed, 20 Oct 2021 01:44:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org BD5AB610D0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=nxp.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:Subject:Message-ID:Date:From: In-Reply-To:References:MIME-Version:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=iPt6dvk59pYoNIF5gpbd4lPEM2DGJgECn8xxYcNqUEE=; b=H4EO/YsGL5BYBk 4TZj+qQ7SK7F6TGNQTF2t2Hv9TLgO8uzz6Vwhe6jeGhwdr0EcTI4VFvAK2qBQFgYPT86vLTox9AOa vlx7FAzLZeADUIIdvPu8wRhbVNCGg1kgz0oWJxv+vj3UtFqj4Ug/OKIocMyXlqwcDnmOZeIyqtz1Y rthXKIRjpCzteBT/wlOLVSGnFMGtWMqV15VCq0Ia/gPiCvUby33TwgdsV1gdsf9YMa8uh8f7cFH6q 91zJcF2V7R8YKB3l+dRV+mrukmHS9jfHZYHFtbhSGzlyLvyqTM4PeAjxC021k1Evtflq/2tT2fUMp TrAyGrVQdUj/haO4na5g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1md0cv-0038BV-13; Wed, 20 Oct 2021 01:42:45 +0000 Received: from mail-qt1-f177.google.com ([209.85.160.177]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1md0cr-00389I-Dr for linux-arm-kernel@lists.infradead.org; Wed, 20 Oct 2021 01:42:42 +0000 Received: by mail-qt1-f177.google.com with SMTP id r17so1697790qtx.10 for ; Tue, 19 Oct 2021 18:42:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=phuizum7Jvmwq/i5uKXc0tZWrbM+XXyJMZ25fUOpTLs=; b=fHu2lGp/JjRgSx6BLMK7NBaeajFG8qGX5CokWOJAJT93qEK6gUlUqh6KZhzkTCWM1S roX14j/7hXRGC1H3+FD4SB6xV54vp1aeIoW8T7Z2qm1B/G9vi+P+94Kos+4pGz+Yre13 b0WXThUxovHO967HMTttAQAaalUCVdACil67yld946P3hFEArikIW6r4CkS85l+/pgvH YpK2/FZBdbDmJzM9YdWiYU4KauUxexCkXSEVaByTDfSsorrmYw9py6F/Xx37EnYnqmZ5 pskVyu2DKCGUGRWbLF4HquDY5PsSW6mQIdRzkftxVqO8kPDJo4AnkkBlFfZccqCu1chF QLWQ== X-Gm-Message-State: AOAM532wrtCWZKYVJOEnP2dkeU+xcq3k9wRGcyqArVoWU743dheMPWyh WzDRf+2pvFvZY1tskNWy+XIQwMmHOYw= X-Google-Smtp-Source: ABdhPJzzLdN1ZboJ6RSr7lFwxerRhEFu1+wYx3BOjolCJOxZxDHPMfUE1y1FHoPAP++a8vNvRiPWyw== X-Received: by 2002:a05:622a:ca:: with SMTP id p10mr3719835qtw.207.1634694159048; Tue, 19 Oct 2021 18:42:39 -0700 (PDT) Received: from mail-qt1-f179.google.com (mail-qt1-f179.google.com. [209.85.160.179]) by smtp.gmail.com with ESMTPSA id bm25sm459467qkb.4.2021.10.19.18.42.38 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 19 Oct 2021 18:42:38 -0700 (PDT) Received: by mail-qt1-f179.google.com with SMTP id z24so1711112qtv.9 for ; Tue, 19 Oct 2021 18:42:38 -0700 (PDT) X-Received: by 2002:a05:622a:1050:: with SMTP id f16mr3965552qte.127.1634694158181; Tue, 19 Oct 2021 18:42:38 -0700 (PDT) MIME-Version: 1.0 References: <20211019030555.29461-1-Meng.Li@windriver.com> In-Reply-To: <20211019030555.29461-1-Meng.Li@windriver.com> From: Li Yang Date: Tue, 19 Oct 2021 20:42:27 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] driver: soc: dpio: use the whole functions to protect critical zone To: Meng.Li@windriver.com Cc: Youri Querry , linuxppc-dev , lkml , "moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE" X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211019_184241_494182_3B7080F7 X-CRM114-Status: GOOD ( 21.01 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Oct 18, 2021 at 10:07 PM wrote: > > From: Meng Li > > In orininal code, use 2 function spin_lock() and local_irq_save() to > protect the critical zone. But when enable the kernel debug config, > there are below inconsistent lock state detected. > ================================ > WARNING: inconsistent lock state > 5.10.63-yocto-standard #1 Not tainted > -------------------------------- > inconsistent {SOFTIRQ-ON-W} -> {IN-SOFTIRQ-W} usage. > lock_torture_wr/226 [HC0[0]:SC1[5]:HE1:SE0] takes: > ffff002005b2dd80 (&p->access_spinlock){+.?.}-{3:3}, at: qbman_swp_enqueue_multiple_mem_back+0x44/0x270 > {SOFTIRQ-ON-W} state was registered at: > lock_acquire.part.0+0xf8/0x250 > lock_acquire+0x68/0x84 > _raw_spin_lock+0x68/0x90 > qbman_swp_enqueue_multiple_mem_back+0x44/0x270 > ...... > cryptomgr_test+0x38/0x60 > kthread+0x158/0x164 > ret_from_fork+0x10/0x38 > irq event stamp: 4498 > hardirqs last enabled at (4498): [] _raw_spin_unlock_irqrestore+0x90/0xb0 > hardirqs last disabled at (4497): [] _raw_spin_lock_irqsave+0xd4/0xe0 > softirqs last enabled at (4458): [] __do_softirq+0x674/0x724 > softirqs last disabled at (4465): [] __irq_exit_rcu+0x190/0x19c > > other info that might help us debug this: > Possible unsafe locking scenario: > CPU0 > ---- > lock(&p->access_spinlock); > > lock(&p->access_spinlock); > *** DEADLOCK *** > > So, in order to avoid deadlock, use the whole functinos s/functinos/functions/ > spin_lock_irqsave/spin_unlock_irqrestore() to protect critical zone. > > Fixes: 3b2abda7d28c ("soc: fsl: dpio: Replace QMAN array mode with ring mode enqueue") > Cc: stable@vger.kernel.org > Signed-off-by: Meng Li Applied for fix. Thanks. > --- > drivers/soc/fsl/dpio/qbman-portal.c | 9 +++------ > 1 file changed, 3 insertions(+), 6 deletions(-) > > diff --git a/drivers/soc/fsl/dpio/qbman-portal.c b/drivers/soc/fsl/dpio/qbman-portal.c > index 845e91416b58..a56dbe4de34f 100644 > --- a/drivers/soc/fsl/dpio/qbman-portal.c > +++ b/drivers/soc/fsl/dpio/qbman-portal.c > @@ -785,8 +785,7 @@ int qbman_swp_enqueue_multiple_mem_back(struct qbman_swp *s, > int i, num_enqueued = 0; > unsigned long irq_flags; > > - spin_lock(&s->access_spinlock); > - local_irq_save(irq_flags); > + spin_lock_irqsave(&s->access_spinlock, irq_flags); > > half_mask = (s->eqcr.pi_ci_mask>>1); > full_mask = s->eqcr.pi_ci_mask; > @@ -797,8 +796,7 @@ int qbman_swp_enqueue_multiple_mem_back(struct qbman_swp *s, > s->eqcr.available = qm_cyc_diff(s->eqcr.pi_ring_size, > eqcr_ci, s->eqcr.ci); > if (!s->eqcr.available) { > - local_irq_restore(irq_flags); > - spin_unlock(&s->access_spinlock); > + spin_unlock_irqrestore(&s->access_spinlock, irq_flags); > return 0; > } > } > @@ -837,8 +835,7 @@ int qbman_swp_enqueue_multiple_mem_back(struct qbman_swp *s, > dma_wmb(); > qbman_write_register(s, QBMAN_CINH_SWP_EQCR_PI, > (QB_RT_BIT)|(s->eqcr.pi)|s->eqcr.pi_vb); > - local_irq_restore(irq_flags); > - spin_unlock(&s->access_spinlock); > + spin_unlock_irqrestore(&s->access_spinlock, irq_flags); > > return num_enqueued; > } > -- > 2.17.1 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel