Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp5621605iog; Thu, 23 Jun 2022 01:47:18 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sy/bV0nHWb+2P+IpO1gg5EFH4EJmu5c65nU9SbcxtSCpb/cyli1czU8K8XdjZRE466e6YJ X-Received: by 2002:a17:907:3e86:b0:6f5:917:10cc with SMTP id hs6-20020a1709073e8600b006f5091710ccmr6709483ejc.53.1655974038456; Thu, 23 Jun 2022 01:47:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655974038; cv=none; d=google.com; s=arc-20160816; b=CN4/Eo4/2CVMuUqUAteFa+iGG1lBYYhUqqviNyo5YUdYIIab+q2SLiZL6nZlPnmlH2 tlijbKfjthFkFnzl2Jmd+JiuqlpdqgooMjvBSj9VsSr08a/zxA5mgQvlYeqDFt11GK6X T7a9tP7loKXjV8sJUGJWdvUbvJ4zRXBzwg89aXNJbszPho969Uc3RVMYSnHmtzyPGCpe vMiBxc5sQvMfgm90Lvoc/22W7Zo6rbFFbBgodXjqzaPYPtTntJfzcJVzn5HHOVDuEsay 13HvTJlKhuZCSNoYhIez8jWnvSMpU442cO1w6ek1jHSPmtrWnSzyF9rLYUPMha4mxcaI ZubA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=etGsHzIwcxa5OLVc3cktP189sxJuN0+4k1V5yHtzrYA=; b=Z/inQzWEiqL5B6t66V+uDgPQjPOYhLxVaUu2vpJ2i9juPvyegsbApodrK0ZWP6P1xl pnJ/B3xGZtjkaCOoGy6rcLjtLufjza+FvVoqArzdMdAT+K+QoFoEJ7XFZVu+7DXAPFU5 WX7x1Qhi9BdEPSXndyvO+xSIygz7FzhIKCMOr54JBPwNIifFO6yszSv5PAN07k2HQxPt nDdzn7U8Q+t3q1XWMPbfMeZPmIKWXBSy7d5iQmpywITXlW4VBNznjMMMecwk4eaF6fcz HNdldsHidkU3j2wWeZKjw5ewjIuRAs1bDYG50QGurVQUu355I6X3p5uRufJQOxHBir3D 4LFw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m5-20020aa7d345000000b004335d160f73si22161845edr.309.2022.06.23.01.46.54; Thu, 23 Jun 2022 01:47:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229943AbiFWIWx (ORCPT + 99 others); Thu, 23 Jun 2022 04:22:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229778AbiFWIWo (ORCPT ); Thu, 23 Jun 2022 04:22:44 -0400 Received: from theia.8bytes.org (8bytes.org [81.169.241.247]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2EC7F488A5 for ; Thu, 23 Jun 2022 01:22:41 -0700 (PDT) Received: by theia.8bytes.org (Postfix, from userid 1000) id 40B0B447; Thu, 23 Jun 2022 10:22:40 +0200 (CEST) Date: Thu, 23 Jun 2022 10:22:38 +0200 From: Joerg Roedel To: Suravee Suthikulpanit Cc: linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, robin.murphy@arm.com, ashish.kalra@amd.com, vasant.hegde@amd.com, thomas.lendacky@amd.com Subject: Re: [PATCH v3 1/7] iommu/amd: Warn when found inconsistency EFR mask Message-ID: References: <20220622171131.11870-1-suravee.suthikulpanit@amd.com> <20220622171131.11870-2-suravee.suthikulpanit@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220622171131.11870-2-suravee.suthikulpanit@amd.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 On Wed, Jun 22, 2022 at 12:11:25PM -0500, Suravee Suthikulpanit wrote: > #ifdef CONFIG_IRQ_REMAP > +/* > + * Iterate through all the IOMMUs to verify if the specified > + * EFR bitmask of IOMMU feature are set. > + * Warn and return false if found inconsistency. > + */ > static bool check_feature_on_all_iommus(u64 mask) > { > bool ret = false; > struct amd_iommu *iommu; > > for_each_iommu(iommu) { > - ret = iommu_feature(iommu, mask); > - if (!ret) > + bool tmp = iommu_feature(iommu, mask); > + > + if ((ret != tmp) && > + !list_is_first(&iommu->list, &amd_iommu_list)) { > + pr_err(FW_BUG "Found inconsistent EFR mask (%#llx) on iommu%d (%04x:%02x:%02x.%01x).\n", > + mask, iommu->index, iommu->pci_seg->id, PCI_BUS_NUM(iommu->devid), > + PCI_SLOT(iommu->devid), PCI_FUNC(iommu->devid)); > return false; > + } > + ret = tmp; It is better to implement this by introducing a global feature mask, which represents the minial set of features supported by any IOMMU in the system. The warning is then something like: if ((global_feature_mask & iommu_features) != global_feature_mask) pr_warn(...); This also makes the global variable to track SNP support obsolete. Regards, Joerg