Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp5929267rwd; Wed, 24 May 2023 08:33:48 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ78HfPp6ybVxm7NgPncI06U+cyXfAlhM3biRl29qCD0UIx64JG8fPUDYjyAJzalQ3z/yM15 X-Received: by 2002:a05:6a20:7493:b0:104:7a4c:6ca6 with SMTP id p19-20020a056a20749300b001047a4c6ca6mr17772093pzd.13.1684942427134; Wed, 24 May 2023 08:33:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684942427; cv=none; d=google.com; s=arc-20160816; b=PF/C/4/HDAwzxdNL9Wvaew5p19+CPyFuuNPuenwoIWPObE1/FB9AKWPKrGJveXPU+V Au+Zav0rrhGGnpIYB5v5gnOfkwXe8JIsWGrRPF5NSZEGROEmKhOAf8gqeC3N6BVa7ijy u8aMi4kygL8ZWBggkqCzWWjI+KwPOZNo3YLixfuWFDw1c0ZA+jOullmr27s93d3ciMHG iKNPMJEDZ/uEvkBKpokPUfmVjmyx7DBmdCZKuQtaJVfXL3C38FHiigPZtKIvzTBszwAB T2SPraRdzrTTnin2j7tJobis2JqpWdpPGeZ8yfj0QWLzuF5suSchTmYpxlCH3pmJUiAx bW3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:ui-outboundreport:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=pqhCABXI16XnCw8UxTLi0hAnYA7Z7fzMfO6p251N+1I=; b=jH36Gp6SNm2itfPExC8E+v6X6kBdkO2vkMAqW7f6baeeE6lWCV8WtqOnDZB4X3Gkuw BnsK04uDh40yG8OgsddKyYlA/OhJN9aUxvIk48Fjv8p3gBUY5bEdLpoUW3dWt596VoBM 1QaHM/yDFZNaHkcqWaEvj+0N0LvrzlzqQBBklh46y10xM849Bd9LVcX6RGGmXDD+TBvU /hO37ZMZ9cfsHm+8+vdN1/6jY7qPmV4o44UQtuxft5cyyEbGIgprmusUts2mhLjpiW7a j4HikvEg1Txlp4Y84F3exGcKuosmG5MNJ0zfFjOWNKTCFedpaL4Zpekwhld6rpgpBvpO 4+Zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=tgq8Qwky; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q3-20020a656a83000000b0053071414c3asi8539560pgu.562.2023.05.24.08.33.32; Wed, 24 May 2023 08:33:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=tgq8Qwky; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234306AbjEXP0v (ORCPT + 99 others); Wed, 24 May 2023 11:26:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234883AbjEXP0q (ORCPT ); Wed, 24 May 2023 11:26:46 -0400 Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12702122; Wed, 24 May 2023 08:26:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1684941999; i=deller@gmx.de; bh=+u+YPRciweWPPguaxEgTzruDX0igJ4dkk2Wtadt6QVA=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=tgq8QwkypsPRETeu+19MR6ZTBDZejuyxcvDSAhNK6C9kPDFZoR+sLoUmYrLp2v0qQ Oo+R6oMG/ZhVh9nYB0o6ro85A/Xo8KQNLZvQL4nEvq+lrObnYr5+lObF8oGxIPXJsO KrwsLQ8A6uxnCygqj5B8dz2XFfHHfzU7addqr6c0kFUZACz7xFiCyHB8Kxp/ERPjg7 SqxDyZ6Xly9UkoUTsoAvLoxekB4JFUzsjbgAnBk/dL2E7J1QkVNa2fDDVZsaYIUfSe oXNS3i2IQaAIyyKqYQIV/hFGfBwd4eBAbR6jiNv/07fDPECCeq2iD3Qk5ptDn1LqBK iBOsESCtXF0rg== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from p100.fritz.box ([94.134.145.4]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1N7R1J-1qCC9r3QFB-017m18; Wed, 24 May 2023 17:26:38 +0200 From: Helge Deller To: linux@armlinux.org.uk, dinguyen@kernel.org, linux-kernel@vger.kernel.org, linux-parisc@vger.kernel.org Cc: Helge Deller Subject: [PATCH 3/3] parisc: Fix flush_dcache_page() for usage from irq context Date: Wed, 24 May 2023 17:26:33 +0200 Message-Id: <20230524152633.203927-4-deller@gmx.de> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230524152633.203927-1-deller@gmx.de> References: <20230524152633.203927-1-deller@gmx.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:1nlE0hasgl6gijxKoEdYfyHTI6vIMSOKaK+RqkKBabLx7UsK7Xo npxRasd38wBp+V4q8fJGGVe6hCTQhHravYda1JFL6bI2UYwo7iwgzUnZI624CMkgi1y9ue+ DMb4jU4oy7QsTpmV/pY1WrN/dhtRBMyXkX+fMTt93HK/7yj+1uyp8VTelCIFyk84E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E= X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since at least kernel 6.1, flush_dcache_page() is called with IRQs disabled, e.g. from aio_complete(). But the current implementation for flush_dcache_page() on parisc unintentionally re-enables IRQs, which may lead to deadlocks. Fix it by using xa_lock_irqsave() and xa_unlock_irqrestore() for the flush_dcache_mmap_*lock() macros instead. Cc: linux-parisc@vger.kernel.org Signed-off-by: Helge Deller =2D-- arch/parisc/include/asm/cacheflush.h | 4 ++++ arch/parisc/kernel/cache.c | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/parisc/include/asm/cacheflush.h b/arch/parisc/include/as= m/cacheflush.h index 0bdee6724132..c8b6928cee1e 100644 =2D-- a/arch/parisc/include/asm/cacheflush.h +++ b/arch/parisc/include/asm/cacheflush.h @@ -48,6 +48,10 @@ void flush_dcache_page(struct page *page); #define flush_dcache_mmap_lock(mapping) xa_lock_irq(&mapping->i_pages) #define flush_dcache_mmap_unlock(mapping) xa_unlock_irq(&mapping->i_pages= ) +#define flush_dcache_mmap_lock_irqsave(mapping, flags) \ + xa_lock_irqsave(&mapping->i_pages, flags) +#define flush_dcache_mmap_unlock_irqrestore(mapping, flags) \ + xa_unlock_irqrestore(&mapping->i_pages, flags) #define flush_icache_page(vma,page) do { \ flush_kernel_dcache_page_addr(page_address(page)); \ diff --git a/arch/parisc/kernel/cache.c b/arch/parisc/kernel/cache.c index 1d3b8bc8a623..ca4a302d4365 100644 =2D-- a/arch/parisc/kernel/cache.c +++ b/arch/parisc/kernel/cache.c @@ -399,6 +399,7 @@ void flush_dcache_page(struct page *page) unsigned long offset; unsigned long addr, old_addr =3D 0; unsigned long count =3D 0; + unsigned long flags; pgoff_t pgoff; if (mapping && !mapping_mapped(mapping)) { @@ -420,7 +421,7 @@ void flush_dcache_page(struct page *page) * to flush one address here for them all to become coherent * on machines that support equivalent aliasing */ - flush_dcache_mmap_lock(mapping); + flush_dcache_mmap_lock_irqsave(mapping, flags); vma_interval_tree_foreach(mpnt, &mapping->i_mmap, pgoff, pgoff) { offset =3D (pgoff - mpnt->vm_pgoff) << PAGE_SHIFT; addr =3D mpnt->vm_start + offset; @@ -460,7 +461,7 @@ void flush_dcache_page(struct page *page) } WARN_ON(++count =3D=3D 4096); } - flush_dcache_mmap_unlock(mapping); + flush_dcache_mmap_unlock_irqrestore(mapping, flags); } EXPORT_SYMBOL(flush_dcache_page); =2D- 2.38.1