Skip to contentSkip to conversation

scsi: libsas: Fix declaration of ncq priority attributes

PATCH Applied Damien Le Moal 3 participants 5 messages Mar 27, 2024 – Apr 2, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi: libsas: Fix declaration of ncq priority attributes

Commit b4d3ddd2df7 ("scsi: libsas: Define NCQ Priority sysfs attributes for SATA devices") introduced support for ATA NCQ priority control for ATA devices managed by libsas. This commit introduces the ncq_prio_supported and ncq_prio_enable sysfs device attributes to discover and control the use of this features, similarly to libata. However, libata publicly declares these device attributes and export them for use in ATA low level drivers. This leads to a compilation error when libsas and libata are built-in due to the double definition:

ld: drivers/ata/libata-sata.o:/home/Linux/scsi/drivers/ata/libata-sata.c:900:
multiple definition of `dev_attr_ncq_prio_supported'; drivers/scsi/libsas/sas_ata.o:/home/Linux/scsi/drivers/scsi/libsas/sas_ata.c:984:
first defined here
ld: drivers/ata/libata-sata.o:/home/Linux/scsi/drivers/ata/libata-sata.c:1026:
multiple definition of `dev_attr_ncq_prio_enable'; drivers/scsi/libsas/sas_ata.o:/home/Linux/scsi/drivers/scsi/libsas/sas_ata.c:1022:
first defined here

Resolve this problem by directly declaring the libsas attributes instead of using the DEVICE_ATTR() macro. And for good measure, the device attribute variables are also renamed.

Fixes b4d3ddd2df7 ("scsi: libsas: Define NCQ Priority sysfs attributes for SATA devices")
---
 drivers/scsi/libsas/sas_ata.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/scsi/libsas/sas_ata.c +7 -5
index b57c041a5544..4c69fc63c119 100644
@@ -981,7 +981,8 @@ static ssize_t sas_ncq_prio_supported_show(struct device *device,
 	return sysfs_emit(buf, "%d\n", supported);
 }
 
-DEVICE_ATTR(ncq_prio_supported, S_IRUGO, sas_ncq_prio_supported_show, NULL);
+static struct device_attribute dev_attr_sas_ncq_prio_supported =
+	__ATTR(ncq_prio_supported, S_IRUGO, sas_ncq_prio_supported_show, NULL);
 
 static ssize_t sas_ncq_prio_enable_show(struct device *device,
 					struct device_attribute *attr,
@@ -1019,12 +1020,13 @@ static ssize_t sas_ncq_prio_enable_store(struct device *device,
 	return len;
 }
 
-DEVICE_ATTR(ncq_prio_enable, S_IRUGO | S_IWUSR,
-	    sas_ncq_prio_enable_show, sas_ncq_prio_enable_store);
+static struct device_attribute dev_attr_sas_ncq_prio_enable =
+	__ATTR(ncq_prio_enable, S_IRUGO | S_IWUSR,
+	       sas_ncq_prio_enable_show, sas_ncq_prio_enable_store);
 
 static struct attribute *sas_ata_sdev_attrs[] = {
-	&dev_attr_ncq_prio_supported.attr,
-	&dev_attr_ncq_prio_enable.attr,
+	&dev_attr_sas_ncq_prio_supported.attr,
+	&dev_attr_sas_ncq_prio_enable.attr,
 	NULL
 };
 
Signature · 1 line
2.44.0
#1 lore raw
Quoted 18 lines · Damien Le Moal

Commit b4d3ddd2df7 ("scsi: libsas: Define NCQ Priority sysfs attributes for SATA devices") introduced support for ATA NCQ priority control for ATA devices managed by libsas. This commit introduces the ncq_prio_supported and ncq_prio_enable sysfs device attributes to discover and control the use of this features, similarly to libata. However, libata publicly declares these device attributes and export them for use in ATA low level drivers. This leads to a compilation error when libsas and libata are built-in due to the double definition:

ld: drivers/ata/libata-sata.o:/home/Linux/scsi/drivers/ata/libata-sata.c:900:
multiple definition of `dev_attr_ncq_prio_supported'; drivers/scsi/libsas/sas_ata.o:/home/Linux/scsi/drivers/scsi/libsas/sas_ata.c:984:
first defined here
ld: drivers/ata/libata-sata.o:/home/Linux/scsi/drivers/ata/libata-sata.c:1026:
multiple definition of `dev_attr_ncq_prio_enable'; drivers/scsi/libsas/sas_ata.o:/home/Linux/scsi/drivers/scsi/libsas/sas_ata.c:1022:
first defined here

Quoted 7 lines

Resolve this problem by directly declaring the libsas attributes instead of using the DEVICE_ATTR() macro. And for good measure, the device attribute variables are also renamed.

Fixes b4d3ddd2df7 ("scsi: libsas: Define NCQ Priority sysfs attributes for SATA devices")

Forgot to add John to the distribution list...

Quoted 36 lines
---
 drivers/scsi/libsas/sas_ata.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/scsi/libsas/sas_ata.c +7 -5
index b57c041a5544..4c69fc63c119 100644
@@ -981,7 +981,8 @@ static ssize_t sas_ncq_prio_supported_show(struct device *device,
 	return sysfs_emit(buf, "%d\n", supported);
 }
 
-DEVICE_ATTR(ncq_prio_supported, S_IRUGO, sas_ncq_prio_supported_show, NULL);
+static struct device_attribute dev_attr_sas_ncq_prio_supported =
+	__ATTR(ncq_prio_supported, S_IRUGO, sas_ncq_prio_supported_show, NULL);
 
 static ssize_t sas_ncq_prio_enable_show(struct device *device,
 					struct device_attribute *attr,
@@ -1019,12 +1020,13 @@ static ssize_t sas_ncq_prio_enable_store(struct device *device,
 	return len;
 }
 
-DEVICE_ATTR(ncq_prio_enable, S_IRUGO | S_IWUSR,
-	    sas_ncq_prio_enable_show, sas_ncq_prio_enable_store);
+static struct device_attribute dev_attr_sas_ncq_prio_enable =
+	__ATTR(ncq_prio_enable, S_IRUGO | S_IWUSR,
+	       sas_ncq_prio_enable_show, sas_ncq_prio_enable_store);
 
 static struct attribute *sas_ata_sdev_attrs[] = {
-	&dev_attr_ncq_prio_supported.attr,
-	&dev_attr_ncq_prio_enable.attr,
+	&dev_attr_sas_ncq_prio_supported.attr,
+	&dev_attr_sas_ncq_prio_enable.attr,
 	NULL
 };
 
Signature · 2 lines
Damien Le Moal
Western Digital Research
reviewer Reviewed-by
#2 lore raw

On 27/03/2024 02:13, Damien Le Moal wrote:

- old address

Quoted 4 lines · Damien Le Moal
Quoted 3 lines

Commit b4d3ddd2df7 ("scsi: libsas: Define NCQ Priority sysfs attributes for SATA devices") introduced support for ATA NCQ priority control for ATA devices managed by libsas. This commit introduces the

nit: /s/This commit introduces the/That commit introduced the/

Quoted 15 lines
Quoted 15 lines

ncq_prio_supported and ncq_prio_enable sysfs device attributes to discover and control the use of this features, similarly to libata. However, libata publicly declares these device attributes and export them for use in ATA low level drivers. This leads to a compilation error when libsas and libata are built-in due to the double definition:

ld: drivers/ata/libata-sata.o:/home/Linux/scsi/drivers/ata/libata-sata.c:900:
multiple definition of `dev_attr_ncq_prio_supported'; drivers/scsi/libsas/sas_ata.o:/home/Linux/scsi/drivers/scsi/libsas/sas_ata.c:984:
first defined here
ld: drivers/ata/libata-sata.o:/home/Linux/scsi/drivers/ata/libata-sata.c:1026:
multiple definition of `dev_attr_ncq_prio_enable'; drivers/scsi/libsas/sas_ata.o:/home/Linux/scsi/drivers/scsi/libsas/sas_ata.c:1022:
first defined here

Quoted 7 lines
Quoted 7 lines

Resolve this problem by directly declaring the libsas attributes instead of using the DEVICE_ATTR() macro. And for good measure, the device attribute variables are also renamed.

Fixes b4d3ddd2df7 ("scsi: libsas: Define NCQ Priority sysfs attributes for SATA devices")
Quoted 40 lines

Forgot to add John to the distribution list...

Quoted 36 lines
---
  drivers/scsi/libsas/sas_ata.c | 12 +++++++-----
  1 file changed, 7 insertions(+), 5 deletions(-)
drivers/scsi/libsas/sas_ata.c +7 -5
index b57c041a5544..4c69fc63c119 100644
@@ -981,7 +981,8 @@ static ssize_t sas_ncq_prio_supported_show(struct device *device,
  	return sysfs_emit(buf, "%d\n", supported);
  }
 
-DEVICE_ATTR(ncq_prio_supported, S_IRUGO, sas_ncq_prio_supported_show, NULL);
+static struct device_attribute dev_attr_sas_ncq_prio_supported =
+	__ATTR(ncq_prio_supported, S_IRUGO, sas_ncq_prio_supported_show, NULL);
 
  static ssize_t sas_ncq_prio_enable_show(struct device *device,
  					struct device_attribute *attr,
@@ -1019,12 +1020,13 @@ static ssize_t sas_ncq_prio_enable_store(struct device *device,
  	return len;
  }
 
-DEVICE_ATTR(ncq_prio_enable, S_IRUGO | S_IWUSR,
-	    sas_ncq_prio_enable_show, sas_ncq_prio_enable_store);
+static struct device_attribute dev_attr_sas_ncq_prio_enable =
+	__ATTR(ncq_prio_enable, S_IRUGO | S_IWUSR,
+	       sas_ncq_prio_enable_show, sas_ncq_prio_enable_store);
 
  static struct attribute *sas_ata_sdev_attrs[] = {
-	&dev_attr_ncq_prio_supported.attr,
-	&dev_attr_ncq_prio_enable.attr,
+	&dev_attr_sas_ncq_prio_supported.attr,
+	&dev_attr_sas_ncq_prio_enable.attr,
  	NULL
  };
 
#3 lore raw
In reply to Damien Le Moal

Damien,

Quoted 3 lines

Commit b4d3ddd2df7 ("scsi: libsas: Define NCQ Priority sysfs attributes for SATA devices") introduced support for ATA NCQ priority control for ATA devices managed by libsas.

Applied to 6.10/scsi-staging, thanks!

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering
#4 lore raw
In reply to Damien Le Moal
Quoted 10 lines · Damien Le Moal

Commit b4d3ddd2df7 ("scsi: libsas: Define NCQ Priority sysfs attributes for SATA devices") introduced support for ATA NCQ priority control for ATA devices managed by libsas. This commit introduces the ncq_prio_supported and ncq_prio_enable sysfs device attributes to discover and control the use of this features, similarly to libata. However, libata publicly declares these device attributes and export them for use in ATA low level drivers. This leads to a compilation error when libsas and libata are built-in due to the double definition:

[...]

Applied to 6.10/scsi-queue, thanks!

[1/1] scsi: libsas: Fix declaration of ncq priority attributes

      https://git.kernel.org/mkp/scsi/c/0ff10cb7f818
Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering