From patchwork Fri Mar 4 04:46:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: yf.wang@mediatek.com X-Patchwork-Id: 548507 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C542EC433F5 for ; Fri, 4 Mar 2022 04:52:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233893AbiCDExf (ORCPT ); Thu, 3 Mar 2022 23:53:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233099AbiCDExf (ORCPT ); Thu, 3 Mar 2022 23:53:35 -0500 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 078DC3B3F5; Thu, 3 Mar 2022 20:52:42 -0800 (PST) X-UUID: a9fa9b595d30426180269d85e18dfcb4-20220304 X-UUID: a9fa9b595d30426180269d85e18dfcb4-20220304 Received: from mtkmbs10n1.mediatek.inc [(172.21.101.34)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 200241363; Fri, 04 Mar 2022 12:52:38 +0800 Received: from mtkcas10.mediatek.inc (172.21.101.39) by mtkmbs10n2.mediatek.inc (172.21.101.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.792.3; Fri, 4 Mar 2022 12:52:37 +0800 Received: from mbjsdccf07.mediatek.inc (10.15.20.246) by mtkcas10.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Fri, 4 Mar 2022 12:52:36 +0800 From: To: Joerg Roedel , Will Deacon , "Matthias Brugger" , "open list:IOMMU DRIVERS" , open list , "moderated list:ARM/Mediatek SoC support" , "moderated list:ARM/Mediatek SoC support" CC: , Libo Kang , Ning Li , Yong Wu , Yunfei Wang , Subject: [PATCH] iommu/iova: Free all CPU rcache for retry when iova alloc failure Date: Fri, 4 Mar 2022 12:46:34 +0800 Message-ID: <20220304044635.4273-1-yf.wang@mediatek.com> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Yunfei Wang In alloc_iova_fast function, if an iova alloc request fail, it will free the iova ranges present in the percpu iova rcaches and free global iova rcache and then retry, but flushing CPU iova rcaches only for each online CPU, which will cause incomplete rcache cleaning, and iova rcaches of not online CPU cannot be flushed, because iova rcaches may also lead to fragmentation of iova space, so the next retry action may still be fail. Based on the above, so need to flushing all iova rcaches for each possible CPU, use for_each_possible_cpu instead of for_each_online_cpu like in free_iova_rcaches function, so that all rcaches can be completely released to try replenishing IOVAs. Signed-off-by: Yunfei Wang Cc: # 5.4.* --- drivers/iommu/iova.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/iommu/iova.c b/drivers/iommu/iova.c index b28c9435b898..5a0637cd7bc2 100644 --- a/drivers/iommu/iova.c +++ b/drivers/iommu/iova.c @@ -460,7 +460,7 @@ alloc_iova_fast(struct iova_domain *iovad, unsigned long size, /* Try replenishing IOVAs by flushing rcache. */ flush_rcache = false; - for_each_online_cpu(cpu) + for_each_possible_cpu(cpu) free_cpu_cached_iovas(cpu, iovad); free_global_cached_iovas(iovad); goto retry;