From patchwork Tue Aug 12 07:25:59 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: wangyijing X-Patchwork-Id: 35224 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f199.google.com (mail-vc0-f199.google.com [209.85.220.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 69C85203C5 for ; Tue, 12 Aug 2014 07:03:24 +0000 (UTC) Received: by mail-vc0-f199.google.com with SMTP id la4sf27790424vcb.2 for ; Tue, 12 Aug 2014 00:03:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe:content-type; bh=VmwDv/HdfrcAdeiv2LtLGOJ4zKfhkEtAVeRa2WGyaxQ=; b=S4i5O6FmRqd04hQ4+E7R8w9DmLbJbUCsEWSqIQdIDxFIw/Zy6c7gJHVVQG8LOa0dp5 v1t211wMNQ+nrYhb94vvnfxnxupkkMfAEpMvvLsGMknOL4Q1ElFCDZ62uhmDyfgzlRn8 qoLQx0OImuqfdEuuSvu5jw6labYlz0Ye9gvacRvvdjx2NWTEwPsgjrZqdsNJFznzGhvG 7j1i90H25l7jCeokinIeRCbwSmzyha5GgRe+ec/vEMS80peq3icYq3Z/Hgn4L7NmFf8s FwN6ovtKedoVRTIIT3QKs7XtHjbvrLEc1q5US+GiRfQvweg8cgFctFTJXg9DXYrYbfu/ h7Gw== X-Gm-Message-State: ALoCoQmqajGBZGtyp1D09mi0Dnh/tqp0KcmJ7U0EzdZcvAuPYG4UOcvEm/zIxHeI5+IZDdw4UJ9Y X-Received: by 10.236.11.80 with SMTP id 56mr16303384yhw.22.1407827004172; Tue, 12 Aug 2014 00:03:24 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.84.47 with SMTP id k44ls4083qgd.73.gmail; Tue, 12 Aug 2014 00:03:24 -0700 (PDT) X-Received: by 10.220.110.77 with SMTP id m13mr2195352vcp.35.1407827004084; Tue, 12 Aug 2014 00:03:24 -0700 (PDT) Received: from mail-vc0-f182.google.com (mail-vc0-f182.google.com [209.85.220.182]) by mx.google.com with ESMTPS id du5si6040704vcb.70.2014.08.12.00.03.24 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 12 Aug 2014 00:03:24 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.182 as permitted sender) client-ip=209.85.220.182; Received: by mail-vc0-f182.google.com with SMTP id hy4so12952282vcb.13 for ; Tue, 12 Aug 2014 00:03:24 -0700 (PDT) X-Received: by 10.221.6.201 with SMTP id ol9mr2165195vcb.2.1407827003992; Tue, 12 Aug 2014 00:03:23 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp224484vcb; Tue, 12 Aug 2014 00:03:23 -0700 (PDT) X-Received: by 10.70.101.201 with SMTP id fi9mr2663782pdb.125.1407827002922; Tue, 12 Aug 2014 00:03:22 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id dh3si11782753pdb.125.2014.08.12.00.03.22 for ; Tue, 12 Aug 2014 00:03:22 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753503AbaHLHDO (ORCPT + 26 others); Tue, 12 Aug 2014 03:03:14 -0400 Received: from szxga03-in.huawei.com ([119.145.14.66]:64829 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753264AbaHLHDI (ORCPT ); Tue, 12 Aug 2014 03:03:08 -0400 Received: from 172.24.2.119 (EHLO szxeml421-hub.china.huawei.com) ([172.24.2.119]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id ASY16058; Tue, 12 Aug 2014 15:02:41 +0800 (CST) Received: from localhost.localdomain (10.175.100.166) by szxeml421-hub.china.huawei.com (10.82.67.160) with Microsoft SMTP Server id 14.3.158.1; Tue, 12 Aug 2014 15:02:32 +0800 From: Yijing Wang To: Bjorn Helgaas CC: , Xinwei Hu , Wuyun , , Marc Zyngier , , Russell King , , , "Arnd Bergmann" , Thomas Gleixner , "H. Peter Anvin" , Konrad Rzeszutek Wilk , , Joerg Roedel , , , "Benjamin Herrenschmidt" , , , Sebastian Ott , "Tony Luck" , , "David S. Miller" , , Chris Metcalf , Yijing Wang Subject: [RFC PATCH 06/20] PCI/MSI: Introduce arch_get_match_msi_chip() to find the match msi_chip Date: Tue, 12 Aug 2014 15:25:59 +0800 Message-ID: <1407828373-24322-7-git-send-email-wangyijing@huawei.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1407828373-24322-1-git-send-email-wangyijing@huawei.com> References: <1407828373-24322-1-git-send-email-wangyijing@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.100.166] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020209.53E9BC13.0072,ss=1,re=0.000,fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2011-05-27 18:58:46 X-Mirapoint-Loop-Id: 72a3d6f8bb94c33bbdaf75d5b1c70beb Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: wangyijing@huawei.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.182 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Introduce __weak arch_get_match_msi_chip() to find the match msi_chip. We prepare to use struct msi_chip to eliminate arch_xxx functions in all platforms. The MSI device and the msi_chip binding is platform specific. For instance, in x86, LAPICs receive all MSI irq, but in arm, PCI device usually deliver their MSI to PCI hostbridge, if more than one msi_chip found in system, DTS file will report the binding between MSI devices and target msi_chip. So we need a platform implemented interface to do that. Signed-off-by: Yijing Wang --- drivers/pci/msi.c | 30 ++++++++++++++++++++++++++---- 1 files changed, 26 insertions(+), 4 deletions(-) diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c index 7b7abe9..feba5dd 100644 --- a/drivers/pci/msi.c +++ b/drivers/pci/msi.c @@ -29,10 +29,22 @@ static int pci_msi_enable = 1; /* Arch hooks */ -int __weak arch_setup_msi_irq(struct pci_dev *dev, struct msi_desc *desc) +struct msi_chip * __weak arch_get_match_msi_chip(struct device *dev) +{ + if (dev_is_pci(dev)) { + struct pci_dev *pdev = to_pci_dev(dev); + struct msi_chip *chip = pdev->bus->msi; + + return chip; + } + + return NULL; +} + +int __weak arch_setup_msi_irq(struct pci_dev *dev, struct msi_desc *desc) { - struct msi_chip *chip = dev->bus->msi; int err; + struct msi_chip *chip = arch_get_match_msi_chip(&dev->dev); if (!chip || !chip->setup_irq) return -EINVAL; @@ -46,7 +58,8 @@ int __weak arch_setup_msi_irq(struct pci_dev *dev, struct msi_desc *desc) void __weak arch_teardown_msi_irq(unsigned int irq) { - struct msi_chip *chip = irq_get_chip_data(irq); + struct msi_desc *entry = irq_get_msi_desc(irq); + struct msi_chip *chip = arch_get_match_msi_chip(&entry->dev->dev); if (!chip || !chip->teardown_irq) return; @@ -56,7 +69,7 @@ void __weak arch_teardown_msi_irq(unsigned int irq) int __weak arch_msi_check_device(struct pci_dev *dev, int nvec, int type) { - struct msi_chip *chip = dev->bus->msi; + struct msi_chip *chip = arch_get_match_msi_chip(&dev->dev); if (!chip || !chip->check_device) return 0; @@ -68,7 +81,12 @@ int __weak arch_setup_msi_irqs(struct pci_dev *dev, int nvec, int type) { struct msi_desc *entry; int ret; + struct msi_chip *chip; + chip = arch_get_match_msi_chip(&dev->dev); + if (chip && chip->setup_irqs) + return chip->setup_irqs(&dev->dev, nvec, type); + /* * If an architecture wants to support multiple MSI, it needs to * override arch_setup_msi_irqs() @@ -133,6 +151,10 @@ static void default_restore_msi_irq(struct pci_dev *dev, int irq) void __weak arch_restore_msi_irqs(struct pci_dev *dev) { + struct msi_chip *chip = arch_get_msi_chip(&dev->dev); + if (chip && chip->restore_irqs) + return chip->restore_irqs(&dev->dev); + return default_restore_msi_irqs(dev); }