From: Dan Williams <dan.j.williams@intel.com>
To: linux-scsi@vger.kernel.org
Cc: linux-ide@vger.kernel.org
Subject: [PATCH v3 06/14] libsas: sas_phy_enable via transport_sas_phy_reset
Date: Thu, 05 Jan 2012 16:59:31 -0800 [thread overview]
Message-ID: <20120106005931.11464.75965.stgit@localhost6.localdomain6> (raw)
In-Reply-To: <20120106005634.11464.64030.stgit@localhost6.localdomain6>
Execute the link-reset triggered by sas_phy_enable via
transport_sas_phy_reset so that it can be managed by libata.
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
---
drivers/scsi/libsas/sas_init.c | 57 ++++++++++++++++++++++++++++++-----
drivers/scsi/libsas/sas_internal.h | 3 ++
drivers/scsi/libsas/sas_scsi_host.c | 1 -
include/scsi/libsas.h | 1 -
4 files changed, 52 insertions(+), 10 deletions(-)
diff --git a/drivers/scsi/libsas/sas_init.c b/drivers/scsi/libsas/sas_init.c
index a15fb86..53ae893 100644
--- a/drivers/scsi/libsas/sas_init.c
+++ b/drivers/scsi/libsas/sas_init.c
@@ -249,15 +249,15 @@ static int transport_sas_phy_reset(struct sas_phy *phy, int hard_reset)
return ret;
}
-int sas_phy_enable(struct sas_phy *phy, int enable)
+static int sas_phy_enable(struct sas_phy *phy, int enable)
{
int ret;
- enum phy_func command;
+ enum phy_func cmd;
if (enable)
- command = PHY_FUNC_LINK_RESET;
+ cmd = PHY_FUNC_LINK_RESET;
else
- command = PHY_FUNC_DISABLE;
+ cmd = PHY_FUNC_DISABLE;
if (scsi_is_sas_phy_local(phy)) {
struct Scsi_Host *shost = dev_to_shost(phy->dev.parent);
@@ -266,15 +266,21 @@ int sas_phy_enable(struct sas_phy *phy, int enable)
struct sas_internal *i =
to_sas_internal(sas_ha->core.shost->transportt);
- if (!enable) {
+ if (enable)
+ ret = transport_sas_phy_reset(phy, 0);
+ else {
sas_phy_disconnected(asd_phy);
sas_ha->notify_phy_event(asd_phy, PHYE_LOSS_OF_SIGNAL);
+ ret = i->dft->lldd_control_phy(asd_phy, cmd, NULL);
}
- ret = i->dft->lldd_control_phy(asd_phy, command, NULL);
} else {
struct sas_rphy *rphy = dev_to_rphy(phy->dev.parent);
struct domain_device *ddev = sas_find_dev_by_rphy(rphy);
- ret = sas_smp_phy_control(ddev, phy->number, command, NULL);
+
+ if (enable)
+ ret = transport_sas_phy_reset(phy, 0);
+ else
+ ret = sas_smp_phy_control(ddev, phy->number, cmd, NULL);
}
return ret;
}
@@ -357,6 +363,13 @@ static void phy_reset_work(struct work_struct *work)
d->reset_result = transport_sas_phy_reset(d->phy, d->hard_reset);
}
+static void phy_enable_work(struct work_struct *work)
+{
+ struct sas_phy_data *d = container_of(work, typeof(*d), enable_work);
+
+ d->enable_result = sas_phy_enable(d->phy, d->enable);
+}
+
static int sas_phy_setup(struct sas_phy *phy)
{
struct sas_phy_data *d = kzalloc(sizeof(*d), GFP_KERNEL);
@@ -366,6 +379,7 @@ static int sas_phy_setup(struct sas_phy *phy)
mutex_init(&d->event_lock);
INIT_WORK(&d->reset_work, phy_reset_work);
+ INIT_WORK(&d->enable_work, phy_enable_work);
d->phy = phy;
phy->hostdata = d;
@@ -399,8 +413,35 @@ static int queue_phy_reset(struct sas_phy *phy, int hard_reset)
return rc;
}
+static int queue_phy_enable(struct sas_phy *phy, int enable)
+{
+ struct Scsi_Host *shost = dev_to_shost(phy->dev.parent);
+ struct sas_ha_struct *ha = SHOST_TO_SAS_HA(shost);
+ struct sas_phy_data *d = phy->hostdata;
+ int rc;
+
+ if (!d)
+ return -ENOMEM;
+
+ /* libsas workqueue coordinates ata-eh reset with discovery */
+ mutex_lock(&d->event_lock);
+ d->enable_result = 0;
+ d->enable = enable;
+
+ spin_lock_irq(&ha->state_lock);
+ sas_queue_work(ha, &d->enable_work);
+ spin_unlock_irq(&ha->state_lock);
+
+ rc = sas_drain_work(ha);
+ if (rc == 0)
+ rc = d->enable_result;
+ mutex_unlock(&d->event_lock);
+
+ return rc;
+}
+
static struct sas_function_template sft = {
- .phy_enable = sas_phy_enable,
+ .phy_enable = queue_phy_enable,
.phy_reset = queue_phy_reset,
.phy_setup = sas_phy_setup,
.phy_release = sas_phy_release,
diff --git a/drivers/scsi/libsas/sas_internal.h b/drivers/scsi/libsas/sas_internal.h
index ae9698d..9e960b2 100644
--- a/drivers/scsi/libsas/sas_internal.h
+++ b/drivers/scsi/libsas/sas_internal.h
@@ -45,6 +45,9 @@ struct sas_phy_data {
int hard_reset;
int reset_result;
struct work_struct reset_work;
+ int enable;
+ int enable_result;
+ struct work_struct enable_work;
};
void sas_scsi_recover_host(struct Scsi_Host *shost);
diff --git a/drivers/scsi/libsas/sas_scsi_host.c b/drivers/scsi/libsas/sas_scsi_host.c
index 57a3484..b849dcd 100644
--- a/drivers/scsi/libsas/sas_scsi_host.c
+++ b/drivers/scsi/libsas/sas_scsi_host.c
@@ -1077,7 +1077,6 @@ EXPORT_SYMBOL_GPL(sas_change_queue_type);
EXPORT_SYMBOL_GPL(sas_bios_param);
EXPORT_SYMBOL_GPL(sas_task_abort);
EXPORT_SYMBOL_GPL(sas_phy_reset);
-EXPORT_SYMBOL_GPL(sas_phy_enable);
EXPORT_SYMBOL_GPL(sas_eh_device_reset_handler);
EXPORT_SYMBOL_GPL(sas_eh_bus_reset_handler);
EXPORT_SYMBOL_GPL(sas_slave_alloc);
diff --git a/include/scsi/libsas.h b/include/scsi/libsas.h
index a32407f..04b74bf 100644
--- a/include/scsi/libsas.h
+++ b/include/scsi/libsas.h
@@ -630,7 +630,6 @@ extern int sas_unregister_ha(struct sas_ha_struct *);
int sas_set_phy_speed(struct sas_phy *phy,
struct sas_phy_linkrates *rates);
-int sas_phy_enable(struct sas_phy *phy, int enabled);
int sas_phy_reset(struct sas_phy *phy, int hard_reset);
int sas_queue_up(struct sas_task *task);
extern int sas_queuecommand(struct Scsi_Host * ,struct scsi_cmnd *);
next prev parent reply other threads:[~2012-01-06 0:59 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-06 0:59 [GIT PATCH v3 00/14] libsas: eh reworks (ata-eh vs discovery, races, ...) Dan Williams
2012-01-06 0:59 ` [PATCH v3 01/14] libsas: introduce sas_drain_work() Dan Williams
2012-01-06 0:59 ` [PATCH v3 02/14] libsas: remove ata_port.lock management duties from lldds Dan Williams
2012-01-06 0:59 ` [PATCH v3 03/14] libsas: prevent domain rediscovery competing with ata error handling Dan Williams
2012-01-09 19:14 ` Dan Williams
2012-01-09 20:03 ` Dan Williams
2012-01-06 0:59 ` [PATCH v3 04/14] libsas: fix timeout vs completion race Dan Williams
2012-01-06 0:59 ` [PATCH v3 05/14] libsas: perform sas-transport resets in shost->workq context Dan Williams
2012-01-06 0:59 ` Dan Williams [this message]
2012-01-06 0:59 ` [PATCH v3 07/14] libsas: async ata-eh Dan Williams
2012-01-06 0:59 ` [PATCH v3 08/14] isci: kill iphy->isci_port lookups Dan Williams
2012-01-23 23:45 ` Dan Williams
2012-01-06 0:59 ` [PATCH v3 09/14] isci: kill isci_port->status Dan Williams
2012-01-06 0:59 ` [PATCH v3 10/14] isci: fix interpretation of "hard" reset Dan Williams
2012-01-06 0:59 ` [PATCH v3 11/14] isci: stop interpreting ->lldd_lu_reset() as an ata soft-reset Dan Williams
2012-01-06 1:00 ` [PATCH v3 12/14] isci: ->lldd_ata_check_ready handler Dan Williams
2012-01-09 1:57 ` Jack Wang
2012-01-09 19:26 ` Dan Williams
2012-01-06 1:00 ` [PATCH v3 13/14] isci: remove bus and reset handlers Dan Williams
2012-01-06 1:00 ` [PATCH v3 14/14] isci: remove IDEV_EH hack to disable "discovery-time" ata resets Dan Williams
2012-01-06 1:46 ` [GIT PATCH v3 00/14] libsas: eh reworks (ata-eh vs discovery, races, ...) Dan Williams
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120106005931.11464.75965.stgit@localhost6.localdomain6 \
--to=dan.j.williams@intel.com \
--cc=linux-ide@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox