Tue Jan 3 01:30:16 2017 UTC ()
The SiI3124 was implemented at a time when the ATA/ACS2
DATA SET MANAGEMENT/TRIM command did not exist.  As such, the (presumably
immutable) lookup table in the chip does not know that this command
indicates a data write to follow.  Use the PRB Protocol Override
functionality to tell the chip the protocol we need for this command.

For PR kern/51756.


(jakllsch)
diff -r1.29 -r1.30 src/sys/dev/ic/siisata.c

cvs diff -r1.29 -r1.30 src/sys/dev/ic/siisata.c (expand / switch to unified diff)

--- src/sys/dev/ic/siisata.c 2016/09/19 19:07:53 1.29
+++ src/sys/dev/ic/siisata.c 2017/01/03 01:30:15 1.30
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: siisata.c,v 1.29 2016/09/19 19:07:53 jakllsch Exp $ */ 1/* $NetBSD: siisata.c,v 1.30 2017/01/03 01:30:15 jakllsch Exp $ */
2 2
3/* from ahcisata_core.c */ 3/* from ahcisata_core.c */
4 4
5/* 5/*
6 * Copyright (c) 2006 Manuel Bouyer. 6 * Copyright (c) 2006 Manuel Bouyer.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
10 * are met: 10 * are met:
11 * 1. Redistributions of source code must retain the above copyright 11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer. 12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright 13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the 14 * notice, this list of conditions and the following disclaimer in the
@@ -69,27 +69,27 @@ @@ -69,27 +69,27 @@
69 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 69 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
70 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 70 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
71 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 71 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
72 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 72 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
73 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 73 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
74 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 74 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
75 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 75 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
76 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 76 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
77 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 77 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
78 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 78 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
79 */ 79 */
80 80
81#include <sys/cdefs.h> 81#include <sys/cdefs.h>
82__KERNEL_RCSID(0, "$NetBSD: siisata.c,v 1.29 2016/09/19 19:07:53 jakllsch Exp $"); 82__KERNEL_RCSID(0, "$NetBSD: siisata.c,v 1.30 2017/01/03 01:30:15 jakllsch Exp $");
83 83
84#include <sys/types.h> 84#include <sys/types.h>
85#include <sys/malloc.h> 85#include <sys/malloc.h>
86#include <sys/param.h> 86#include <sys/param.h>
87#include <sys/kernel.h> 87#include <sys/kernel.h>
88#include <sys/systm.h> 88#include <sys/systm.h>
89#include <sys/syslog.h> 89#include <sys/syslog.h>
90#include <sys/disklabel.h> 90#include <sys/disklabel.h>
91#include <sys/buf.h> 91#include <sys/buf.h>
92#include <sys/proc.h> 92#include <sys/proc.h>
93 93
94#include <dev/ata/atareg.h> 94#include <dev/ata/atareg.h>
95#include <dev/ata/satavar.h> 95#include <dev/ata/satavar.h>
@@ -836,26 +836,31 @@ siisata_cmd_start(struct ata_channel *ch @@ -836,26 +836,31 @@ siisata_cmd_start(struct ata_channel *ch
836 836
837 chp->ch_status = 0; 837 chp->ch_status = 0;
838 chp->ch_error = 0; 838 chp->ch_error = 0;
839 839
840 prb = schp->sch_prb[slot]; 840 prb = schp->sch_prb[slot];
841 memset(prb, 0, sizeof(struct siisata_prb)); 841 memset(prb, 0, sizeof(struct siisata_prb));
842 842
843 satafis_rhd_construct_cmd(ata_c, prb->prb_fis); 843 satafis_rhd_construct_cmd(ata_c, prb->prb_fis);
844 KASSERT(xfer->c_drive <= PMP_PORT_CTL); 844 KASSERT(xfer->c_drive <= PMP_PORT_CTL);
845 prb->prb_fis[rhd_c] |= xfer->c_drive; 845 prb->prb_fis[rhd_c] |= xfer->c_drive;
846 846
847 memset(prb->prb_atapi, 0, sizeof(prb->prb_atapi)); 847 memset(prb->prb_atapi, 0, sizeof(prb->prb_atapi));
848 848
 849 if (ata_c->r_command == ATA_DATA_SET_MANAGEMENT) {
 850 prb->prb_control |= htole16(PRB_CF_PROTOCOL_OVERRIDE);
 851 prb->prb_protocol_override |= htole16(PRB_PO_WRITE);
 852 }
 853
849 if (siisata_dma_setup(chp, slot, 854 if (siisata_dma_setup(chp, slot,
850 (ata_c->flags & (AT_READ | AT_WRITE)) ? ata_c->data : NULL, 855 (ata_c->flags & (AT_READ | AT_WRITE)) ? ata_c->data : NULL,
851 ata_c->bcount, 856 ata_c->bcount,
852 (ata_c->flags & AT_READ) ? BUS_DMA_READ : BUS_DMA_WRITE)) {  857 (ata_c->flags & AT_READ) ? BUS_DMA_READ : BUS_DMA_WRITE)) {
853 ata_c->flags |= AT_DF; 858 ata_c->flags |= AT_DF;
854 siisata_cmd_complete(chp, xfer, slot); 859 siisata_cmd_complete(chp, xfer, slot);
855 return; 860 return;
856 } 861 }
857 862
858 if (xfer->c_flags & C_POLL) { 863 if (xfer->c_flags & C_POLL) {
859 /* polled command, disable interrupts */ 864 /* polled command, disable interrupts */
860 prb->prb_control = htole16(PRB_CF_INTERRUPT_MASK); 865 prb->prb_control = htole16(PRB_CF_INTERRUPT_MASK);
861 siisata_disable_port_interrupt(chp); 866 siisata_disable_port_interrupt(chp);