From patchwork Tue Jun 16 01:17:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rajat Jain X-Patchwork-Id: 194092 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.4 required=3.0 tests=DKIMWL_WL_MED, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EAF97C433E2 for ; Tue, 16 Jun 2020 01:18:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CC1D820768 for ; Tue, 16 Jun 2020 01:18:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="K64yw4Ua" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726906AbgFPBRz (ORCPT ); Mon, 15 Jun 2020 21:17:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726897AbgFPBRy (ORCPT ); Mon, 15 Jun 2020 21:17:54 -0400 Received: from mail-qt1-x849.google.com (mail-qt1-x849.google.com [IPv6:2607:f8b0:4864:20::849]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 213A3C08C5C3 for ; Mon, 15 Jun 2020 18:17:54 -0700 (PDT) Received: by mail-qt1-x849.google.com with SMTP id u26so15429347qtj.21 for ; Mon, 15 Jun 2020 18:17:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=/xX6nZw43qnrS5POTejrGqQ7NU/q6i+TSuGWkPxARP8=; b=K64yw4UaVuSTB06zM70ynWO3Qe34OlpnWZDFtQx+XohI9pGel76JaZtLQSBoWSuTVn iUzYet0x27iuRTb1k2C8psq+ocK+eUc+lbqn/lM4DjoyK8Lwthh6he1ErlgUVUwd2DYt +Ye+ql9uWjMbbc98okBddDJZZSEPasbtsclPT6fSyzC2cMfQoctWhwgA1EprQkRAaKW3 kZpng1WUzZbMtCYVB9VeNUn8PkNpzWWpfDFshQHOc4eQsm4yRF+loPV3Fp3xPvwnmEqr I9MkdliB1IiEzSTXoV4J1n+HUh2x8Vc310feGGYXQTOVnGd2k9zdRqFaiLC6Nf2wojul zk3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=/xX6nZw43qnrS5POTejrGqQ7NU/q6i+TSuGWkPxARP8=; b=mv6ZkC/p/OCWX6Ohfw68dziHjK7UYltDqFE3S+Wz25+6Xx6RsHDVhORk+IVtRcB7tk mxt3Sw7eNwGaDFWSF1BI9JzXFGYwGJiI0xMGV0ysO89BzrJvSkGCu0lhk5tPOovTZts2 XgtzwNAlwLwKn9nrQOE5cWXa9Do/wlkmCbc81G6LB69lj5kOh3L6gzA7kEh+k/RcMqcx WmkAzm7F+4h7Fqm2XfcT6N7wrmzl6lGUQlDmpc8mujopWNn+Uk48dRj3m/l0y4CKcNOX 6ffEthrv1LVBkKI9oDgicJsrOq1R2En6CjOLorHBPQ6P8THKZiGnltt7K+s8d1lAiaAx whww== X-Gm-Message-State: AOAM531B6yhiwkw23aYAsVZtbtkrgkd1ML356eF487jHei3Gu1xyG7Pk BOz9fqTJf6suvaHc8ddk3BpAZljtDiCM X-Google-Smtp-Source: ABdhPJx/VShp5rkGDpPUGAg/FhXNCRybPGhdLZkWV0hxwM8Gk42L1iKKJC5+PkUN237Ww8vlTPH4HPEgQvLG X-Received: by 2002:ad4:4374:: with SMTP id u20mr548678qvt.144.1592270273220; Mon, 15 Jun 2020 18:17:53 -0700 (PDT) Date: Mon, 15 Jun 2020 18:17:41 -0700 In-Reply-To: <20200616011742.138975-1-rajatja@google.com> Message-Id: <20200616011742.138975-3-rajatja@google.com> Mime-Version: 1.0 References: <20200616011742.138975-1-rajatja@google.com> X-Mailer: git-send-email 2.27.0.290.gba653c62da-goog Subject: [PATCH 3/4] pci: acs: Enable PCI_ACS_TB for untrusted/external-facing devices From: Rajat Jain To: David Woodhouse , Lu Baolu , Joerg Roedel , Bjorn Helgaas , "Rafael J. Wysocki" , Len Brown , iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, linux-acpi@vger.kernel.org, Raj Ashok , lalithambika.krishnakumar@intel.com, Mika Westerberg , Jean-Philippe Brucker , Prashant Malani , Benson Leung , Todd Broch , Alex Levin , Mattias Nissler , Rajat Jain , Bernie Keany , Aaron Durbin , Diego Rivas , Duncan Laurie , Furquan Shaikh , Jesse Barnes , Christian Kellner , Alex Williamson , Greg Kroah-Hartman , oohall@gmail.com Cc: Rajat Jain Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org When enabling ACS, currently the bit "translation blocking" was not getting changed at all. Set it to disable translation blocking too for all external facing or untrusted devices. This is OK because ATS is only allowed on internal devces. Signed-off-by: Rajat Jain --- drivers/pci/pci.c | 4 ++++ drivers/pci/quirks.c | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index d2ff987585855..79853b52658a2 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -3330,6 +3330,10 @@ static void pci_std_enable_acs(struct pci_dev *dev) /* Upstream Forwarding */ ctrl |= (cap & PCI_ACS_UF); + if (dev->external_facing || dev->untrusted) + /* Translation Blocking */ + ctrl |= (cap & PCI_ACS_TB); + pci_write_config_word(dev, pos + PCI_ACS_CTRL, ctrl); } diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index b341628e47527..6294adeac4049 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c @@ -4934,6 +4934,13 @@ static void pci_quirk_enable_intel_rp_mpc_acs(struct pci_dev *dev) } } +/* + * Currently this quirk does the equivalent of + * PCI_ACS_RR | PCI_ACS_CR | PCI_ACS_UF | PCI_ACS_SV + * + * Currently missing, it also needs to do equivalent of PCI_ACS_TB, + * if dev->external_facing || dev->untrusted + */ static int pci_quirk_enable_intel_pch_acs(struct pci_dev *dev) { if (!pci_quirk_intel_pch_acs_match(dev)) @@ -4973,6 +4980,10 @@ static int pci_quirk_enable_intel_spt_pch_acs(struct pci_dev *dev) ctrl |= (cap & PCI_ACS_CR); ctrl |= (cap & PCI_ACS_UF); + if (dev->external_facing || dev->untrusted) + /* Translation Blocking */ + ctrl |= (cap & PCI_ACS_TB); + pci_write_config_dword(dev, pos + INTEL_SPT_ACS_CTRL, ctrl); pci_info(dev, "Intel SPT PCH root port ACS workaround enabled\n");