From patchwork Mon Oct 27 13:22:07 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: wangyijing X-Patchwork-Id: 39614 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f69.google.com (mail-ee0-f69.google.com [74.125.83.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id DA8AC2118A for ; Mon, 27 Oct 2014 12:42:22 +0000 (UTC) Received: by mail-ee0-f69.google.com with SMTP id c13sf1214032eek.4 for ; Mon, 27 Oct 2014 05:42:22 -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=Wi6mYDBEy2x3d6rT7FtJ+EGPVxETF4CMMBk4nvgJJZk=; b=IxKpPlWgp8u9gQ3BOsvg3+DJ+uFMucY7i2NyCsXbVD9F1ZjlAPK9C0NN7OqAKijFjf tPR33lXe/ZyFf888asfYv3tqjYkhSF3b5LcIkbbVcIkAYc8Ff1iBWaDhU28bcgz4KA2p Wz14DfXxGZtWcmC8n3nBwnYcfeCwBg7fidY2KeYkVflIidlqDngFYPeJEXMzr85pHzmq hxaYoWCTslc9y1m3aEXSw9f0+OsfMDMOy3yK1aP/NAs4u3XP78+IVV42P7IXVbT10JLG vCvRI+mVtXCJoQG80WVxmNInBqW2UNM/BxjmbHdw/xp8X++QX9Qe/FLQxkjoYb2pyQDs VLRg== X-Gm-Message-State: ALoCoQmnt1RrY4y1hNu0LkgzeIxIG0FIDO+Ixx/7hZtgtB2jtppncTc6kLS19zqoN7f0oQKaQxe9 X-Received: by 10.180.19.198 with SMTP id h6mr3844561wie.5.1414413742061; Mon, 27 Oct 2014 05:42:22 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.20.42 with SMTP id k10ls649857lae.66.gmail; Mon, 27 Oct 2014 05:42:21 -0700 (PDT) X-Received: by 10.152.203.231 with SMTP id kt7mr9347725lac.84.1414413741872; Mon, 27 Oct 2014 05:42:21 -0700 (PDT) Received: from mail-la0-f46.google.com (mail-la0-f46.google.com. [209.85.215.46]) by mx.google.com with ESMTPS id i9si19718903lag.115.2014.10.27.05.42.21 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 27 Oct 2014 05:42:21 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) client-ip=209.85.215.46; Received: by mail-la0-f46.google.com with SMTP id gi9so5838450lab.33 for ; Mon, 27 Oct 2014 05:42:21 -0700 (PDT) X-Received: by 10.152.116.102 with SMTP id jv6mr23506568lab.40.1414413741626; Mon, 27 Oct 2014 05:42:21 -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.112.84.229 with SMTP id c5csp281679lbz; Mon, 27 Oct 2014 05:42:20 -0700 (PDT) X-Received: by 10.70.96.227 with SMTP id dv3mr20213365pdb.119.1414413740012; Mon, 27 Oct 2014 05:42:20 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id nk11si10362303pdb.213.2014.10.27.05.42.19 for ; Mon, 27 Oct 2014 05:42:20 -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 S1753063AbaJ0MmH (ORCPT + 26 others); Mon, 27 Oct 2014 08:42:07 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:28071 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752570AbaJ0Mlm (ORCPT ); Mon, 27 Oct 2014 08:41:42 -0400 Received: from 172.24.2.119 (EHLO szxeml404-hub.china.huawei.com) ([172.24.2.119]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id CBJ49231; Mon, 27 Oct 2014 20:41:29 +0800 (CST) Received: from localhost.localdomain (10.175.100.166) by szxeml404-hub.china.huawei.com (10.82.67.59) with Microsoft SMTP Server id 14.3.158.1; Mon, 27 Oct 2014 20:41:15 +0800 From: Yijing Wang To: Bjorn Helgaas CC: , , Xinwei Hu , Wuyun , , Russell King , , Thomas Gleixner , Konrad Rzeszutek Wilk , , Joerg Roedel , , , "Benjamin Herrenschmidt" , , , Sebastian Ott , "Tony Luck" , , "David S. Miller" , , Chris Metcalf , Ralf Baechle , Lucas Stach , David Vrabel , "Sergei Shtylyov" , Michael Ellerman , Thierry Reding , "Thomas Petazzoni" , Yijing Wang Subject: [PATCH 01/16] PCI/MSI: Refactor MSI controller to make it become more common Date: Mon, 27 Oct 2014 21:22:07 +0800 Message-ID: <1414416142-31239-2-git-send-email-wangyijing@huawei.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1414416142-31239-1-git-send-email-wangyijing@huawei.com> References: <1414416142-31239-1-git-send-email-wangyijing@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.100.166] X-CFilter-Loop: Reflected 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.215.46 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: , Now there are a lot of weak arch MSI functions in MSI code. These functions make MSI driver complex. Because people need to know much which arch MSI function should be overrode and which is not. Thierry introduced MSI chip framework to configure MSI/MSI-X irq in arm. MSI chip framework is better than raw arch MSI functions, people can clearly know they should implement which MSI ops in specific platform. Use MSI chip framework to refactor all other platform MSI code to eliminate weak arch MSI functions. This patch add .restore_irqs(), .teardown_irqs() and .setup_irqs() to make it become more common. Signed-off-by: Yijing Wang Reviewed-by: Lucas Stach --- drivers/pci/msi.c | 15 +++++++++++++++ include/linux/msi.h | 8 ++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c index 27b6a54..0e1da3e 100644 --- a/drivers/pci/msi.c +++ b/drivers/pci/msi.c @@ -70,6 +70,11 @@ int __weak arch_setup_msi_irqs(struct pci_dev *dev, int nvec, int type) { struct msi_desc *entry; int ret; + struct msi_controller *ctrl; + + ctrl = pci_msi_controller(dev->bus); + if (ctrl && ctrl->setup_irqs) + return ctrl->setup_irqs(ctrl, dev, nvec, type); /* * If an architecture wants to support multiple MSI, it needs to @@ -112,6 +117,11 @@ void default_teardown_msi_irqs(struct pci_dev *dev) void __weak arch_teardown_msi_irqs(struct pci_dev *dev) { + struct msi_controller *ctrl = pci_msi_controller(dev->bus); + + if (ctrl && ctrl->teardown_irqs) + return ctrl->teardown_irqs(ctrl, dev); + return default_teardown_msi_irqs(dev); } @@ -135,6 +145,11 @@ static void default_restore_msi_irq(struct pci_dev *dev, int irq) void __weak arch_restore_msi_irqs(struct pci_dev *dev) { + struct msi_controller *ctrl = pci_msi_controller(dev->bus); + + if (ctrl && ctrl->restore_irqs) + return ctrl->restore_irqs(ctrl, dev); + return default_restore_msi_irqs(dev); } diff --git a/include/linux/msi.h b/include/linux/msi.h index 6704991..4426cb4 100644 --- a/include/linux/msi.h +++ b/include/linux/msi.h @@ -71,9 +71,13 @@ struct msi_controller { struct device_node *of_node; struct list_head list; - int (*setup_irq)(struct msi_controller *chip, struct pci_dev *dev, + int (*setup_irq)(struct msi_controller *ctrl, struct pci_dev *dev, struct msi_desc *desc); - void (*teardown_irq)(struct msi_controller *chip, unsigned int irq); + int (*setup_irqs)(struct msi_controller *ctrl, struct pci_dev *dev, + int nvec, int type); + void (*teardown_irq)(struct msi_controller *ctrl, unsigned int irq); + void (*teardown_irqs)(struct msi_controller *ctrl, struct pci_dev *dev); + void (*restore_irqs)(struct msi_controller *ctrl, struct pci_dev *dev); }; #endif /* LINUX_MSI_H */