linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH v2] scsi: libsas: no need to join wide port again in sas_ex_discover_dev()
  2019-05-20 14:06 [PATCH v2] scsi: libsas: no need to join wide port again in sas_ex_discover_dev() Jason Yan
@ 2019-05-20 13:51 ` John Garry
  2019-05-30  2:11 ` Martin K. Petersen
  1 sibling, 0 replies; 3+ messages in thread
From: John Garry @ 2019-05-20 13:51 UTC (permalink / raw)
  To: Jason Yan, martin.petersen, jejb
  Cc: linux-scsi, linux-kernel, hare, dan.j.williams, jthumshirn, hch,
	huangdaode, chenxiang66, miaoxie, zhaohongjiang

On 20/05/2019 15:06, Jason Yan wrote:
> Since we are processing events synchronously now, the second call of
> sas_ex_join_wide_port() in sas_ex_discover_dev() is not needed. There
> will be no races with other works in disco workqueue. So remove the
> second sas_ex_join_wide_port().
>
> I did not change the return value of 'res' to error when discover failed
> because we need to continue to discover other phys if one phy discover
> failed. So let's keep that logic as before and just add a debug log to
> detect the failure. And directly return if second fanout expander
> attatched to the parent expander because it has nothing to do after the
> phy is disabled.
>
> Signed-off-by: Jason Yan <yanaijie@huawei.com>
> ---

Reviewed-by: John Garry <john.garry@huawei.com>


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

* [PATCH v2] scsi: libsas: no need to join wide port again in sas_ex_discover_dev()
@ 2019-05-20 14:06 Jason Yan
  2019-05-20 13:51 ` John Garry
  2019-05-30  2:11 ` Martin K. Petersen
  0 siblings, 2 replies; 3+ messages in thread
From: Jason Yan @ 2019-05-20 14:06 UTC (permalink / raw)
  To: martin.petersen, jejb
  Cc: linux-scsi, linux-kernel, hare, dan.j.williams, jthumshirn, hch,
	huangdaode, chenxiang66, miaoxie, john.garry, zhaohongjiang,
	Jason Yan

Since we are processing events synchronously now, the second call of
sas_ex_join_wide_port() in sas_ex_discover_dev() is not needed. There
will be no races with other works in disco workqueue. So remove the
second sas_ex_join_wide_port().

I did not change the return value of 'res' to error when discover failed
because we need to continue to discover other phys if one phy discover
failed. So let's keep that logic as before and just add a debug log to
detect the failure. And directly return if second fanout expander
attatched to the parent expander because it has nothing to do after the
phy is disabled.

Signed-off-by: Jason Yan <yanaijie@huawei.com>
---

v2: Directly return in the "second fanout expander" case and change the
	log level to notice.

 drivers/scsi/libsas/sas_expander.c | 26 ++++----------------------
 1 file changed, 4 insertions(+), 22 deletions(-)

diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c
index 83f2fd70ce76..a148be23ca09 100644
--- a/drivers/scsi/libsas/sas_expander.c
+++ b/drivers/scsi/libsas/sas_expander.c
@@ -1104,7 +1104,7 @@ static int sas_ex_discover_dev(struct domain_device *dev, int phy_id)
 				 SAS_ADDR(dev->sas_addr),
 				 phy_id);
 			sas_ex_disable_phy(dev, phy_id);
-			break;
+			return res;
 		} else
 			memcpy(dev->port->disc.fanout_sas_addr,
 			       ex_phy->attached_sas_addr, SAS_ADDR_SIZE);
@@ -1116,27 +1116,9 @@ static int sas_ex_discover_dev(struct domain_device *dev, int phy_id)
 		break;
 	}
 
-	if (child) {
-		int i;
-
-		for (i = 0; i < ex->num_phys; i++) {
-			if (ex->ex_phy[i].phy_state == PHY_VACANT ||
-			    ex->ex_phy[i].phy_state == PHY_NOT_PRESENT)
-				continue;
-			/*
-			 * Due to races, the phy might not get added to the
-			 * wide port, so we add the phy to the wide port here.
-			 */
-			if (SAS_ADDR(ex->ex_phy[i].attached_sas_addr) ==
-			    SAS_ADDR(child->sas_addr)) {
-				ex->ex_phy[i].phy_state= PHY_DEVICE_DISCOVERED;
-				if (sas_ex_join_wide_port(dev, i))
-					pr_debug("Attaching ex phy%02d to wide port %016llx\n",
-						 i, SAS_ADDR(ex->ex_phy[i].attached_sas_addr));
-			}
-		}
-	}
-
+	if (!child)
+		pr_notice("ex %016llx phy%02d failed to discover\n",
+			  SAS_ADDR(dev->sas_addr), phy_id);
 	return res;
 }
 
-- 
2.17.2


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

* Re: [PATCH v2] scsi: libsas: no need to join wide port again in sas_ex_discover_dev()
  2019-05-20 14:06 [PATCH v2] scsi: libsas: no need to join wide port again in sas_ex_discover_dev() Jason Yan
  2019-05-20 13:51 ` John Garry
@ 2019-05-30  2:11 ` Martin K. Petersen
  1 sibling, 0 replies; 3+ messages in thread
From: Martin K. Petersen @ 2019-05-30  2:11 UTC (permalink / raw)
  To: Jason Yan
  Cc: martin.petersen, jejb, linux-scsi, linux-kernel, hare,
	dan.j.williams, jthumshirn, hch, huangdaode, chenxiang66,
	miaoxie, john.garry, zhaohongjiang


Jason,

> Since we are processing events synchronously now, the second call of
> sas_ex_join_wide_port() in sas_ex_discover_dev() is not needed. There
> will be no races with other works in disco workqueue. So remove the
> second sas_ex_join_wide_port().

Applied to 5.3/scsi-queue, thanks!

-- 
Martin K. Petersen	Oracle Linux Engineering

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

end of thread, other threads:[~2019-05-30  2:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-20 14:06 [PATCH v2] scsi: libsas: no need to join wide port again in sas_ex_discover_dev() Jason Yan
2019-05-20 13:51 ` John Garry
2019-05-30  2:11 ` Martin K. Petersen

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).