Re: [PATCH V9 4/8] PCI/sysfs: Add a 10-Bit Tag sysfs file PCIe Endpoint devices

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Krzysztof

Many thanks for your review.
On 2021/9/23 12:21, Krzysztof Wilczyński wrote:
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?
OK, will do.

	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?
Seems make sense, Will do. It is better do the same thing on the
"disable" path too.

+		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()
Will fix.

Thanks,
Dongdong

Albeit, I appreciate that you followed the existing naming pattern.

	Krzysztof
.




[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux