Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1678365pxb; Wed, 9 Feb 2022 01:59:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJwN2kzcP+S9y30q9STfHN/v8eGYvVytscxuFOa5RGT7k7/SQK6cMGRT1fuHVn0H/x4aFqao X-Received: by 2002:a17:90b:4d82:: with SMTP id oj2mr2524112pjb.79.1644400775257; Wed, 09 Feb 2022 01:59:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644400775; cv=none; d=google.com; s=arc-20160816; b=g169SoYzyZsJ8T+EG+8xvzqGlyPcn5S72eEoPFm9eMT2MvklzfiTsJLfkCFOB08sC9 0CTG6+B3YN+64fEza6TUmEpEfJel6lYoju3uHFVHDb8UCaZnSH2vcgE8UwQ3t60Oybtr HC3tH11yKG/oxYEoaTdKbdNH7nlVFGX5riXKBbVku+VU0gDoHQlJBm89NU6Sxgwnx94T RNPWQpKvZ4xM7ECJeRxruibjmC7JHSM97MbvFHcDSHYCYI40OakBRmbultKcaVmHhhHr CgnIkpm0KYebrMkSqk1kzDJdVPFLE18PUrUoOwPAzimlID6YyAIdM1ORB3V0+pdJGvRg 82Bg== 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=9EGFtluI9dDcpFQ2UxPz4yP99biOr+e65DB37AFk7uo=; b=G3vU0KLFsWZhDwoPtYWzGenU26jjqrZZFCWmCGh9CYCo1llt/qqEqnngsHS876X9O6 4/LaPMorHuTjYB/ITdkEK9I0Ncuyro7tmNPFbvBNy54tLajO5QCeXyuRmNgG2owFOFbT 7QNXvDJYjaeCjk1FTqgXaGd2Zqa0aw+BvAyBjcJCjUvCbZJR2dphYnUJHVEp4wGnEaR0 EEEquNXZisPsmRHeSg2BbYryoXDhUCKE9I90U5ep/c/BpaSwh6H0w3ZhRuWiOVC7j+61 /WdFCXnc+CFk+YPQ5620lB3iDy57HhfH6tY5qh6mNhqXcF1mxEsp4gS0eWAxROZTgCNq 1kbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=h6QgdKTn; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id pc6si5680295pjb.3.2022.02.09.01.59.20; Wed, 09 Feb 2022 01:59:35 -0800 (PST) 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=@linuxfoundation.org header.s=korg header.b=h6QgdKTn; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1389446AbiBGLsc (ORCPT + 99 others); Mon, 7 Feb 2022 06:48:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1386550AbiBGLez (ORCPT ); Mon, 7 Feb 2022 06:34:55 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 271D1C043181; Mon, 7 Feb 2022 03:34:54 -0800 (PST) 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 C7D42B80EBD; Mon, 7 Feb 2022 11:34:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E8BE4C004E1; Mon, 7 Feb 2022 11:34:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233691; bh=ScHomgUOORKGXC3cq+pTzaGi0+yCAoM+r4g/KqfAQEg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=h6QgdKTnJHWnHESXfj7+tS8sTK7eOFbfUnqtSeXxHHR6hf4U23rx1SoRoc27Pw3Ku s2DtfT+JWsbsp++0kcWA2zZT6VTWo6LRPcCJqlZGmrzod5hIP/ccjmmao64N62pCCo jOdgZJE72U9TVbCHi11MMvM1zT4kxujWLvLFfMv4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Joerg Roedel Subject: [PATCH 5.16 058/126] iommu/amd: Fix loop timeout issue in iommu_ga_log_enable() Date: Mon, 7 Feb 2022 12:06:29 +0100 Message-Id: <20220207103806.115758833@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103804.053675072@linuxfoundation.org> References: <20220207103804.053675072@linuxfoundation.org> User-Agent: quilt/0.66 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=unavailable 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: Joerg Roedel commit 9b45a7738eec52bf0f5d8d3d54e822962781c5f2 upstream. The polling loop for the register change in iommu_ga_log_enable() needs to have a udelay() in it. Otherwise the CPU might be faster than the IOMMU hardware and wrongly trigger the WARN_ON() further down the code stream. Use a 10us for udelay(), has there is some hardware where activation of the GA log can take more than a 100ms. A future optimization should move the activation check of the GA log to the point where it gets used for the first time. But that is a bigger change and not suitable for a fix. Fixes: 8bda0cfbdc1a ("iommu/amd: Detect and initialize guest vAPIC log") Signed-off-by: Joerg Roedel Link: https://lore.kernel.org/r/20220204115537.3894-1-joro@8bytes.org Signed-off-by: Greg Kroah-Hartman --- drivers/iommu/amd/init.c | 2 ++ 1 file changed, 2 insertions(+) --- a/drivers/iommu/amd/init.c +++ b/drivers/iommu/amd/init.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -834,6 +835,7 @@ static int iommu_ga_log_enable(struct am status = readl(iommu->mmio_base + MMIO_STATUS_OFFSET); if (status & (MMIO_STATUS_GALOG_RUN_MASK)) break; + udelay(10); } if (WARN_ON(i >= LOOP_TIMEOUT))