Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1582983pxb; Tue, 8 Feb 2022 23:06:08 -0800 (PST) X-Google-Smtp-Source: ABdhPJxH4VJ8j7Iy5Pz1UfEQgwrc12eXqvqP9wHN06tsv8duXaRg5CpXAbGSgIhYZCyqweOBNH8I X-Received: by 2002:a05:6a00:244e:: with SMTP id d14mr937019pfj.45.1644390368455; Tue, 08 Feb 2022 23:06:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644390368; cv=none; d=google.com; s=arc-20160816; b=cY/fTxUfXvQXHDGBlaQKDYJZagTl6D/8jMYMDSAiL8RvHWFrKKXIs0NON5zk6QXVss qJS2eFwt/ZDUaXfIAJms6jInGJyiwqZYHicQ+SZlydaYIQ+faatiOnAdu/XpcEMAEAb0 DCjYHpYxlK1V4jRKe9JTHASOdR60RHYWHJr4z0Vemo71tSRWiXW4RUAZlqymI6XbWhAX y0TTuONvO1XDBO8lPV8o72lcMlH4bn7QVGLremc9XB/cY9sMoNizlPVDawOfsQmtKTVe IhWGYXne8M/Cxs7Wh/IxDsRXRI3aJN/y0T44o4yjoIwYWvAp0IjZneTivk2n/9dE35Ar T9fQ== 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 :message-id:date:subject:cc:to:from; bh=rsmpttdPYazZEUrUi1VShONFfqcW71W/rnuozKZ+O9I=; b=feOi1HgPcM49OFoyURW08KiXqU1PSx+OwZ3n+19E6SE9AhslE4z1/ZrpyKSb5GxSl3 KAqA+hFX4xsXWRzI1h1kz/8hVsjgO3Kbe6X4jyjNNfIIZwg+BFHdUaUy47SlLsdu+z63 RmsMPDZ5oUmexzzyVZKGisQPGGYNnAhvUEBnku8gnTL06GjXuqd1NkOe2X6kGmJt8AqB SrEW5k6+2YypbEjsFE0w+fXfofGDf4o2RiV0KRPI+Wo8+m8XCWc5dYkX+F2h02g3lv95 UjnQsPITu3BtN64qpE7QtrEqSrG0WK+76X3YT5+H9KSFaoOH5t25EI7MhboaBIOPeOI4 HYTw== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id n18si13871762pff.307.2022.02.08.23.06.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 23:06:08 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 03AFDE03E221; Tue, 8 Feb 2022 22:20:45 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1358497AbiBDLzm (ORCPT + 99 others); Fri, 4 Feb 2022 06:55:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39572 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230501AbiBDLzl (ORCPT ); Fri, 4 Feb 2022 06:55:41 -0500 Received: from theia.8bytes.org (8bytes.org [IPv6:2a01:238:4383:600:38bc:a715:4b6d:a889]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53D91C061714 for ; Fri, 4 Feb 2022 03:55:41 -0800 (PST) Received: from cap.home.8bytes.org (p549ad610.dip0.t-ipconnect.de [84.154.214.16]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by theia.8bytes.org (Postfix) with ESMTPSA id 3B50C2F6; Fri, 4 Feb 2022 12:55:39 +0100 (CET) From: Joerg Roedel To: Joerg Roedel Cc: Suravee Suthikulpanit , Will Deacon , iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Joerg Roedel Subject: [PATCH v2] iommu/amd: Fix loop timeout issue in iommu_ga_log_enable() Date: Fri, 4 Feb 2022 12:55:37 +0100 Message-Id: <20220204115537.3894-1-joro@8bytes.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, SPF_HELO_PASS,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 From: Joerg Roedel 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 --- drivers/iommu/amd/init.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/iommu/amd/init.c b/drivers/iommu/amd/init.c index dc338acf3338..b10fb52ea442 100644 --- 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 amd_iommu *iommu) status = readl(iommu->mmio_base + MMIO_STATUS_OFFSET); if (status & (MMIO_STATUS_GALOG_RUN_MASK)) break; + udelay(10); } if (WARN_ON(i >= LOOP_TIMEOUT)) -- 2.34.1