From patchwork Sat Jul 26 03:08:42 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: wangyijing X-Patchwork-Id: 34336 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pd0-f197.google.com (mail-pd0-f197.google.com [209.85.192.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 8C388235AB for ; Sat, 26 Jul 2014 02:46:43 +0000 (UTC) Received: by mail-pd0-f197.google.com with SMTP id y10sf32468816pdj.0 for ; Fri, 25 Jul 2014 19:46:42 -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=QmlwYiMA2a21uyil2j/om5aQ1lqb5SNXNxhymdBrt9A=; b=Hc3P5yjtVJSkaozGJDw+fMq66ywo31YgJ6Q+INucDBinsRUNE+a5a+i9gKZ6fSEcBb MnhxP+CTwriZSU+5MPOkTxEUe8PvJCjQ1yZAf+HkuJS2CuXaz2k5LURJdqQFneBZr2vy qgq6cSIEo996SK9OsRPk9d3bcEH/MmotCOXyAJ5tprA3yWNZzXVuCwu2e4OOvbWQByFK OJ7ACJZqqSSp/E3NAG3k0/ox+gYdFVWOQI/o8tK+i6gSS4hEwewRpyIrC8d6uyfz/L+R cQhKrDXCF3RZb3YBMt8fh0pitz9bs9UpG4a1ZDDkVJk1t760CjL+IZY2sFqLa0wnf5rA eG6w== X-Gm-Message-State: ALoCoQmosQuuJrvHxdN6NZUTNbLz/mY58YOx1r9BioVetWdiZM7UOK12ztfJkOhkl45vLcULMeE5 X-Received: by 10.68.107.33 with SMTP id gz1mr9845995pbb.5.1406342802806; Fri, 25 Jul 2014 19:46:42 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.109.36 with SMTP id k33ls1362158qgf.79.gmail; Fri, 25 Jul 2014 19:46:42 -0700 (PDT) X-Received: by 10.140.101.86 with SMTP id t80mr32564432qge.91.1406342802691; Fri, 25 Jul 2014 19:46:42 -0700 (PDT) Received: from mail-qg0-f52.google.com (mail-qg0-f52.google.com [209.85.192.52]) by mx.google.com with ESMTPS id n7si19256415qag.73.2014.07.25.19.46.42 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 25 Jul 2014 19:46:42 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.192.52 as permitted sender) client-ip=209.85.192.52; Received: by mail-qg0-f52.google.com with SMTP id f51so5983462qge.11 for ; Fri, 25 Jul 2014 19:46:42 -0700 (PDT) X-Received: by 10.140.26.149 with SMTP id 21mr32580086qgv.51.1406342802570; Fri, 25 Jul 2014 19:46:42 -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.96.16.166 with SMTP id h6csp70443qdd; Fri, 25 Jul 2014 19:46:42 -0700 (PDT) X-Received: by 10.68.139.194 with SMTP id ra2mr22768783pbb.20.1406342801659; Fri, 25 Jul 2014 19:46:41 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id aa1si10986921pad.55.2014.07.25.19.46.41 for ; Fri, 25 Jul 2014 19:46:41 -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 S1760738AbaGZCoH (ORCPT + 15 others); Fri, 25 Jul 2014 22:44:07 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:6657 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752637AbaGZCnt (ORCPT ); Fri, 25 Jul 2014 22:43:49 -0400 Received: from 172.24.2.119 (EHLO szxeml419-hub.china.huawei.com) ([172.24.2.119]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id BXE25886; Sat, 26 Jul 2014 10:43:42 +0800 (CST) Received: from localhost.localdomain (10.175.100.166) by szxeml419-hub.china.huawei.com (10.82.67.158) with Microsoft SMTP Server id 14.3.158.1; Sat, 26 Jul 2014 10:43:32 +0800 From: Yijing Wang To: CC: Xinwei Hu , Wuyun , "Bjorn Helgaas" , , , "James E.J. Bottomley" , "Marc Zyngier" , , Russell King , , , , Hanjun Guo , Yijing Wang Subject: [RFC PATCH 05/11] PCI/MSI: Move populate_msi_sysfs() out of msi_capability_init() Date: Sat, 26 Jul 2014 11:08:42 +0800 Message-ID: <1406344128-27055-6-git-send-email-wangyijing@huawei.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1406344128-27055-1-git-send-email-wangyijing@huawei.com> References: <1406344128-27055-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.192.52 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: , Because some Non-PCI devices don't need to create sysfs object, so move populate_msi_sysfs() out of generic MSI function msi/x_capability_init(). Signed-off-by: Yijing Wang --- drivers/pci/msi.c | 31 ++++++++++++++++++------------- 1 files changed, 18 insertions(+), 13 deletions(-) diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c index 116383c..21b16e0 100644 --- a/drivers/pci/msi.c +++ b/drivers/pci/msi.c @@ -646,13 +646,6 @@ static int msi_capability_init(struct pci_dev *dev, int nvec) return ret; } - ret = populate_msi_sysfs(dev); - if (ret) { - msi_mask_irq(entry, mask, ~mask); - free_msi_irqs(dev); - return ret; - } - /* Set MSI enabled bits */ pci_intx_for_msi(dev, 0); msi_set_enable(dev, 1); @@ -760,10 +753,6 @@ static int msix_capability_init(struct pci_dev *dev, void __iomem *base, msix_program_entries(dev, entries); - ret = populate_msi_sysfs(dev); - if (ret) - goto out_free; - /* Set MSI-X enabled bits and unmask the function */ pci_intx_for_msi(dev, 0); dev->msix_enabled = 1; @@ -789,7 +778,6 @@ out_avail: ret = avail; } -out_free: free_msi_irqs(dev); return ret; @@ -939,7 +927,7 @@ EXPORT_SYMBOL(pci_msix_vec_count); int pci_enable_msix(struct pci_dev *dev, struct msix_entry *entries, int nvec) { int status, nr_entries; - int i, j; + int i, j, ret; void __iomem *base; u16 control; @@ -980,6 +968,14 @@ int pci_enable_msix(struct pci_dev *dev, struct msix_entry *entries, int nvec) return -ENOMEM; status = msix_capability_init(dev, base, entries, nvec); + if (!status) { + ret = populate_msi_sysfs(dev); + if (ret) { + dev->msix_enabled = 0; + pci_intx_for_msi(dev, 1); + free_msi_irqs(dev); + } + } return status; } EXPORT_SYMBOL(pci_enable_msix); @@ -1109,6 +1105,15 @@ int pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec) } } while (rc); + rc = populate_msi_sysfs(dev); + if (rc) { + msi_set_enable(dev, 0); + pci_intx_for_msi(dev, 1); + dev->msi_enabled = 0; + free_msi_irqs(dev); + return rc; + } + return nvec; } EXPORT_SYMBOL(pci_enable_msi_range);