From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS, T_DKIMWL_WL_HIGH,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4ADF7C43219 for ; Thu, 2 May 2019 19:16:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1D3B221479 for ; Thu, 2 May 2019 19:16:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556824583; bh=ztapzPlmSiYCt4nMj4OICaKQS1K1FzkfxA+tbrWwVwI=; h=From:To:Subject:Date:In-Reply-To:References:In-Reply-To: References:List-ID:From; b=X50Fn8fMZwSg3Ma5GPQoPfaTehO0VUGMQ2M84Ibmomg1d+pdAaBSFyjuLHORBOI4/ r8LbOHQZLsS7lNY1WIWWjtKo48+S7fX99/5ixNPQz21uD+VzV8A/G8SAH3b3eekhNo mezBUaMcePF8atVmLLwS7M0fOUEIwwNwoBF6mbHA= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726589AbfEBTQW (ORCPT ); Thu, 2 May 2019 15:16:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:33204 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726477AbfEBTQE (ORCPT ); Thu, 2 May 2019 15:16:04 -0400 Received: from localhost.localdomain (c-98-220-238-81.hsd1.il.comcast.net [98.220.238.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D0FAC2087F; Thu, 2 May 2019 19:16:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556824563; bh=ztapzPlmSiYCt4nMj4OICaKQS1K1FzkfxA+tbrWwVwI=; h=From:To:Subject:Date:In-Reply-To:References:In-Reply-To: References:From; b=eMrYT3UX28W25Euer93AaJnulBqVmpc32cms0MggPiO5wp9eeSwrNlLdQwCngEQ5n givX2m0+SIAdnN1iM0gLD5kqaSjuZ/pb4b0W117KuU49NQJaPpzqZqNGowqzM5LADL tFtBjW9BlWA9KTuh4yeZ5YcdQN+r54vyM3L62dlM= From: zanussi@kernel.org To: LKML , linux-rt-users , Steven Rostedt , Thomas Gleixner , Carsten Emde , John Kacur , Sebastian Andrzej Siewior , Daniel Wagner , Tom Zanussi , Julia Cartwright Subject: [PATCH RT 2/4] powerpc/pseries/iommu: Use a locallock instead local_irq_save() Date: Thu, 2 May 2019 14:15:37 -0500 Message-Id: X-Mailer: git-send-email 2.14.1 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sebastian Andrzej Siewior v3.18.138-rt116-rc1 stable review patch. If anyone has any objections, please let me know. ----------- [ Upstream commit 5c1b4cd70e2ca0c81038b65babe6dc66086322e0 ] The locallock protects the per-CPU variable tce_page. The function attempts to allocate memory while tce_page is protected (by disabling interrupts). Use local_irq_save() instead of local_irq_disable(). Cc: stable-rt@vger.kernel.org Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Tom Zanussi Conflicts: arch/powerpc/platforms/pseries/iommu.c --- arch/powerpc/platforms/pseries/iommu.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c index 05a2c9eefc08..acc6f64f0cb8 100644 --- a/arch/powerpc/platforms/pseries/iommu.c +++ b/arch/powerpc/platforms/pseries/iommu.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -177,6 +178,7 @@ static int tce_build_pSeriesLP(struct iommu_table *tbl, long tcenum, } static DEFINE_PER_CPU(__be64 *, tce_page); +static DEFINE_LOCAL_IRQ_LOCK(tcp_page_lock); static int tce_buildmulti_pSeriesLP(struct iommu_table *tbl, long tcenum, long npages, unsigned long uaddr, @@ -197,7 +199,8 @@ static int tce_buildmulti_pSeriesLP(struct iommu_table *tbl, long tcenum, direction, attrs); } - local_irq_save(flags); /* to protect tcep and the page behind it */ + /* to protect tcep and the page behind it */ + local_lock_irqsave(tcp_page_lock, flags); tcep = __get_cpu_var(tce_page); @@ -208,7 +211,7 @@ static int tce_buildmulti_pSeriesLP(struct iommu_table *tbl, long tcenum, tcep = (__be64 *)__get_free_page(GFP_ATOMIC); /* If allocation fails, fall back to the loop implementation */ if (!tcep) { - local_irq_restore(flags); + local_unlock_irqrestore(tcp_page_lock, flags); return tce_build_pSeriesLP(tbl, tcenum, npages, uaddr, direction, attrs); } @@ -242,7 +245,7 @@ static int tce_buildmulti_pSeriesLP(struct iommu_table *tbl, long tcenum, tcenum += limit; } while (npages > 0 && !rc); - local_irq_restore(flags); + local_unlock_irqrestore(tcp_page_lock, flags); if (unlikely(rc == H_NOT_ENOUGH_RESOURCES)) { ret = (int)rc; @@ -397,13 +400,14 @@ static int tce_setrange_multi_pSeriesLP(unsigned long start_pfn, u64 rc = 0; long l, limit; - local_irq_disable(); /* to protect tcep and the page behind it */ + /* to protect tcep and the page behind it */ + local_lock_irq(tcp_page_lock); tcep = __get_cpu_var(tce_page); if (!tcep) { tcep = (__be64 *)__get_free_page(GFP_ATOMIC); if (!tcep) { - local_irq_enable(); + local_unlock_irq(tcp_page_lock); return -ENOMEM; } __get_cpu_var(tce_page) = tcep; @@ -449,7 +453,7 @@ static int tce_setrange_multi_pSeriesLP(unsigned long start_pfn, /* error cleanup: caller will clear whole range */ - local_irq_enable(); + local_unlock_irq(tcp_page_lock); return rc; } -- 2.14.1