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: 9423125 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 0E97060484 for ; Fri, 11 Nov 2016 14:37:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ED9AE27D8D for ; Fri, 11 Nov 2016 14:37:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E27FD293E1; Fri, 11 Nov 2016 14:37:47 +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=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7DD9B293E8 for ; Fri, 11 Nov 2016 14:37:41 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E107F6E912; Fri, 11 Nov 2016 14:37:35 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm0-x243.google.com (mail-wm0-x243.google.com [IPv6:2a00:1450:400c:c09::243]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2B4806E912 for ; Fri, 11 Nov 2016 14:37:34 +0000 (UTC) Received: by mail-wm0-x243.google.com with SMTP id m203so8231303wma.3 for ; Fri, 11 Nov 2016 06:37:34 -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=U+Y5yN52eAePf1PwSkUxUfxJJUY4SdM+pQHHk+cxeMqusQ9C5wJXpSpXFYnlMobvxn gx7la7EqCtrUo9o16tKLLG/f20VWigI5Z6sVv1ptTssr0zaQhF3wiCN3pPQIgdwKn1T6 0KJo34ySZtQfjSqSPJTKYI4pFuWlfE7FPY0Zjz6oqgN/tcZU2M3bKmVL1qNoTC5uTj7R zKkpg0LmGDebJ4kQtGH+oLJL/lnsbrXR0ggCHteD1sDulPgZIbz0fATlDwCvSWRiwaYN mQ+2I73tWttPbvihJ5ilHDQDR3QREQFpO8lJi30bpM0p3pZmOHyuGS7LPZdiDFPfkuwX VYcQ== X-Gm-Message-State: ABUngvdcWJTjJvTx/1ji+pg90qzBhwtdyhUCIJRoTxNxZiXtB34gdF95FB4iibTXXIBPDQ== 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 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> Cc: Bjorn Helgaas , linux-pci@vger.kernel.org, emil.l.velikov@gmail.com, Greg KH X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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,