Received: by 2002:a17:90a:3541:0:0:0:0 with SMTP id q59csp69606pjb; Mon, 8 Jun 2020 15:01:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwNt9wa5FwZWAhnD3P+XLFewyqEib6DHT8uUBdy88Yr9Cf0z53AD+0WmunBrfNEZRrC2K8p X-Received: by 2002:a17:906:2343:: with SMTP id m3mr21998285eja.301.1591653680740; Mon, 08 Jun 2020 15:01:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591653680; cv=none; d=google.com; s=arc-20160816; b=E/F0wQwIV5syCdO35BndDP8vAhzRhWglJcfJvpdVBfnLaVkboQ0OUglGQL/wrhSerL XVJIMsG3DnsNTgDbPenadez0CIYkAgrpazT+teSlGvIoSAOQ6kpWlYfWmaMvA+bh4Nav 4OTmLpzFjJi5kyycD6oNJTslxwnFcwgyhdYcmR7wfrRmjdq0M3RdXjKA/DdSr0AeebLM mcRn9ohALjkPtdhMOU2n5PNO098uyhE/1LWu3WPfol5zOkAt2rOSbFYkFtuFl4vjnqR0 9sZzCZsyjiNg+NSxW1sY0qbTFw959GVGcF2MuZofN1ZE76KUvwUMlu+bB2553o7MHag/ fhUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=SWZL+kux4yDhzDGbd5a35TWK1xHZ00dTohAmVgLX3eM=; b=cYBuUBTPWyouRCeeBgfZ1jQBIBLxIlijNdt7+d7UdSplQ23wBvbjO4PbXN4uMpMPpd aHDtvViSboQ2rpfH9M4gwFmyCw0x9oKptD8yynPqLKQqzB1iA0ZEHclCRyNe8AQT3EaI 7VdjwuCZ7SiMSqMJbjwCe+JyhGztEBYe3UWoPxIzmWAmfdn2u/wRY0BNkkPkBXUOsMIR v1xRH1To6k6jw3huNvwOz+eMWaTAAcBQjVU1vPEeuGUjhdZkGQpvpimtuBs4pdey159G UK0ahBxQoopd+3PmEO6zCNW4+URaDMc7sFNvalItiBpTcsiSaKgmovPEmhPGkOuL+BpO la9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=KtRvm0FM; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s4si9503415edr.359.2020.06.08.15.00.56; Mon, 08 Jun 2020 15:01:20 -0700 (PDT) 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=@chromium.org header.s=google header.b=KtRvm0FM; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726814AbgFHV56 (ORCPT + 99 others); Mon, 8 Jun 2020 17:57:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726723AbgFHV56 (ORCPT ); Mon, 8 Jun 2020 17:57:58 -0400 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C81D7C08C5C2 for ; Mon, 8 Jun 2020 14:57:56 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id p21so9323293pgm.13 for ; Mon, 08 Jun 2020 14:57:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=SWZL+kux4yDhzDGbd5a35TWK1xHZ00dTohAmVgLX3eM=; b=KtRvm0FMKtiPbVuxwAkIVonwCkmmc+hCJFa+v5OdiA9+Kd85RX7E7Dz4su1hEFMAfC N0A+cMW+t6t/S1vbd1lbon+NR+2axYhEMd2KilR+OoBHlQQH6TGZAh4S69qP7stRdrmy z+5F/p1OZ19QuZpRriO3Zf8y1YXiv8zZ27CUU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=SWZL+kux4yDhzDGbd5a35TWK1xHZ00dTohAmVgLX3eM=; b=B0sGCbiTaOdkgZnNMkblK+44CNeUFLTnQgR2DZOGfbEmS2ykTahcwKbuf+GHkM8pnx fY2S49FabviV85WvTBdqkEMQU3gmiMqkqX8veH2RuukcvtDVyDbDpmNZPowsMJXlSXPS EOiB6tCTFoihO5HYz8oYNSxJYNBF7DRJW66y/F/2ap+1VLU2QwcF4z/5/WMwuvAQUimP Xs/yBpUvTC7piXJpPDLVamZtnvWqtOL5p6S175yFxtnvF+tEDxAm4MofpEFNxmld6ty3 xqWAUMCD5MQTg2mJIi/gorbD9m2zvh+dc4UWH2KhzlzlgLCrHCH222/VZD7KJMjjuLNP 6n/w== X-Gm-Message-State: AOAM531UpcCPKqEqiyQlPLXHXyu+p9Oy4MVX08qHaMlK1KC5LrwcB1SK +wWCYu2gs4T1f0HpMLgz8FUrGQ== X-Received: by 2002:a62:154f:: with SMTP id 76mr23212427pfv.322.1591653476006; Mon, 08 Jun 2020 14:57:56 -0700 (PDT) Received: from evgreen-glaptop.cheshire.ch ([2601:646:c780:1404:1c5a:73fa:6d5a:5a3c]) by smtp.gmail.com with ESMTPSA id p190sm8170178pfp.207.2020.06.08.14.57.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 08 Jun 2020 14:57:55 -0700 (PDT) From: Evan Green To: Bjorn Andersson Cc: Markus Elfring , Evan Green , Andy Gross , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] soc: qcom: smp2p: Safely acquire spinlock without IRQs Date: Mon, 8 Jun 2020 14:57:36 -0700 Message-Id: <20200608145653.1.Ideabf6dcdfc577cf39ce3d95b0e4aa1ac8b38f0c@changeid> X-Mailer: git-send-email 2.24.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Fixes: 50e99641413e7 ("soc: qcom: smp2p: Qualcomm Shared Memory Point to Point") Signed-off-by: Evan Green --- drivers/soc/qcom/smp2p.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/soc/qcom/smp2p.c b/drivers/soc/qcom/smp2p.c index 07183d731d747..a9709aae54abb 100644 --- a/drivers/soc/qcom/smp2p.c +++ b/drivers/soc/qcom/smp2p.c @@ -318,15 +318,16 @@ static int qcom_smp2p_inbound_entry(struct qcom_smp2p *smp2p, 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); -- 2.24.1