* [PATCH v2 0/3] Three small fixes for libsas
@ 2018-01-04 11:47 Jason Yan
2018-01-04 11:47 ` [PATCH v2 1/3] scsi: libsas: fix memory leak in sas_smp_get_phy_events() Jason Yan
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Jason Yan @ 2018-01-04 11:47 UTC (permalink / raw)
To: martin.petersen, jejb
Cc: linux-scsi, zhaohongjiang, miaoxie, hch, hare, Jason Yan
We've found three small bugs. Please consider including them for 4.15.
V2:
- Add "Fixes" tag.
Jason Yan (2):
scsi: libsas: fix memory leak in sas_smp_get_phy_events()
scsi: libsas: fix error when getting phy events
chenxiang (1):
scsi: libsas: initialize sas_phy status according to response of
DISCOVER
drivers/scsi/libsas/sas_expander.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
--
2.9.5
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v2 1/3] scsi: libsas: fix memory leak in sas_smp_get_phy_events()
2018-01-04 11:47 [PATCH v2 0/3] Three small fixes for libsas Jason Yan
@ 2018-01-04 11:47 ` Jason Yan
2018-01-04 12:38 ` Christoph Hellwig
2018-01-04 11:47 ` [PATCH v2 2/3] scsi: libsas: fix error when getting phy events Jason Yan
2018-01-04 11:47 ` [PATCH v2 3/3] scsi: libsas: initialize sas_phy status according to response of DISCOVER Jason Yan
2 siblings, 1 reply; 8+ messages in thread
From: Jason Yan @ 2018-01-04 11:47 UTC (permalink / raw)
To: martin.petersen, jejb
Cc: linux-scsi, zhaohongjiang, miaoxie, hch, hare, Jason Yan,
John Garry, chenqilin, chenxiang
We've got a memory leak with the following producer:
while true;
do cat /sys/class/sas_phy/phy-1:0:12/invalid_dword_count >/dev/null;
done
The buffer req is allocated and not freed after we return. Fix it.
Fixes: 2908d778ab3e ("[SCSI] aic94xx: new driver")
Signed-off-by: Jason Yan <yanaijie@huawei.com>
CC: John Garry <john.garry@huawei.com>
CC: chenqilin <chenqilin2@huawei.com>
CC: chenxiang <chenxiang66@hisilicon.com>
---
drivers/scsi/libsas/sas_expander.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c
index 3183d63..4b0c67f 100644
--- a/drivers/scsi/libsas/sas_expander.c
+++ b/drivers/scsi/libsas/sas_expander.c
@@ -695,6 +695,7 @@ int sas_smp_get_phy_events(struct sas_phy *phy)
phy->phy_reset_problem_count = scsi_to_u32(&resp[24]);
out:
+ kfree(req);
kfree(resp);
return res;
--
2.9.5
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 2/3] scsi: libsas: fix error when getting phy events
2018-01-04 11:47 [PATCH v2 0/3] Three small fixes for libsas Jason Yan
2018-01-04 11:47 ` [PATCH v2 1/3] scsi: libsas: fix memory leak in sas_smp_get_phy_events() Jason Yan
@ 2018-01-04 11:47 ` Jason Yan
2018-01-04 12:39 ` Christoph Hellwig
2018-01-04 11:47 ` [PATCH v2 3/3] scsi: libsas: initialize sas_phy status according to response of DISCOVER Jason Yan
2 siblings, 1 reply; 8+ messages in thread
From: Jason Yan @ 2018-01-04 11:47 UTC (permalink / raw)
To: martin.petersen, jejb
Cc: linux-scsi, zhaohongjiang, miaoxie, hch, hare, Jason Yan,
John Garry, chenqilin, chenxiang
The intend purpose here was to goto out if smp_execute_task() returned
error. Obviously something got screwed up. We will never get these link
error statistics below:
~:/sys/class/sas_phy/phy-1:0:12 # cat invalid_dword_count
0
~:/sys/class/sas_phy/phy-1:0:12 # cat running_disparity_error_count
0
~:/sys/class/sas_phy/phy-1:0:12 # cat loss_of_dword_sync_count
0
~:/sys/class/sas_phy/phy-1:0:12 # cat phy_reset_problem_count
0
Obviously we should goto error handler if smp_execute_task() returns
non-zero.
Fixes: 2908d778ab3e ("[SCSI] aic94xx: new driver")
Signed-off-by: Jason Yan <yanaijie@huawei.com>
CC: John Garry <john.garry@huawei.com>
CC: chenqilin <chenqilin2@huawei.com>
CC: chenxiang <chenxiang66@hisilicon.com>
---
drivers/scsi/libsas/sas_expander.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c
index 4b0c67f..6eab487 100644
--- a/drivers/scsi/libsas/sas_expander.c
+++ b/drivers/scsi/libsas/sas_expander.c
@@ -686,7 +686,7 @@ int sas_smp_get_phy_events(struct sas_phy *phy)
res = smp_execute_task(dev, req, RPEL_REQ_SIZE,
resp, RPEL_RESP_SIZE);
- if (!res)
+ if (res)
goto out;
phy->invalid_dword_count = scsi_to_u32(&resp[12]);
--
2.9.5
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v2 3/3] scsi: libsas: initialize sas_phy status according to response of DISCOVER
2018-01-04 11:47 [PATCH v2 0/3] Three small fixes for libsas Jason Yan
2018-01-04 11:47 ` [PATCH v2 1/3] scsi: libsas: fix memory leak in sas_smp_get_phy_events() Jason Yan
2018-01-04 11:47 ` [PATCH v2 2/3] scsi: libsas: fix error when getting phy events Jason Yan
@ 2018-01-04 11:47 ` Jason Yan
2018-01-04 12:41 ` Christoph Hellwig
2 siblings, 1 reply; 8+ messages in thread
From: Jason Yan @ 2018-01-04 11:47 UTC (permalink / raw)
To: martin.petersen, jejb
Cc: linux-scsi, zhaohongjiang, miaoxie, hch, hare, chenxiang,
Jason Yan
From: chenxiang <chenxiang66@hisilicon.com>
The status of SAS PHY is in sas_phy->enabled. There is an issue that the
status of a remote SAS PHY may be initialized incorrectly: if disable remote
SAS PHY through sysfs interface (such as echo 0 > /sys/class/sas_phy/phy-1:0:0/enable),
then reboot the system, and we will find the status of remote SAS PHY which is
disabled before is 1 (cat /sys/class/sas_phy/phy-1:0:0/enable). But actually
the status of remote SAS PHY is disabled and the device attached is not found.
In SAS protocol, NEGOTIATED LOGICAL LINK RATE field of DISCOVER response is 0x1
when remote SAS PHY is disabled. So initialize sas_phy->enabled according to
the value of NEGOTIATED LOGICAL LINK RATE field.
Signed-off-by: chenxiang <chenxiang66@hisilicon.com>
Reviewed-by: John Garry <john.garry@huawei.com>
Signed-off-by: Jason Yan <yanaijie@huawei.com>
---
drivers/scsi/libsas/sas_expander.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c
index 6eab487..c79cfd1 100644
--- a/drivers/scsi/libsas/sas_expander.c
+++ b/drivers/scsi/libsas/sas_expander.c
@@ -293,6 +293,7 @@ static void sas_set_ex_phy(struct domain_device *dev, int phy_id, void *rsp)
phy->phy->minimum_linkrate = dr->pmin_linkrate;
phy->phy->maximum_linkrate = dr->pmax_linkrate;
phy->phy->negotiated_linkrate = phy->linkrate;
+ phy->phy->enabled = (phy->linkrate == SAS_PHY_DISABLED) ? 0:1;
skip:
if (new_phy)
--
2.9.5
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v2 1/3] scsi: libsas: fix memory leak in sas_smp_get_phy_events()
2018-01-04 11:47 ` [PATCH v2 1/3] scsi: libsas: fix memory leak in sas_smp_get_phy_events() Jason Yan
@ 2018-01-04 12:38 ` Christoph Hellwig
0 siblings, 0 replies; 8+ messages in thread
From: Christoph Hellwig @ 2018-01-04 12:38 UTC (permalink / raw)
To: Jason Yan
Cc: martin.petersen, jejb, linux-scsi, zhaohongjiang, miaoxie, hch,
hare, John Garry, chenqilin, chenxiang
Looks good,
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 2/3] scsi: libsas: fix error when getting phy events
2018-01-04 11:47 ` [PATCH v2 2/3] scsi: libsas: fix error when getting phy events Jason Yan
@ 2018-01-04 12:39 ` Christoph Hellwig
0 siblings, 0 replies; 8+ messages in thread
From: Christoph Hellwig @ 2018-01-04 12:39 UTC (permalink / raw)
To: Jason Yan
Cc: martin.petersen, jejb, linux-scsi, zhaohongjiang, miaoxie, hch,
hare, John Garry, chenqilin, chenxiang
Looks good,
Reviewed-by: Christoph Hellwig <hch@lst.de>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 3/3] scsi: libsas: initialize sas_phy status according to response of DISCOVER
2018-01-04 11:47 ` [PATCH v2 3/3] scsi: libsas: initialize sas_phy status according to response of DISCOVER Jason Yan
@ 2018-01-04 12:41 ` Christoph Hellwig
2018-01-04 12:42 ` Jason Yan
0 siblings, 1 reply; 8+ messages in thread
From: Christoph Hellwig @ 2018-01-04 12:41 UTC (permalink / raw)
To: Jason Yan
Cc: martin.petersen, jejb, linux-scsi, zhaohongjiang, miaoxie, hch,
hare, chenxiang
On Thu, Jan 04, 2018 at 07:47:41PM +0800, Jason Yan wrote:
> + phy->phy->enabled = (phy->linkrate == SAS_PHY_DISABLED) ? 0:1;
missing whitespaces around the ":, but this could just be simplified to:
phy->phy->enabled = (phy->linkrate != SAS_PHY_DISABLED);
Otherwise this looks fine.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2 3/3] scsi: libsas: initialize sas_phy status according to response of DISCOVER
2018-01-04 12:41 ` Christoph Hellwig
@ 2018-01-04 12:42 ` Jason Yan
0 siblings, 0 replies; 8+ messages in thread
From: Jason Yan @ 2018-01-04 12:42 UTC (permalink / raw)
To: Christoph Hellwig
Cc: martin.petersen, jejb, linux-scsi, zhaohongjiang, miaoxie, hare,
chenxiang
On 2018/1/4 20:41, Christoph Hellwig wrote:
> On Thu, Jan 04, 2018 at 07:47:41PM +0800, Jason Yan wrote:
>> + phy->phy->enabled = (phy->linkrate == SAS_PHY_DISABLED) ? 0:1;
>
> missing whitespaces around the ":, but this could just be simplified to:
>
> phy->phy->enabled = (phy->linkrate != SAS_PHY_DISABLED);
>
That's better, will update. Thanks.
> Otherwise this looks fine.
>
> .
>
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2018-01-04 12:45 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-04 11:47 [PATCH v2 0/3] Three small fixes for libsas Jason Yan
2018-01-04 11:47 ` [PATCH v2 1/3] scsi: libsas: fix memory leak in sas_smp_get_phy_events() Jason Yan
2018-01-04 12:38 ` Christoph Hellwig
2018-01-04 11:47 ` [PATCH v2 2/3] scsi: libsas: fix error when getting phy events Jason Yan
2018-01-04 12:39 ` Christoph Hellwig
2018-01-04 11:47 ` [PATCH v2 3/3] scsi: libsas: initialize sas_phy status according to response of DISCOVER Jason Yan
2018-01-04 12:41 ` Christoph Hellwig
2018-01-04 12:42 ` Jason Yan
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).