From patchwork Sat Jul 26 01:48:36 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yijing Wang X-Patchwork-Id: 4626271 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7E70C9F36A for ; Sat, 26 Jul 2014 01:23:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B489B20211 for ; Sat, 26 Jul 2014 01:23:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D8790201FE for ; Sat, 26 Jul 2014 01:23:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752031AbaGZBX2 (ORCPT ); Fri, 25 Jul 2014 21:23:28 -0400 Received: from szxga01-in.huawei.com ([119.145.14.64]:21684 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751853AbaGZBX1 (ORCPT ); Fri, 25 Jul 2014 21:23:27 -0400 Received: from 172.24.2.119 (EHLO szxeml417-hub.china.huawei.com) ([172.24.2.119]) by szxrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id BZG02936; Sat, 26 Jul 2014 09:23:15 +0800 (CST) Received: from localhost.localdomain (10.175.100.166) by szxeml417-hub.china.huawei.com (10.82.67.156) with Microsoft SMTP Server id 14.3.158.1; Sat, 26 Jul 2014 09:23:08 +0800 From: To: Bjorn Helgaas CC: , Yijing Wang Subject: [PATCH 3/3] PCI/MSI: Refactor msi_bus to support EP enable/disable MSI Date: Sat, 26 Jul 2014 09:48:36 +0800 Message-ID: <1406339316-20163-4-git-send-email-wangyijing@huawei.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1406339316-20163-1-git-send-email-wangyijing@huawei.com> References: <1406339316-20163-1-git-send-email-wangyijing@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.175.100.166] X-CFilter-Loop: Reflected Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-6.9 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 From: Yijing Wang Msi_bus attribute is only valid for bridge device. We can enable or disable MSI capability for a bus, if we echo 1/0 > /sys/bus/pci/devices/$EP/msi_bus, the action will be ignored. Sometime we need to only enable/disable a device MSI, not all devices share the same bus. Signed-off-by: Yijing Wang --- drivers/pci/pci-sysfs.c | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index 9ff0a90..b199ad9 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c @@ -251,11 +251,9 @@ static ssize_t msi_bus_show(struct device *dev, struct device_attribute *attr, { struct pci_dev *pdev = to_pci_dev(dev); - if (!pdev->subordinate) - return 0; - - return sprintf(buf, "%u\n", - !(pdev->subordinate->bus_flags & PCI_BUS_FLAGS_NO_MSI)); + return sprintf(buf, "%u\n", pdev->subordinate ? + !(pdev->subordinate->bus_flags & PCI_BUS_FLAGS_NO_MSI) + : !pdev->no_msi); } static ssize_t msi_bus_store(struct device *dev, struct device_attribute *attr, @@ -278,8 +276,10 @@ static ssize_t msi_bus_store(struct device *dev, struct device_attribute *attr, * Maybe devices without subordinate buses shouldn't have this * attribute in the first place? */ - if (!pdev->subordinate) + if (!pdev->subordinate) { + pdev->no_msi = !val; return count; + } /* Is the flag going to change, or keep the value it already had? */ if (!(pdev->subordinate->bus_flags & PCI_BUS_FLAGS_NO_MSI) ^