Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9412495pxu; Mon, 28 Dec 2020 15:39:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJwa/2co6lqLKkQdyA0F0qsiSDb76g4t9WmKbqHkTff/Nf6oDAsCXDB9iuNEeCOgF8jL9GBI X-Received: by 2002:a17:906:814a:: with SMTP id z10mr42238298ejw.96.1609198795365; Mon, 28 Dec 2020 15:39:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609198795; cv=none; d=google.com; s=arc-20160816; b=OFI/c2qDk1J+fadsJGqP9LALPnD0sPEssZj1Drn9hFokmEwpjxQl5DtLo0m3mLBMCA UevEaCuvHnFG3EzCdTKfsP3PPjui2iQVhfkAdhuMQrIGoAq3lP7tJ7b2O5vWdswTk78i 2+ny/5CxL1ky9Am9Ti8vvTUrUywfnhL0+NwKAtwMY/UCurh6p9qqF4kKG4smXJkdhCUC CugKZLthei98wXmIdrMj2Mz1gyoDLLHVU7kcSOR7gD31KS/yUEGtO+pwLXYH+wcxPJC0 +JXLISQU6pVxdLo7MZDMaolIjPdlrZnErd/JZ3XDl7BL0mWBK+K1l5Nq3vPfwpDPJ0Jy FyPQ== 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=tyiBkInUDwo7i7X/fQJB3bg/5DZtcgbakDXq/a8Icw0=; b=sfeCjGjRfYiNxmZP+kAb0KWzw3zYtBRYPH15oMqK3PjldSFfLjlPyEylibqihO7Ncl y2UYlcEI2SRHS1yaZhZ/5kpfkEzKMZEcn79UBfdOALT1c7GNxItyQWMric2euEIl0nRj Za7M+dhfIFB4qm9WxeIUe5nOV2v6XQ2h2+MU9nHn9l9oZE7fYdeJk47SYrze/Mx0kIqu LZ8j2JGwIDfI+tMj0vG886uZLR1U/QYR/i7ES22ODef64BFqmCyLUU8sYBpylDQA+8es TeR74dJAyGaEcFX1B6GcdA61UqpTu222510pFzA6fnbV0oyA6M7bHq+XgYCKnekjtcUx QK7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="dZ82h/7D"; 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 dn4si17359297ejc.519.2020.12.28.15.39.33; Mon, 28 Dec 2020 15:39:55 -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="dZ82h/7D"; 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 S2504096AbgL1ObA (ORCPT + 99 others); Mon, 28 Dec 2020 09:31:00 -0500 Received: from mail.kernel.org ([198.145.29.99]:38992 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2504066AbgL1Oax (ORCPT ); Mon, 28 Dec 2020 09:30:53 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9F63A206D4; Mon, 28 Dec 2020 14:30:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609165813; bh=nVSzycZt+EukXHEr+gvwkZdSZQA/LEWomxafvatUCB8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dZ82h/7DXLASCk+G+rXqXuc2rvUu6yoL1iuwMRlm9YKr2JFsQA3gDX2qp/YNvJhAa Gn1pQl72ca21nouoUTtpEAp4P251MAL3KwrIIA5LUWPN5eCD0qHDApWGM+5r2duojR oSY1FoSs16L45jJDIu9KbQ8lhmcVHICPGo+jS6bY= 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 5.10 663/717] soc: qcom: smp2p: Safely acquire spinlock without IRQs Date: Mon, 28 Dec 2020 13:51:01 +0100 Message-Id: <20201228125052.740191406@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228125020.963311703@linuxfoundation.org> References: <20201228125020.963311703@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 @@ -318,15 +318,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);