Fix panic when a SES device is attached to a hpsa logical volume.
Subsystems (2)
v2 cover Fix panic when a SES device is attached to a hpsa logical volume.
The first patch provides stub implementations for scsi_is_sas_phy() and sas_get_address() for the case that CONFIG_SCSI_SAS_ATTRS is not defined.
The second patch implements the actual fix in ses.c by changing the is_sas_attached() call to scsi_is_sas_rphy().
The third and last patch removes is_sas_attached() as it doesn't have any more consumers left.
Johannes Thumshirn (3):
sas: provide stub implementations for scsi_is_sas_phy and
sas_get_address
ses: use scsi_is_sas_rphy instead of is_sas_attached
sas: remove is_sas_attached()
drivers/scsi/scsi_transport_sas.c | 16 ---------------- drivers/scsi/ses.c | 2 +- include/scsi/scsi_transport_sas.h | 12 ++++++++---- 3 files changed, 9 insertions(+), 21 deletions(-)
Signature · 1 line
1.8.5.6
PATCH v2 1/3 sas: provide stub implementations for scsi_is_sas_phy and sas_get_address
Provide stub implementations for scsi_is_sas_phy and sas_get_address for kernel configurations which do not have CONFIG_SCSI_SAS_ATTRS defined.
--- include/scsi/scsi_transport_sas.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
include/scsi/scsi_transport_sas.h +12 -2
@@ -15,8 +15,20 @@ static inline int is_sas_attached(struct scsi_device *sdev) {return 0 ; } + +static inline int scsi_is_sas_phy (const struct device *sdev) +{ +return 0 ; +} + +static inline u64 sas_get_address (struct scsi_device *sdev) +{ +return 0 ; +}#else extern int is_sas_attached (struct scsi_device *sdev); +extern int scsi_is_sas_phy (const struct device *); +u64 sas_get_address (struct scsi_device *);#endif static inline int sas_protocol_ata (enum sas_protocol proto)
@@ -187,9 +199,7 @@ extern struct sas_phy *sas_phy_alloc(struct device *, int);extern void sas_phy_free (struct sas_phy *);extern int sas_phy_add (struct sas_phy *);extern void sas_phy_delete (struct sas_phy *); -extern int scsi_is_sas_phy (const struct device *); -u64 sas_get_address (struct scsi_device *);unsigned int sas_tlr_supported (struct scsi_device *);unsigned int sas_is_tlr_enabled (struct scsi_device *);void sas_disable_tlr (struct scsi_device *);
Signature · 1 line
1.8.5.6
Re: [PATCH v2 1/3] sas: provide stub implementations for scsi_is_sas_phy and sas_get_address
include/scsi/scsi_transport_sas.h static inline int is_sas_attached(struct scsi_device *sdev) · line 27
Quoted 4 lines · Johannes Thumshirn
include/scsi/scsi_transport_sas.h +4
-0+static inline u64 sas_get_address (struct scsi_device *sdev) +{ +return 0 ; +}
To be honest, we don't want this. We do want the code to fail to compile if you ever use sas_get_address where you shouldn't because the code will be incorrect at that point. If we could return an error, fine, but we just return the address.
James
PATCH v2 2/3 ses: use scsi_is_sas_rphy instead of is_sas_attached
In reply to Johannes ThumshirnUse scsi_is_sas_rphy() instead of is_sas_attached() to decide whether we should obtain the SAS address from a scsi device or not. This will prevent us from tripping on the BUG_ON() in sas_sdev_to_rdev() if the rphy isn't attached to the SAS transport class, like it is with hpsa's logical devices.
--- drivers/scsi/ses.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/ses.c +1 -1
@@ -587,7 +587,7 @@ static void ses_match_to_enclosure(struct enclosure_device *edev,ses_enclosure_data_process (edev,to_scsi_device (edev->edev.parent),0 ); -if (is_sas_attached (sdev)) +if (scsi_is_sas_rphy (&sdev->sdev_gendev)) efd.addr =sas_get_address (sdev);if (efd.addr) {
Signature · 1 line
1.8.5.6
kbuild test robot
build botRe: [PATCH v2 2/3] ses: use scsi_is_sas_rphy instead of is_sas_attached
reproduce:
Hi Johannes,
[auto build test ERROR on scsi/for-next]
[also build test ERROR on v4.8-rc2 next-20160815]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Johannes-Thumshirn/Fix-panic-when-a-SES-device-is-attached-to-a-hpsa-logical-volume/20160815-231901 base: https://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git for-next config: i386-randconfig-h0-08161012 (attached as .config) compiler: gcc-6 (Debian 6.1.1-9) 6.1.1 20160705 reproduce: # save the attached .config to linux build tree make ARCH=i386
All errors (new ones prefixed by >>):
>> ERROR: "scsi_is_sas_rphy" [drivers/scsi/ses.ko] undefined!
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
PATCH v2 3/3 sas: remove is_sas_attached()
In reply to Johannes ThumshirnAs there are no more users of is_sas_attached() left, remove it.
--- drivers/scsi/scsi_transport_sas.c | 16 ---------------- include/scsi/scsi_transport_sas.h | 6 ------ 2 files changed, 22 deletions(-)
drivers/scsi/scsi_transport_sas.c +0 -16
@@ -341,22 +341,6 @@ static int do_sas_phy_delete(struct device *dev, void *data) }/** -* is_sas_attached - check if device is SAS attached -* @sdev: scsi device to check -* -* returns true if the device is SAS attached -*/ -int is_sas_attached (struct scsi_device *sdev) -{ -struct Scsi_Host *shost = sdev->host; - -return shost->transportt->host_attrs.ac.class == - &sas_host_class.class; -} -EXPORT_SYMBOL (is_sas_attached); - - -/** * sas_remove_children - tear down a devices SAS data structures * @dev: device belonging to the sas object *
include/scsi/scsi_transport_sas.h +0 -6
@@ -11,11 +11,6 @@ struct sas_rphy;struct request ;#if !IS_ENABLED (CONFIG_SCSI_SAS_ATTRS ) -static inline int is_sas_attached (struct scsi_device *sdev) -{ -return 0 ; -} -static inline int scsi_is_sas_phy (const struct device *sdev) {return 0 ;
@@ -26,7 +21,6 @@ static inline u64 sas_get_address(struct scsi_device *sdev) return 0; }#else -extern int is_sas_attached (struct scsi_device *sdev);extern int scsi_is_sas_phy (const struct device *);u64 sas_get_address (struct scsi_device *);#endif
Signature · 1 line
1.8.5.6