Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9039496pxu; Mon, 28 Dec 2020 05:09:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJzI8KNbiGL/VPMFt/N5K9ffgN7kD5gGgogRTMghnqIB2KH0zC8BOwDaFyZpfmYL7I1Crrob X-Received: by 2002:aa7:ce16:: with SMTP id d22mr41946138edv.381.1609160948806; Mon, 28 Dec 2020 05:09:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609160948; cv=none; d=google.com; s=arc-20160816; b=hPilAHfn5AVH3G8jUn2W3gGmVusM5mPV5ng0Ewp/4mXAC9e6k6+pljRVbhonHDFBda hNk8TiYiGCXzQEKtV7vh8A9dXnW2881ld4vAJn9Iou8kOPwJpE89S60qWnVIvCmK2jex mkVFD8rE9A/0cuGqmM0kASbyy8dF5Gl87jzbgb4QQLd+D2pOwnvz5RlImYTDIXLe2XUm 9EN8yqelcz3m8kaS+siIO+JM7LZQVqLglpRxhEgTNm3tlCNyrMI81y1wHKeUO5y4g+px knGdTUWa1tCepBonHfHVbRUcVKir90zkwFIKE5eYnBFRn28ds0JceuheldZiiK6NHXJV TfzQ== 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=Ix/sfbNibReKq1agA/xom7l5gFerq9yc4QGcEr1t6XkQI/FJFRh6SPC/0CcL2UrxjN +Y9jF4T1fmg0Oex8f0dWlB5Gk/YX+/7MD6EAniEdqdruyUQ5Mrf2nWcB0KCeKH801gnv eqSM/y+G4S/rlm3DRfZ6HWL8QgIyjEkw1lfPXEqlja1xtaKqgaVd/WHEL1141RYFGM5x vRD/djrYOtpl6taZ+VxK8YJfpRMg4pv1BcrIVLHR/if+EmVbOz05CwqsWLEsbgEXaqPi +lAskqQOhWWq+0LpAi3YcVauJxajw3akeYNC+kuSwrbf8vVUUSR2PsscbzoyqF0fAp3h pqfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="aQoEaJe/"; 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 ga18si18502113ejc.66.2020.12.28.05.08.45; Mon, 28 Dec 2020 05:09:08 -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="aQoEaJe/"; 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 S1729726AbgL1NGp (ORCPT + 99 others); Mon, 28 Dec 2020 08:06:45 -0500 Received: from mail.kernel.org ([198.145.29.99]:33828 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729639AbgL1NGd (ORCPT ); Mon, 28 Dec 2020 08:06:33 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id BEC35208BA; Mon, 28 Dec 2020 13:06:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609160777; bh=FQP+rt9NpICwzj/HNlIQdtXAEm7tcSEAdjcSZDwBpWA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aQoEaJe/PYanlZQcFFNE+6F9vrHrQl8dFzMsDnP92gOLHIhWT6D06Hxi7QMXPrYHb //g1iTN5yVSKHHksJpgSM2nc+oMfIp3edoOnK3kCRbFVFOhJhM8vkwJ/5pmJ8O7sIx oEOrjeA2EkB1eQ8zfDx6PYH4u1rL9gRTmADmJhKo= 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.9 168/175] soc: qcom: smp2p: Safely acquire spinlock without IRQs Date: Mon, 28 Dec 2020 13:50:21 +0100 Message-Id: <20201228124901.372180359@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228124853.216621466@linuxfoundation.org> References: <20201228124853.216621466@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);