From patchwork Sat Jul 26 03:08:41 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: wangyijing X-Patchwork-Id: 34335 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oi0-f69.google.com (mail-oi0-f69.google.com [209.85.218.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 700CF235AB for ; Sat, 26 Jul 2014 02:46:24 +0000 (UTC) Received: by mail-oi0-f69.google.com with SMTP id h136sf21582686oig.0 for ; Fri, 25 Jul 2014 19:46: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=QcdYgnsnjx9BwTQZ0KdG0QLr6u+H1XHYElLaWqPlVZE=; b=fx3N9LS774KjOegbaI5EjDUvVb1FDv8EVax85Yisspm8F9GFTYQscgM0cGguEyigOA 4fHCyDZpuo7XRJfDzgyC0MEAcutbSQH9k2lt960cVka91UHEK2Qp7ti/oygJG8s9frdT urGY4E4K5SsXu294mUsxyu2ZAqWhkDhCfH++yAnOjWgzAgmU3RLUKdoEnCtWmb5AJ7Yd Ay4rq0d0J6LEtQBTpt6faeWt/L7taWe2IE7OtXGPazbZ563Disx9ZN00Iq5rEv8LL2+B yYPWQ+fVo+2qMewG6RmDlWRgCyOdbMaExI7GN9pFMjoapbFyHGnlXkPXa/lfBVMDu46t KBrg== X-Gm-Message-State: ALoCoQm1MFYZ2FCG0+OYrWMuCn7S8F//oqUpuXv0DYwLK3zjl+AxyVlGDolP4kcMVdw/kf70Ads3 X-Received: by 10.50.73.5 with SMTP id h5mr4081000igv.2.1406342783994; Fri, 25 Jul 2014 19:46:23 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.37.142 with SMTP id r14ls1398108qgr.16.gmail; Fri, 25 Jul 2014 19:46:23 -0700 (PDT) X-Received: by 10.224.89.10 with SMTP id c10mr34637225qam.51.1406342783848; Fri, 25 Jul 2014 19:46:23 -0700 (PDT) Received: from mail-qg0-f47.google.com (mail-qg0-f47.google.com [209.85.192.47]) by mx.google.com with ESMTPS id d14si19228903qaa.105.2014.07.25.19.46.23 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 25 Jul 2014 19:46:23 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.192.47 as permitted sender) client-ip=209.85.192.47; Received: by mail-qg0-f47.google.com with SMTP id i50so5996520qgf.6 for ; Fri, 25 Jul 2014 19:46:23 -0700 (PDT) X-Received: by 10.224.43.77 with SMTP id v13mr33428434qae.34.1406342783744; Fri, 25 Jul 2014 19:46: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.96.16.166 with SMTP id h6csp70432qdd; Fri, 25 Jul 2014 19:46:23 -0700 (PDT) X-Received: by 10.68.139.194 with SMTP id ra2mr22767492pbb.20.1406342782851; Fri, 25 Jul 2014 19:46:22 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id do1si5472789pdb.498.2014.07.25.19.46.22 for ; Fri, 25 Jul 2014 19:46: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 S1760833AbaGZCoJ (ORCPT + 15 others); Fri, 25 Jul 2014 22:44:09 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:6656 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752850AbaGZCnt (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 BXE25887; 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:31 +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 04/11] PCI/MSI: Move MSIX table address mapping out of msix_capability_init Date: Sat, 26 Jul 2014 11:08:41 +0800 Message-ID: <1406344128-27055-5-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.47 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: , Move MSIX table address mapping work to PCI MSIX layer. Some Non-PCI MSI device will do their address mapping work before enable MSIX capability or their MSIX table address is within device address block. So Move address mapping stuff out of the generic MSIX core. This is prepartion for generic MSI drvier. Suggested-by: Yun Wu Signed-off-by: Yijing Wang --- drivers/pci/msi.c | 25 +++++++++++++------------ 1 files changed, 13 insertions(+), 12 deletions(-) diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c index d5c8e56..116383c 100644 --- a/drivers/pci/msi.c +++ b/drivers/pci/msi.c @@ -668,8 +668,8 @@ static void __iomem *msix_map_region(struct pci_dev *dev, unsigned nr_entries) u32 table_offset; u8 bir; - pci_read_config_dword(dev, dev->msix_cap + PCI_MSIX_TABLE, - &table_offset); + pci_read_config_dword(dev, dev->msix_cap + PCI_MSIX_TABLE, + &table_offset); bir = (u8)(table_offset & PCI_MSIX_TABLE_BIR); table_offset &= PCI_MSIX_TABLE_OFFSET; phys_addr = pci_resource_start(dev, bir) + table_offset; @@ -734,22 +734,14 @@ static void msix_program_entries(struct pci_dev *dev, * single MSI-X irq. A return of zero indicates the successful setup of * requested MSI-X entries with allocated irqs or non-zero for otherwise. **/ -static int msix_capability_init(struct pci_dev *dev, +static int msix_capability_init(struct pci_dev *dev, void __iomem *base, struct msix_entry *entries, int nvec) { int ret; - u16 control; - void __iomem *base; /* Ensure MSI-X is disabled while it is set up */ msix_clear_and_set_ctrl(dev, PCI_MSIX_FLAGS_ENABLE, 0); - pci_read_config_word(dev, dev->msix_cap + PCI_MSIX_FLAGS, &control); - /* Request & Map MSI-X table region */ - base = msix_map_region(dev, msix_table_size(control)); - if (!base) - return -ENOMEM; - ret = msix_setup_entries(dev, base, entries, nvec); if (ret) return ret; @@ -948,6 +940,8 @@ int pci_enable_msix(struct pci_dev *dev, struct msix_entry *entries, int nvec) { int status, nr_entries; int i, j; + void __iomem *base; + u16 control; if (!entries || !dev->msix_cap || dev->current_state != PCI_D0) return -EINVAL; @@ -978,7 +972,14 @@ int pci_enable_msix(struct pci_dev *dev, struct msix_entry *entries, int nvec) dev_info(&dev->dev, "can't enable MSI-X (MSI IRQ already assigned)\n"); return -EINVAL; } - status = msix_capability_init(dev, entries, nvec); + + /* Request & Map MSI-X table region */ + pci_read_config_word(dev, dev->msix_cap + PCI_MSIX_FLAGS, &control); + base = msix_map_region(dev, msix_table_size(control)); + if (!base) + return -ENOMEM; + + status = msix_capability_init(dev, base, entries, nvec); return status; } EXPORT_SYMBOL(pci_enable_msix);