Re: [PATCH V9 4/8] PCI/sysfs: Add a 10-Bit Tag sysfs file PCIe Endpoint devices
From: Krzysztof Wilczyński <hidden>
Date: 2021-09-23 04:22:04
Also in:
linux-pci, netdev
Hi, Thank you for sending the patch over! A few small comments below. [...]
+static ssize_t pci_10bit_tag_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct pci_dev *pdev = to_pci_dev(dev);
+ bool enable;Would you mind adding the following capabilities check here? if (!capable(CAP_SYS_ADMIN)) return -EPERM; This is so we make sure that whatever user is going to use this sysfs attribute actually has enough permissions to update this value safely.
+ if (kstrtobool(buf, &enable) < 0)
+ return -EINVAL;
+
+ if (pdev->driver)
+ return -EBUSY;
+
+ if (enable) {
+ if (!pcie_rp_10bit_tag_cmp_supported(pdev))
+ return -EPERM;Would it make sense to also verify 10-Bit Tag Completer support on the "disable" path too? We won't be able to set a value if there is no support, but nothing will stop us from clearing it regardless - unless this would be safe to do? What do you think?
+ pcie_capability_set_word(pdev, PCI_EXP_DEVCTL2,
+ PCI_EXP_DEVCTL2_10BIT_TAG_REQ_EN);
+ } else {
+ pcie_capability_clear_word(pdev, PCI_EXP_DEVCTL2,
+ PCI_EXP_DEVCTL2_10BIT_TAG_REQ_EN);
+ }
+
+ return count;
+}[...]
+> +static umode_t pcie_dev_10bit_tag_attrs_are_visible(struct kobject *kobj, + struct attribute *a, int n)
The preferred function name for the .is_visible() callback in a case when there is only a single sysfs attribute being added would be: pcie_dev_10bit_tag_attr_is_visible() Albeit, I appreciate that you followed the existing naming pattern. Krzysztof