All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] libata: add support for NCQ commands for SG interface
@ 2015-10-17 11:48 vinayak.kale
  2015-10-17 12:00 ` Sergei Shtylyov
  2015-10-21  5:09 ` Vinayak Kale
  0 siblings, 2 replies; 9+ messages in thread
From: vinayak.kale @ 2015-10-17 11:48 UTC (permalink / raw)
  To: tj, linux-ide, linux-kernel; +Cc: sumit.g.gupta, Vinayak Kale

From: Vinayak Kale <vinayak.kale@seagate.com>

This patch is needed to make NCQ commands with FPDMA protocol value
(eg READ/WRITE FPDMA) work over SCSI Generic (SG) interface.

Signed-off-by: Vinayak Kale <vinayak.kale@seagate.com>
---
 drivers/ata/libata-scsi.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index 0d7f0da..5b0a5ab 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -2914,12 +2914,14 @@ ata_scsi_map_proto(u8 byte1)
 	case 5:		/* PIO Data-out */
 		return ATA_PROT_PIO;
 
+	case 12:	/* FPDMA */
+		return ATA_PROT_NCQ;
+
 	case 0:		/* Hard Reset */
 	case 1:		/* SRST */
 	case 8:		/* Device Diagnostic */
 	case 9:		/* Device Reset */
 	case 7:		/* DMA Queued */
-	case 12:	/* FPDMA */
 	case 15:	/* Return Response Info */
 	default:	/* Reserved */
 		break;
@@ -2963,7 +2965,7 @@ static unsigned int ata_scsi_pass_thru(struct ata_queued_cmd *qc)
 			tf->hob_lbal = cdb[7];
 			tf->hob_lbam = cdb[9];
 			tf->hob_lbah = cdb[11];
-			tf->flags |= ATA_TFLAG_LBA48;
+			tf->flags |= (ATA_TFLAG_LBA48 | ATA_TFLAG_LBA);
 		} else
 			tf->flags &= ~ATA_TFLAG_LBA48;
 
@@ -2992,6 +2994,10 @@ static unsigned int ata_scsi_pass_thru(struct ata_queued_cmd *qc)
 		tf->command = cdb[9];
 	}
 
+	/* For NCQ commands with FPDMA protocol, copy the tag value */
+	if (tf->protocol == ATA_PROT_NCQ)
+		tf->nsect = qc->tag << 3;
+
 	/* enforce correct master/slave bit */
 	tf->device = dev->devno ?
 		tf->device | ATA_DEV1 : tf->device & ~ATA_DEV1;
-- 
1.9.1


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

* Re: [PATCH] libata: add support for NCQ commands for SG interface
  2015-10-17 11:48 [PATCH] libata: add support for NCQ commands for SG interface vinayak.kale
@ 2015-10-17 12:00 ` Sergei Shtylyov
  2015-10-17 12:25   ` Vinayak Kale
  2015-10-21  5:09 ` Vinayak Kale
  1 sibling, 1 reply; 9+ messages in thread
From: Sergei Shtylyov @ 2015-10-17 12:00 UTC (permalink / raw)
  To: vinayak.kale, tj, linux-ide, linux-kernel; +Cc: sumit.g.gupta, Vinayak Kale

Hello.

On 10/17/2015 2:48 PM, vinayak.kale@gmail.com wrote:

> From: Vinayak Kale <vinayak.kale@seagate.com>
>
> This patch is needed to make NCQ commands with FPDMA protocol value
> (eg READ/WRITE FPDMA) work over SCSI Generic (SG) interface.
>
> Signed-off-by: Vinayak Kale <vinayak.kale@seagate.com>
> ---
>   drivers/ata/libata-scsi.c | 10 ++++++++--
>   1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
> index 0d7f0da..5b0a5ab 100644
> --- a/drivers/ata/libata-scsi.c
> +++ b/drivers/ata/libata-scsi.c
[...]
> @@ -2963,7 +2965,7 @@ static unsigned int ata_scsi_pass_thru(struct ata_queued_cmd *qc)
>   			tf->hob_lbal = cdb[7];
>   			tf->hob_lbam = cdb[9];
>   			tf->hob_lbah = cdb[11];
> -			tf->flags |= ATA_TFLAG_LBA48;
> +			tf->flags |= (ATA_TFLAG_LBA48 | ATA_TFLAG_LBA);

    Parens not needed here.

[...]

MBR, Sergei


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

* Re: [PATCH] libata: add support for NCQ commands for SG interface
  2015-10-17 12:00 ` Sergei Shtylyov
@ 2015-10-17 12:25   ` Vinayak Kale
  2015-10-17 18:42     ` Sergei Shtylyov
  0 siblings, 1 reply; 9+ messages in thread
From: Vinayak Kale @ 2015-10-17 12:25 UTC (permalink / raw)
  To: Sergei Shtylyov; +Cc: tj, linux-ide, linux-kernel, sumit.g.gupta, Vinayak Kale

On Sat, Oct 17, 2015 at 5:30 PM, Sergei Shtylyov
<sergei.shtylyov@cogentembedded.com> wrote:
> Hello.
>
> On 10/17/2015 2:48 PM, vinayak.kale@gmail.com wrote:
>
>> From: Vinayak Kale <vinayak.kale@seagate.com>
>>
>> This patch is needed to make NCQ commands with FPDMA protocol value
>> (eg READ/WRITE FPDMA) work over SCSI Generic (SG) interface.
>>
>> Signed-off-by: Vinayak Kale <vinayak.kale@seagate.com>
>> ---
>>   drivers/ata/libata-scsi.c | 10 ++++++++--
>>   1 file changed, 8 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
>> index 0d7f0da..5b0a5ab 100644
>> --- a/drivers/ata/libata-scsi.c
>> +++ b/drivers/ata/libata-scsi.c
>
> [...]
>>
>> @@ -2963,7 +2965,7 @@ static unsigned int ata_scsi_pass_thru(struct
>> ata_queued_cmd *qc)
>>                         tf->hob_lbal = cdb[7];
>>                         tf->hob_lbam = cdb[9];
>>                         tf->hob_lbah = cdb[11];
>> -                       tf->flags |= ATA_TFLAG_LBA48;
>> +                       tf->flags |= (ATA_TFLAG_LBA48 | ATA_TFLAG_LBA);
>
>
>    Parens not needed here.
That's quite neat :-) Thanks, will change it in V2.
>
> [...]
>
> MBR, Sergei
>

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

* Re: [PATCH] libata: add support for NCQ commands for SG interface
  2015-10-17 12:25   ` Vinayak Kale
@ 2015-10-17 18:42     ` Sergei Shtylyov
  2015-10-19  6:55       ` Vinayak Kale
  0 siblings, 1 reply; 9+ messages in thread
From: Sergei Shtylyov @ 2015-10-17 18:42 UTC (permalink / raw)
  To: Vinayak Kale; +Cc: tj, linux-ide, linux-kernel, sumit.g.gupta, Vinayak Kale

On 10/17/2015 3:25 PM, Vinayak Kale wrote:

>>> From: Vinayak Kale <vinayak.kale@seagate.com>
>>>
>>> This patch is needed to make NCQ commands with FPDMA protocol value
>>> (eg READ/WRITE FPDMA) work over SCSI Generic (SG) interface.
>>>
>>> Signed-off-by: Vinayak Kale <vinayak.kale@seagate.com>
>>> ---
>>>    drivers/ata/libata-scsi.c | 10 ++++++++--
>>>    1 file changed, 8 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
>>> index 0d7f0da..5b0a5ab 100644
>>> --- a/drivers/ata/libata-scsi.c
>>> +++ b/drivers/ata/libata-scsi.c
>>
>> [...]
>>>
>>> @@ -2963,7 +2965,7 @@ static unsigned int ata_scsi_pass_thru(struct
>>> ata_queued_cmd *qc)
>>>                          tf->hob_lbal = cdb[7];
>>>                          tf->hob_lbam = cdb[9];
>>>                          tf->hob_lbah = cdb[11];
>>> -                       tf->flags |= ATA_TFLAG_LBA48;
>>> +                       tf->flags |= (ATA_TFLAG_LBA48 | ATA_TFLAG_LBA);
>>
>>
>>     Parens not needed here.
> That's quite neat :-) Thanks, will change it in V2.

     Looking at this hunk again, it seems an unrelated change.

MBR, Sergei

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

* Re: [PATCH] libata: add support for NCQ commands for SG interface
  2015-10-17 18:42     ` Sergei Shtylyov
@ 2015-10-19  6:55       ` Vinayak Kale
  0 siblings, 0 replies; 9+ messages in thread
From: Vinayak Kale @ 2015-10-19  6:55 UTC (permalink / raw)
  To: Sergei Shtylyov; +Cc: tj, linux-ide, linux-kernel, sumit.g.gupta, Vinayak Kale

On Sun, Oct 18, 2015 at 12:12 AM, Sergei Shtylyov
<sergei.shtylyov@cogentembedded.com> wrote:
> On 10/17/2015 3:25 PM, Vinayak Kale wrote:
>
>>>> From: Vinayak Kale <vinayak.kale@seagate.com>
>>>>
>>>> This patch is needed to make NCQ commands with FPDMA protocol value
>>>> (eg READ/WRITE FPDMA) work over SCSI Generic (SG) interface.
>>>>
>>>> Signed-off-by: Vinayak Kale <vinayak.kale@seagate.com>
>>>> ---
>>>>    drivers/ata/libata-scsi.c | 10 ++++++++--
>>>>    1 file changed, 8 insertions(+), 2 deletions(-)
>>>>
>>>> diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
>>>> index 0d7f0da..5b0a5ab 100644
>>>> --- a/drivers/ata/libata-scsi.c
>>>> +++ b/drivers/ata/libata-scsi.c
>>>
>>>
>>> [...]
>>>>
>>>>
>>>> @@ -2963,7 +2965,7 @@ static unsigned int ata_scsi_pass_thru(struct
>>>> ata_queued_cmd *qc)
>>>>                          tf->hob_lbal = cdb[7];
>>>>                          tf->hob_lbam = cdb[9];
>>>>                          tf->hob_lbah = cdb[11];
>>>> -                       tf->flags |= ATA_TFLAG_LBA48;
>>>> +                       tf->flags |= (ATA_TFLAG_LBA48 | ATA_TFLAG_LBA);
>>>
>>>
>>>
>>>     Parens not needed here.
>>
>> That's quite neat :-) Thanks, will change it in V2.
>
>
>     Looking at this hunk again, it seems an unrelated change.

I added ATA_TFLAG_LBA to tf->flags just to conform with similar piece
of code in libata-core.c.
FPDMA Read/Write commands run smoothly even without this flag.
I wouldn't mind removing this change from current patch if it's deemed
unfit here.

>
> MBR, Sergei
>

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

* Re: [PATCH] libata: add support for NCQ commands for SG interface
  2015-10-17 11:48 [PATCH] libata: add support for NCQ commands for SG interface vinayak.kale
  2015-10-17 12:00 ` Sergei Shtylyov
@ 2015-10-21  5:09 ` Vinayak Kale
  2015-10-22  8:57   ` Tejun Heo
  1 sibling, 1 reply; 9+ messages in thread
From: Vinayak Kale @ 2015-10-21  5:09 UTC (permalink / raw)
  To: tj; +Cc: sumit.g.gupta, Vinayak Kale, linux-kernel, linux-ide

Hi Tejun,

On Sat, Oct 17, 2015 at 5:18 PM,  <vinayak.kale@gmail.com> wrote:
> From: Vinayak Kale <vinayak.kale@seagate.com>
>
> This patch is needed to make NCQ commands with FPDMA protocol value
> (eg READ/WRITE FPDMA) work over SCSI Generic (SG) interface.
>
> Signed-off-by: Vinayak Kale <vinayak.kale@seagate.com>
> ---
>  drivers/ata/libata-scsi.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
> index 0d7f0da..5b0a5ab 100644
> --- a/drivers/ata/libata-scsi.c
> +++ b/drivers/ata/libata-scsi.c
> @@ -2914,12 +2914,14 @@ ata_scsi_map_proto(u8 byte1)
>         case 5:         /* PIO Data-out */
>                 return ATA_PROT_PIO;
>
> +       case 12:        /* FPDMA */
> +               return ATA_PROT_NCQ;
> +
>         case 0:         /* Hard Reset */
>         case 1:         /* SRST */
>         case 8:         /* Device Diagnostic */
>         case 9:         /* Device Reset */
>         case 7:         /* DMA Queued */
> -       case 12:        /* FPDMA */
>         case 15:        /* Return Response Info */
>         default:        /* Reserved */
>                 break;
> @@ -2963,7 +2965,7 @@ static unsigned int ata_scsi_pass_thru(struct ata_queued_cmd *qc)
>                         tf->hob_lbal = cdb[7];
>                         tf->hob_lbam = cdb[9];
>                         tf->hob_lbah = cdb[11];
> -                       tf->flags |= ATA_TFLAG_LBA48;
> +                       tf->flags |= (ATA_TFLAG_LBA48 | ATA_TFLAG_LBA);
>                 } else
>                         tf->flags &= ~ATA_TFLAG_LBA48;
>
> @@ -2992,6 +2994,10 @@ static unsigned int ata_scsi_pass_thru(struct ata_queued_cmd *qc)
>                 tf->command = cdb[9];
>         }
>
> +       /* For NCQ commands with FPDMA protocol, copy the tag value */
> +       if (tf->protocol == ATA_PROT_NCQ)
> +               tf->nsect = qc->tag << 3;
> +
>         /* enforce correct master/slave bit */
>         tf->device = dev->devno ?
>                 tf->device | ATA_DEV1 : tf->device & ~ATA_DEV1;
> --
> 1.9.1
>
Any comments on this?

Regards,
Vinayak

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

* Re: [PATCH] libata: add support for NCQ commands for SG interface
  2015-10-21  5:09 ` Vinayak Kale
@ 2015-10-22  8:57   ` Tejun Heo
       [not found]     ` <CAAtun4jvUaVsGSofq5n-sJzmSf4qBsPvQ7WU6dOik4JYSMnZNw@mail.gmail.com>
  0 siblings, 1 reply; 9+ messages in thread
From: Tejun Heo @ 2015-10-22  8:57 UTC (permalink / raw)
  To: Vinayak Kale; +Cc: sumit.g.gupta, Vinayak Kale, linux-kernel, linux-ide

Hello,

On Wed, Oct 21, 2015 at 10:39:32AM +0530, Vinayak Kale wrote:
...
> > diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
> > index 0d7f0da..5b0a5ab 100644
> > --- a/drivers/ata/libata-scsi.c
> > +++ b/drivers/ata/libata-scsi.c
> > @@ -2914,12 +2914,14 @@ ata_scsi_map_proto(u8 byte1)
> >         case 5:         /* PIO Data-out */
> >                 return ATA_PROT_PIO;
> >
> > +       case 12:        /* FPDMA */
> > +               return ATA_PROT_NCQ;
> > +
> >         case 0:         /* Hard Reset */
> >         case 1:         /* SRST */
> >         case 8:         /* Device Diagnostic */
> >         case 9:         /* Device Reset */
> >         case 7:         /* DMA Queued */
> > -       case 12:        /* FPDMA */
> >         case 15:        /* Return Response Info */
> >         default:        /* Reserved */
> >                 break;
> > @@ -2963,7 +2965,7 @@ static unsigned int ata_scsi_pass_thru(struct ata_queued_cmd *qc)
> >                         tf->hob_lbal = cdb[7];
> >                         tf->hob_lbam = cdb[9];
> >                         tf->hob_lbah = cdb[11];
> > -                       tf->flags |= ATA_TFLAG_LBA48;
> > +                       tf->flags |= (ATA_TFLAG_LBA48 | ATA_TFLAG_LBA);
> >                 } else
> >                         tf->flags &= ~ATA_TFLAG_LBA48;
> >
> > @@ -2992,6 +2994,10 @@ static unsigned int ata_scsi_pass_thru(struct ata_queued_cmd *qc)
> >                 tf->command = cdb[9];
> >         }
> >
> > +       /* For NCQ commands with FPDMA protocol, copy the tag value */
> > +       if (tf->protocol == ATA_PROT_NCQ)
> > +               tf->nsect = qc->tag << 3;
> > +
> >         /* enforce correct master/slave bit */
> >         tf->device = dev->devno ?
> >                 tf->device | ATA_DEV1 : tf->device & ~ATA_DEV1;
>
> Any comments on this?

It looks like it'd work given that it's forcing qc->tag into
tf->nsect.  What's the use case tho?

Thanks.

-- 
tejun

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

* Re: [PATCH] libata: add support for NCQ commands for SG interface
       [not found]     ` <CAAtun4jvUaVsGSofq5n-sJzmSf4qBsPvQ7WU6dOik4JYSMnZNw@mail.gmail.com>
@ 2015-10-23  5:39       ` Tejun Heo
  2015-10-23 20:08         ` Vinayak Kale
  0 siblings, 1 reply; 9+ messages in thread
From: Tejun Heo @ 2015-10-23  5:39 UTC (permalink / raw)
  To: Vinayak Kale; +Cc: linux-ide, linux-kernel, Vinayak Kale, sumit.g.gupta

Hello,

On Fri, Oct 23, 2015 at 10:01:35AM +0530, Vinayak Kale wrote:
> > It looks like it'd work given that it's forcing qc->tag into
> > tf->nsect.  What's the use case tho?
> 
> We need to issue NCQ commands with priority bit from user space application.
> 
> BTW, Sergei Shtylyov raised concern regarding usefulness of adding
> ATA_TFLAG_LBA to tf->flags. Can you please comment on that as well?
> Accordingly I will either keep it or discard it in V2. Thanks.

I like the change but can you please put that in a separate patch?
Also, can you please verify that this works fine with multiple regular
NCQ commands in flight?

Thanks.

-- 
tejun

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

* Re: [PATCH] libata: add support for NCQ commands for SG interface
  2015-10-23  5:39       ` Tejun Heo
@ 2015-10-23 20:08         ` Vinayak Kale
  0 siblings, 0 replies; 9+ messages in thread
From: Vinayak Kale @ 2015-10-23 20:08 UTC (permalink / raw)
  To: Tejun Heo; +Cc: linux-ide, linux-kernel, Vinayak Kale, Sumit Gupta

Hi Tejun,

On Fri, Oct 23, 2015 at 11:09 AM, Tejun Heo <tj@kernel.org> wrote:
> Hello,
>
> On Fri, Oct 23, 2015 at 10:01:35AM +0530, Vinayak Kale wrote:
>> > It looks like it'd work given that it's forcing qc->tag into
>> > tf->nsect.  What's the use case tho?
>>
>> We need to issue NCQ commands with priority bit from user space application.
>>
>> BTW, Sergei Shtylyov raised concern regarding usefulness of adding
>> ATA_TFLAG_LBA to tf->flags. Can you please comment on that as well?
>> Accordingly I will either keep it or discard it in V2. Thanks.
>
> I like the change but can you please put that in a separate patch?

Ok. I'll put this in a separate patch.

> Also, can you please verify that this works fine with multiple regular
> NCQ commands in flight?

I verified that multiple FPDMA Read/Write commands issued
simultaneously by different processes, work fine.
I hooked up our application's queued Read/Write APIs to fio, ran fio
for 'random rw' over multiple processes. It worked fine.

>
> Thanks.
>
> --
> tejun

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

end of thread, other threads:[~2015-10-23 20:08 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-17 11:48 [PATCH] libata: add support for NCQ commands for SG interface vinayak.kale
2015-10-17 12:00 ` Sergei Shtylyov
2015-10-17 12:25   ` Vinayak Kale
2015-10-17 18:42     ` Sergei Shtylyov
2015-10-19  6:55       ` Vinayak Kale
2015-10-21  5:09 ` Vinayak Kale
2015-10-22  8:57   ` Tejun Heo
     [not found]     ` <CAAtun4jvUaVsGSofq5n-sJzmSf4qBsPvQ7WU6dOik4JYSMnZNw@mail.gmail.com>
2015-10-23  5:39       ` Tejun Heo
2015-10-23 20:08         ` Vinayak Kale

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.