Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1950363ybt; Mon, 15 Jun 2020 13:51:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzpE1W/HZVL+yFlvhR4RVyNnjXj58ZxDzc+AbcCiWJV/Ae1g1DPgilJD0NRhSYqMZN5tOoZ X-Received: by 2002:a17:906:6c98:: with SMTP id s24mr28589089ejr.438.1592254298576; Mon, 15 Jun 2020 13:51:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592254298; cv=none; d=google.com; s=arc-20160816; b=YbDAxVipesw+TCQJFsCpcnnSNFUs5bw2DD7JL7Zs2p5ouwOZXFHoAsgOsrYhrMHJt1 WbcrYRQESM1QL/JmJCIqT9Z2S32Plyv7DlN28v6FWFUNOGz7sbc7BcG2mipw5kEpghfh tGX/XawBFUXuYm/UQBSmbnbEXi1lDeO49c9Y9X5Y2uZKNb8qHTNaQfSpcMqwOG8RWwSi y2Lm5lOtA8PoydYSPkZfMLzebyl5ZQuRUwluWsk7wmNTw+PKY5NbyQSYU+gSNRvAN+kv PT8EWg/Q6ilfmx5XoJyef9nDBIJwaU6FzTUW3BUVWm126QXZsjZQCms0dLaW7iN5zChQ IuNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date; bh=FLO9/mI8LswX5E0B/XaVBHZi0Tx+zaCgUVzOsQjMfmg=; b=EqryrF2+Rx4U6RQ4q2aeHOo1ZbxWg0R+3tkD7BHzdOJQ7m83Jj8aYF06Ql/jGEw8Bh 4wxY7WjSCgFV5c8S2ix+T8tujYU47p3QmbTQ4juW6No4LWiFMinTY8a6hqO7V4cz+My7 79p4DyQ5yKoAHKFOGCnMuGl5ASPU/ow+d5mBiv/0yBUUZeXJqx0oLSsX7bEYoVVuaUqi tCg3DnYclArsXIo8gk1sr01uHxEU1GXFLs+65B8jAab5ypmhZ+Xk0T+eAiuFBhH6SvXl gZLB+RsPwpIOzCcHbwFxoR9pazrRGapgcafVkni7Gd6bVLFcFP/6w3GpbjNZ+uw81BjF YmOw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=ispras.ru Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e11si9293196ejh.44.2020.06.15.13.51.16; Mon, 15 Jun 2020 13:51:38 -0700 (PDT) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=ispras.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731610AbgFOUs6 (ORCPT + 99 others); Mon, 15 Jun 2020 16:48:58 -0400 Received: from winnie.ispras.ru ([83.149.199.91]:13370 "EHLO smtp.ispras.ru" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729692AbgFOUs6 (ORCPT ); Mon, 15 Jun 2020 16:48:58 -0400 Received: from [10.10.3.121] (monopod.intra.ispras.ru [10.10.3.121]) by smtp.ispras.ru (Postfix) with ESMTP id CF78A203BF; Mon, 15 Jun 2020 23:48:53 +0300 (MSK) Date: Mon, 15 Jun 2020 23:48:52 +0300 (MSK) From: Alexander Monakov To: Suravee Suthikulpanit cc: linux-kernel@vger.kernel.org, Joerg Roedel , iommu@lists.linux-foundation.org Subject: Re: [PATCH] iommu/amd: Fix event counter availability check In-Reply-To: Message-ID: References: <20200529200738.1923-1-amonakov@ispras.ru> <56761139-f794-39b1-4dfa-dfc05fbe5f60@amd.com> User-Agent: Alpine 2.20.13 (LNX 116 2015-12-14) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 1 Jun 2020, Suravee Suthikulpanit wrote: > Alexander > > On 6/1/20 4:01 PM, Alexander Monakov wrote: > > On Mon, 1 Jun 2020, Suravee Suthikulpanit wrote: > > > > > > Moving init_iommu_perf_ctr just after iommu_flush_all_caches resolves > > > > the issue. This is the earliest point in amd_iommu_init_pci where the > > > > call succeeds on my laptop. > > > > > > According to your description, it should just need to be anywhere after > > > the > > > pci_enable_device() is called for the IOMMU device, isn't it? So, on your > > > system, what if we just move the init_iommu_perf_ctr() here: > > > > No, this doesn't work, as I already said in the paragraph you are responding > > to. See my last sentence in the quoted part. > > > > So the implication is init_device_table_dma together with subsequent cache > > flush is also setting up something that is necessary for counters to be > > writable. > > > > Alexander > > > > Instead of blindly moving the code around to a spot that would just work, > I am trying to understand what might be required here. In this case, > the init_device_table_dma()should not be needed. I suspect it's the IOMMU > invalidate all command that's also needed here. > > I'm also checking with the HW and BIOS team. Meanwhile, could you please give > the following change a try: Hello. Can you give any update please? Alexander > diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c > index 5b81fd16f5fa..b07458cc1b0b 100644 > --- a/drivers/iommu/amd_iommu_init.c > +++ b/drivers/iommu/amd_iommu_init.c > @@ -1875,6 +1875,8 @@ static int __init amd_iommu_init_pci(void) > ret = iommu_init_pci(iommu); > if (ret) > break; > + iommu_flush_all_caches(iommu); > + init_iommu_perf_ctr(iommu); > } > > /* > -- > 2.17.1 > > Thanks, > Suravee >