Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3321211rwa; Tue, 23 Aug 2022 02:47:34 -0700 (PDT) X-Google-Smtp-Source: AA6agR5Ei9XzDbbmS5GnuKJGaVmk12kCRV5l3F0e2nibW+d1Rv/hDnpA/RZpyvQ+2QhyZnUd5x+N X-Received: by 2002:a63:154:0:b0:42a:5176:bd74 with SMTP id 81-20020a630154000000b0042a5176bd74mr14546912pgb.521.1661248054629; Tue, 23 Aug 2022 02:47:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661248054; cv=none; d=google.com; s=arc-20160816; b=blvmYFqHN4ezL1+I9LtbdL5leoDC71RzHS4aD7VYc1fse8U93KP1YixBKMF23MrwnX iY8P/99yVsgkIsUHlh5REd8X0F44yV3nZUMsXU9CViL70UFqdaJw5qLCZwmOsYL8Gbl+ 60z12D6W7OntW3k6qmjzqMGj+dTg3AEi/tQSVT4C/g782Zi7XbwSyf8XFjN1Kb8pDRMO dcElKoR7ptQbnk220qqPAynnVadOybDnzuevsW/e5v0FZ2BivcVHbJWeK13XBBdxupq6 lMASOFyAY9um4HejASbUodxxUrVOuClqMX5jHHLm66JaoMvGoRNnz+H4dqtn47UqdQFp HK4A== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=cTvGcPwVzIxX1aImEejPGsCGbKHm2fRhuvVjAjRH6+c=; b=K+LWyipTfBfyoXcfDq3Dmm4y7d1LmlYw9oSUStgl/A8FdS/7uaa2XCmERnihYLN8i6 Yd+5V560TJsYUvfSU/LFjdm0VAQytClkbXYqLMaarXqJIbNckaayaTp2+o7BNykcDgSm ae0PCCXdGIkI3vCnjCBUzMECJ0fXgPhDhts2x2/U+Gvdg8m3sgi1fUwf68g6OmiN/esm kvIJ4k5T1lR8hWO3oksHc0eXZdufAmIHm6VNFw9mIzMPv+5bIGbTPD3UhJW1mYKd5Elc Wt0GbplQAYqx+01Ms9m4dmgwVzwFV0aWVnvrFnJv7CGghgJbFn7GWC0YYxBGeeIakAVA P2zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=WxWzT9sy; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s35-20020a634523000000b004161e72a055si9941406pga.310.2022.08.23.02.47.23; Tue, 23 Aug 2022 02:47:34 -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=@linuxfoundation.org header.s=korg header.b=WxWzT9sy; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349353AbiHWJWh (ORCPT + 99 others); Tue, 23 Aug 2022 05:22:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243671AbiHWJUI (ORCPT ); Tue, 23 Aug 2022 05:20:08 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 03109895FB; Tue, 23 Aug 2022 01:33:51 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 51CB1B81C20; Tue, 23 Aug 2022 08:32:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9F9CBC433D6; Tue, 23 Aug 2022 08:32:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661243573; bh=uVE2rYO/FwoZI6CHQRFOhSMx6E4j3S4MrjD6MhJyUfg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WxWzT9sy1MDBQoEr0eBtf3ZI/Ehv8UnInir7NwKLSwZwaOdJItWKpIeKncZfEfS0s o1rhxmdtwVQk5+j7ymOANGTkxRPcrbsv2JTUVCXqD8utxoBTRLt8fTLxUd+gn3LQzc uDuWkob2usXZhiUt0c9sMBglsaKlwpWy8Bpbpv5I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dongli Zhang , Christoph Hellwig , Sasha Levin Subject: [PATCH 5.19 319/365] swiotlb: panic if nslabs is too small Date: Tue, 23 Aug 2022 10:03:40 +0200 Message-Id: <20220823080131.532813281@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080118.128342613@linuxfoundation.org> References: <20220823080118.128342613@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 From: Dongli Zhang [ Upstream commit 0bf28fc40d89b1a3e00d1b79473bad4e9ca20ad1 ] Panic on purpose if nslabs is too small, in order to sync with the remap retry logic. In addition, print the number of bytes for tlb alloc failure. Signed-off-by: Dongli Zhang Signed-off-by: Christoph Hellwig Signed-off-by: Sasha Levin --- kernel/dma/swiotlb.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c index 5830dce6081b..f5304e2f6a35 100644 --- a/kernel/dma/swiotlb.c +++ b/kernel/dma/swiotlb.c @@ -242,6 +242,9 @@ void __init swiotlb_init_remap(bool addressing_limit, unsigned int flags, if (swiotlb_force_disable) return; + if (nslabs < IO_TLB_MIN_SLABS) + panic("%s: nslabs = %lu too small\n", __func__, nslabs); + /* * By default allocate the bounce buffer memory from low memory, but * allow to pick a location everywhere for hypervisors with guest @@ -254,7 +257,8 @@ void __init swiotlb_init_remap(bool addressing_limit, unsigned int flags, else tlb = memblock_alloc_low(bytes, PAGE_SIZE); if (!tlb) { - pr_warn("%s: failed to allocate tlb structure\n", __func__); + pr_warn("%s: Failed to allocate %zu bytes tlb structure\n", + __func__, bytes); return; } -- 2.35.1