Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1095782ybl; Thu, 23 Jan 2020 13:30:24 -0800 (PST) X-Google-Smtp-Source: APXvYqzL1NCLOmXzdHDBicKo5xhKbTmDHvFj4i6RoWLNhLcV+6bHTXXsbvED+W59ZoR229ELvoOU X-Received: by 2002:a9d:3cf:: with SMTP id f73mr314544otf.11.1579815024374; Thu, 23 Jan 2020 13:30:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579815024; cv=none; d=google.com; s=arc-20160816; b=i8TTnfbNCN8JJobIC6IwfLGhA017tfnL+wSfQCMJVbTv1gcpyGJJLqdQXn+RmZpG14 CMargtxTwjF/CSHSqeCBFzgdikxkhJyi7Ug3WXdMQA2Out0ZdReAWk/uZh4e17eje5Eb /n89rjocoeJ4BNgZv4m7dPVqEDGS+CcmFHmKoS4QfAF5RAT/nAfJe9RrjkKv76PzCru4 1Rlln5MMicJd3z82SXrrc0feqTDqdYAQe3dyQ3ukBLLttYLfbNIOu4ceiYclYRqFdCiG bu1wY8D9IiqwUepaJY5yXLf4xVENNDc8GTDeKECAjvVTFq1CaRnWt78GiukgD2Ac3Xwm i3aA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=Rlz3hvUu+9u2oNJYG4g2Rw59Iz8hixxTpHD2vCOcLXo=; b=h8wG+R9LAfW4PQVKIX0xFmULqIGmyjUBCC5IBIXSygZFNhFnjh71lwf8gli1N6qVwE UuF9S18ij7+UcFhyepqQKDS4KaINsCTh9mrfcQfUqqhVsbHNpViCUgSBzwKKlfXPlcN7 YWx4R8P5yJKLWqF6gUgNid7Cx9E/Ua+CQXTCdv9DzWKZMSgLxWU8xrkshhBs8jTeIa3K ulqrRlZtUIdv9BiaEf2pcwd0jtUPy9w05vPG4/9yvR1l7fnYPrLP/klq7xoTStwlAeKL mpYQsKhxLmFWc9TsA7KtF5XrrSnn6FNSg7pGBFGTWu41oKLV+VxrRKR7fJRgp45o1S7R 4DoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=google header.b=PwBvHXWc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i11si1831723otc.105.2020.01.23.13.30.12; Thu, 23 Jan 2020 13:30:24 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=google header.b=PwBvHXWc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727453AbgAWV1S (ORCPT + 99 others); Thu, 23 Jan 2020 16:27:18 -0500 Received: from mail-il1-f196.google.com ([209.85.166.196]:40255 "EHLO mail-il1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726118AbgAWV1S (ORCPT ); Thu, 23 Jan 2020 16:27:18 -0500 Received: by mail-il1-f196.google.com with SMTP id c4so38778ilo.7 for ; Thu, 23 Jan 2020 13:27:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=Rlz3hvUu+9u2oNJYG4g2Rw59Iz8hixxTpHD2vCOcLXo=; b=PwBvHXWcPbHsFtHuoq3AUL5vFUZnWEbflYLFA0fa+kpnrYlFYyZ0WNPhmm0JH5IX20 wOJlpK/ta+WU/QC7YYY/nAK98YO4OkEzz+mMqfx2W1MeL5DIBZGjjs2GThFWLbmP4ZXO BWndEWvmKE617UUJcuQWCt1gg1wDNoy4ZugQk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=Rlz3hvUu+9u2oNJYG4g2Rw59Iz8hixxTpHD2vCOcLXo=; b=H7y0+0+jgHLxp7cLT7toRm+yEi0dmrKaIfgTDQb05lCYmpMemi833jMOOkZbVcoT/D QQB1JUDaG9ViGcglDczICJdUcLbPVBO+RxaYBXIOWA6aR4AFpJ+DE9r7TTHoDE9Ue5Uy 6c8nk3XpR/BOHDbdJPXSporfA7uGL5Lh9uRb5UGd3fODT2wHEB4wkbbeeqet9pjGJBFy tT9Sgh8RW/+LmzI15UYtqLqb0YmbH+X98uVQrQBCe9FD/DIEmArItGddcFEB4qI1n78H brn6Vh1OslAPVrbsM2D31Tcy7XZ+zdYSyTs5T1d5zsU+ly553TerG9XLMknJ6sQhE29V tmfQ== X-Gm-Message-State: APjAAAXoth0PIlCtxbSUO7qpjZuc1b3Mc4ayc+dBWzog6hKyH4jWYhbS QUxMfZS1MTTyaLTNTfTsRFAm1Q== X-Received: by 2002:a05:6e02:cc5:: with SMTP id c5mr249989ilj.47.1579814837406; Thu, 23 Jan 2020 13:27:17 -0800 (PST) Received: from [192.168.1.112] (c-24-9-64-241.hsd1.co.comcast.net. [24.9.64.241]) by smtp.gmail.com with ESMTPSA id i11sm701592ion.1.2020.01.23.13.27.16 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 23 Jan 2020 13:27:16 -0800 (PST) Subject: Re: [PATCH] iommu: amd: Fix IOMMU perf counter clobbering during init To: Suravee Suthikulpanit , Joerg Roedel Cc: iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Shuah Khan References: <20200114151220.29578-1-skhan@linuxfoundation.org> <20200117100829.GE15760@8bytes.org> <42c0a806-9947-1401-9754-8aa88bd7062f@amd.com> <24a46b0f-33d7-5f94-661a-80f035213892@linuxfoundation.org> From: Shuah Khan Message-ID: Date: Thu, 23 Jan 2020 14:27:15 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: <24a46b0f-33d7-5f94-661a-80f035213892@linuxfoundation.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 1/21/20 8:32 AM, Shuah Khan wrote: > On 1/20/20 7:10 PM, Suravee Suthikulpanit wrote: >> On 1/17/2020 5:08 PM, Joerg Roedel wrote: >>> Adding Suravee, who wrote the IOMMU Perf Counter code. >>> >>> On Tue, Jan 14, 2020 at 08:12:20AM -0700, Shuah Khan wrote: >>>> init_iommu_perf_ctr() clobbers the register when it checks write access >>>> to IOMMU perf counters and fails to restore when they are writable. >>>> >>>> Add save and restore to fix it. >>>> >>>> Signed-off-by: Shuah Khan >>>> --- >>>>   drivers/iommu/amd_iommu_init.c | 22 ++++++++++++++++------ >>>>   1 file changed, 16 insertions(+), 6 deletions(-) >>> Suravee, can you please review this patch? >>> >> >> This looks ok. Does this fix certain issues? Or is this just for sanity. > > I didn't notice any problems. Counters aren't writable on my system. > However, it certainly looks like a bog since registers aren't restored > like in other places in this file where such checks are done on other > registers. > > I see 2 banks and 4 counters on my system. Is it sufficient to check > the first bank and first counter? In other words, if the first one > isn't writable, are all counters non-writable? > > Should we read the config first and then, try to see if any of the > counters are writable? I have a patch that does that, I can send it > out for review. > >> >> Reviewed-by: Suravee Suthikulpanit Joerg, Please don't pull this in. I introduced a bug in this patch. It always returns amd_iommu_pc_present false even when it can write to the counters. My bad. I will send v2. thanks, -- Shuah