All of lore.kernel.org
 help / color / mirror / Atom feed
* How to assess PMP register
@ 2009-04-30  1:49 s ticket
  2009-04-30 16:08 ` Grant Grundler
  2009-04-30 22:34 ` Mark Lord
  0 siblings, 2 replies; 10+ messages in thread
From: s ticket @ 2009-04-30  1:49 UTC (permalink / raw)
  To: linux-ide, jgarzik

Is there any way to read PMP registers after hardreset/softreset?
SATA Controller is marvell 88SX7042 and driver is sata_mv.
I try to send 0xE4 and 0xE6 command to read/write PMP registers:

	struct sg_io_hdr io_hdr;
	unsigned char cdb[SG_ATA_16_LEN];
	unsigned char sb[32];
	unsigned char data[4096];

	memset(&io_hdr, 0, sizeof(io_hdr));
	memset(&cdb, 0, sizeof(cdb));
	memset(&sb, 0, sizeof(sb));
	memset(&data, 0, sizeof(data));

	cdb[0] = SG_ATA_16;
	cdb[1] = SG_ATA_PROTO_NON_DATA;

	cdb[2] = SG_CDB2_CHECK_COND;
	cdb[4] = (unsigned char)reg;
	cdb[13] = 0xF;
	cdb[14] = 0xe8;

	io_hdr.interface_id = 'S';
	io_hdr.mx_sb_len = sizeof(sb);
	io_hdr.dxfer_direction = SG_DXFER_NONE;
	io_hdr.dxfer_len = 0;
	io_hdr.dxferp = NULL;
	io_hdr.cmdp = cdb;
	io_hdr.cmd_len = SG_ATA_16_LEN;
	io_hdr.sbp = sb;

	io_hdr.pack_id = 0;
	io_hdr.timeout = 16000;
        if (ioctl(fd, SG_IO, &io_hdr) == -1) {
		perror("ioctl(fd, SG_IO)");
		return -1;
	}

But after 'ioctl', the SATA link fails to read SCR1 and start resetting:

ata1.00: failed to read SCR 1 (Emask=0x40)
ata1.01: failed to read SCR 1 (Emask=0x40)
ata1.02: failed to read SCR 1 (Emask=0x40)
ata1.03: failed to read SCR 1 (Emask=0x40)
ata1.00: exception Emask 0x100 SAct 0x0 SErr 0x0 action 0x6 frozen
ata1.01: exception Emask 0x100 SAct 0x0 SErr 0x0 action 0x6 frozen
ata1.01: cmd e8/00:00:00:00:00/00:00:00:00:00/0f tag 0
         res 58/00:00:00:00:00/00:00:00:00:00/0f Emask 0x2 (HSM violation)
ata1.01: status: { DRDY DRQ }
ata1.02: exception Emask 0x100 SAct 0x0 SErr 0x0 action 0x6 frozen
ata1.03: exception Emask 0x100 SAct 0x0 SErr 0x0 action 0x6 frozen
ata1.15: hard resetting link

Is there any suggestion?

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

* Re: How to assess PMP register
  2009-04-30  1:49 How to assess PMP register s ticket
@ 2009-04-30 16:08 ` Grant Grundler
  2009-04-30 22:34 ` Mark Lord
  1 sibling, 0 replies; 10+ messages in thread
From: Grant Grundler @ 2009-04-30 16:08 UTC (permalink / raw)
  To: s ticket; +Cc: linux-ide, jgarzik

On Wed, Apr 29, 2009 at 6:49 PM, s ticket <smticket@gmail.com> wrote:
> Is there any way to read PMP registers after hardreset/softreset?

hard or soft reset of the port behind 88SX7042 or the port behind the PMP?

After a 88SX7042 port hard reset, will anything interesting remain on
the PMP to read?

Have you looked at sata_pmp_read_gscr() andsata_pmp_scr_read()
in drivers/ata/libata-pmp.c?

sorry, just more questions.
grant

> SATA Controller is marvell 88SX7042 and driver is sata_mv.
> I try to send 0xE4 and 0xE6 command to read/write PMP registers:
>
>        struct sg_io_hdr io_hdr;
>        unsigned char cdb[SG_ATA_16_LEN];
>        unsigned char sb[32];
>        unsigned char data[4096];
>
>        memset(&io_hdr, 0, sizeof(io_hdr));
>        memset(&cdb, 0, sizeof(cdb));
>        memset(&sb, 0, sizeof(sb));
>        memset(&data, 0, sizeof(data));
>
>        cdb[0] = SG_ATA_16;
>        cdb[1] = SG_ATA_PROTO_NON_DATA;
>
>        cdb[2] = SG_CDB2_CHECK_COND;
>        cdb[4] = (unsigned char)reg;
>        cdb[13] = 0xF;
>        cdb[14] = 0xe8;
>
>        io_hdr.interface_id = 'S';
>        io_hdr.mx_sb_len = sizeof(sb);
>        io_hdr.dxfer_direction = SG_DXFER_NONE;
>        io_hdr.dxfer_len = 0;
>        io_hdr.dxferp = NULL;
>        io_hdr.cmdp = cdb;
>        io_hdr.cmd_len = SG_ATA_16_LEN;
>        io_hdr.sbp = sb;
>
>        io_hdr.pack_id = 0;
>        io_hdr.timeout = 16000;
>        if (ioctl(fd, SG_IO, &io_hdr) == -1) {
>                perror("ioctl(fd, SG_IO)");
>                return -1;
>        }
>
> But after 'ioctl', the SATA link fails to read SCR1 and start resetting:
>
> ata1.00: failed to read SCR 1 (Emask=0x40)
> ata1.01: failed to read SCR 1 (Emask=0x40)
> ata1.02: failed to read SCR 1 (Emask=0x40)
> ata1.03: failed to read SCR 1 (Emask=0x40)
> ata1.00: exception Emask 0x100 SAct 0x0 SErr 0x0 action 0x6 frozen
> ata1.01: exception Emask 0x100 SAct 0x0 SErr 0x0 action 0x6 frozen
> ata1.01: cmd e8/00:00:00:00:00/00:00:00:00:00/0f tag 0
>         res 58/00:00:00:00:00/00:00:00:00:00/0f Emask 0x2 (HSM violation)
> ata1.01: status: { DRDY DRQ }
> ata1.02: exception Emask 0x100 SAct 0x0 SErr 0x0 action 0x6 frozen
> ata1.03: exception Emask 0x100 SAct 0x0 SErr 0x0 action 0x6 frozen
> ata1.15: hard resetting link
>
> Is there any suggestion?
> --
> To unsubscribe from this list: send the line "unsubscribe linux-ide" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

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

* Re: How to assess PMP register
  2009-04-30  1:49 How to assess PMP register s ticket
  2009-04-30 16:08 ` Grant Grundler
@ 2009-04-30 22:34 ` Mark Lord
  2009-05-04  5:04   ` s ticket
  1 sibling, 1 reply; 10+ messages in thread
From: Mark Lord @ 2009-04-30 22:34 UTC (permalink / raw)
  To: s ticket; +Cc: linux-ide, jgarzik

s ticket wrote:
> Is there any way to read PMP registers after hardreset/softreset?
> SATA Controller is marvell 88SX7042 and driver is sata_mv.
> I try to send 0xE4 and 0xE6 command to read/write PMP registers:
..
>         if (ioctl(fd, SG_IO, &io_hdr) == -1) {
..

No, there is no existing way to access PMP registers from user space.

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

* Re: How to assess PMP register
  2009-04-30 22:34 ` Mark Lord
@ 2009-05-04  5:04   ` s ticket
  2009-05-04 23:37     ` Mark Lord
  0 siblings, 1 reply; 10+ messages in thread
From: s ticket @ 2009-05-04  5:04 UTC (permalink / raw)
  To: Mark Lord; +Cc: linux-ide, jgarzik

>> Is there any way to read PMP registers after hardreset/softreset?
>> SATA Controller is marvell 88SX7042 and driver is sata_mv.
>> I try to send 0xE4 and 0xE6 command to read/write PMP registers:
>
> ..
>>
>>        if (ioctl(fd, SG_IO, &io_hdr) == -1) {
>
> ..
>
> No, there is no existing way to access PMP registers from user space.
>
But what's the difference in dealing with '0xE4' and '0xE8' commands.
I found that only the two commands will reset the link

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

* Re: How to assess PMP register
  2009-05-04  5:04   ` s ticket
@ 2009-05-04 23:37     ` Mark Lord
  2009-05-06  7:03       ` Gwendal Grignou
  0 siblings, 1 reply; 10+ messages in thread
From: Mark Lord @ 2009-05-04 23:37 UTC (permalink / raw)
  To: s ticket; +Cc: linux-ide, jgarzik

s ticket wrote:
>>> Is there any way to read PMP registers after hardreset/softreset?
>>> SATA Controller is marvell 88SX7042 and driver is sata_mv.
>>> I try to send 0xE4 and 0xE6 command to read/write PMP registers:
>> ..
>>>        if (ioctl(fd, SG_IO, &io_hdr) == -1) {
>> ..
>>
>> No, there is no existing way to access PMP registers from user space.
>>
> But what's the difference in dealing with '0xE4' and '0xE8' commands.
> I found that only the two commands will reset the link
..

There's no guaranteed way to do that (reset the link) from userspace either.

You're trying to do device driver things -- those should be done inside
the device driver in the kernel proper.

Cheers

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

* Re: How to assess PMP register
  2009-05-04 23:37     ` Mark Lord
@ 2009-05-06  7:03       ` Gwendal Grignou
  2009-05-09  5:12         ` s ticket
  0 siblings, 1 reply; 10+ messages in thread
From: Gwendal Grignou @ 2009-05-06  7:03 UTC (permalink / raw)
  To: s ticket; +Cc: linux-ide, jgarzik, Mark Lord

- you can not access a PMP device from user space directly because
there is no file descriptor for it.
- however, libata stores a dump of PMP registers taken after every
reset in gscr structure of the ata_device structure that represent the
PMP in the kernel. You can modify libata to print the registers you
need.
- To reset the PMP, you would have to alter ata_scsi_user_scan() to
include looping through the host port and force reset on the whole ata
port by issuing echo "- - -" > /sys/class/scsi_host/hostX/scan
Instead of ata_for_each_link(link, ap, EDGE), do
ata_for_each_link(link, ap, HOST_FIRST)

Gwendal.


On Mon, May 4, 2009 at 4:37 PM, Mark Lord <liml@rtr.ca> wrote:
> s ticket wrote:
>>>>
>>>> Is there any way to read PMP registers after hardreset/softreset?
>>>> SATA Controller is marvell 88SX7042 and driver is sata_mv.
>>>> I try to send 0xE4 and 0xE6 command to read/write PMP registers:
>>>
>>> ..
>>>>
>>>>       if (ioctl(fd, SG_IO, &io_hdr) == -1) {
>>>
>>> ..
>>>
>>> No, there is no existing way to access PMP registers from user space.
>>>
>> But what's the difference in dealing with '0xE4' and '0xE8' commands.
>> I found that only the two commands will reset the link
>
> ..
>
> There's no guaranteed way to do that (reset the link) from userspace either.
>
> You're trying to do device driver things -- those should be done inside
> the device driver in the kernel proper.
>
> Cheers
> --
> To unsubscribe from this list: send the line "unsubscribe linux-ide" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

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

* Re: How to assess PMP register
  2009-05-06  7:03       ` Gwendal Grignou
@ 2009-05-09  5:12         ` s ticket
  2009-05-09  5:18           ` Tejun Heo
  0 siblings, 1 reply; 10+ messages in thread
From: s ticket @ 2009-05-09  5:12 UTC (permalink / raw)
  To: Gwendal Grignou; +Cc: linux-ide, jgarzik, Mark Lord

2009/5/6 Gwendal Grignou <gwendal@google.com>:
> - you can not access a PMP device from user space directly because
> there is no file descriptor for it.
> - however, libata stores a dump of PMP registers taken after every
> reset in gscr structure of the ata_device structure that represent the
> PMP in the kernel. You can modify libata to print the registers you
> need.

I add a  `pmp_attach' function ata_port_operation, and call
`sata_pmp_read' in that
function. It works fine. But when I call `sata_pmp_read' in process
context while another
process is writing to disks, the kernel hangs (deadlock?). Is there
any suggestion?
I found that `sata_pmp_read' finally calls `ata_exec_internal_sg' to
do the real work and
'ata_exec_internal_sg' takes ata_port->lock.

BTW, why `sata_pmp_read' and `sata_pmp_write' aren't exported?


                                                jbin

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

* Re: How to assess PMP register
  2009-05-09  5:12         ` s ticket
@ 2009-05-09  5:18           ` Tejun Heo
  2009-05-09  6:23             ` s ticket
  0 siblings, 1 reply; 10+ messages in thread
From: Tejun Heo @ 2009-05-09  5:18 UTC (permalink / raw)
  To: s ticket; +Cc: Gwendal Grignou, linux-ide, jgarzik, Mark Lord

s ticket wrote:
> 2009/5/6 Gwendal Grignou <gwendal@google.com>:
>> - you can not access a PMP device from user space directly because
>> there is no file descriptor for it.
>> - however, libata stores a dump of PMP registers taken after every
>> reset in gscr structure of the ata_device structure that represent the
>> PMP in the kernel. You can modify libata to print the registers you
>> need.
> 
> I add a  `pmp_attach' function ata_port_operation, and call
> `sata_pmp_read' in that
> function. It works fine. But when I call `sata_pmp_read' in process
> context while another
> process is writing to disks, the kernel hangs (deadlock?). Is there
> any suggestion?
> I found that `sata_pmp_read' finally calls `ata_exec_internal_sg' to
> do the real work and
> 'ata_exec_internal_sg' takes ata_port->lock.
> 
> BTW, why `sata_pmp_read' and `sata_pmp_write' aren't exported?

The PMP access functions can only be called from EH context and that's
one of the reasons they aren't exported?  What are you trying to
achieve?

Thanks.

-- 
tejun

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

* Re: How to assess PMP register
  2009-05-09  5:18           ` Tejun Heo
@ 2009-05-09  6:23             ` s ticket
  2009-05-09  8:09               ` Tejun Heo
  0 siblings, 1 reply; 10+ messages in thread
From: s ticket @ 2009-05-09  6:23 UTC (permalink / raw)
  To: Tejun Heo; +Cc: linux-ide, Mark Lord

>
> The PMP access functions can only be called from EH context and that's
> one of the reasons they aren't exported?  What are you trying to
> achieve?

To driver some gpios on the PMP ;-).
I tried to directly access the PMP and send ATA command from user space,
but all failed.
It seems there are no suitable way so far?


                        jbin

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

* Re: How to assess PMP register
  2009-05-09  6:23             ` s ticket
@ 2009-05-09  8:09               ` Tejun Heo
  0 siblings, 0 replies; 10+ messages in thread
From: Tejun Heo @ 2009-05-09  8:09 UTC (permalink / raw)
  To: s ticket; +Cc: linux-ide, Mark Lord

s ticket wrote:
>> The PMP access functions can only be called from EH context and that's
>> one of the reasons they aren't exported?  What are you trying to
>> achieve?
> 
> To driver some gpios on the PMP ;-).
> I tried to directly access the PMP and send ATA command from user space,
> but all failed.
> It seems there are no suitable way so far?

Hmm... the best way would be implementing an EH action for PMP r/w and
export it via ioctl or sysfs.  When invoked, it should schedule the EH
action and an EH handler should do actual IO and then get the result
back to the userland.  That would automatically solve synchronization
problem too.

-- 
tejun

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

end of thread, other threads:[~2009-05-09  8:09 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-30  1:49 How to assess PMP register s ticket
2009-04-30 16:08 ` Grant Grundler
2009-04-30 22:34 ` Mark Lord
2009-05-04  5:04   ` s ticket
2009-05-04 23:37     ` Mark Lord
2009-05-06  7:03       ` Gwendal Grignou
2009-05-09  5:12         ` s ticket
2009-05-09  5:18           ` Tejun Heo
2009-05-09  6:23             ` s ticket
2009-05-09  8:09               ` Tejun Heo

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.