linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] scsi: Add sysfs attributes for VPD pages 0h and 89h
@ 2019-09-26 16:22 Ryan Attard
  2019-09-27  2:44 ` Bart Van Assche
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Ryan Attard @ 2019-09-26 16:22 UTC (permalink / raw)
  To: jejb, martin.petersen, linux-scsi; +Cc: Ryan Attard

Add sysfs attributes for the ATA information page and
Supported VPD Pages page.

Signed-off-by: Ryan Attard <ryanattard@ryanattard.info>
---
 drivers/scsi/scsi.c        |  4 ++++
 drivers/scsi/scsi_sysfs.c  | 19 +++++++++++++++++++
 include/scsi/scsi_device.h |  2 ++
 3 files changed, 25 insertions(+)

diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
index a7e4fba724b7..088b8ca473e6 100644
--- a/drivers/scsi/scsi.c
+++ b/drivers/scsi/scsi.c
@@ -485,10 +485,14 @@ void scsi_attach_vpd(struct scsi_device *sdev)
 		return;
 
 	for (i = 4; i < vpd_buf->len; i++) {
+		if (vpd_buf->data[i] == 0x0)
+			scsi_update_vpd_page(sdev, 0x0, &sdev->vpd_pg0);
 		if (vpd_buf->data[i] == 0x80)
 			scsi_update_vpd_page(sdev, 0x80, &sdev->vpd_pg80);
 		if (vpd_buf->data[i] == 0x83)
 			scsi_update_vpd_page(sdev, 0x83, &sdev->vpd_pg83);
+		if (vpd_buf->data[i] == 0x89)
+			scsi_update_vpd_page(sdev, 0x89, &sdev->vpd_pg89);
 	}
 	kfree(vpd_buf);
 }
diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
index 8ce12ffcbb7a..eb6764f92c93 100644
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -429,6 +429,7 @@ static void scsi_device_dev_release_usercontext(struct work_struct *work)
 	struct device *parent;
 	struct list_head *this, *tmp;
 	struct scsi_vpd *vpd_pg80 = NULL, *vpd_pg83 = NULL;
+	struct scsi_vpd *vpd_pg0 = NULL, *vpd_pg89 = NULL;
 	unsigned long flags;
 
 	sdev = container_of(work, struct scsi_device, ew.work);
@@ -458,16 +459,24 @@ static void scsi_device_dev_release_usercontext(struct work_struct *work)
 	sdev->request_queue = NULL;
 
 	mutex_lock(&sdev->inquiry_mutex);
+	rcu_swap_protected(sdev->vpd_pg0, vpd_pg0,
+			   lockdep_is_held(&sdev->inquiry_mutex));
 	rcu_swap_protected(sdev->vpd_pg80, vpd_pg80,
 			   lockdep_is_held(&sdev->inquiry_mutex));
 	rcu_swap_protected(sdev->vpd_pg83, vpd_pg83,
 			   lockdep_is_held(&sdev->inquiry_mutex));
+	rcu_swap_protected(sdev->vpd_pg89, vpd_pg89,
+			   lockdep_is_held(&sdev->inquiry_mutex));
 	mutex_unlock(&sdev->inquiry_mutex);
 
+	if (vpd_pg0)
+		kfree_rcu(vpd_pg0, rcu);
 	if (vpd_pg83)
 		kfree_rcu(vpd_pg83, rcu);
 	if (vpd_pg80)
 		kfree_rcu(vpd_pg80, rcu);
+	if (vpd_pg89)
+		kfree_rcu(vpd_pg89, rcu);
 	kfree(sdev->inquiry);
 	kfree(sdev);
 
@@ -840,6 +849,8 @@ static struct bin_attribute dev_attr_vpd_##_page = {		\
 
 sdev_vpd_pg_attr(pg83);
 sdev_vpd_pg_attr(pg80);
+sdev_vpd_pg_attr(pg89);
+sdev_vpd_pg_attr(pg0);
 
 static ssize_t show_inquiry(struct file *filep, struct kobject *kobj,
 			    struct bin_attribute *bin_attr,
@@ -1136,12 +1147,18 @@ static umode_t scsi_sdev_bin_attr_is_visible(struct kobject *kobj,
 	struct scsi_device *sdev = to_scsi_device(dev);
 
 
+	if (attr == &dev_attr_vpd_pg0 && !sdev->vpd_pg0)
+		return 0;
+
 	if (attr == &dev_attr_vpd_pg80 && !sdev->vpd_pg80)
 		return 0;
 
 	if (attr == &dev_attr_vpd_pg83 && !sdev->vpd_pg83)
 		return 0;
 
+	if (attr == &dev_attr_vpd_pg89 && !sdev->vpd_pg89)
+		return 0;
+
 	return S_IRUGO;
 }
 
@@ -1183,8 +1200,10 @@ static struct attribute *scsi_sdev_attrs[] = {
 };
 
 static struct bin_attribute *scsi_sdev_bin_attrs[] = {
+	&dev_attr_vpd_pg0,
 	&dev_attr_vpd_pg83,
 	&dev_attr_vpd_pg80,
+	&dev_attr_vpd_pg89,
 	&dev_attr_inquiry,
 	NULL
 };
diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
index 571ddb49b926..f4f176c79fae 100644
--- a/include/scsi/scsi_device.h
+++ b/include/scsi/scsi_device.h
@@ -135,8 +135,10 @@ struct scsi_device {
 	const char * rev;		/* ... "nullnullnullnull" before scan */
 
 #define SCSI_VPD_PG_LEN                255
+	struct scsi_vpd __rcu *vpd_pg0;
 	struct scsi_vpd __rcu *vpd_pg83;
 	struct scsi_vpd __rcu *vpd_pg80;
+	struct scsi_vpd __rcu *vpd_pg89;
 	unsigned char current_tag;	/* current tag */
 	struct scsi_target      *sdev_target;   /* used only for single_lun */
 
-- 
2.23.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] scsi: Add sysfs attributes for VPD pages 0h and 89h
  2019-09-26 16:22 [PATCH v2] scsi: Add sysfs attributes for VPD pages 0h and 89h Ryan Attard
@ 2019-09-27  2:44 ` Bart Van Assche
  2019-10-01  3:26 ` Martin K. Petersen
  2019-10-08 11:30 ` Hannes Reinecke
  2 siblings, 0 replies; 4+ messages in thread
From: Bart Van Assche @ 2019-09-27  2:44 UTC (permalink / raw)
  To: Ryan Attard, jejb, martin.petersen, linux-scsi

On 2019-09-26 09:22, Ryan Attard wrote:
> Add sysfs attributes for the ATA information page and
> Supported VPD Pages page.

Reviewed-by: Bart Van Assche <bvanassche@acm.org>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] scsi: Add sysfs attributes for VPD pages 0h and 89h
  2019-09-26 16:22 [PATCH v2] scsi: Add sysfs attributes for VPD pages 0h and 89h Ryan Attard
  2019-09-27  2:44 ` Bart Van Assche
@ 2019-10-01  3:26 ` Martin K. Petersen
  2019-10-08 11:30 ` Hannes Reinecke
  2 siblings, 0 replies; 4+ messages in thread
From: Martin K. Petersen @ 2019-10-01  3:26 UTC (permalink / raw)
  To: Ryan Attard; +Cc: jejb, martin.petersen, linux-scsi


Ryan,

> Add sysfs attributes for the ATA information page and Supported VPD
> Pages page.

Applied to 5.5/scsi-queue, thank you.

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] scsi: Add sysfs attributes for VPD pages 0h and 89h
  2019-09-26 16:22 [PATCH v2] scsi: Add sysfs attributes for VPD pages 0h and 89h Ryan Attard
  2019-09-27  2:44 ` Bart Van Assche
  2019-10-01  3:26 ` Martin K. Petersen
@ 2019-10-08 11:30 ` Hannes Reinecke
  2 siblings, 0 replies; 4+ messages in thread
From: Hannes Reinecke @ 2019-10-08 11:30 UTC (permalink / raw)
  To: Ryan Attard, jejb, martin.petersen, linux-scsi

On 9/26/19 6:22 PM, Ryan Attard wrote:
> Add sysfs attributes for the ATA information page and
> Supported VPD Pages page.
> 
> Signed-off-by: Ryan Attard <ryanattard@ryanattard.info>
> ---
>  drivers/scsi/scsi.c        |  4 ++++
>  drivers/scsi/scsi_sysfs.c  | 19 +++++++++++++++++++
>  include/scsi/scsi_device.h |  2 ++
>  3 files changed, 25 insertions(+)
> 
> diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
> index a7e4fba724b7..088b8ca473e6 100644
> --- a/drivers/scsi/scsi.c
> +++ b/drivers/scsi/scsi.c
> @@ -485,10 +485,14 @@ void scsi_attach_vpd(struct scsi_device *sdev)
>  		return;
>  
>  	for (i = 4; i < vpd_buf->len; i++) {
> +		if (vpd_buf->data[i] == 0x0)
> +			scsi_update_vpd_page(sdev, 0x0, &sdev->vpd_pg0);
>  		if (vpd_buf->data[i] == 0x80)
>  			scsi_update_vpd_page(sdev, 0x80, &sdev->vpd_pg80);
>  		if (vpd_buf->data[i] == 0x83)
>  			scsi_update_vpd_page(sdev, 0x83, &sdev->vpd_pg83);
> +		if (vpd_buf->data[i] == 0x89)
> +			scsi_update_vpd_page(sdev, 0x89, &sdev->vpd_pg89);
>  	}
>  	kfree(vpd_buf);
>  }
> diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
> index 8ce12ffcbb7a..eb6764f92c93 100644
> --- a/drivers/scsi/scsi_sysfs.c
> +++ b/drivers/scsi/scsi_sysfs.c
> @@ -429,6 +429,7 @@ static void scsi_device_dev_release_usercontext(struct work_struct *work)
>  	struct device *parent;
>  	struct list_head *this, *tmp;
>  	struct scsi_vpd *vpd_pg80 = NULL, *vpd_pg83 = NULL;
> +	struct scsi_vpd *vpd_pg0 = NULL, *vpd_pg89 = NULL;
>  	unsigned long flags;
>  
>  	sdev = container_of(work, struct scsi_device, ew.work);
> @@ -458,16 +459,24 @@ static void scsi_device_dev_release_usercontext(struct work_struct *work)
>  	sdev->request_queue = NULL;
>  
>  	mutex_lock(&sdev->inquiry_mutex);
> +	rcu_swap_protected(sdev->vpd_pg0, vpd_pg0,
> +			   lockdep_is_held(&sdev->inquiry_mutex));
>  	rcu_swap_protected(sdev->vpd_pg80, vpd_pg80,
>  			   lockdep_is_held(&sdev->inquiry_mutex));
>  	rcu_swap_protected(sdev->vpd_pg83, vpd_pg83,
>  			   lockdep_is_held(&sdev->inquiry_mutex));
> +	rcu_swap_protected(sdev->vpd_pg89, vpd_pg89,
> +			   lockdep_is_held(&sdev->inquiry_mutex));
>  	mutex_unlock(&sdev->inquiry_mutex);
>  
> +	if (vpd_pg0)
> +		kfree_rcu(vpd_pg0, rcu);
>  	if (vpd_pg83)
>  		kfree_rcu(vpd_pg83, rcu);
>  	if (vpd_pg80)
>  		kfree_rcu(vpd_pg80, rcu);
> +	if (vpd_pg89)
> +		kfree_rcu(vpd_pg89, rcu);
>  	kfree(sdev->inquiry);
>  	kfree(sdev);
>  
> @@ -840,6 +849,8 @@ static struct bin_attribute dev_attr_vpd_##_page = {		\
>  
>  sdev_vpd_pg_attr(pg83);
>  sdev_vpd_pg_attr(pg80);
> +sdev_vpd_pg_attr(pg89);
> +sdev_vpd_pg_attr(pg0);
>  
>  static ssize_t show_inquiry(struct file *filep, struct kobject *kobj,
>  			    struct bin_attribute *bin_attr,
> @@ -1136,12 +1147,18 @@ static umode_t scsi_sdev_bin_attr_is_visible(struct kobject *kobj,
>  	struct scsi_device *sdev = to_scsi_device(dev);
>  
>  
> +	if (attr == &dev_attr_vpd_pg0 && !sdev->vpd_pg0)
> +		return 0;
> +
>  	if (attr == &dev_attr_vpd_pg80 && !sdev->vpd_pg80)
>  		return 0;
>  
>  	if (attr == &dev_attr_vpd_pg83 && !sdev->vpd_pg83)
>  		return 0;
>  
> +	if (attr == &dev_attr_vpd_pg89 && !sdev->vpd_pg89)
> +		return 0;
> +
>  	return S_IRUGO;
>  }
>  
> @@ -1183,8 +1200,10 @@ static struct attribute *scsi_sdev_attrs[] = {
>  };
>  
>  static struct bin_attribute *scsi_sdev_bin_attrs[] = {
> +	&dev_attr_vpd_pg0,
>  	&dev_attr_vpd_pg83,
>  	&dev_attr_vpd_pg80,
> +	&dev_attr_vpd_pg89,
>  	&dev_attr_inquiry,
>  	NULL
>  };
> diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
> index 571ddb49b926..f4f176c79fae 100644
> --- a/include/scsi/scsi_device.h
> +++ b/include/scsi/scsi_device.h
> @@ -135,8 +135,10 @@ struct scsi_device {
>  	const char * rev;		/* ... "nullnullnullnull" before scan */
>  
>  #define SCSI_VPD_PG_LEN                255
> +	struct scsi_vpd __rcu *vpd_pg0;
>  	struct scsi_vpd __rcu *vpd_pg83;
>  	struct scsi_vpd __rcu *vpd_pg80;
> +	struct scsi_vpd __rcu *vpd_pg89;
>  	unsigned char current_tag;	/* current tag */
>  	struct scsi_target      *sdev_target;   /* used only for single_lun */
>  
> 
Reviewed-by: Hannes Reinecke <hare@suse.com>

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		      Teamlead Storage & Networking
hare@suse.de			                  +49 911 74053 688
SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 247165 (AG München), GF: Felix Imendörffer

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-10-08 11:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-09-26 16:22 [PATCH v2] scsi: Add sysfs attributes for VPD pages 0h and 89h Ryan Attard
2019-09-27  2:44 ` Bart Van Assche
2019-10-01  3:26 ` Martin K. Petersen
2019-10-08 11:30 ` Hannes Reinecke

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).