From patchwork Tue Jul 10 15:54:02 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiang Liu X-Patchwork-Id: 170220 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 9302D2C007A for ; Wed, 11 Jul 2012 01:55:07 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756012Ab2GJPyu (ORCPT ); Tue, 10 Jul 2012 11:54:50 -0400 Received: from mail-pb0-f46.google.com ([209.85.160.46]:43454 "EHLO mail-pb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752464Ab2GJPys (ORCPT ); Tue, 10 Jul 2012 11:54:48 -0400 Received: by pbbrp8 with SMTP id rp8so456687pbb.19 for ; Tue, 10 Jul 2012 08:54:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :in-reply-to:references; bh=4eI2376UJPmkHAgBkRgMVLsNsZ9WtTKACdEcsfPD8Y0=; b=xlDfoDYLENJbNdiqzManI5lIT5+dzOIkLK42sbPrebNCBi3s0OM7dm2BO1cCgHuhna G2KOBJoJupRsXQZhig6A3qzlbYQpHH4ZpBK9duyj7aYoLK+zJl0g2c8Hy63dBPgPZrmZ wB5jqvRDZb3qVyG0kqeapOZIX97JtQ9A2IaTjWnjfi5hFSkAgdJT1KOt3kZ5QZvzT0RN 9JVzpJnVj2pfKC8eaPuHqhDzzkNfGfdqWjEAfI72AhMjGrFHjqggKR+3gbh1N1ENbbY3 f3kypeP4VgyTWa4u4KkUeyrHj/k/zdOQs/fvoX1GNWK3WWtKScUgvJdu3b52XuqnwApp xmOQ== Received: by 10.68.202.99 with SMTP id kh3mr54062779pbc.157.1341935688276; Tue, 10 Jul 2012 08:54:48 -0700 (PDT) Received: from localhost.localdomain ([221.221.21.23]) by mx.google.com with ESMTPS id oq4sm3056662pbb.21.2012.07.10.08.54.38 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 10 Jul 2012 08:54:47 -0700 (PDT) From: Jiang Liu To: Bjorn Helgaas , Don Dutile Cc: Yijing Wang , Yinghai Lu , Taku Izumi , "Rafael J . Wysocki" , Kenji Kaneshige , Keping Chen , linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, Jiang Liu Subject: [RFC PATCH 01/14] PCI: add pcie_flags into struct pci_dev to cache PCIe capabilities register Date: Tue, 10 Jul 2012 23:54:02 +0800 Message-Id: <1341935655-5381-2-git-send-email-jiang.liu@huawei.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1341935655-5381-1-git-send-email-jiang.liu@huawei.com> References: <1341935655-5381-1-git-send-email-jiang.liu@huawei.com> In-Reply-To: References: Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org From: Yijing Wang From: Yijing Wang Since PCI Express Capabilities Register is read only, cache its value into struct pci_dev to avoid repeatedly calling pci_read_config_*(). Signed-off-by: Yijing Wang Signed-off-by: Jiang Liu --- drivers/pci/probe.c | 1 + include/linux/pci.h | 1 + 2 files changed, 2 insertions(+) diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 6c143b4..65e82e3 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -929,6 +929,7 @@ void set_pcie_port_type(struct pci_dev *pdev) pdev->is_pcie = 1; pdev->pcie_cap = pos; pci_read_config_word(pdev, pos + PCI_EXP_FLAGS, ®16); + pdev->pcie_flags = reg16; pdev->pcie_type = (reg16 & PCI_EXP_FLAGS_TYPE) >> 4; pci_read_config_word(pdev, pos + PCI_EXP_DEVCAP, ®16); pdev->pcie_mpss = reg16 & PCI_EXP_DEVCAP_PAYLOAD; diff --git a/include/linux/pci.h b/include/linux/pci.h index 5faa831..f4a7ad6 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -258,6 +258,7 @@ struct pci_dev { u8 pcie_mpss:3; /* PCI-E Max Payload Size Supported */ u8 rom_base_reg; /* which config register controls the ROM */ u8 pin; /* which interrupt pin this device uses */ + u16 pcie_flags; /* cached PCI-E Capabilities Register */ struct pci_driver *driver; /* which driver has allocated this device */ u64 dma_mask; /* Mask of the bits of bus address this