Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp5944010ybi; Wed, 12 Jun 2019 11:07:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqwq1VKuip0YxRJS/7n3HKaatwbP78f/maUVPauCLC0jyQM7xXZR2GByP09rHjK+o8JoQjUr X-Received: by 2002:a17:90a:1b4c:: with SMTP id q70mr448754pjq.69.1560362877531; Wed, 12 Jun 2019 11:07:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560362877; cv=none; d=google.com; s=arc-20160816; b=zg6vLWNK1c9YRVJ1UsTOqEmFCp/YXvch14RjrlKva7cHINtLLfENYqgauZKy05KphA HsNZebojt/XUKNnS886+hf7CGPxJyoEvGLqzFforvljjRRro2+MzlFqCk9dQsOKgHNDV n+IB21SqIdNrOGQnpGuffViAodVTtDYDsliUjnoBrGePYfr0P+h2/TDZqTb6ioszDxSi pAZCnM3Vq/Vkn0VEnBCMVb71lraf3OwwmjL8qJByq2NMur8goHfRBW07pUe7HdRrhKxF eBh1twzYcCPUbNrEF20TLCEioQHSi+CTV2oYkOrbprr66ROmDk4++Wjk6BdrrTgR3/HJ 1WjA== 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=qwWo+akHhlZN759UthpDVFhEBLlz80sQdVkMQwf8D3I=; b=xbR/vSSvsnx00VxW2WgjDSHfFMsSpcl1hyuYwzgF7zwXqkffwF2iBtGH7wrkKFxJOV y5rl/Yz76wRiUZqagBZ8cwObWNHRAqLZvADb3wqPdC1XNJibD+fUw7P1NGQBcvDMuG5e Dx9+s6CjltYhJAKgzKTU6nPaQ10Sy0lxRBRjRT1BtKcueDssuMB73pV4leDcnRwZTIHL oZCxAnFLAz2gLVCidZzX+rg3vf2oZhtRE3TtD5HPExyfXPNunsfW+ljafoplCmQZzkpl D0UqzhdCuh3D7biODhKN3Jbd+HDtWJkBG3WVUu4Sk/1UDrq8PiVSM63//61k7KavECGS KNQg== 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 i22si437357pju.59.2019.06.12.11.07.42; Wed, 12 Jun 2019 11:07:57 -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 S2440237AbfFLQXx (ORCPT + 99 others); Wed, 12 Jun 2019 12:23:53 -0400 Received: from foss.arm.com ([217.140.110.172]:56684 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2440150AbfFLQXx (ORCPT ); Wed, 12 Jun 2019 12:23:53 -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 F33442B; Wed, 12 Jun 2019 09:23:51 -0700 (PDT) Received: from redmoon (unknown [10.1.196.255]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id EEDCC3F73C; Wed, 12 Jun 2019 09:23:49 -0700 (PDT) Date: Wed, 12 Jun 2019 17:23:47 +0100 From: Lorenzo Pieralisi To: "Z.q. Hou" , "bhelgaas@google.com" Cc: "linux-pci@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "devicetree@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "robh+dt@kernel.org" , "mark.rutland@arm.com" , "l.subrahmanya@mobiveil.co.in" , "shawnguo@kernel.org" , Leo Li , "catalin.marinas@arm.com" , "will.deacon@arm.com" , Mingkai Hu , "M.h. Lian" , Xiaowei Bao Subject: Re: [PATCHv5 18/20] PCI: mobiveil: Disable IB and OB windows set by bootloader Message-ID: <20190612162347.GF15747@redmoon> References: <20190412083635.33626-1-Zhiqiang.Hou@nxp.com> <20190412083635.33626-19-Zhiqiang.Hou@nxp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190412083635.33626-19-Zhiqiang.Hou@nxp.com> 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 Fri, Apr 12, 2019 at 08:37:00AM +0000, Z.q. Hou wrote: > From: Hou Zhiqiang > > Disable all inbound and outbound windows before set up the windows > in kernel, in case transactions match the window set by bootloader. There must be no PCI transactions ongoing at bootloader<->OS handover. The bootloader needs fixing and this patch should be dropped, the host bridge driver assumes the host bridge state is disabled, it will program the bridge apertures from scratch with no ongoing transactions, anything deviating from this behaviour is a bootloader bug and a recipe for disaster. Lorenzo > Signed-off-by: Hou Zhiqiang > Reviewed-by: Minghuan Lian > Reviewed-by: Subrahmanya Lingappa > --- > V5: > - No functionality change. > > drivers/pci/controller/pcie-mobiveil.c | 25 +++++++++++++++++++++++++ > 1 file changed, 25 insertions(+) > > diff --git a/drivers/pci/controller/pcie-mobiveil.c b/drivers/pci/controller/pcie-mobiveil.c > index 8dc87c7a600e..411e9779da12 100644 > --- a/drivers/pci/controller/pcie-mobiveil.c > +++ b/drivers/pci/controller/pcie-mobiveil.c > @@ -565,6 +565,24 @@ static int mobiveil_bringup_link(struct mobiveil_pcie *pcie) > return -ETIMEDOUT; > } > > +static void mobiveil_pcie_disable_ib_win(struct mobiveil_pcie *pcie, int idx) > +{ > + u32 val; > + > + val = csr_readl(pcie, PAB_PEX_AMAP_CTRL(idx)); > + val &= ~(1 << AMAP_CTRL_EN_SHIFT); > + csr_writel(pcie, val, PAB_PEX_AMAP_CTRL(idx)); > +} > + > +static void mobiveil_pcie_disable_ob_win(struct mobiveil_pcie *pcie, int idx) > +{ > + u32 val; > + > + val = csr_readl(pcie, PAB_AXI_AMAP_CTRL(idx)); > + val &= ~(1 << WIN_ENABLE_SHIFT); > + csr_writel(pcie, val, PAB_AXI_AMAP_CTRL(idx)); > +} > + > static void mobiveil_pcie_enable_msi(struct mobiveil_pcie *pcie) > { > phys_addr_t msg_addr = pcie->pcie_reg_base; > @@ -585,6 +603,13 @@ static int mobiveil_host_init(struct mobiveil_pcie *pcie) > { > u32 value, pab_ctrl, type; > struct resource_entry *win; > + int i; > + > + /* Disable all inbound/outbound windows */ > + for (i = 0; i < pcie->apio_wins; i++) > + mobiveil_pcie_disable_ob_win(pcie, i); > + for (i = 0; i < pcie->ppio_wins; i++) > + mobiveil_pcie_disable_ib_win(pcie, i); > > /* setup bus numbers */ > value = csr_readl(pcie, PCI_PRIMARY_BUS); > -- > 2.17.1 >