Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9047465pxu; Mon, 28 Dec 2020 05:21:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJxQ4mOaw3ubIZe5PzYgz69JeARI74OZw7Vn7uzr/fV01wsPjFfQHTjOdgVh3R/FBuJpresU X-Received: by 2002:a50:abc6:: with SMTP id u64mr13715952edc.21.1609161686602; Mon, 28 Dec 2020 05:21:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609161686; cv=none; d=google.com; s=arc-20160816; b=LMmeYwLLoeBRdGBqGS47ViRoHWFJzsnW+PXuzC9GRBKH2Mo2PY+/rUL1jGw6sVKGvf Iv9duYY8h5tk+icPjLS+dbZDdcR/dyi5La7brKxADLLJVT1QBb4ijhjyjr+HDJZnHyxB Wvst2h/qCsmmK4OfOq+WZMbvsHD0qo5YLSD3fgOMbRGHZpDvevn0X7Lp93gHvxFxtuQj +hbiffdG6lleQYJwin1w6s+e49wGTbZGGlvDjcGwafpV2y90ADZqW5WTZa5mqdSvn1bq HF0srSbOUZ4jOLZvaBSVB5s0Auf6QJsVsV0b1hsT30zqX4gfPjCmPHJdfWJt6mAhbGXF VH4g== 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=asxqdA+yy+5/nW+bpEhjp236NNWb8mMeHT0fAiikFRs=; b=YzF6pkgdp5JnM4obf+VHBg1zVAHp+cOjVu9n2WgHxkxa7VzR2Cr9uRAN04I4FSm4gh q84pHhgQhECADPztNCnhDvTh5yZbG+HKVSb3cK9RbAJTnFc94Am7nbiRyjiCp/T2an1V MwfpSRHfxxhKWrahtNWpnce3qbkvePm5UNrqe7TY+wigmCn7l93eF9v7lpjQsv3H7HTW 6vSAbJFcZxUeb3zgiTwBvcP5Y6TXTNEpbZbiT5oo5C5sVgBY/nsGOhmbVl1wpZgIbbLo MQowi9uW5mWq/sfnrjxgicTo9QH5V04nNYwXe95SFxK79wySNmtIOPA/1FPYa+Swu2nP Ujdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="r/Am6bLn"; 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 i10si10566818ejd.572.2020.12.28.05.21.03; Mon, 28 Dec 2020 05:21:26 -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=@linuxfoundation.org header.s=korg header.b="r/Am6bLn"; 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 S1731801AbgL1NSn (ORCPT + 99 others); Mon, 28 Dec 2020 08:18:43 -0500 Received: from mail.kernel.org ([198.145.29.99]:47174 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731793AbgL1NSj (ORCPT ); Mon, 28 Dec 2020 08:18:39 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6743622583; Mon, 28 Dec 2020 13:17:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609161479; bh=FQP+rt9NpICwzj/HNlIQdtXAEm7tcSEAdjcSZDwBpWA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r/Am6bLnbWmZDHfXoiz8+PLfqQEc/AiR66wg+lRAcaTG94B+wEYxn+CMhcnfkEoVZ yTK7/gWh6itU7nWRVYXnwTxCeca+LXblS6dNKLTY/+AmmxITWiRFYVhXtywjdVuJWy o7eodRIyJ8zYrcxlFuMH0UQqDfpflQJEVrmeXL7g= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Bjorn Andersson , Stephen Boyd , Evan Green Subject: [PATCH 4.14 226/242] soc: qcom: smp2p: Safely acquire spinlock without IRQs Date: Mon, 28 Dec 2020 13:50:31 +0100 Message-Id: <20201228124915.797161331@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228124904.654293249@linuxfoundation.org> References: <20201228124904.654293249@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: Evan Green commit fc3e62e25c3896855b7c3d72df19ca6be3459c9f upstream. smp2p_update_bits() should disable interrupts when it acquires its spinlock. This is important because without the _irqsave, a priority inversion can occur. This function is called both with interrupts enabled in qcom_q6v5_request_stop(), and with interrupts disabled in ipa_smp2p_panic_notifier(). IRQ handling of spinlocks should be consistent to avoid the panic notifier deadlocking because it's sitting on the thread that's already got the lock via _request_stop(). Found via lockdep. Cc: stable@vger.kernel.org Fixes: 50e99641413e7 ("soc: qcom: smp2p: Qualcomm Shared Memory Point to Point") Reviewed-by: Bjorn Andersson Reviewed-by: Stephen Boyd Signed-off-by: Evan Green Link: https://lore.kernel.org/r/20200929133040.RESEND.1.Ideabf6dcdfc577cf39ce3d95b0e4aa1ac8b38f0c@changeid Signed-off-by: Bjorn Andersson Signed-off-by: Greg Kroah-Hartman --- drivers/soc/qcom/smp2p.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- a/drivers/soc/qcom/smp2p.c +++ b/drivers/soc/qcom/smp2p.c @@ -314,15 +314,16 @@ static int qcom_smp2p_inbound_entry(stru static int smp2p_update_bits(void *data, u32 mask, u32 value) { struct smp2p_entry *entry = data; + unsigned long flags; u32 orig; u32 val; - spin_lock(&entry->lock); + spin_lock_irqsave(&entry->lock, flags); val = orig = readl(entry->value); val &= ~mask; val |= value; writel(val, entry->value); - spin_unlock(&entry->lock); + spin_unlock_irqrestore(&entry->lock, flags); if (val != orig) qcom_smp2p_kick(entry->smp2p);