Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp21665657ybl; Mon, 6 Jan 2020 08:52:51 -0800 (PST) X-Google-Smtp-Source: APXvYqwtvltFXqvvHRyIC1/nia8ylCk5c0TyedKzBOVIWfCEDAnZq3Yyqch12C1LqM9Hcf+Dje7+ X-Received: by 2002:a9d:c02:: with SMTP id 2mr119422314otr.183.1578329571793; Mon, 06 Jan 2020 08:52:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578329571; cv=none; d=google.com; s=arc-20160816; b=dEAySWNCh0RTCFQzNVPs4xKkBNblZvnf/PfZxpvUb8TegH0SnBMsl28UXqcXfkgj/w A2ToX+aJ3R6+Mm6eksg86vpB54mDlwy2KQmqgONBBJXnggIxY4UfWYsjpuaucwbGmhuE e7xjeY9YJIVPovO4rfr1429YXVQgoHWR0KAalxj1rlbjueDFw1f7UzhKJN2DgFwcgCNP zbLiqIpgWdi1a5PhPL68v0rd7uwk1syO0husayq3aQv3mqhsdRJOiKazU6yfyUvQ4dkP ZZJqIiZqMoCsg6hi+zd0E+P83mamhtqMg/4sOTP/5A+Ef40PNH76vfxfMCc/+GI3xdV6 lVDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:subject:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to; bh=+C4ZmUKng1qhuWs+kZIsfCTDSqQuxPOqLUjPpv1Fm+o=; b=c8Rmw3Y8sftYllEzKwOXUPVbYDxjpZaKvoa6LwsIWsiweTN/6nDjf9/M/KSkSKNHXq y4oYlB9ep2oiKxsiI8ox/vjprMjnPv3Ej9MuvGTFElsX4cEyw3a1m4eUssYN8KVx3iHk 91kTvfmGOcxoOxVQcuJQgrKKtF8fZY5gdoYaKyGBCtkBenIGPWhA0ZJW8gexMuXtktZa xH0XpdCZ/u2mPY6X2FCMxq46dyFpl36Vm5jdcmbRgq0Wayga3oEAkv0qL9eJgiSGj7J2 IQa37Cgg/WlEAlA5/ax5cbPjIocutk2aML3NCu92nph/jEXakGJSWuxWvu+uHiFAJQZu WO2w== ARC-Authentication-Results: i=1; mx.google.com; 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 l21si31235448oic.126.2020.01.06.08.52.38; Mon, 06 Jan 2020 08:52:51 -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; 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 S1726647AbgAFQv4 (ORCPT + 99 others); Mon, 6 Jan 2020 11:51:56 -0500 Received: from ale.deltatee.com ([207.54.116.67]:52638 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726448AbgAFQv4 (ORCPT ); Mon, 6 Jan 2020 11:51:56 -0500 Received: from guinness.priv.deltatee.com ([172.16.1.162]) by ale.deltatee.com with esmtp (Exim 4.92) (envelope-from ) id 1ioVbd-0002qj-Sl; Mon, 06 Jan 2020 09:51:54 -0700 To: Deepa Dinamani , bhelgaas@google.com Cc: mika.westerberg@linux.intel.com, alex.williamson@redhat.com, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org References: <20200104225149.27342-1-deepa.kernel@gmail.com> From: Logan Gunthorpe Message-ID: <724d80ee-3a81-23bc-74b0-4b786b3ace53@deltatee.com> Date: Mon, 6 Jan 2020 09:51:52 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <20200104225149.27342-1-deepa.kernel@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-CA Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 172.16.1.162 X-SA-Exim-Rcpt-To: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, alex.williamson@redhat.com, mika.westerberg@linux.intel.com, bhelgaas@google.com, deepa.kernel@gmail.com X-SA-Exim-Mail-From: logang@deltatee.com X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on ale.deltatee.com X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham autolearn_force=no version=3.4.2 Subject: Re: [PATCH] drivers: pci: Clear ACS state at kexec X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on ale.deltatee.com) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-01-04 3:51 p.m., Deepa Dinamani wrote: > ACS bits remain sticky through kexec reset. This is not really a > problem for Linux because turning IOMMU on assumes ACS on. But, > this becomes a problem if we kexec into something other than > Linux and that does not turn ACS on always. > > Reset the ACS bits to default before kexec or device remove. Hmm, I'm slightly hesitant about disabling ACS on a device's unbind... Not sure if that's going to open up a hole on us. > + > +/* Standard PCI ACS capailities > + * Source Validation | P2P Request Redirect | P2P Completion Redirect | Upstream Forwarding > + */ > +#define PCI_STD_ACS_CAP (PCI_ACS_SV | PCI_ACS_RR | PCI_ACS_CR | PCI_ACS_UF) > + > /** > - * pci_std_enable_acs - enable ACS on devices using standard ACS capabilities > + * pci_std_enable_disable_acs - enable/disable ACS on devices using standard > + * ACS capabilities > * @dev: the PCI device > */ > -static void pci_std_enable_acs(struct pci_dev *dev) > +static void pci_std_enable_disable_acs(struct pci_dev *dev, int enable) > { > int pos; > u16 cap; > u16 ctrl; > + u16 val = 0; > > pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_ACS); > if (!pos) > @@ -3278,19 +3286,26 @@ static void pci_std_enable_acs(struct pci_dev *dev) > pci_read_config_word(dev, pos + PCI_ACS_CAP, &cap); > pci_read_config_word(dev, pos + PCI_ACS_CTRL, &ctrl); > > - /* Source Validation */ > - ctrl |= (cap & PCI_ACS_SV); > + val = (cap & PCI_STD_ACS_CAP); Can we open code PCI_STD_ACS_CAP? I don't see any value in it being defined above the function, it just makes the code harder to read. Logan