title: Using WRITE SECTOR(S) EXT ATA command with SCSI ATA PASS-THROUGH(16)
body: <p>Welcome.
  I have a problem while executing SCSI command ATA PASS-THROUGH(16) for WRITE SECTOR(S) EXT - 34h, PIO Data-Out (for WRITE DMA EXT - 35h, DMA identical result). I use kernel 2.6.39. I have one HDD(SATA) that is controlled by SCSI. I want to write data to particular sector of this drive. To achieve that goal I use SCSI command ATA PASS_THROUGH(16). In source code it brings to execute ioctl like this:</p>
  
  <pre><code>sg_io_hdr_t command;
  //hear goes a code that sets proper values to command structure
  int fd = open("/dev/sda", O_RDWR);
  int result = ioctl(fd, SG_IO, command);
  //I know that there is no error checking but it isn't a case at this moment
  </code></pre>
  
  <p>This operation works fine when LBA for ATA command is less that 0xFE2600. Data is wrote to drive, can be read and after rebooting is still present. But when the LBA >= 0xFE2600 while executing of this ATA command the following message is displayed: </p>
  
  <p>[ 5127.415214] ata1.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x0</p>
  
  <p>[ 5127.421751] ata1.00: irq_stat 0x40000001 </p>
  
  <p>[ 5127.425737] ata1.00: failed command: WRITE DMA EXT </p>
  
  <p>[ 5127.430659] ata1.00: cmd 35/00:01:ff:ff:00/00:00:ff:00:00/40 tag 0 dma 512 out </p>
  
  <p>[ 5127.430664]     res 51/10:01:ff:ff:00/00:00:ff:00:00/40 Emask 0x81 (invalid argument)</p>
  
  <p>[ 5127.446389] ata1.00: status: { DRDY ERR } [ 5127.450446] ata1.00:</p>
  
  <p>error: { IDNF }</p>
  
  <p>At the beginning I was thinking that maybe there is something wrong with kernel and that it only support LBA 24-bit and do not support LBA 48-bit, but this theory isn't fully consistent with threshold 0xFE2600 (I think that it would if threshold was 0x1000000). From the data returned by IDENTIFY DEVICE - ECh, PIO Data-In I can read that the max LBA is 0x2542EAB0, and that the drive is supporting LBA 48-bit. 
  Don't really now where to even stat investigate this problem. If anyone have some idea pleas share with me. If there is other info that You would like I provide let me know and I will do it as soon I can.</p>