From patchwork Fri Nov 11 14:37:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Velikov X-Patchwork-Id: 9423123 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 52E9B60484 for ; Fri, 11 Nov 2016 14:37:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3BCEB27D8D for ; Fri, 11 Nov 2016 14:37:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2F2C12950C; Fri, 11 Nov 2016 14:37:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DC50527D8D for ; Fri, 11 Nov 2016 14:37:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755708AbcKKOhi (ORCPT ); Fri, 11 Nov 2016 09:37:38 -0500 Received: from mail-wm0-f68.google.com ([74.125.82.68]:33305 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752395AbcKKOhi (ORCPT ); Fri, 11 Nov 2016 09:37:38 -0500 Received: by mail-wm0-f68.google.com with SMTP id u144so9864462wmu.0 for ; Fri, 11 Nov 2016 06:37:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=XZGC5AytfB6Vmu1vLqjOt6O8SiQVZ/smAgA41jvxEAE=; b=zYCj4a/yRvWNp9Snc1R8AN4HQlUpoG31osr1U13FAEok+6sZqU15e/u7G3e+GDBkY/ MSKJFzdV2+U0ukgk89zk2FSiQPs8VfXX7Dfve+fMQWQfkpqnvxHvKPnUDTwqNzQCosvi DvYiWEgicMnmmD1He2bYnfVPzflZAranBpidlZeCjMOK4dOi6ZrR5QRDHbdYIoc6kbVW CkiZ67QhT8Y9Oein74FNSOz/AWQ7PfQ3BLyG2kf+Qbv0xMaIbTxFhOgjwZciR5NAz+/t f64hZYhKLv0YSqhnUIZDwMYYCtPwwNCEyIOSljjTwzNRkeJO1to2/bWr+5nktQ/yF47U i8bw== 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=XZGC5AytfB6Vmu1vLqjOt6O8SiQVZ/smAgA41jvxEAE=; b=OkTw8xvJzM+DdXlRTAZA+tAnJiJLr0AlDz9mKtrA7FIJe3LohsmV49nchzq/bYyc84 pwylifmyhjbnw1l/SOvgymnmFHsUXfcylOmE6+dpClRLxxDc6bpL4XVD3b7VRnYwArhn TkO2WPs1wSQiSnaDVwacjzwczyjnYh7pslYb+0a9CbS1boz9oImy86N5SyTWt9BujeQ2 2m6C/P0Ufs9fOeXY0n6sSabuWkxkslzErW64mzLK16/eY+nEpD8A57Wf1C/9aQhOFwev 8fHiV4cBeXdoEDXQzqlNKuUt8qPU4b6/PT3HhibHwTIgZN8DcC6YNpDfOGozosxIlr0P 4nGQ== X-Gm-Message-State: ABUngvcPeRg/xFTg4W3IvQpsPCnOW7OuolBCQr3yZoOxWWBnF86v3OkBNZgmUarrIDM2mA== X-Received: by 10.194.95.35 with SMTP id dh3mr10612358wjb.141.1478875052543; Fri, 11 Nov 2016 06:37:32 -0800 (PST) Received: from arch-x220.cbg.collabora.co.uk ([2a00:1098:5:0:120b:a9ff:fe8d:c914]) by smtp.gmail.com with ESMTPSA id 70sm19301666wmv.1.2016.11.11.06.37.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Nov 2016 06:37:31 -0800 (PST) From: Emil Velikov To: dri-devel@lists.freedesktop.org Cc: emil.l.velikov@gmail.com, Bjorn Helgaas , linux-pci@vger.kernel.org, Greg KH Subject: [PATCH v3] PCI: create revision file in sysfs Date: Fri, 11 Nov 2016 14:37:23 +0000 Message-Id: <20161111143723.5818-1-emil.l.velikov@gmail.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20161101154232.6451-1-emil.l.velikov@gmail.com> References: <20161101154232.6451-1-emil.l.velikov@gmail.com> Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Emil Velikov Currently the revision isn't available via sysfs/libudev thus if one wants to know the value they need to read through the config file. This in itself wakes/powers up the device, causing unwanted delay since it can be quite costly. There are at least two userspace components which could make use the new file libpciaccess and libdrm. The former [used in various places] wakes up _every_ PCI device, which can be observed via glxinfo [when using Mesa 10.0+ drivers]. While the latter [in association with Mesa 13.0] can lead to 2-3 second delays while starting firefox, thunderbird or chromium. Expose the revision as a separate file, just like we do for the device, vendor, their subsystem version and class. Cc: Bjorn Helgaas Cc: linux-pci@vger.kernel.org Cc: Greg KH Link: https://bugs.freedesktop.org/show_bug.cgi?id=98502 Tested-by: Mauro Santos Reviewed-by: Alex Deucher Signed-off-by: Emil Velikov Reviewed-by: Daniel Vetter --- v2: Add r-b/t-b tags, slim down CC list, add note about userspace. v3: Add Documentation/ bits (Greg KH) Gents, please keep me in the CC list. Thanks Emil --- Documentation/ABI/testing/sysfs-bus-pci | 7 +++++++ Documentation/filesystems/sysfs-pci.txt | 2 ++ drivers/pci/pci-sysfs.c | 2 ++ 3 files changed, 11 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-bus-pci b/Documentation/ABI/testing/sysfs-bus-pci index b3bc50f..5a1732b 100644 --- a/Documentation/ABI/testing/sysfs-bus-pci +++ b/Documentation/ABI/testing/sysfs-bus-pci @@ -294,3 +294,10 @@ Description: a firmware bug to the system vendor. Writing to this file taints the kernel with TAINT_FIRMWARE_WORKAROUND, which reduces the supportability of your system. + +What: /sys/bus/pci/devices/.../revision +Date: November 2016 +Contact: Emil Velikov +Description: + This file contains the revision field of the the PCI device. + The value comes from device config space. The file is read only. diff --git a/Documentation/filesystems/sysfs-pci.txt b/Documentation/filesystems/sysfs-pci.txt index 74eaac2..6ea1ced 100644 --- a/Documentation/filesystems/sysfs-pci.txt +++ b/Documentation/filesystems/sysfs-pci.txt @@ -17,6 +17,7 @@ that support it. For example, a given bus might look like this: | |-- resource0 | |-- resource1 | |-- resource2 + | |-- revision | |-- rom | |-- subsystem_device | |-- subsystem_vendor @@ -41,6 +42,7 @@ files, each with their own function. resource PCI resource host addresses (ascii, ro) resource0..N PCI resource N, if present (binary, mmap, rw[1]) resource0_wc..N_wc PCI WC map resource N, if prefetchable (binary, mmap) + revision PCI revision (ascii, ro) rom PCI ROM resource, if present (binary, ro) subsystem_device PCI subsystem device (ascii, ro) subsystem_vendor PCI subsystem vendor (ascii, ro) diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index bcd10c7..0666287 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c @@ -50,6 +50,7 @@ pci_config_attr(vendor, "0x%04x\n"); pci_config_attr(device, "0x%04x\n"); pci_config_attr(subsystem_vendor, "0x%04x\n"); pci_config_attr(subsystem_device, "0x%04x\n"); +pci_config_attr(revision, "0x%02x\n"); pci_config_attr(class, "0x%06x\n"); pci_config_attr(irq, "%u\n"); @@ -568,6 +569,7 @@ static struct attribute *pci_dev_attrs[] = { &dev_attr_device.attr, &dev_attr_subsystem_vendor.attr, &dev_attr_subsystem_device.attr, + &dev_attr_revision.attr, &dev_attr_class.attr, &dev_attr_irq.attr, &dev_attr_local_cpus.attr,