From patchwork Fri Nov 20 09:49:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marc Zyngier X-Patchwork-Id: 7666231 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: X-Original-To: patchwork-linux-sh@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 26064BF90C for ; Fri, 20 Nov 2015 09:49:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1F2972045E for ; Fri, 20 Nov 2015 09:49:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2122920443 for ; Fri, 20 Nov 2015 09:49:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1162374AbbKTJtg (ORCPT ); Fri, 20 Nov 2015 04:49:36 -0500 Received: from foss.arm.com ([217.140.101.70]:44746 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1162376AbbKTJte (ORCPT ); Fri, 20 Nov 2015 04:49:34 -0500 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 A78F749; Fri, 20 Nov 2015 01:49:17 -0800 (PST) Received: from [10.1.209.125] (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A990E3F267; Fri, 20 Nov 2015 01:49:31 -0800 (PST) Message-ID: <564EECA9.9070400@arm.com> Date: Fri, 20 Nov 2015 09:49:29 +0000 From: Marc Zyngier Organization: ARM Ltd User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Icedove/31.7.0 MIME-Version: 1.0 To: Phil Edworthy CC: Thierry Reding , Bjorn Helgaas , Wolfram Sang , Geert Uytterhoeven , Simon Horman , "linux-pci@vger.kernel.org" , "linux-sh@vger.kernel.org" , "linux-kernel@vger.kernel.org" , Ley Foon Tan , Jingoo Han Subject: Re: [PATCH] PCI: pcie-rcar: Fix OF node passed to MSI irq domain References: <1446542899-25137-1-git-send-email-phil.edworthy@renesas.com> <20151109161115.GA13870@ulmo.nvidia.com> <20151110155232.GA25368@ulmo.nvidia.com> <20151111163802.3a96080c@arm.com> <20151112203100.2e91da2a@arm.com> <564A2101.90600@arm.com> In-Reply-To: Sender: linux-sh-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sh@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On 18/11/15 18:01, Phil Edworthy wrote: > Hi Marc, > > On 16 November 2015 18:31, Marc Zyngier wrote: >> On 13/11/15 09:36, Phil Edworthy wrote: > >>> Since the stack trace doesn't help that much I added some tracing: >>> pci_msi_setup_msi_irqs() >>> calls pci_msi_get_domain() >>> calls dev_get_msi_domain(), gets a non-NULL domain. >>> pci_msi_setup_msi_irqs() >>> calls pci_msi_domain_alloc_irqs() >>> calls msi_domain_alloc_irqs() >>> msi_domain_alloc_irqs:273: ops=ffffffc03193a810 >>> msi_domain_alloc_irqs:274: ops->msi_check=ffffffc031161418 >>> systemd-udevd[1311]: undefined instruction: pc=ffffffc03116141c >>> That looks to me as though msi_check is off pointing to the weeds. >> >> So the next step is to find out who initializes msi_check. Assuming >> someone does... > Nothing initializes msi_check... > > >>> By passing a NULL domain into irq_domain_add_linear() you get: >>> pci_msi_setup_msi_irqs() >>> calls pci_msi_get_domain() >>> calls dev_get_msi_domain(), gets a NULL domain. >>> calls arch_setup_msi_irq() >>> All ok then. >> >> Yes, because you're sidestepping the issue. Any chance you could dig a >> bit deeper? I'd really like to nail this one down (before we convert >> your PCI driver to the right API... ;-). > The problem appears to be that when the pci host driver enables msi > it calls the following: > msi->domain = irq_domain_add_linear(pcie->dev->of_node, INT_PCI_MSI_NR, > &msi_domain_ops, &msi->chip); > The last arg is documented as: > * @host_data: Controller private data pointer > In _irq_domain_add() this ptr is stored in struct irq_domain's host_data. > > However, msi_domain_alloc_irqs() expects host_data to be a ptr to a > struct msi_domain_info. > > It seems that a number of other pci host drivers do the same, so I am > surprised that no one else has seen this. Can you please give this hack a go and let me know if that helps? Thanks, M. diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c index 53e4632..7eaa4c8 100644 --- a/drivers/pci/msi.c +++ b/drivers/pci/msi.c @@ -54,7 +54,7 @@ static int pci_msi_setup_msi_irqs(struct pci_dev *dev, int nvec, int type) struct irq_domain *domain; domain = pci_msi_get_domain(dev); - if (domain) + if (domain && irq_domain_is_hierarchy(domain)) return pci_msi_domain_alloc_irqs(domain, dev, nvec, type); return arch_setup_msi_irqs(dev, nvec, type); @@ -65,7 +65,7 @@ static void pci_msi_teardown_msi_irqs(struct pci_dev *dev) struct irq_domain *domain; domain = pci_msi_get_domain(dev); - if (domain) + if (domain && irq_domain_is_hierarchy(domain)) pci_msi_domain_free_irqs(domain, dev); else arch_teardown_msi_irqs(dev);