Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp596612imu; Thu, 13 Dec 2018 00:47:26 -0800 (PST) X-Google-Smtp-Source: AFSGD/XzPXglfKhoBpsuAnt/0b0btm+DHxev+ZN8wuLZSM9EUPuQdVsFRsRJNbXMEp2pZj6vzVP0 X-Received: by 2002:a17:902:7107:: with SMTP id a7mr22782070pll.290.1544690846898; Thu, 13 Dec 2018 00:47:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544690846; cv=none; d=google.com; s=arc-20160816; b=ufshpTH5XTDvQiao/lZOJQH83z16nxcn5LdmfUrnLx7yNmg33/F/nNEvl4TpaoD9OL 0yMMibIzvDPc3ybfZJZvCYMvTK9tjov4Jkm6pwTH4lSyVk+tH9gdXHKsts/9++U1Jr13 +4h4DZwWLup+BXS3CihMEOuHpoH4NNG/pGMkI5onawGe+TUKx8fH4hMk8IzQFUhVshRE oSQi7Xc97UZU/Ae8HSS9vXn0UaKTZ78xJAFIxE29LxwuRgkLelrXvezwopKU8taizTI/ cejuc65Y94K8vgqhjubM1gophrY2A4M7Cj4wUXB1iddZmvZ6W0jhVFTjPY5FAZj3Zopi eh8A== 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:mime-version :message-id:date:in-reply-to:subject:cc:to:from:user-agent :references; bh=oWiBREWiV0bGWDlQoGAaMOj5fVPbckCzdRG2RAuyIzc=; b=RsPHSyvnJAnX2yPddXPvmZczYRhtgA5HuvJuwWnI0k+9gss/I5QX1qm7TBznNOvy9i iFqu18UUE7b5FqkPO8+zlX4CZtEXIfX6P73IlyPe4as78ZNsbrn+a9tgpjJ1Aqeq2kEt dBkciaHoKJTPWvcw5Ir90GFWrHuXSQPDxephf6ZCyqNW2iwm7k2vPpIxiqLexENN9+3y qvsB8BMUfmvYl4BmJLBSE5h7sAu7WR01WNbq2AWTkYo8Katgzoh6OhqdiSgxvEXCM7rH 4sPBEyOrksEruGGQ0rQVIAvh8nELVmQDETYQJCqFP8rqVICUwtJ9yqFfi8tFzRw5/dEU Tisg== 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 p64si1118052pfg.79.2018.12.13.00.47.11; Thu, 13 Dec 2018 00:47:26 -0800 (PST) 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 S1727276AbeLMIqU (ORCPT + 99 others); Thu, 13 Dec 2018 03:46:20 -0500 Received: from guitar.tcltek.co.il ([192.115.133.116]:50431 "EHLO mx.tkos.co.il" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725949AbeLMIqU (ORCPT ); Thu, 13 Dec 2018 03:46:20 -0500 Received: from tarshish (unknown [10.0.8.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx.tkos.co.il (Postfix) with ESMTPS id C4DD044083B; Thu, 13 Dec 2018 10:46:17 +0200 (IST) References: <1544687042-16595-1-git-send-email-hongxing.zhu@nxp.com> <87zht96e15.fsf@tkos.co.il> User-agent: mu4e 1.0; emacs 25.2.2 From: Baruch Siach To: Richard Zhu Cc: "bhelgaas\@google.com" , "lorenzo.pieralisi\@arm.com" , "l.stach\@pengutronix.de" , "andrew.smirnov\@gmail.com" , "linux-pci\@vger.kernel.org" , "linux-kernel\@vger.kernel.org" , "linux-arm-kernel\@lists.infradead.org" Subject: Re: [v2] PCI: imx: make msi work without pcieportbus In-reply-to: Date: Thu, 13 Dec 2018 10:46:17 +0200 Message-ID: <87y38t6ch2.fsf@tkos.co.il> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Richard, Richard Zhu writes: >> -----Original Message----- >> From: Baruch Siach [mailto:baruch@tkos.co.il] >> Sent: 2018年12月13日 16:13 >> To: Richard Zhu >> Cc: bhelgaas@google.com; lorenzo.pieralisi@arm.com; >> l.stach@pengutronix.de; andrew.smirnov@gmail.com; >> linux-pci@vger.kernel.org; linux-kernel@vger.kernel.org; >> linux-arm-kernel@lists.infradead.org >> Subject: Re: [v2] PCI: imx: make msi work without pcieportbus >> >> Richard Zhu writes: >> > MSI_EN of iMX PCIe RC would be asserted when PCIEPORTBUS driver is >> > selected. >> > Thus, the MSI works fine on iMX PCIe before. >> > Assert it unconditionally when MSI is supported. >> > Otherwise, the MSI wouldn't be triggered although the EP is present >> > and the MSIs are assigned. >> > >> > Signed-off-by: Richard Zhu >> > --- >> > drivers/pci/controller/dwc/pci-imx6.c | 7 +++++++ >> > 1 file changed, 7 insertions(+) >> > >> > diff --git a/drivers/pci/controller/dwc/pci-imx6.c >> > b/drivers/pci/controller/dwc/pci-imx6.c >> > index 26087b3..d3e4296 100644 >> > --- a/drivers/pci/controller/dwc/pci-imx6.c >> > +++ b/drivers/pci/controller/dwc/pci-imx6.c >> > @@ -74,6 +74,7 @@ struct imx6_pcie { >> > #define PHY_PLL_LOCK_WAIT_USLEEP_MAX 200 >> > >> > /* PCIe Root Complex registers (memory-mapped) */ >> > +#define PCI_MSI_CAP 0x50 >> > #define PCIE_RC_LCR 0x7c >> > #define PCIE_RC_LCR_MAX_LINK_SPEEDS_GEN1 0x1 >> > #define PCIE_RC_LCR_MAX_LINK_SPEEDS_GEN2 0x2 >> > @@ -926,6 +927,7 @@ static int imx6_pcie_probe(struct platform_device >> *pdev) >> > struct resource *dbi_base; >> > struct device_node *node = dev->of_node; >> > int ret; >> > + u16 val; >> > >> > imx6_pcie = devm_kzalloc(dev, sizeof(*imx6_pcie), GFP_KERNEL); >> > if (!imx6_pcie) >> > @@ -1070,6 +1072,11 @@ static int imx6_pcie_probe(struct >> platform_device *pdev) >> > ret = imx6_add_pcie_port(imx6_pcie, pdev); >> > if (ret < 0) >> > return ret; >> > + if (IS_ENABLED(CONFIG_PCI_MSI)) { >> >> CONFIG_PCI_IMX6 depends on CONFIG_PCI_MSI_IRQ_DOMAIN that in turn >> depends on CONFIG_PCI_MSI. So this condition should always be true. If so, >> you can drop this one as well. > [Richard Zhu] Thanks. > Can we have the double check here? > Thus, it's aligned to the MSI enable codes in the other place of the driver. > For example: > ... > if (IS_ENABLED(CONFIG_PCI_MSI)) > dw_pcie_msi_init(pp); > ... > Secondly, the driver has a better portability with the double check here. > How do you think about it? Kernel driver are not meant to be "portable" as far as I understand. But I'll let the PCI maintainers comment on that. For reference, mainline kernel makes CONFIG_PCI_MSI a hard dependency of pci-imx6 since commit 3ee803641e76 ("PCI/MSI: irqchip: Fix PCI_MSI dependencies") in v4.8. In my opinion, if the driver actually compiles and is usable without CONFIG_PCI_MSI then Kconfig dependencies should reflect that. >> > + val = dw_pcie_readw_dbi(pci, PCI_MSI_CAP + PCI_MSI_FLAGS); >> > + val |= PCI_MSI_FLAGS_ENABLE; >> > + dw_pcie_writew_dbi(pci, PCI_MSI_CAP + PCI_MSI_FLAGS, val); >> > + } >> > >> > return 0; >> > } baruch -- http://baruch.siach.name/blog/ ~. .~ Tk Open Systems =}------------------------------------------------ooO--U--Ooo------------{= - baruch@tkos.co.il - tel: +972.52.368.4656, http://www.tkos.co.il -