From patchwork Tue Sep 15 04:10:22 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Horman X-Patchwork-Id: 517659 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 AD4EA140D16 for ; Tue, 15 Sep 2015 14:10:36 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751666AbbIOEKg (ORCPT ); Tue, 15 Sep 2015 00:10:36 -0400 Received: from mail-pa0-f48.google.com ([209.85.220.48]:35652 "EHLO mail-pa0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751573AbbIOEKf (ORCPT ); Tue, 15 Sep 2015 00:10:35 -0400 Received: by pacfv12 with SMTP id fv12so166720741pac.2 for ; Mon, 14 Sep 2015 21:10:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=JTpqJDsQ5DyGugwoy8T2RXqnysT13KcOvtMzZFt6utI=; b=YX3pxWDuJVQpBMXdE1UwwWhw37FvzvdAG/9Dhlk2VUWjoAF7YwmVveXj6zGc0Kx4Aj jiTg/HpBM0V1Dj+5E+ET3ysOZE0/AoWMr5AzeidSS1k2ua6L/qtUHUcC2zAR8PS32fcO 2a5Y4piSzRhvv8Y3uVAow/Drejsx3sOrrg6YoJAPuft5zD1ui63aYK8OZ3GJwEETRJuh 3Bwm83KpM4yjASLXTNrKpYynI1bbyHC3kpIMN10499qA354XAAPDoMpe2vUMLcKABIM9 CwTZss2//Lxu7sLeMEj5jSMRgAjwuDFeTAGHWY1m5k35YoP4GNcQwicYzCCYFSmoVQiN 3XEg== X-Gm-Message-State: ALoCoQnrMmRBol49K09SbVckyFrB5jmx0SybMMsPMEZCUJDk9KR4qHqMDux7LK8ZKitIaPvBVukH X-Received: by 10.66.102.71 with SMTP id fm7mr41955064pab.5.1442290235043; Mon, 14 Sep 2015 21:10:35 -0700 (PDT) Received: from reginn.isobedori.kobe.vergenet.net (p7129-ipbfp904kobeminato.hyogo.ocn.ne.jp. [118.10.130.129]) by smtp.gmail.com with ESMTPSA id fd9sm19106300pab.34.2015.09.14.21.10.33 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 14 Sep 2015 21:10:34 -0700 (PDT) From: Simon Horman To: Bjorn Helgaas Cc: linux-pci@vger.kernel.org, Simon Horman Subject: [PATCH/RFC 1/3] PCI: Support PCIe devices with short cfg_size Date: Tue, 15 Sep 2015 13:10:22 +0900 Message-Id: <1442290224-21729-2-git-send-email-simon.horman@netronome.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1442290224-21729-1-git-send-email-simon.horman@netronome.com> References: <1442290224-21729-1-git-send-email-simon.horman@netronome.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org From: "Jason S. McMullan" If a PCIe device has a 'quirk' where the quirk modifies the pci_dev->cfg_size to be less than PCI_CFG_SPACE_EXP_SIZE, but greater than PCI_CFG_SPACE_SIZE then the pci sysfs interface truncates the readable size to PCI_CFG_SPACE_SIZE. This patch corrects this issue. This is in preparation for adding a quirk for such a case. Signed-off-by: Jason S. McMullan [simon: edited changelog] Signed-off-by: Simon Horman --- drivers/pci/pci-sysfs.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index 312f23a8429c..cf8eba5d8e14 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c @@ -1369,10 +1369,10 @@ int __must_check pci_create_sysfs_dev_files(struct pci_dev *pdev) if (!sysfs_initialized) return -EACCES; - if (pdev->cfg_size < PCI_CFG_SPACE_EXP_SIZE) - retval = sysfs_create_bin_file(&pdev->dev.kobj, &pci_config_attr); - else + if (pdev->cfg_size > PCI_CFG_SPACE_SIZE) retval = sysfs_create_bin_file(&pdev->dev.kobj, &pcie_config_attr); + else + retval = sysfs_create_bin_file(&pdev->dev.kobj, &pci_config_attr); if (retval) goto err; @@ -1424,10 +1424,10 @@ err_rom_file: err_resource_files: pci_remove_resource_files(pdev); err_config_file: - if (pdev->cfg_size < PCI_CFG_SPACE_EXP_SIZE) - sysfs_remove_bin_file(&pdev->dev.kobj, &pci_config_attr); - else + if (pdev->cfg_size > PCI_CFG_SPACE_SIZE) sysfs_remove_bin_file(&pdev->dev.kobj, &pcie_config_attr); + else + sysfs_remove_bin_file(&pdev->dev.kobj, &pci_config_attr); err: return retval; } @@ -1461,10 +1461,10 @@ void pci_remove_sysfs_dev_files(struct pci_dev *pdev) pci_remove_capabilities_sysfs(pdev); - if (pdev->cfg_size < PCI_CFG_SPACE_EXP_SIZE) - sysfs_remove_bin_file(&pdev->dev.kobj, &pci_config_attr); - else + if (pdev->cfg_size > PCI_CFG_SPACE_SIZE) sysfs_remove_bin_file(&pdev->dev.kobj, &pcie_config_attr); + else + sysfs_remove_bin_file(&pdev->dev.kobj, &pci_config_attr); pci_remove_resource_files(pdev);