From patchwork Thu Feb 22 17:07:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 204877 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp83751dyb; Thu, 22 Feb 2024 09:15:42 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCX0pwwoXAI24hw+MM6W/v22KhCSmQ9VewW0+LjfyPykNrKnxd5oycbFOURoQhYEaEXXtAEjETjVftqGuWZvQFxH9Js22Q== X-Google-Smtp-Source: AGHT+IEMhz3gMD6VVCoAvXZMo4mCNKQZ/e60SQhRFreZaMdPblfPtB9c6dcNuOJNv6VP5GbiRvKx X-Received: by 2002:a17:902:ec90:b0:1db:c564:5938 with SMTP id x16-20020a170902ec9000b001dbc5645938mr21769506plg.60.1708622141990; Thu, 22 Feb 2024 09:15:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708622141; cv=pass; d=google.com; s=arc-20160816; b=WcGq785h9K6zh6K3fWZAGW0GU95+i3jXuT1RKDLXQEONtllFF9PWV5hdv6EDllm86j upL41MgPmFE+x/ciJIZi0GMyjbSR2pvVBgc39DlurAGXYBZvhI8vq2EBIxUlW07ZhzgA O41GSkcZMTwruiigI9siM9Syn/7wludFF/caTcNINVGncSc5baJuFU8zQ762UTOddSX3 rM3t+qhkL8i4e1Em0209s/aG38LeiGiJY3/WO3UExPToyVxiv7MOvB+ZEs/lwtIRoSws WjGe0VYJAH9cgqbPYIFOEAEhLsa/jMmTqFmZAUKmHBrLU8A0DS11qYs49nXUVTP+Lmgb EZ8A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=O7tlgS7MkdA1L6vxpIiDfXudireah7BPJ6Dyc7UeOKw=; fh=HqB+/TIc6T7UT9VpL/KHYgcd5ZuflgOi9dG8pl6GyHY=; b=zvaOkPgOoppGtG8BDNkegthCiY+8OzxlqN6GE7Ve4MXKDi3K7WGsEf1iIwd2sqRQ7a gZVdGiOkkWQ23Tv3sS8WIukvMtKkRSzX0WomHQ0A4ToUpv4FlCUmPkmtNCANMaysrdDp G/PBAslw+VzdzNAedGry/k9Ib2CPGC7d5n7qlGCuso77QrhENJ4WqEbgnJTpYU4Z0R7P Q8EsOtIlO6w14bOES9iBAtq4877InPscg3mImX6yQnXVFWuIlSDw49Ac9Rna610BUw6M hMdpdMTciTkfJQdSWoPEJ5OhcitAg3pi0dqYj13A5mYC4kB0FQSXgoiJ+FY0n6HjvgrQ 6KkA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=v2hlfZd2; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-76921-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76921-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id t3-20020a170902e84300b001d5f009098bsi10817178plg.408.2024.02.22.09.15.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 09:15:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76921-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=v2hlfZd2; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-76921-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76921-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id EDA472890C7 for ; Thu, 22 Feb 2024 17:08:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 32098155A45; Thu, 22 Feb 2024 17:08:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="v2hlfZd2" Received: from out-188.mta1.migadu.com (out-188.mta1.migadu.com [95.215.58.188]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7A06D148FF2 for ; Thu, 22 Feb 2024 17:08:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.188 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708621687; cv=none; b=E8NVNm7/A8JHZpe4QRj6BFmR4Gra948uFgjVJn08k/NlJAeiWSYe3xhw651lBdHaidDJez8stgxev9ZIghC4Ca1DSAtH1BQBgwzvKEGo9V8js5M+Om+r7JX5I/HNyL8AIQnjPX/kcB/URs9OLf2ZuCErgIhn1VH6XA5+92Qj8l4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708621687; c=relaxed/simple; bh=bjbBKm61sS3OCiUiTraEzgDb0fORpdkoRq5LcJPn/Iw=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=t+Bl6Y4zA8+UCxexDvG+tigRuxwApVOm5YJdvc7IEigVjzci6d2J6gmvbWOdNyUirS0un/8reGTf3BHItZwJeXyAnPLRnS0njnAmhFNzm9ECw9JXZeSFE8LwIM/dUXOOqmsJXEYViUkegVAgsRYAztBtI8hAvIWEJnURN1UCuxI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=v2hlfZd2; arc=none smtp.client-ip=95.215.58.188 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1708621681; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=O7tlgS7MkdA1L6vxpIiDfXudireah7BPJ6Dyc7UeOKw=; b=v2hlfZd2C3xXw8cSD+mG/AWXt4cPww48KC+Yl2NE0ShrDnG7iKAcyA4P/30m+d3Wy1N4l7 1OvH3paUYLfUVPW1dT1KiweB4c9jOB3an6HIr+xD2LtIOzS1yXTReMa6UyBxkDxS4UOLMN Cnu4tKGVlc5mx/+HeM4pLas0mCEkWwg= From: Sean Anderson To: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, Claudiu Manoil , Vladimir Oltean , linuxppc-dev@lists.ozlabs.org, Steffen Trumtrar , linux-kernel@vger.kernel.org, Camelia Groza , Roy Pledge , Scott Wood , Li Yang , Sean Anderson , stable@vger.kernel.org Subject: [RESEND2 PATCH net v4 1/2] soc: fsl: qbman: Always disable interrupts when taking cgr_lock Date: Thu, 22 Feb 2024 12:07:48 -0500 Message-Id: <20240222170749.2607485-1-sean.anderson@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791620171494502235 X-GMAIL-MSGID: 1791620171494502235 smp_call_function_single disables IRQs when executing the callback. To prevent deadlocks, we must disable IRQs when taking cgr_lock elsewhere. This is already done by qman_update_cgr and qman_delete_cgr; fix the other lockers. Fixes: 96f413f47677 ("soc/fsl/qbman: fix issue in qman_delete_cgr_safe()") CC: stable@vger.kernel.org Signed-off-by: Sean Anderson Reviewed-by: Camelia Groza Tested-by: Vladimir Oltean --- Resent from a non-mangling email. (no changes since v3) Changes in v3: - Change blamed commit to something more appropriate Changes in v2: - Fix one additional call to spin_unlock drivers/soc/fsl/qbman/qman.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/soc/fsl/qbman/qman.c b/drivers/soc/fsl/qbman/qman.c index 739e4eee6b75..1bf1f1ea67f0 100644 --- a/drivers/soc/fsl/qbman/qman.c +++ b/drivers/soc/fsl/qbman/qman.c @@ -1456,11 +1456,11 @@ static void qm_congestion_task(struct work_struct *work) union qm_mc_result *mcr; struct qman_cgr *cgr; - spin_lock(&p->cgr_lock); + spin_lock_irq(&p->cgr_lock); qm_mc_start(&p->p); qm_mc_commit(&p->p, QM_MCC_VERB_QUERYCONGESTION); if (!qm_mc_result_timeout(&p->p, &mcr)) { - spin_unlock(&p->cgr_lock); + spin_unlock_irq(&p->cgr_lock); dev_crit(p->config->dev, "QUERYCONGESTION timeout\n"); qman_p_irqsource_add(p, QM_PIRQ_CSCI); return; @@ -1476,7 +1476,7 @@ static void qm_congestion_task(struct work_struct *work) list_for_each_entry(cgr, &p->cgr_cbs, node) if (cgr->cb && qman_cgrs_get(&c, cgr->cgrid)) cgr->cb(p, cgr, qman_cgrs_get(&rr, cgr->cgrid)); - spin_unlock(&p->cgr_lock); + spin_unlock_irq(&p->cgr_lock); qman_p_irqsource_add(p, QM_PIRQ_CSCI); } @@ -2440,7 +2440,7 @@ int qman_create_cgr(struct qman_cgr *cgr, u32 flags, preempt_enable(); cgr->chan = p->config->channel; - spin_lock(&p->cgr_lock); + spin_lock_irq(&p->cgr_lock); if (opts) { struct qm_mcc_initcgr local_opts = *opts; @@ -2477,7 +2477,7 @@ int qman_create_cgr(struct qman_cgr *cgr, u32 flags, qman_cgrs_get(&p->cgrs[1], cgr->cgrid)) cgr->cb(p, cgr, 1); out: - spin_unlock(&p->cgr_lock); + spin_unlock_irq(&p->cgr_lock); put_affine_portal(); return ret; } From patchwork Thu Feb 22 17:07:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 204867 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp79428dyb; Thu, 22 Feb 2024 09:08:45 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVxDl+lhQvxYLpNQCJqpuD19zvBMeOvjKl6IiICS+ns9J0mYpBtyE7vOeyKfc90q++wp+AUUVJbYXc6CAYFazJPX3f9BA== X-Google-Smtp-Source: AGHT+IFbaVDTur3O6KuiruT9xksd2BSES7wWdhEkK3KfpMekb5EWEfp+BDLnXdwOXAegOQ04ShYI X-Received: by 2002:a17:906:2459:b0:a3e:5cb9:8a4f with SMTP id a25-20020a170906245900b00a3e5cb98a4fmr10761255ejb.58.1708621725187; Thu, 22 Feb 2024 09:08:45 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708621725; cv=pass; d=google.com; s=arc-20160816; b=O0uNGk0RlFVd2YTLz2qKVSsD+B2tEw0NrAjZL/mkybm8IT+4s8K4u319FS/m7f8yDX 6aY4XziZjHeujcZ8vTpV6f0vfaV6nV0CGyaXAaCLLkEKex8XfbYMoDkUrMsjQGT+a5Rl cFg+ronUa+q0VGKsuR/MVx1LeEHRaniIpSjUV+Qev80yU2L3O2rJG5G+JTs2G7qY7E3C TG0lxHjLfo5wxaiPbqzWvBaWgdGekyoD3ewsQ46FTHIMgxKTb+v7qnhFLQNrUUAgtI6s AjK/g2hIjNn6CfK3goS18ZjKMVOgzBWnLUUdMYSZC40ybblWJMkNCuKp2vlAunG/9AWo eYMw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=A9cw43y7Ag2nW/FmjThiF7L/nsZOb2YeI0T4JXqjgN0=; fh=HqB+/TIc6T7UT9VpL/KHYgcd5ZuflgOi9dG8pl6GyHY=; b=ym5EzajweB1qyab4bJq3n/NnD6b9q5AIJ5eowZFMZ9tIIMlbfVfrlQOI36A0FAvoQR rQVv9zCEbjCnoVSaAZ5IpNR6c75n1Wg/Wj122DkxbQXDCc0DeLFDlj3nMP37oWy4196m WAKeaLdmSFX6xCxmd64a+jxJmfTx66JjusA9FNhbOUkIe8UTMElxC2zKtRNC47biJ4uR MaHlMbP+/CxGkjZ8/uZgf4SQ7+JWMA6rKx/HoMsMrAD8a/flmkdxn02q7c2AmsmtWjWL Xh3W+x+lLPaASc1Gc28EpNosSjMNCE1CcTk7te52WE6BPOivauYXfNDLawxjlO0urcSL jfTA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=rzeeEd49; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-76922-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76922-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id mf18-20020a170906cb9200b00a3eaadd1893si3637293ejb.836.2024.02.22.09.08.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Feb 2024 09:08:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-76922-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=rzeeEd49; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-76922-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-76922-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id A310D1F2908F for ; Thu, 22 Feb 2024 17:08:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B6030153BD5; Thu, 22 Feb 2024 17:08:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="rzeeEd49" Received: from out-171.mta1.migadu.com (out-171.mta1.migadu.com [95.215.58.171]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E8AEB154BE3 for ; Thu, 22 Feb 2024 17:08:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708621688; cv=none; b=KiJLTVZMl6NNPYf3JXzB7nfD2+L3dRaG3Zj+6qk48FGHXbTbiilY+06/b6FSq7KXeNr2WKgWjy6AD8sPxKXYiZpX3exeuNo3T5MNEM0F806D0Y1kzUKLhXU75IRsetM7zdsrcHWYOvdSbkDdNddyEiq9Spw78kb7HqG74PYkTWM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708621688; c=relaxed/simple; bh=LGLwT+i1W1ha4eOjAP8fBHDzSr0BgjvWb8WNdS7atjs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=C7HXVDn0TYlOWR3GLhj2QzaKSLpHTuBjQqUnqPoZuYl85e32ylEWYS2yVTn1oZRC81MItLKKMmPWU7/qO7gzatYe1flkuE46dwl1cfCelv9SvAn2To8tljF9mlSFKuJUo00CahV65RiEe/Og7uBMLfsvh2Nknt64RaG1pI5H2jg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=rzeeEd49; arc=none smtp.client-ip=95.215.58.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1708621684; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=A9cw43y7Ag2nW/FmjThiF7L/nsZOb2YeI0T4JXqjgN0=; b=rzeeEd49VE0/ALeGOGSSbg143s8OTwaFAvrxCY6yGJTNFwwjFnEicT6dia7ttVnRyvmbnK HyDFt3Yl46a0RnAXHRXJg/oBUW/egxgGR1825W80HSdBCnN6zALR51w2yk6tin+AfQdKwQ QIFIm5ehJbZHhRkiGNuQTCV3GBhhgdo= From: Sean Anderson To: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, Claudiu Manoil , Vladimir Oltean , linuxppc-dev@lists.ozlabs.org, Steffen Trumtrar , linux-kernel@vger.kernel.org, Camelia Groza , Roy Pledge , Scott Wood , Li Yang , Sean Anderson , stable@vger.kernel.org Subject: [RESEND2 PATCH net v4 2/2] soc: fsl: qbman: Use raw spinlock for cgr_lock Date: Thu, 22 Feb 2024 12:07:49 -0500 Message-Id: <20240222170749.2607485-2-sean.anderson@linux.dev> In-Reply-To: <20240222170749.2607485-1-sean.anderson@linux.dev> References: <20240222170749.2607485-1-sean.anderson@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791619733688411980 X-GMAIL-MSGID: 1791619733688411980 cgr_lock may be locked with interrupts already disabled by smp_call_function_single. As such, we must use a raw spinlock to avoid problems on PREEMPT_RT kernels. Although this bug has existed for a while, it was not apparent until commit ef2a8d5478b9 ("net: dpaa: Adjust queue depth on rate change") which invokes smp_call_function_single via qman_update_cgr_safe every time a link goes up or down. Fixes: 96f413f47677 ("soc/fsl/qbman: fix issue in qman_delete_cgr_safe()") CC: stable@vger.kernel.org Reported-by: Vladimir Oltean Closes: https://lore.kernel.org/all/20230323153935.nofnjucqjqnz34ej@skbuf/ Reported-by: Steffen Trumtrar Closes: https://lore.kernel.org/linux-arm-kernel/87wmsyvclu.fsf@pengutronix.de/ Signed-off-by: Sean Anderson Reviewed-by: Camelia Groza Tested-by: Vladimir Oltean --- Changes in v4: - Add a note about how raw spinlocks aren't quite right Changes in v3: - Change blamed commit to something more appropriate drivers/soc/fsl/qbman/qman.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/drivers/soc/fsl/qbman/qman.c b/drivers/soc/fsl/qbman/qman.c index 1bf1f1ea67f0..7e9074519ad2 100644 --- a/drivers/soc/fsl/qbman/qman.c +++ b/drivers/soc/fsl/qbman/qman.c @@ -991,7 +991,7 @@ struct qman_portal { /* linked-list of CSCN handlers. */ struct list_head cgr_cbs; /* list lock */ - spinlock_t cgr_lock; + raw_spinlock_t cgr_lock; struct work_struct congestion_work; struct work_struct mr_work; char irqname[MAX_IRQNAME]; @@ -1281,7 +1281,7 @@ static int qman_create_portal(struct qman_portal *portal, /* if the given mask is NULL, assume all CGRs can be seen */ qman_cgrs_fill(&portal->cgrs[0]); INIT_LIST_HEAD(&portal->cgr_cbs); - spin_lock_init(&portal->cgr_lock); + raw_spin_lock_init(&portal->cgr_lock); INIT_WORK(&portal->congestion_work, qm_congestion_task); INIT_WORK(&portal->mr_work, qm_mr_process_task); portal->bits = 0; @@ -1456,11 +1456,14 @@ static void qm_congestion_task(struct work_struct *work) union qm_mc_result *mcr; struct qman_cgr *cgr; - spin_lock_irq(&p->cgr_lock); + /* + * FIXME: QM_MCR_TIMEOUT is 10ms, which is too long for a raw spinlock! + */ + raw_spin_lock_irq(&p->cgr_lock); qm_mc_start(&p->p); qm_mc_commit(&p->p, QM_MCC_VERB_QUERYCONGESTION); if (!qm_mc_result_timeout(&p->p, &mcr)) { - spin_unlock_irq(&p->cgr_lock); + raw_spin_unlock_irq(&p->cgr_lock); dev_crit(p->config->dev, "QUERYCONGESTION timeout\n"); qman_p_irqsource_add(p, QM_PIRQ_CSCI); return; @@ -1476,7 +1479,7 @@ static void qm_congestion_task(struct work_struct *work) list_for_each_entry(cgr, &p->cgr_cbs, node) if (cgr->cb && qman_cgrs_get(&c, cgr->cgrid)) cgr->cb(p, cgr, qman_cgrs_get(&rr, cgr->cgrid)); - spin_unlock_irq(&p->cgr_lock); + raw_spin_unlock_irq(&p->cgr_lock); qman_p_irqsource_add(p, QM_PIRQ_CSCI); } @@ -2440,7 +2443,7 @@ int qman_create_cgr(struct qman_cgr *cgr, u32 flags, preempt_enable(); cgr->chan = p->config->channel; - spin_lock_irq(&p->cgr_lock); + raw_spin_lock_irq(&p->cgr_lock); if (opts) { struct qm_mcc_initcgr local_opts = *opts; @@ -2477,7 +2480,7 @@ int qman_create_cgr(struct qman_cgr *cgr, u32 flags, qman_cgrs_get(&p->cgrs[1], cgr->cgrid)) cgr->cb(p, cgr, 1); out: - spin_unlock_irq(&p->cgr_lock); + raw_spin_unlock_irq(&p->cgr_lock); put_affine_portal(); return ret; } @@ -2512,7 +2515,7 @@ int qman_delete_cgr(struct qman_cgr *cgr) return -EINVAL; memset(&local_opts, 0, sizeof(struct qm_mcc_initcgr)); - spin_lock_irqsave(&p->cgr_lock, irqflags); + raw_spin_lock_irqsave(&p->cgr_lock, irqflags); list_del(&cgr->node); /* * If there are no other CGR objects for this CGRID in the list, @@ -2537,7 +2540,7 @@ int qman_delete_cgr(struct qman_cgr *cgr) /* add back to the list */ list_add(&cgr->node, &p->cgr_cbs); release_lock: - spin_unlock_irqrestore(&p->cgr_lock, irqflags); + raw_spin_unlock_irqrestore(&p->cgr_lock, irqflags); put_affine_portal(); return ret; } @@ -2577,9 +2580,9 @@ static int qman_update_cgr(struct qman_cgr *cgr, struct qm_mcc_initcgr *opts) if (!p) return -EINVAL; - spin_lock_irqsave(&p->cgr_lock, irqflags); + raw_spin_lock_irqsave(&p->cgr_lock, irqflags); ret = qm_modify_cgr(cgr, 0, opts); - spin_unlock_irqrestore(&p->cgr_lock, irqflags); + raw_spin_unlock_irqrestore(&p->cgr_lock, irqflags); put_affine_portal(); return ret; }