Unverified Commit 349daf70 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!12136 Backport some SAS patches to OLK-5.10

Merge Pull Request from: @chenyi211 
 
Conflicts:
drivers/scsi/libsas/sas_expander.c (scsi: libsas: Move sas_add_parent_port() to sas_expander.c)

Xingui Yang (5):
  scsi: libsas: Add helper for port add ex_phy
  scsi: libsas: Move sas_add_parent_port() to sas_expander.c
  scsi: libsas: Set port when ex_phy is added or deleted
  scsi: libsas: Fix the failure of adding phy with zero-address to port
  scsi: libsas: Fix exp-attached device scan after probe failure scanned in again after probe failed

 
 
Link:https://gitee.com/openeuler/kernel/pulls/12136

 

Reviewed-by: default avatarYihang Li <liyihang9@huawei.com>
Reviewed-by: default avatarYu Kuai <yukuai3@huawei.com>
Signed-off-by: default avatarYang Yingliang <yangyingliang@huawei.com>
parents af371d58 d55a2f89
Loading
Loading
Loading
Loading
+30 −8
Original line number Diff line number Diff line
@@ -26,6 +26,28 @@ static int sas_configure_phy(struct domain_device *dev, int phy_id,
			     u8 *sas_addr, int include);
static int sas_disable_routing(struct domain_device *dev,  u8 *sas_addr);

static void sas_port_add_ex_phy(struct sas_port *port, struct ex_phy *ex_phy)
{
	sas_port_add_phy(port, ex_phy->phy);
	ex_phy->port = port;
	ex_phy->phy_state = PHY_DEVICE_DISCOVERED;
}

static void sas_ex_add_parent_port(struct domain_device *dev, int phy_id)
{
	struct expander_device *ex = &dev->ex_dev;
	struct ex_phy *ex_phy = &ex->ex_phy[phy_id];

	if (!ex->parent_port) {
		ex->parent_port = sas_port_alloc(&dev->rphy->dev, phy_id);
		/* FIXME: error handling */
		BUG_ON(!ex->parent_port);
		BUG_ON(sas_port_add(ex->parent_port));
		sas_port_mark_backlink(ex->parent_port);
	}
	sas_port_add_ex_phy(ex->parent_port, ex_phy);
}

/* ---------- SMP task management ---------- */

static void smp_task_timedout(struct timer_list *t)
@@ -259,8 +281,7 @@ static void sas_set_ex_phy(struct domain_device *dev, int phy_id, void *rsp)
	/* help some expanders that fail to zero sas_address in the 'no
	 * device' case
	 */
	if (phy->attached_dev_type == SAS_PHY_UNUSED ||
	    phy->linkrate < SAS_LINK_RATE_1_5_GBPS)
	if (phy->attached_dev_type == SAS_PHY_UNUSED)
		memset(phy->attached_sas_addr, 0, SAS_ADDR_SIZE);
	else
		memcpy(phy->attached_sas_addr, dr->attached_sas_addr, SAS_ADDR_SIZE);
@@ -927,9 +948,7 @@ static bool sas_ex_join_wide_port(struct domain_device *parent, int phy_id)

		if (!memcmp(phy->attached_sas_addr, ephy->attached_sas_addr,
			    SAS_ADDR_SIZE) && ephy->port) {
			sas_port_add_phy(ephy->port, phy->phy);
			phy->port = ephy->port;
			phy->phy_state = PHY_DEVICE_DISCOVERED;
			sas_port_add_ex_phy(ephy->port, phy);
			return true;
		}
	}
@@ -1034,12 +1053,12 @@ static int sas_ex_discover_dev(struct domain_device *dev, int phy_id)
	/* Parent and domain coherency */
	if (!dev->parent && (SAS_ADDR(ex_phy->attached_sas_addr) ==
			     SAS_ADDR(dev->port->sas_addr))) {
		sas_add_parent_port(dev, phy_id);
		sas_ex_add_parent_port(dev, phy_id);
		return 0;
	}
	if (dev->parent && (SAS_ADDR(ex_phy->attached_sas_addr) ==
			    SAS_ADDR(dev->parent->sas_addr))) {
		sas_add_parent_port(dev, phy_id);
		sas_ex_add_parent_port(dev, phy_id);
		if (ex_phy->routing_attr == TABLE_ROUTING)
			sas_configure_phy(dev, phy_id, dev->port->sas_addr, 1);
		return 0;
@@ -1903,9 +1922,12 @@ static void sas_unregister_devs_sas_addr(struct domain_device *parent,
	if (phy->port) {
		sas_port_delete_phy(phy->port, phy->phy);
		sas_device_set_phy(found, phy->port);
		if (phy->port->num_phys == 0)
		if (phy->port->num_phys == 0) {
			list_add_tail(&phy->port->del_list,
				&parent->port->sas_port_del_list);
			if (ex_dev->parent_port == phy->port)
				ex_dev->parent_port = NULL;
		}
		phy->port = NULL;
	}
}
+14 −15
Original line number Diff line number Diff line
@@ -115,6 +115,20 @@ static inline void sas_fail_probe(struct domain_device *dev, const char *func, i
		func, dev->parent ? "exp-attached" :
		"direct-attached",
		SAS_ADDR(dev->sas_addr), err);

	/*
	 * If the device probe failed, the expander phy attached address
	 * needs to be reset so that the phy will not be treated as flutter
	 * in the next revalidation
	 */
	if (dev->parent && !dev_is_expander(dev->dev_type)) {
		struct sas_phy *phy = dev->phy;
		struct domain_device *parent = dev->parent;
		struct ex_phy *ex_phy = &parent->ex_dev.ex_phy[phy->number];

		memset(ex_phy->attached_sas_addr, 0, SAS_ADDR_SIZE);
	}

	sas_unregister_dev(dev->port, dev);
}

@@ -159,21 +173,6 @@ static inline void sas_phy_set_target(struct asd_sas_phy *p, struct domain_devic
	}
}

static inline void sas_add_parent_port(struct domain_device *dev, int phy_id)
{
	struct expander_device *ex = &dev->ex_dev;
	struct ex_phy *ex_phy = &ex->ex_phy[phy_id];

	if (!ex->parent_port) {
		ex->parent_port = sas_port_alloc(&dev->rphy->dev, phy_id);
		/* FIXME: error handling */
		BUG_ON(!ex->parent_port);
		BUG_ON(sas_port_add(ex->parent_port));
		sas_port_mark_backlink(ex->parent_port);
	}
	sas_port_add_phy(ex->parent_port, ex_phy->phy);
}

static inline struct domain_device *sas_alloc_device(void)
{
	struct domain_device *dev = kzalloc(sizeof(*dev), GFP_KERNEL);