All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] ata: ahci: find eSATA ports and flag them as removable
@ 2015-09-30 19:10 Manuel Lauss
  2015-09-30 21:39 ` Tejun Heo
  0 siblings, 1 reply; 5+ messages in thread
From: Manuel Lauss @ 2015-09-30 19:10 UTC (permalink / raw)
  To: linux-ide; +Cc: Manuel Lauss

If the AHCI ports' HPCP or ESP bits are set, the port
should be considered external (e.g. eSATA) and is marked
as removable.  Userspace tools like udisks then treat it
like an usb drive.

With this patch applied, when I plug a drive into the esata port,
KDE pops up a window asking what to do with the drives(s), just
like it does for any random USB stick.

Removability is indicated to the upper layers by way of the
SCSI RMB bit, as I haven't found another way to signal
userspace to treat a sata disk like any usb stick.

Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
---
 drivers/ata/ahci.h        | 2 ++
 drivers/ata/libahci.c     | 7 +++++++
 drivers/ata/libata-scsi.c | 7 +++++--
 include/linux/libata.h    | 1 +
 4 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/drivers/ata/ahci.h b/drivers/ata/ahci.h
index 5b8e8a0..45586c1 100644
--- a/drivers/ata/ahci.h
+++ b/drivers/ata/ahci.h
@@ -181,6 +181,8 @@ enum {
 	PORT_CMD_ALPE		= (1 << 26), /* Aggressive Link PM enable */
 	PORT_CMD_ATAPI		= (1 << 24), /* Device is ATAPI */
 	PORT_CMD_FBSCP		= (1 << 22), /* FBS Capable Port */
+	PORT_CMD_ESP		= (1 << 21), /* External Sata Port */
+	PORT_CMD_HPCP		= (1 << 18), /* HotPlug Capable Port */
 	PORT_CMD_PMP		= (1 << 17), /* PMP attached */
 	PORT_CMD_LIST_ON	= (1 << 15), /* cmd list DMA engine running */
 	PORT_CMD_FIS_ON		= (1 << 14), /* FIS DMA engine running */
diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
index d256a66..2fa551a 100644
--- a/drivers/ata/libahci.c
+++ b/drivers/ata/libahci.c
@@ -1117,6 +1117,7 @@ static void ahci_port_init(struct device *dev, struct ata_port *ap,
 			   int port_no, void __iomem *mmio,
 			   void __iomem *port_mmio)
 {
+	struct ahci_host_priv *hpriv = ap->host->private_data;
 	const char *emsg = NULL;
 	int rc;
 	u32 tmp;
@@ -1138,6 +1139,12 @@ static void ahci_port_init(struct device *dev, struct ata_port *ap,
 		writel(tmp, port_mmio + PORT_IRQ_STAT);
 
 	writel(1 << port_no, mmio + HOST_IRQ_STAT);
+
+	/* mark esata ports */
+	tmp = readl(port_mmio + PORT_CMD);
+	if ((tmp & PORT_CMD_HPCP) ||
+	    ((tmp & PORT_CMD_ESP) && (hpriv->cap & HOST_CAP_SXS)))
+		ap->pflags |= ATA_PFLAG_EXTERNAL;
 }
 
 void ahci_init_controller(struct ata_host *host)
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index 0d7f0da..183a57b 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -2015,8 +2015,11 @@ static unsigned int ata_scsiop_inq_std(struct ata_scsi_args *args, u8 *rbuf)
 
 	VPRINTK("ENTER\n");
 
-	/* set scsi removable (RMB) bit per ata bit */
-	if (ata_id_removable(args->id))
+	/* set scsi removable (RMB) bit per ata bit, or if the
+	 * AHCI port says it's external (Hotplug-capable, eSATA).
+	 */
+	if (ata_id_removable(args->id) ||
+	    (args->dev->link->ap->pflags & ATA_PFLAG_EXTERNAL))
 		hdr[1] |= (1 << 7);
 
 	if (args->dev->class == ATA_DEV_ZAC) {
diff --git a/include/linux/libata.h b/include/linux/libata.h
index c9cfbcd..83577f8 100644
--- a/include/linux/libata.h
+++ b/include/linux/libata.h
@@ -254,6 +254,7 @@ enum {
 
 	ATA_PFLAG_PIO32		= (1 << 20),  /* 32bit PIO */
 	ATA_PFLAG_PIO32CHANGE	= (1 << 21),  /* 32bit PIO can be turned on/off */
+	ATA_PFLAG_EXTERNAL	= (1 << 22),  /* eSATA/external port */
 
 	/* struct ata_queued_cmd flags */
 	ATA_QCFLAG_ACTIVE	= (1 << 0), /* cmd not yet ack'd to scsi lyer */
-- 
2.5.3


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

* Re: [PATCH v2] ata: ahci: find eSATA ports and flag them as removable
  2015-09-30 19:10 [PATCH v2] ata: ahci: find eSATA ports and flag them as removable Manuel Lauss
@ 2015-09-30 21:39 ` Tejun Heo
  2015-10-16 12:42   ` Mark Lord
  0 siblings, 1 reply; 5+ messages in thread
From: Tejun Heo @ 2015-09-30 21:39 UTC (permalink / raw)
  To: Manuel Lauss; +Cc: linux-ide

On Wed, Sep 30, 2015 at 09:10:25PM +0200, Manuel Lauss wrote:
> If the AHCI ports' HPCP or ESP bits are set, the port
> should be considered external (e.g. eSATA) and is marked
> as removable.  Userspace tools like udisks then treat it
> like an usb drive.
> 
> With this patch applied, when I plug a drive into the esata port,
> KDE pops up a window asking what to do with the drives(s), just
> like it does for any random USB stick.
> 
> Removability is indicated to the upper layers by way of the
> SCSI RMB bit, as I haven't found another way to signal
> userspace to treat a sata disk like any usb stick.
> 
> Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>

Applied to libata/for-4.4.  Let's see what happens.

Thanks.

-- 
tejun

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

* Re: [PATCH v2] ata: ahci: find eSATA ports and flag them as removable
  2015-09-30 21:39 ` Tejun Heo
@ 2015-10-16 12:42   ` Mark Lord
  2015-10-16 12:54     ` Tejun Heo
  0 siblings, 1 reply; 5+ messages in thread
From: Mark Lord @ 2015-10-16 12:42 UTC (permalink / raw)
  To: Tejun Heo, Manuel Lauss; +Cc: linux-ide

On 15-09-30 05:39 PM, Tejun Heo wrote:
> On Wed, Sep 30, 2015 at 09:10:25PM +0200, Manuel Lauss wrote:
>> If the AHCI ports' HPCP or ESP bits are set, the port
>> should be considered external (e.g. eSATA) and is marked
>> as removable.  Userspace tools like udisks then treat it
>> like an usb drive.
>>
>> With this patch applied, when I plug a drive into the esata port,
>> KDE pops up a window asking what to do with the drives(s), just
>> like it does for any random USB stick.
>>
>> Removability is indicated to the upper layers by way of the
>> SCSI RMB bit, as I haven't found another way to signal
>> userspace to treat a sata disk like any usb stick.
>>
>> Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
>
> Applied to libata/for-4.4.  Let's see what happens.

Ugh.  Yet another revert to include in my own builds, I guess.

eSATA is used for permanent storage expansion with port-multipliers,
and having to stop command queuing frequently for useless polling
is gonna be a performance drain.

-ml


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

* Re: [PATCH v2] ata: ahci: find eSATA ports and flag them as removable
  2015-10-16 12:42   ` Mark Lord
@ 2015-10-16 12:54     ` Tejun Heo
  2015-10-19  2:32       ` Mark Lord
  0 siblings, 1 reply; 5+ messages in thread
From: Tejun Heo @ 2015-10-16 12:54 UTC (permalink / raw)
  To: Mark Lord; +Cc: Manuel Lauss, linux-ide

Hello, Mark.

On Fri, Oct 16, 2015 at 08:42:02AM -0400, Mark Lord wrote:
> >Applied to libata/for-4.4.  Let's see what happens.
> 
> Ugh.  Yet another revert to include in my own builds, I guess.

Hmmm... what other patches are you reverting?

> eSATA is used for permanent storage expansion with port-multipliers,
> and having to stop command queuing frequently for useless polling
> is gonna be a performance drain.

What would poll it regularly?

Thanks.

-- 
tejun

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

* Re: [PATCH v2] ata: ahci: find eSATA ports and flag them as removable
  2015-10-16 12:54     ` Tejun Heo
@ 2015-10-19  2:32       ` Mark Lord
  0 siblings, 0 replies; 5+ messages in thread
From: Mark Lord @ 2015-10-19  2:32 UTC (permalink / raw)
  To: Tejun Heo; +Cc: Manuel Lauss, linux-ide

On 15-10-16 08:54 AM, Tejun Heo wrote:
> Hello, Mark.
>
> On Fri, Oct 16, 2015 at 08:42:02AM -0400, Mark Lord wrote:
>>> Applied to libata/for-4.4.  Let's see what happens.
>>
>> Ugh.  Yet another revert to include in my own builds, I guess.
>
> Hmmm... what other patches are you reverting?

For libata, other than this one, I only disable SATA LPM.
But something is wrong with the Seagate 8TB drives in
the latest kernels, so I'll have to figure that one out too
at some point.  The drives keep dropping offline, requiring a
system power cycle to recover.  Cause unknown.  Nothing in S.M.A.R.T.

>> eSATA is used for permanent storage expansion with port-multipliers,
>> and having to stop command queuing frequently for useless polling
>> is gonna be a performance drain.
>
> What would poll it regularly?

I though your own earlier post suggested something there,
but I no longer have it to re-read.

I'm expecting that "removable" will imply different elevator
scheduling and more frequent journal flushing etc.

But perhaps it's a bit unfair to just presume that just yet,
so you have my apologies!

But I'm still reverting/disabling this one locally.

Cheers
Mark

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

end of thread, other threads:[~2015-10-19  2:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-30 19:10 [PATCH v2] ata: ahci: find eSATA ports and flag them as removable Manuel Lauss
2015-09-30 21:39 ` Tejun Heo
2015-10-16 12:42   ` Mark Lord
2015-10-16 12:54     ` Tejun Heo
2015-10-19  2:32       ` Mark Lord

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.