Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4072408pxk; Tue, 29 Sep 2020 13:35:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw2dtGa460ccaKXrgC0VnMZOH0IrDqLtIeEWJSiRXxVQRshsJQxqQrAc09goj6o46c2Mb15 X-Received: by 2002:a17:907:20d9:: with SMTP id qq25mr5475182ejb.382.1601411717797; Tue, 29 Sep 2020 13:35:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601411717; cv=none; d=google.com; s=arc-20160816; b=DS4hauIEF18cNww+qPqv91wZequUG0UPC5vtcTG4pVcqsbnB28q+J3YSvb9ERu4DI+ fFX7x9hUnbUtaDzq4SH/iafXp2VYM+FpwDM4dfk97DSd7Apg2a7VcN2jjak8moFhR4AH HEIUsJX4F+Qrq0aa06zObMylWrbC0I/F0c6fmzp+7Zby6sQr2uaEtqIhfnn6PW494rrj 6fJQ46OdZbEa+SJP0FNKKzxmCIT4AVc1ZRx7Ia6VAtJnM7sVDBoX+jqmB7EYXv+na2S4 0g0UcZpqmfLmcPsTIA8lzMOFsOME6t4L3HxKbHtTBolhJpcfj8J0qfbeddDiIlq13aLO Gwqw== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=w6Gs5CgGrT7/dE/0i0Kz33QzSpxebvhL70Kc9W54Bfk=; b=BbTDm79bK1goKl7STuKaotyv5ybfvAIO0evh8DSpuw5OA9JerelgXeKeLlJKodoAA7 JkInVdHyqrMJnsFh/nilfGuErPyyb6f4jPvmA5tyP6/LBiDjz3DlBTo4nCgaLzAyDxaz 5YKIJek47aHVldEYfXbSpRXJ6tbW1KmtHBlABKJEkE23p/3RpU4inblLwmuEUae6TfgI 98eTMZR4gwXKtk/IdJil2g8ma//srfKi2Wy+ZE475qIfwevPKP6K87ETvhyhnTRKcSNW xJUOObLqBzwgrQE/8K6MgRTw/fUHgCxZcgZrPyJDJ+0FszI13KmK3oe6rWxGLjz4lx0U p4xQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b="FgEC/9Tj"; 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 y16si3655255edm.444.2020.09.29.13.34.54; Tue, 29 Sep 2020 13:35:17 -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="FgEC/9Tj"; 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 S1729293AbgI2UbI (ORCPT + 99 others); Tue, 29 Sep 2020 16:31:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727740AbgI2UbI (ORCPT ); Tue, 29 Sep 2020 16:31:08 -0400 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D456EC0613D0 for ; Tue, 29 Sep 2020 13:31:06 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id kk9so3347046pjb.2 for ; Tue, 29 Sep 2020 13:31:06 -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=w6Gs5CgGrT7/dE/0i0Kz33QzSpxebvhL70Kc9W54Bfk=; b=FgEC/9TjFwz3LPuu1b3e38wqyfYZXVCqBvGpZ+E6u8Kdp5LeC4QfJscyElLXVW4tfr vRBfHkvctRKVaQL7QyBu8BrHU5iDWdwmJ8MaGj4PMgeSw2W1dshGhEBEvFtkHMk9TuHg OwbSbd7mZGtr2aB+KZOl8Dyxb+aaZjO5Gzh90= 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=w6Gs5CgGrT7/dE/0i0Kz33QzSpxebvhL70Kc9W54Bfk=; b=XNtH5Y9QVTsSULUhzoeC0XKOR7L7HUeKR5jCwdJZavkZxbh8jcUsBZFNKhwAYq9znQ fsGFz3JKJqbbQHS27joGeoZ/lQ2vWFuQmZZ+GMJs5lfH8ha413h0XhEqcAvgoeR1iOyU UyF7U1hMS2PJm+dV1/jtiu0D8w3CgOpX1O7Nsq7RSN1DX5C+7Jt6mT+0NakXoJCoOTdT PNzUsQsLIRYPPy95BWXDI5r6dtgklJ3ogOw39jX3utDwv8tqnfZ6Nm6JQpABmAz3RwCu +VtFFg2hz1wrDHSffLmEpwwvMxU+zlWc7qENnkohndTfrI/Tb9rxDLn3S7XcAUdC1Kjz MMKQ== X-Gm-Message-State: AOAM530FiuCq3cmjbEa+AzMkFohfJervd9FiLpMo52R16Z3sumGtPOAi Zuc4WNhxjcq4pPE93dBm3hR/f0RM+A1ccWxR X-Received: by 2002:a17:90a:fb53:: with SMTP id iq19mr5465867pjb.122.1601411465785; Tue, 29 Sep 2020 13:31:05 -0700 (PDT) Received: from evgreen-glaptop.cheshire.ch ([2601:646:c780:1404:a2ce:c8ff:fec4:54a3]) by smtp.gmail.com with ESMTPSA id j9sm5997167pfc.175.2020.09.29.13.31.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 29 Sep 2020 13:31:05 -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: [RESEND PATCH] soc: qcom: smp2p: Safely acquire spinlock without IRQs Date: Tue, 29 Sep 2020 13:30:57 -0700 Message-Id: <20200929133040.RESEND.1.Ideabf6dcdfc577cf39ce3d95b0e4aa1ac8b38f0c@changeid> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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.26.2