All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2 v2] ahci: EM message type auto detect
@ 2010-04-23  9:27 Harry Zhang
  2010-04-23  9:52 ` Tejun Heo
  2010-05-14 21:24 ` Jeff Garzik
  0 siblings, 2 replies; 3+ messages in thread
From: Harry Zhang @ 2010-04-23  9:27 UTC (permalink / raw)
  To: jgarzik; +Cc: linux-ide, tj, shane.huang, Zhang, Harry

To detect enclosure management message type automatically at driver
initialization, instead of using module parameter "ahci_em_messages".

Signed-off-by: Harry Zhang <harry.zhang@amd.com>
---
v2: Move this patch to the first one.

 drivers/ata/ahci.c    |    2 +-
 drivers/ata/ahci.h    |    8 +++++++-
 drivers/ata/libahci.c |   38 ++++++++++++++++++++------------------
 3 files changed, 28 insertions(+), 20 deletions(-)

diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index c44d112..8ca16f5 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -1185,7 +1185,7 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 
 		/* set enclosure management message type */
 		if (ap->flags & ATA_FLAG_EM)
-			ap->em_message_type = ahci_em_messages;
+			ap->em_message_type = hpriv->em_msg_type;
 
 
 		/* disabled/not-implemented port */
diff --git a/drivers/ata/ahci.h b/drivers/ata/ahci.h
index 733def2..5edce44 100644
--- a/drivers/ata/ahci.h
+++ b/drivers/ata/ahci.h
@@ -227,6 +227,12 @@ enum {
 	EM_CTL_RST			= (1 << 9), /* Reset */
 	EM_CTL_TM			= (1 << 8), /* Transmit Message */
 	EM_CTL_ALHD			= (1 << 26), /* Activity LED */
+
+	/* em message type */
+	EM_MSG_TYPE_LED		= (1 << 0), /* LED */
+	EM_MSG_TYPE_SAFTE	= (1 << 1), /* SAF-TE */
+	EM_MSG_TYPE_SES2	= (1 << 2), /* SES-2 */
+	EM_MSG_TYPE_SGPIO	= (1 << 3), /* SGPIO */
 };
 
 struct ahci_cmd_hdr {
@@ -282,9 +288,9 @@ struct ahci_host_priv {
 	u32			saved_cap2;	/* saved initial cap2 */
 	u32			saved_port_map;	/* saved initial port_map */
 	u32 			em_loc; /* enclosure management location */
+	u32			em_msg_type;	/* EM message type */
 };
 
-extern int ahci_em_messages;
 extern int ahci_ignore_sss;
 
 extern struct scsi_host_template ahci_sht;
diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
index 34fc57d..817bcd0 100644
--- a/drivers/ata/libahci.c
+++ b/drivers/ata/libahci.c
@@ -184,7 +184,7 @@ EXPORT_SYMBOL_GPL(ahci_em_messages);
 module_param(ahci_em_messages, int, 0444);
 /* add other LED protocol types when they become supported */
 MODULE_PARM_DESC(ahci_em_messages,
-	"Set AHCI Enclosure Management Message type (0 = disabled, 1 = LED");
+	"AHCI Enclosure Management Message control (0 = off, 1 = on)");
 
 static void ahci_enable_ahci(void __iomem *mmio)
 {
@@ -931,27 +931,29 @@ static ssize_t ahci_transmit_led_message(struct ata_port *ap, u32 state,
 		return -EBUSY;
 	}
 
-	/*
-	 * create message header - this is all zero except for
-	 * the message size, which is 4 bytes.
-	 */
-	message[0] |= (4 << 8);
+	if (hpriv->em_msg_type & EM_MSG_TYPE_LED) {
+		/*
+		 * create message header - this is all zero except for
+		 * the message size, which is 4 bytes.
+		 */
+		message[0] |= (4 << 8);
 
-	/* ignore 0:4 of byte zero, fill in port info yourself */
-	message[1] = ((state & ~EM_MSG_LED_HBA_PORT) | ap->port_no);
+		/* ignore 0:4 of byte zero, fill in port info yourself */
+		message[1] = ((state & ~EM_MSG_LED_HBA_PORT) | ap->port_no);
 
-	/* write message to EM_LOC */
-	writel(message[0], mmio + hpriv->em_loc);
-	writel(message[1], mmio + hpriv->em_loc+4);
+		/* write message to EM_LOC */
+		writel(message[0], mmio + hpriv->em_loc);
+		writel(message[1], mmio + hpriv->em_loc+4);
+
+		/*
+		 * tell hardware to transmit the message
+		 */
+		writel(em_ctl | EM_CTL_TM, mmio + HOST_EM_CTL);
+	}
 
 	/* save off new led state for port/slot */
 	emp->led_state = state;
 
-	/*
-	 * tell hardware to transmit the message
-	 */
-	writel(em_ctl | EM_CTL_TM, mmio + HOST_EM_CTL);
-
 	spin_unlock_irqrestore(ap->lock, flags);
 	return size;
 }
@@ -2094,10 +2096,10 @@ void ahci_set_em_messages(struct ahci_host_priv *hpriv,
 
 	messages = (em_ctl & EM_CTRL_MSG_TYPE) >> 16;
 
-	/* we only support LED message type right now */
-	if ((messages & 0x01) && (ahci_em_messages == 1)) {
+	if (messages) {
 		/* store em_loc */
 		hpriv->em_loc = ((em_loc >> 16) * 4);
+		hpriv->em_msg_type = messages;
 		pi->flags |= ATA_FLAG_EM;
 		if (!(em_ctl & EM_CTL_ALHD))
 			pi->flags |= ATA_FLAG_SW_ACTIVITY;
-- 
1.6.4.2




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

* Re: [PATCH 1/2 v2] ahci: EM message type auto detect
  2010-04-23  9:27 [PATCH 1/2 v2] ahci: EM message type auto detect Harry Zhang
@ 2010-04-23  9:52 ` Tejun Heo
  2010-05-14 21:24 ` Jeff Garzik
  1 sibling, 0 replies; 3+ messages in thread
From: Tejun Heo @ 2010-04-23  9:52 UTC (permalink / raw)
  To: Harry Zhang; +Cc: jgarzik, linux-ide, shane.huang

On 04/23/2010 11:27 AM, Harry Zhang wrote:
> To detect enclosure management message type automatically at driver
> initialization, instead of using module parameter "ahci_em_messages".
> 
> Signed-off-by: Harry Zhang <harry.zhang@amd.com>

Acked-by: Tejun Heo <tj@kernel.org>

Thanks.

-- 
tejun

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

* Re: [PATCH 1/2 v2] ahci: EM message type auto detect
  2010-04-23  9:27 [PATCH 1/2 v2] ahci: EM message type auto detect Harry Zhang
  2010-04-23  9:52 ` Tejun Heo
@ 2010-05-14 21:24 ` Jeff Garzik
  1 sibling, 0 replies; 3+ messages in thread
From: Jeff Garzik @ 2010-05-14 21:24 UTC (permalink / raw)
  To: Harry Zhang; +Cc: linux-ide, tj, shane.huang

On 04/23/2010 05:27 AM, Harry Zhang wrote:
> To detect enclosure management message type automatically at driver
> initialization, instead of using module parameter "ahci_em_messages".
>
> Signed-off-by: Harry Zhang<harry.zhang@amd.com>
> ---
> v2: Move this patch to the first one.
>
>   drivers/ata/ahci.c    |    2 +-
>   drivers/ata/ahci.h    |    8 +++++++-
>   drivers/ata/libahci.c |   38 ++++++++++++++++++++------------------
>   3 files changed, 28 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
> index c44d112..8ca16f5 100644
> --- a/drivers/ata/ahci.c
> +++ b/drivers/ata/ahci.c
> @@ -1185,7 +1185,7 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
>
>   		/* set enclosure management message type */
>   		if (ap->flags&  ATA_FLAG_EM)
> -			ap->em_message_type = ahci_em_messages;
> +			ap->em_message_type = hpriv->em_msg_type;
>
>
>   		/* disabled/not-implemented port */

you missed ahci_platform.c update.

applied 1-2, and fixed up this problem



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

end of thread, other threads:[~2010-05-14 21:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-23  9:27 [PATCH 1/2 v2] ahci: EM message type auto detect Harry Zhang
2010-04-23  9:52 ` Tejun Heo
2010-05-14 21:24 ` Jeff Garzik

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.