Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp272075ybg; Tue, 2 Jun 2020 23:56:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwSmopLTO+Kt/VXkXRqH1s6HkNZoD1ZpolzqdFYz51IdQNzw6Sa0ORXZlIKA+seb+q0zdvl X-Received: by 2002:a17:907:2636:: with SMTP id aq22mr25977639ejc.384.1591167418466; Tue, 02 Jun 2020 23:56:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591167418; cv=none; d=google.com; s=arc-20160816; b=EBEP6kzCcspgVAQ4q5KSnDdNqaDBCfnO51/QN1LNmiY4sBpWGkeeRgi6B/0qwMT0aS hLgOSMtWoJgbEDYl6zBu92IhryBHKE8+fzr/VtIHnSy6qWpc2Lr0CXUnwt6KBJNcLjvw uebJW2ELD6WafmMXc88JPbNVRs6uwkG/hSEyhQdfY9DjozpdI0vQzdfgM82pHE9ylfXm 2MnvBLX+lYA0N7F6YWiCzuEGGLYwxSD3ccN1pQWts+x8cFUkzSoGvhyuoxQoWchUsPze banFtXq0Np+nDYJj9tUhwKov+hvRlRYlEIRVJdJLSHkjGDpy6htdn2JDYPmaQM+3dW4d L0Kw== 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=rKzOooNwf3YP/RWT7uJF1k2KofpmuwFMREuFsxyZu+4=; b=tOi7LqOACFuCvYBMi/mNDmQl2I5vBZj4MJqk7ipG7RDfIHWUC/ojp4Zz/euKXs7f1O a9xR9qIfkIay98AXIJDm4Bd9A0Q61md5TYgl8sI8R2ri2cc/FyXZS0kGTTUOLXyc84Q/ Exao4zt4pjDd4Em9LekibyvygYk7qss7JPYt9LBlBKwSfXgBfO4QCyDDWumq+U8t8qzg vTayZiVdRYJEqdQjSynFfVHCouhVob5Nn8qUzE6KsvfnxqsLWvJIyKSmqkat5wRVlozU 6nqlwc5VrfOep2yD3sh7rNqmR6KJCegOYnJwTlwocmdC/afEG6S1j7rqBeLMmsR9rLBi mU7Q== 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 n18si600540edq.195.2020.06.02.23.56.35; Tue, 02 Jun 2020 23:56:58 -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 S1726123AbgFCGyr (ORCPT + 99 others); Wed, 3 Jun 2020 02:54:47 -0400 Received: from winnie.ispras.ru ([83.149.199.91]:21904 "EHLO smtp.ispras.ru" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726057AbgFCGyr (ORCPT ); Wed, 3 Jun 2020 02:54:47 -0400 Received: from monopod.intra.ispras.ru (monopod.intra.ispras.ru [10.10.3.121]) by smtp.ispras.ru (Postfix) with ESMTP id 2F94B203BF; Wed, 3 Jun 2020 09:54:42 +0300 (MSK) Date: Wed, 3 Jun 2020 09:54:42 +0300 (MSK) From: Alexander Monakov To: Shuah Khan cc: linux-kernel@vger.kernel.org, Joerg Roedel , Suravee Suthikulpanit , 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> 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 Tue, 2 Jun 2020, Shuah Khan wrote: > I changed the logic to read config to get max banks and counters > before checking if counters are writable and tried writing to all. > The result is the same and all of them aren't writable. However, > when disable the writable check and assume they are, I can run [snip] This is similar to what I did. I also noticed that counters can be successfully used with perf if the initial check is ignored. I was considering sending a patch to remove the check and adjust the event counting logic to use counters as read-only, but after a bit more investigation I've noticed how late pci_enable_device is done, and came up with this patch. It's a path of less resistance: I'd expect maintainers to be more averse to removing the check rather than fixing it so it works as intended (even though I think the check should not be there in the first place). However: The ability to modify the counters is needed only for sampling the events (getting an interrupt when a counter overflows). There's no code to do that for these AMD IOMMU counters. A solution I would prefer is to not write to those counters at all. It would simplify or even remove a bunch of code. I can submit a corresponding patch if there's general agreement this path is ok. What do you think? Alexander