Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp4088518ybg; Mon, 21 Oct 2019 03:39:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqyyMyTpdogKa/girYmb/OWDK1Ncua6EUwH65oMuLwnF2+GgWlBwqKYnKKMD9FlLFfsv0IxC X-Received: by 2002:a50:ee8f:: with SMTP id f15mr24216538edr.127.1571654352641; Mon, 21 Oct 2019 03:39:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571654352; cv=none; d=google.com; s=arc-20160816; b=tZHJfWLT2ORBef+iyu1VfUaAf/v6HwTJ0eg6w0acNif2wNlzdoCKg6nGEa8GrbTADR ltFjKnw5za2CaJtooUHU8rp/FyVCsuFkbrHIGIH9tVySBDsfsO5xzeuoTvW6Onlz0NWU zj+8M2O3UFlNj8BHnJFt+06MHP+bfoL+Hw18fST7zj8tHsqIy9yVnqB+2y3v0WiS73UI GnVAc9+txH4EE9o6N3SFZcczZ1UQs+jzUbF/0Ku2Y20wwfI38b6NGDL+hTwhyhSD+0Uv 603gECL9ZV3YuzuB0yxcyg3WT7gc6r0qfYFohMTcs5Xa4t31keR9tCU92zUAgY/v9BuD mfWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=IYfcWUunDoxQ73gmSI9PJGt367SUa74OpKe6u+/RLMQ=; b=Sg5Me7zQFUT0rDbpaNE1H51631dz4gh9yC7vN1ikm/pwgyyjkDu79j9pfTiGeqPSHd Mo/zB+zrDAI6xEPD1jigFn62NnveX/jDR7dQNpc7w+1gKkrWWzW22eNcOkZhzs/C5Vzz NZAHSkTextk5iNc1vssXN3GfnJzbxbk65TWWqDvKRkFvuxPR+F02nDkDyHlFmJ7Qt7aH lpFGGu/8VN1ozkv8UJqjrM+E5DcB+VT4y1CXTrzR0InyVEgO4CJMGNG8lJRD3tulaA60 a5+goM3857o5DDIfqpMRfMDDAJgcVk54azrCyr0nPoms2KizKL4qbA+04SNFOVc5xlAV XZkg== 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 p20si1177805ejj.394.2019.10.21.03.38.49; Mon, 21 Oct 2019 03:39:12 -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 S1728245AbfJUKip (ORCPT + 99 others); Mon, 21 Oct 2019 06:38:45 -0400 Received: from [217.140.110.172] ([217.140.110.172]:48602 "EHLO foss.arm.com" rhost-flags-FAIL-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1727987AbfJUKio (ORCPT ); Mon, 21 Oct 2019 06:38:44 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8C95CEBD; Mon, 21 Oct 2019 03:38:15 -0700 (PDT) Received: from e121166-lin.cambridge.arm.com (e121166-lin.cambridge.arm.com [10.1.196.255]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 6DE2B3F718; Mon, 21 Oct 2019 03:38:14 -0700 (PDT) Date: Mon, 21 Oct 2019 11:38:08 +0100 From: Lorenzo Pieralisi To: Abhishek Shah Cc: Bjorn Helgaas , Ray Jui , Scott Branden , linux-pci@vger.kernel.org, linux-arm-kernel , open list , BCM Kernel Feedback Subject: Re: [PATCH 1/1] PCI: iproc: Invalidate PAXB address mapping before programming it Message-ID: <20191021103808.GA29528@e121166-lin.cambridge.arm.com> References: <20190906035813.24046-1-abhishek.shah@broadcom.com> <20191015164303.GC25674@e121166-lin.cambridge.arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 17, 2019 at 07:57:56PM +0530, Abhishek Shah wrote: > Hi Lorenzo, > > Please see my comments inline: > > On Tue, Oct 15, 2019 at 10:13 PM Lorenzo Pieralisi > wrote: > > > > On Fri, Sep 06, 2019 at 09:28:13AM +0530, Abhishek Shah wrote: > > > Invalidate PAXB inbound/outbound address mapping each time before > > > programming it. This is helpful for the cases where we need to > > > reprogram inbound/outbound address mapping without resetting PAXB. > > > kexec kernel is one such example. > > > > This looks like a hack, explain to us please what it actually solves and > > why a full reset is not necessary. > > > The PAXB IP performs address translation(PCI<->AXI address) for both inbound and > outbound addresses (amongst other things) based on version of IP being used. > It does so using the IMAP/IARR/OMAP/OARR registers. > > These registers get programmed as per mappings specified in device tree during > PCI driver probe for each RC and do not get reset when kexec/kdump kernel boots. > This results in driver assuming valid mappings in place for some mapping windows > during kexec/kdump kernel boot, consequently it skips those windows and > we run out of available mapping windows, leading to mapping failure. > > Normally, we take care of resetting PAXB block in firmware, but in > primary kernel to kexec/kdump kernel handover, no firmware is executed > in between. So, we just, by default, invalidate the mapping registers > each time before > programming them to solve the issue described above.. > We do not need full reset for handling this. I see. A simple bitmap to detect which windows are *actually* programmed by the current kernel (that can be used by iproc_pcie_ob_is_valid() to carry out a valid check) would do as well instead of having to invalidate all the OB registers. It is up to you, let me know and I will merge code accordingly. Lorenzo > > > Signed-off-by: Abhishek Shah > > > Reviewed-by: Ray Jui > > > Reviewed-by: Vikram Mysore Prakash > > > > Patches are reviewed on public mailing lists, remove tags given > > on internal reviews - they are not relevant. > > > Ok, will remove. > > > > --- > > > drivers/pci/controller/pcie-iproc.c | 28 ++++++++++++++++++++++++++++ > > > 1 file changed, 28 insertions(+) > > > > > > diff --git a/drivers/pci/controller/pcie-iproc.c b/drivers/pci/controller/pcie-iproc.c > > > index e3ca46497470..99a9521ba7ab 100644 > > > --- a/drivers/pci/controller/pcie-iproc.c > > > +++ b/drivers/pci/controller/pcie-iproc.c > > > @@ -1245,6 +1245,32 @@ static int iproc_pcie_map_dma_ranges(struct iproc_pcie *pcie) > > > return ret; > > > } > > > > > > +static void iproc_pcie_invalidate_mapping(struct iproc_pcie *pcie) > > > +{ > > > + struct iproc_pcie_ib *ib = &pcie->ib; > > > + struct iproc_pcie_ob *ob = &pcie->ob; > > > + int idx; > > > + > > > + if (pcie->ep_is_internal) > > > > What's this check for and why leaving mappings in place is safe for > > this category of IPs ? > For this category of IP(PAXC), no mappings need to be programmed in > the first place. > > > > > > + return; > > > + > > > + if (pcie->need_ob_cfg) { > > > + /* iterate through all OARR mapping regions */ > > > + for (idx = ob->nr_windows - 1; idx >= 0; idx--) { > > > + iproc_pcie_write_reg(pcie, > > > + MAP_REG(IPROC_PCIE_OARR0, idx), 0); > > > + } > > > + } > > > + > > > + if (pcie->need_ib_cfg) { > > > + /* iterate through all IARR mapping regions */ > > > + for (idx = 0; idx < ib->nr_regions; idx++) { > > > + iproc_pcie_write_reg(pcie, > > > + MAP_REG(IPROC_PCIE_IARR0, idx), 0); > > > + } > > > + } > > > +} > > > + > > > static int iproce_pcie_get_msi(struct iproc_pcie *pcie, > > > struct device_node *msi_node, > > > u64 *msi_addr) > > > @@ -1517,6 +1543,8 @@ int iproc_pcie_setup(struct iproc_pcie *pcie, struct list_head *res) > > > iproc_pcie_perst_ctrl(pcie, true); > > > iproc_pcie_perst_ctrl(pcie, false); > > > > > > + iproc_pcie_invalidate_mapping(pcie); > > > > It makes more sense to call this in the .shutdown() method if I > > understand what it does. > > > It would work for kexec kernel, but not for kdump kernel as only for > kexec'ed kernel, > "device_shutdown" callback is present. We are here taking care of both the cases > with this patch. > > > Regards, > Abhishek > > > Lorenzo > > > > > if (pcie->need_ob_cfg) { > > > ret = iproc_pcie_map_ranges(pcie, res); > > > if (ret) { > > > -- > > > 2.17.1 > > >