Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp375932imm; Mon, 21 May 2018 07:27:24 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqcg51D1bIamM9YLD1DROnqn2qhkw4lzfBOfClJHKnogJGcoIBAzgHg6iAR3iWO3u41k+ET X-Received: by 2002:a65:61a6:: with SMTP id i6-v6mr15757506pgv.88.1526912844805; Mon, 21 May 2018 07:27:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526912844; cv=none; d=google.com; s=arc-20160816; b=ZMIB2GrusdGNDekTaldqPQKcUGOLGT7nadodB9XQNQBO0b24X6mS4mY6HDQgc/ZiQG 9yTTMUVym6SOW3Fk+stYje9CKNtJBJUSjVZ6mlIPO3zDkvfGK4VAhpkCL5+DwAjtLv7p 8Llu5QDp0iRQEzhDF+iwlZkz+6PRfRlYxFHlBjbYxHzcNyg1gV5HzitsIvKwn/+BqkyQ nwDK+7ZWUWQ4iBqxGvoKq8yXx/8g3myBiPjB2sqFZRb/oRLo1tq4Ot4P0Lcv9bVCzz1L Omz/mG6uwY01W7lNsjJkBz7MYFZRtREpaZ1HwHf5Nfzqq1SVoj6V/XED/H5Ta8mTi13A Tv/Q== 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:arc-authentication-results; bh=1+F8FlSgp7hpa8x2IvMbJy/zA+Uf9LEVKD8VQsUOhJ8=; b=An7hirFnGlUTYeFTymKACndl8dHitX/jhXb/kqoZfgZdRoYqdQ0N1ygYW3CNfXMy4x sWkOPffty/ZYx3vnckfS40qfFbdFfpMKDuF/pwraXP65ykoT0BMiPswIlq/lcimXEioB XItd90I9pXVJZaJblrJGHiEx8wV6X5NMUPdfTjOdcfv86IzHVmQKH10RoR3DTfQfSvLj zI5/uVcG7Ii9E6M828ljCv+o4H3z/o0ZGYxurOSFUd4cShjv9MtCz6g78pmNrbZ9GDqw 1uzzSsHYyTJ93LCw2xfGeBQKeCIsbYvnlUvDfRGufbY6XjqFbpmx1lYWLSjhhx03bhHH 6OzA== 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 l33-v6si13840891pld.440.2018.05.21.07.27.09; Mon, 21 May 2018 07:27:24 -0700 (PDT) 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 S1753089AbeEUO0f (ORCPT + 99 others); Mon, 21 May 2018 10:26:35 -0400 Received: from foss.arm.com ([217.140.101.70]:51162 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752838AbeEUO0a (ORCPT ); Mon, 21 May 2018 10:26:30 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 313ED80D; Mon, 21 May 2018 07:26:30 -0700 (PDT) Received: from [10.1.210.88] (e110467-lin.cambridge.arm.com [10.1.210.88]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 9F9363F577; Mon, 21 May 2018 07:26:28 -0700 (PDT) Subject: Re: [PATCH INTERNAL 3/3] PCI: iproc: Disable MSI parsing in certain PAXC blocks To: Lorenzo Pieralisi , Ray Jui Cc: poza@codeaurora.org, Bjorn Helgaas , Bjorn Helgaas , linux-kernel@vger.kernel.org, bcm-kernel-feedback-list@broadcom.com, linux-pci@vger.kernel.org, linux-pci-owner@vger.kernel.org References: <1526577692-21104-1-git-send-email-ray.jui@broadcom.com> <1526577692-21104-4-git-send-email-ray.jui@broadcom.com> <20180518135614.GA18605@e107981-ln.cambridge.arm.com> <20180521133305.GB1443@e107981-ln.cambridge.arm.com> From: Robin Murphy Message-ID: <073832d4-88a0-efa1-2da8-5e07479e51e0@arm.com> Date: Mon, 21 May 2018 15:26:27 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180521133305.GB1443@e107981-ln.cambridge.arm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 21/05/18 14:33, Lorenzo Pieralisi wrote: > [+Robin] > > On Fri, May 18, 2018 at 12:48:28PM -0700, Ray Jui wrote: >> Hi Lorenzo, >> >> On 5/18/2018 6:56 AM, Lorenzo Pieralisi wrote: >>> On Fri, May 18, 2018 at 02:53:41PM +0530, poza@codeaurora.org wrote: >>>> On 2018-05-17 22:51, Ray Jui wrote: >>>>> The internal MSI parsing logic in certain revisions of PAXC root >>>>> complexes does not work properly and can casue corruptions on the >>>>> writes. They need to be disabled >>>>> >>>>> Signed-off-by: Ray Jui >>>>> Reviewed-by: Scott Branden >>>>> --- >>>>> drivers/pci/host/pcie-iproc.c | 34 ++++++++++++++++++++++++++++++++-- >>>>> 1 file changed, 32 insertions(+), 2 deletions(-) >>>>> >>>>> diff --git a/drivers/pci/host/pcie-iproc.c b/drivers/pci/host/pcie-iproc.c >>>>> index 3c76c5f..b906d80 100644 >>>>> --- a/drivers/pci/host/pcie-iproc.c >>>>> +++ b/drivers/pci/host/pcie-iproc.c >>>>> @@ -1144,10 +1144,22 @@ static int iproc_pcie_paxb_v2_msi_steer(struct >>>>> iproc_pcie *pcie, u64 msi_addr) >>>>> return ret; >>>>> } >>>>> >>>>> -static void iproc_pcie_paxc_v2_msi_steer(struct iproc_pcie *pcie, u64 >>>>> msi_addr) >>>>> +static void iproc_pcie_paxc_v2_msi_steer(struct iproc_pcie *pcie, u64 >>>>> msi_addr, >>>>> + bool enable) >>>>> { >>>>> u32 val; >>>>> >>>>> + if (!enable) { >>>>> + /* >>>>> + * Disable PAXC MSI steering. All write transfers will be >>>>> + * treated as non-MSI transfers >>>>> + */ >>>>> + val = iproc_pcie_read_reg(pcie, IPROC_PCIE_MSI_EN_CFG); >>>>> + val &= ~MSI_ENABLE_CFG; >>>>> + iproc_pcie_write_reg(pcie, IPROC_PCIE_MSI_EN_CFG, val); >>>>> + return; >>>>> + } >>>>> + >>>>> /* >>>>> * Program bits [43:13] of address of GITS_TRANSLATER register into >>>>> * bits [30:0] of the MSI base address register. In fact, in all iProc >>>>> @@ -1201,7 +1213,7 @@ static int iproc_pcie_msi_steer(struct iproc_pcie >>>>> *pcie, >>>>> return ret; >>>>> break; >>>>> case IPROC_PCIE_PAXC_V2: >>>>> - iproc_pcie_paxc_v2_msi_steer(pcie, msi_addr); >>>>> + iproc_pcie_paxc_v2_msi_steer(pcie, msi_addr, true); >>>> >>>> Are you calling iproc_pcie_paxc_v2_msi_steer() anywhere else with 'false' ? >>>> I see its getting called only from one place in current code >>>> iproc_pcie_msi_steer(). >>> >>> It is called below with the false field to disable MSIs. That's probably >>> one reason more to create a function to enable/disable MSIs instead of >>> adding a parameter to iproc_pcie_paxc_v2_msi_steer(). >> >> Correct. Thanks for helping to explain. >> >>> >>> Which brings me to the question: what happens to those MSIs writes >>> when MSIs are disabled according to this patch ? Are they terminated >>> at the root complex ? >> >> Note the PAXC block parses MSI writes from our internally connected >> endpoints (i.e., an embedded network processor). The PAXC block examines >> these MSI writes and modifies the memory attributes (to DEVICE) of these >> data and then send them out to the AXI bus. These MSI writes will then be >> forwarded to the GIC (e.g., GICv2m, GICv3-ITS from ARM) for further >> processing. This is saying, PAXC itself does not process these MSI writes. >> They are processed by the GIC and associated interrupt will be generated >> form the GIC. PAXC's job is to parse and tag them properly so these MSI >> writes can reach the GIC, and at the same, reach the GIC at the right order. >> >> On some of these problematic PAXCs, we are being forced to disable this PAXC >> internal parsing logic. In this case, we set up static mapping with the >> IOMMU to modify the memory attributes of these MSI writes. These MSI writes >> are always designated towards a specific memory address (e.g., on the GICv3 >> based system, it's the address of the translator register), and that's why >> static mapping table can be set up to work around this. > > Which means, I presume, that there must be some code that somehow > somewhere in the kernel sets-up those mappings and it has to be related > to this patch, in which case I wonder why we enable the PAXC steering at > all given that this (hack) can be done through the IOMMU (and I assume > that on all PAXC platforms that do need MSIs there is an IOMMU IP > upstream the root bridge, otherwise I have no idea what will happen to > those MSI writes). If it's only rewriting memory attributes (FWIW it sounds like this thing is comparable to the AXI translation table of the PLDA root complex we have in Juno), then if the IOMMU is controlled by Linux the PAXC shouldn't be needed anyway. In that situation the GICv2m/ITS doorbell will be already mapped for the endpoint as device memory (and usually at some arbitrary address that the PAXC won't recognise anyway) - see iommu_dma_get_msi_page(). If Linux *doesn't* know about the IOMMU, then the firmware should be free to set it up with a static 1:1 mapping of the PA space and leave it that way, provided Linux can't inadvertently stomp on those page tables later. Robin.