From patchwork Mon Oct 9 10:29:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 9992595 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E829D60223 for ; Mon, 9 Oct 2017 10:29:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D84C520855 for ; Mon, 9 Oct 2017 10:29:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CC17022701; Mon, 9 Oct 2017 10:29:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2C8F820855 for ; Mon, 9 Oct 2017 10:29:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751834AbdJIK3l (ORCPT ); Mon, 9 Oct 2017 06:29:41 -0400 Received: from mail-qk0-f194.google.com ([209.85.220.194]:34477 "EHLO mail-qk0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751693AbdJIK3k (ORCPT ); Mon, 9 Oct 2017 06:29:40 -0400 Received: by mail-qk0-f194.google.com with SMTP id o187so3059522qke.1; Mon, 09 Oct 2017 03:29:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=h/Zuc8S3HuzqG+yDYNNgw0SCb59Yav1J4qRGCOdxQQo=; b=rf6IAdCCCgUaz+2KLPnTtvEIigaPBgLCVqsWsZpaH3iDIfC4pOv2cnjvW4g1cWI46p 3GG80mWBhJp9A9mfSF9Q9YJByXZdGZmRLDnD3IZnTcZF6FolIegNBI7+DboI3XlpNwMo x8IjsjyyriJGl3Vyr2TfY3k0cW8njokNr8nBgRmvCF82Vgb0HL3n6IS4nWHhDXHVIeUg dzXniIDdGj3LFFuo2g3Ev93zxtqirmJ/2QekPQiRhoV3M/vd0VFP2Kgw1uJOqQ7+C3sv 2YnAfepKOCIe1Z56RHpCttTu0QXHgnS2NYV0ElJ3KKckKOP4ARC+1eJkuRgd8hyK7miW UHYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=h/Zuc8S3HuzqG+yDYNNgw0SCb59Yav1J4qRGCOdxQQo=; b=XHDN1TBno8v3t9o3WOT9jqUet71/dqHQQrIxAx3UihSNjQndC26qr4+xCZL6YgMvff PRACQQENJ7HIqCCe9qPwg1gSoezmhAyM6DTKmjhVuDgsRd5YSEV1hokIn82rzQtzKW/x oIy5lX0pCc8TfESup5C/UiBAMnylkjI5copGqsi1D6s8EsPAwBxGQFNl9ExJgA/8xSCS tNGRYm6QuJch2GWnw+ms2xbN14Ym2UuQNiUyWkpXA69B8B3AIJTFnqNzae/5qeMlCNtK nCyb/thoMAxkIt22gvQ2lXnBooBLqVy2AVwiNEewoQzrFvgbjYw15oCM5woNdEresuyI 89+w== X-Gm-Message-State: AMCzsaUWF6/id4JnBHyRlhHHXNJoQ2IPa4UtfMg+fPKogB3hi8kRYmBE fSBfFWfVeO3E9+SDzgj6HOo= X-Google-Smtp-Source: AOwi7QCIuyJS+usHQQSL0hKGrx0sF1fxmgOrTbcx8Xr9Xn2IdutUP7JwnABxflTMVqFsLho6dDD0tw== X-Received: by 10.55.164.215 with SMTP id n206mr8198786qke.85.1507544979209; Mon, 09 Oct 2017 03:29:39 -0700 (PDT) Received: from localhost (p200300E41BE4FD00CEAD5B94E1CFD280.dip0.t-ipconnect.de. [2003:e4:1be4:fd00:cead:5b94:e1cf:d280]) by smtp.gmail.com with ESMTPSA id b37sm4792698qkb.19.2017.10.09.03.29.38 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 09 Oct 2017 03:29:38 -0700 (PDT) From: Thierry Reding To: Bjorn Helgaas Cc: Jonathan Hunter , Vidya Sagar , Erik Faye-Lund , Tomasz Maciej Nowak , linux-pci@vger.kernel.org, linux-tegra@vger.kernel.org Subject: [PATCH] Revert "PCI: tegra: Do not allocate MSI target memory" Date: Mon, 9 Oct 2017 12:29:35 +0200 Message-Id: <20171009102935.14515-1-thierry.reding@gmail.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171002201924.GC5407@bhelgaas-glaptop.roam.corp.google.com> References: <20171002201924.GC5407@bhelgaas-glaptop.roam.corp.google.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Thierry Reding This reverts commit d7bd554f27c942e6b8b54100b4044f9be1038edf. It turns out that Tegra20 has a bug in the implementation of the MSI target address register (which is worked around by the existence of the struct tegra_pcie_soc.msi_base_shift parameter) that restricts the MSI target memory to the lower 32 bits of physical memory on that particular generation. The offending patch causes a regression on TrimSlice, which is a Tegra20-based device and has a PCI network interface card. An initial, simpler fix was to change the MSI target address for Tegra20 only, but it was pointed out that the offending commit also prevents the use of 32-bit only MSI capable devices, even on later chips. Technically this was never guaranteed to work with the prior code in the first place because the allocated page could have resided beyond the 4 GiB boundary, but it is still possible that this could've introduced a regression. The proper fix that was settled on is to select a fixed address within the lowest 32 bits of physical address space that is otherwise unused, but testing of that patch has provided mixed results that are not fully understood yet. Given all of the above and the relative urgency to get this fixed in v4.13, revert the offending commit until a universal fix is found. Cc: stable@vger.kernel.org # 4.13.x Reported-by: Tomasz Maciej Nowak Reported-by: Erik Faye-Lund Signed-off-by: Thierry Reding --- drivers/pci/host/pci-tegra.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/drivers/pci/host/pci-tegra.c b/drivers/pci/host/pci-tegra.c index 9c40da54f88a..1987fec1f126 100644 --- a/drivers/pci/host/pci-tegra.c +++ b/drivers/pci/host/pci-tegra.c @@ -233,6 +233,7 @@ struct tegra_msi { struct msi_controller chip; DECLARE_BITMAP(used, INT_PCI_MSI_NR); struct irq_domain *domain; + unsigned long pages; struct mutex lock; u64 phys; int irq; @@ -1529,22 +1530,9 @@ static int tegra_pcie_enable_msi(struct tegra_pcie *pcie) goto err; } - /* - * The PCI host bridge on Tegra contains some logic that intercepts - * MSI writes, which means that the MSI target address doesn't have - * to point to actual physical memory. Rather than allocating one 4 - * KiB page of system memory that's never used, we can simply pick - * an arbitrary address within an area reserved for system memory - * in the FPCI address map. - * - * However, in order to avoid confusion, we pick an address that - * doesn't map to physical memory. The FPCI address map reserves a - * 1012 GiB region for system memory and memory-mapped I/O. Since - * none of the Tegra SoCs that contain this PCI host bridge can - * address more than 16 GiB of system memory, the last 4 KiB of - * these 1012 GiB is a good candidate. - */ - msi->phys = 0xfcfffff000; + /* setup AFI/FPCI range */ + msi->pages = __get_free_pages(GFP_KERNEL, 0); + msi->phys = virt_to_phys((void *)msi->pages); afi_writel(pcie, msi->phys >> soc->msi_base_shift, AFI_MSI_FPCI_BAR_ST); afi_writel(pcie, msi->phys, AFI_MSI_AXI_BAR_ST); @@ -1596,6 +1584,8 @@ static int tegra_pcie_disable_msi(struct tegra_pcie *pcie) afi_writel(pcie, 0, AFI_MSI_EN_VEC6); afi_writel(pcie, 0, AFI_MSI_EN_VEC7); + free_pages(msi->pages, 0); + if (msi->irq > 0) free_irq(msi->irq, pcie);