Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'ata-6.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/libata/linux

Pull ata updates from Niklas Cassel:

- ATA PASS-THROUGH sense data cleanups and fixes (Igor Pylypiv)

Store the sense data for ATA PASS-THROUGH commands at the correct
offset in the sense buffer when using fixed format sense data.

Cleanup the logic related to generating sense data for PASS-THROUGH
commands. Generating sense data for PASS-THROUGH commands would
overwrite any eventual (real) sense data received from the device.

Honor the D_SENSE bit when generating sense data for PASS-THROUGH
commands. (The D_SENSE bit can be set by the user, and determines if
the returned sense data should be in fixed format or descriptor
format)

- ata port allocation cleanups (me)

Assign the ata port print_id at port allocation time, such that the
ata_port_* print functions can be used earlier in the init call
chain.

Change the ata port port print_id to use ida_alloc(), such that
print_ids will get reused on rmmod + modprobe, instead of being
incremented indefinitely.

Remove wrappers that only existed in order to export the internal
libata functions which they wrapped, and instead export the libata
functions directly.

- Update SATA_MOBILE_LPM_POLICY Kconfig default to med_power_with_dipm
(Mario Limonciello)

Using this default was not always a good idea before, because it
would break hot plug support. However, with LPM changes in recent
kernels, a port marked as external will not enable LPM (in order to
not break hot plug), so it is now safe to change the default value of
this Kconfig.

All major Linux distros have had SATA_MOBILE_LPM_POLICY set to
med_power_with_dipm for quite a long time

- Convert ahci-fsl-qoriq device tree binding to yaml format (Frank Li)

* tag 'ata-6.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/libata/linux:
dt-bindings: ata: ahci-fsl-qoriq: add fsl,ls1046a-ahci and fsl,ls1012a-ahci
ata: ahci: Add debug print for external port
ata,scsi: Remove wrapper ata_sas_port_alloc()
ata: libata-core: Reuse available ata_port print_ids
ata: libata: Assign print_id at port allocation time
ata: libata-core: Remove local_port_no struct member
ata: libata-sata: Remove superfluous assignment in ata_sas_port_alloc()
ata: libata-core: Remove support for decreasing the number of ports
ata: libata: Remove unused function declaration for ata_scsi_detect()
ata,scsi: Remove wrappers ata_sas_tport_{add,delete}()
ata: libata-scsi: Check ATA_QCFLAG_RTF_FILLED before using result_tf
ata: libata-core: Set ATA_QCFLAG_RTF_FILLED in fill_result_tf()
ata: libata-scsi: Do not pass ATA device id to ata_to_sense_error()
ata: libata-scsi: Remove redundant sense_buffer memsets
ata: libata-scsi: Honor the D_SENSE bit for CK_COND=1 and no error
ata: libata-scsi: Do not overwrite valid sense data when CK_COND=1
ata: libata-scsi: Fix offsets for the fixed format sense data
dt-bindings: ata: ahci-fsl-qoriq: convert to yaml format
ata: Kconfig: Update SATA_MOBILE_LPM_POLICY default to med_power_with_dipm

+230 -225
-21
Documentation/devicetree/bindings/ata/ahci-fsl-qoriq.txt
··· 1 - Binding for Freescale QorIQ AHCI SATA Controller 2 - 3 - Required properties: 4 - - reg: Physical base address and size of the controller's register area. 5 - - compatible: Compatibility string. Must be 'fsl,<chip>-ahci', where 6 - chip could be ls1021a, ls1043a, ls1046a, ls1088a, ls2080a etc. 7 - - clocks: Input clock specifier. Refer to common clock bindings. 8 - - interrupts: Interrupt specifier. Refer to interrupt binding. 9 - 10 - Optional properties: 11 - - dma-coherent: Enable AHCI coherent DMA operation. 12 - - reg-names: register area names when there are more than 1 register area. 13 - 14 - Examples: 15 - sata@3200000 { 16 - compatible = "fsl,ls1021a-ahci"; 17 - reg = <0x0 0x3200000 0x0 0x10000>; 18 - interrupts = <GIC_SPI 101 IRQ_TYPE_LEVEL_HIGH>; 19 - clocks = <&platform_clk 1>; 20 - dma-coherent; 21 - };
+64
Documentation/devicetree/bindings/ata/fsl,ahci.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/ata/fsl,ahci.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Freescale QorIQ AHCI SATA Controller 8 + 9 + maintainers: 10 + - Frank Li <Frank.Li@nxp.com> 11 + 12 + properties: 13 + compatible: 14 + oneOf: 15 + - description: SATA controller for ls1012a 16 + items: 17 + - const: fsl,ls1012a-ahci 18 + - const: fsl,ls1043a-ahci 19 + - enum: 20 + - fsl,ls1021a-ahci 21 + - fsl,ls1028a-ahci 22 + - fsl,ls1043a-ahci 23 + - fsl,ls1046a-ahci 24 + - fsl,ls1088a-ahci 25 + - fsl,ls2080a-ahci 26 + - fsl,lx2160a-ahci 27 + 28 + reg: 29 + minItems: 1 30 + maxItems: 2 31 + 32 + reg-names: 33 + items: 34 + - const: ahci 35 + - const: sata-ecc 36 + minItems: 1 37 + 38 + clocks: 39 + maxItems: 1 40 + 41 + interrupts: 42 + maxItems: 1 43 + 44 + dma-coherent: true 45 + 46 + required: 47 + - compatible 48 + - reg 49 + - clocks 50 + - interrupts 51 + 52 + additionalProperties: false 53 + 54 + examples: 55 + - | 56 + #include <dt-bindings/interrupt-controller/arm-gic.h> 57 + 58 + sata@3200000 { 59 + compatible = "fsl,ls1021a-ahci"; 60 + reg = <0x3200000 0x10000>; 61 + interrupts = <GIC_SPI 101 IRQ_TYPE_LEVEL_HIGH>; 62 + clocks = <&platform_clk 1>; 63 + dma-coherent; 64 + };
+1 -1
drivers/ata/Kconfig
··· 118 118 config SATA_MOBILE_LPM_POLICY 119 119 int "Default SATA Link Power Management policy" 120 120 range 0 4 121 - default 0 121 + default 3 122 122 depends on SATA_AHCI 123 123 help 124 124 Select the Default SATA Link Power Management (LPM) policy to use
+3 -1
drivers/ata/ahci.c
··· 1732 1732 * Management Interaction in AHCI 1.3.1. Therefore, do not enable 1733 1733 * LPM if the port advertises itself as an external port. 1734 1734 */ 1735 - if (ap->pflags & ATA_PFLAG_EXTERNAL) 1735 + if (ap->pflags & ATA_PFLAG_EXTERNAL) { 1736 + ata_port_dbg(ap, "external port, not enabling LPM\n"); 1736 1737 return; 1738 + } 1737 1739 1738 1740 /* If no LPM states are supported by the HBA, do not bother with LPM */ 1739 1741 if ((ap->host->flags & ATA_HOST_NO_PART) &&
+2 -10
drivers/ata/libahci.c
··· 2075 2075 struct ahci_port_priv *pp = qc->ap->private_data; 2076 2076 u8 *rx_fis = pp->rx_fis; 2077 2077 2078 - /* 2079 - * rtf may already be filled (e.g. for successful NCQ commands). 2080 - * If that is the case, we have nothing to do. 2081 - */ 2082 - if (qc->flags & ATA_QCFLAG_RTF_FILLED) 2083 - return; 2084 - 2085 2078 if (pp->fbs_enabled) 2086 2079 rx_fis += qc->dev->link->pmp * AHCI_RX_FIS_SZ; 2087 2080 ··· 2088 2095 !(qc->flags & ATA_QCFLAG_EH)) { 2089 2096 ata_tf_from_fis(rx_fis + RX_FIS_PIO_SETUP, &qc->result_tf); 2090 2097 qc->result_tf.status = (rx_fis + RX_FIS_PIO_SETUP)[15]; 2091 - qc->flags |= ATA_QCFLAG_RTF_FILLED; 2092 2098 return; 2093 2099 } 2094 2100 ··· 2110 2118 */ 2111 2119 qc->result_tf.status = fis[2]; 2112 2120 qc->result_tf.error = fis[3]; 2113 - qc->flags |= ATA_QCFLAG_RTF_FILLED; 2114 2121 return; 2115 2122 } 2116 2123 2117 2124 ata_tf_from_fis(rx_fis + RX_FIS_D2H_REG, &qc->result_tf); 2118 - qc->flags |= ATA_QCFLAG_RTF_FILLED; 2119 2125 } 2120 2126 2121 2127 static void ahci_qc_ncq_fill_rtf(struct ata_port *ap, u64 done_mask) ··· 2148 2158 if (qc && ata_is_ncq(qc->tf.protocol)) { 2149 2159 qc->result_tf.status = status; 2150 2160 qc->result_tf.error = error; 2161 + qc->result_tf.flags = qc->tf.flags; 2151 2162 qc->flags |= ATA_QCFLAG_RTF_FILLED; 2152 2163 } 2153 2164 done_mask &= ~(1ULL << tag); ··· 2173 2182 fis += RX_FIS_SDB; 2174 2183 qc->result_tf.status = fis[2]; 2175 2184 qc->result_tf.error = fis[3]; 2185 + qc->result_tf.flags = qc->tf.flags; 2176 2186 qc->flags |= ATA_QCFLAG_RTF_FILLED; 2177 2187 } 2178 2188 done_mask &= ~(1ULL << tag);
+23 -26
drivers/ata/libata-core.c
··· 86 86 static void ata_dev_xfermask(struct ata_device *dev); 87 87 static unsigned long ata_dev_blacklisted(const struct ata_device *dev); 88 88 89 - atomic_t ata_print_id = ATOMIC_INIT(0); 89 + static DEFINE_IDA(ata_ida); 90 90 91 91 #ifdef CONFIG_ATA_FORCE 92 92 struct ata_force_param { ··· 4800 4800 { 4801 4801 struct ata_port *ap = qc->ap; 4802 4802 4803 + /* 4804 + * rtf may already be filled (e.g. for successful NCQ commands). 4805 + * If that is the case, we have nothing to do. 4806 + */ 4807 + if (qc->flags & ATA_QCFLAG_RTF_FILLED) 4808 + return; 4809 + 4803 4810 qc->result_tf.flags = qc->tf.flags; 4804 4811 ap->ops->qc_fill_rtf(qc); 4812 + qc->flags |= ATA_QCFLAG_RTF_FILLED; 4805 4813 } 4806 4814 4807 4815 static void ata_verify_xfer(struct ata_queued_cmd *qc) ··· 5463 5455 struct ata_port *ata_port_alloc(struct ata_host *host) 5464 5456 { 5465 5457 struct ata_port *ap; 5458 + int id; 5466 5459 5467 5460 ap = kzalloc(sizeof(*ap), GFP_KERNEL); 5468 5461 if (!ap) ··· 5471 5462 5472 5463 ap->pflags |= ATA_PFLAG_INITIALIZING | ATA_PFLAG_FROZEN; 5473 5464 ap->lock = &host->lock; 5474 - ap->print_id = -1; 5475 - ap->local_port_no = -1; 5465 + id = ida_alloc_min(&ata_ida, 1, GFP_KERNEL); 5466 + if (id < 0) { 5467 + kfree(ap); 5468 + return NULL; 5469 + } 5470 + ap->print_id = id; 5476 5471 ap->host = host; 5477 5472 ap->dev = host->dev; 5478 5473 ··· 5501 5488 5502 5489 return ap; 5503 5490 } 5491 + EXPORT_SYMBOL_GPL(ata_port_alloc); 5504 5492 5505 5493 void ata_port_free(struct ata_port *ap) 5506 5494 { ··· 5511 5497 kfree(ap->pmp_link); 5512 5498 kfree(ap->slave_link); 5513 5499 kfree(ap->ncq_sense_buf); 5500 + ida_free(&ata_ida, ap->print_id); 5514 5501 kfree(ap); 5515 5502 } 5516 5503 EXPORT_SYMBOL_GPL(ata_port_free); ··· 5562 5547 /** 5563 5548 * ata_host_alloc - allocate and init basic ATA host resources 5564 5549 * @dev: generic device this host is associated with 5565 - * @max_ports: maximum number of ATA ports associated with this host 5550 + * @n_ports: the number of ATA ports associated with this host 5566 5551 * 5567 5552 * Allocate and initialize basic ATA host resources. LLD calls 5568 5553 * this function to allocate a host, initializes it fully and 5569 5554 * attaches it using ata_host_register(). 5570 - * 5571 - * @max_ports ports are allocated and host->n_ports is 5572 - * initialized to @max_ports. The caller is allowed to decrease 5573 - * host->n_ports before calling ata_host_register(). The unused 5574 - * ports will be automatically freed on registration. 5575 5555 * 5576 5556 * RETURNS: 5577 5557 * Allocate ATA host on success, NULL on failure. ··· 5574 5564 * LOCKING: 5575 5565 * Inherited from calling layer (may sleep). 5576 5566 */ 5577 - struct ata_host *ata_host_alloc(struct device *dev, int max_ports) 5567 + struct ata_host *ata_host_alloc(struct device *dev, int n_ports) 5578 5568 { 5579 5569 struct ata_host *host; 5580 5570 size_t sz; ··· 5582 5572 void *dr; 5583 5573 5584 5574 /* alloc a container for our list of ATA ports (buses) */ 5585 - sz = sizeof(struct ata_host) + (max_ports + 1) * sizeof(void *); 5575 + sz = sizeof(struct ata_host) + n_ports * sizeof(void *); 5586 5576 host = kzalloc(sz, GFP_KERNEL); 5587 5577 if (!host) 5588 5578 return NULL; ··· 5602 5592 spin_lock_init(&host->lock); 5603 5593 mutex_init(&host->eh_mutex); 5604 5594 host->dev = dev; 5605 - host->n_ports = max_ports; 5595 + host->n_ports = n_ports; 5606 5596 kref_init(&host->kref); 5607 5597 5608 5598 /* allocate ports bound to this host */ 5609 - for (i = 0; i < max_ports; i++) { 5599 + for (i = 0; i < n_ports; i++) { 5610 5600 struct ata_port *ap; 5611 5601 5612 5602 ap = ata_port_alloc(host); ··· 5913 5903 dev_err(host->dev, "BUG: trying to register unstarted host\n"); 5914 5904 WARN_ON(1); 5915 5905 return -EINVAL; 5916 - } 5917 - 5918 - /* Blow away unused ports. This happens when LLD can't 5919 - * determine the exact number of ports to allocate at 5920 - * allocation time. 5921 - */ 5922 - for (i = host->n_ports; host->ports[i]; i++) 5923 - ata_port_free(host->ports[i]); 5924 - 5925 - /* give ports names and add SCSI hosts */ 5926 - for (i = 0; i < host->n_ports; i++) { 5927 - host->ports[i]->print_id = atomic_inc_return(&ata_print_id); 5928 - host->ports[i]->local_port_no = i + 1; 5929 5906 } 5930 5907 5931 5908 /* Create associated sysfs transport objects */
-49
drivers/ata/libata-sata.c
··· 1205 1205 EXPORT_SYMBOL_GPL(ata_scsi_change_queue_depth); 1206 1206 1207 1207 /** 1208 - * ata_sas_port_alloc - Allocate port for a SAS attached SATA device 1209 - * @host: ATA host container for all SAS ports 1210 - * @port_info: Information from low-level host driver 1211 - * @shost: SCSI host that the scsi device is attached to 1212 - * 1213 - * LOCKING: 1214 - * PCI/etc. bus probe sem. 1215 - * 1216 - * RETURNS: 1217 - * ata_port pointer on success / NULL on failure. 1218 - */ 1219 - 1220 - struct ata_port *ata_sas_port_alloc(struct ata_host *host, 1221 - struct ata_port_info *port_info, 1222 - struct Scsi_Host *shost) 1223 - { 1224 - struct ata_port *ap; 1225 - 1226 - ap = ata_port_alloc(host); 1227 - if (!ap) 1228 - return NULL; 1229 - 1230 - ap->port_no = 0; 1231 - ap->lock = &host->lock; 1232 - ap->pio_mask = port_info->pio_mask; 1233 - ap->mwdma_mask = port_info->mwdma_mask; 1234 - ap->udma_mask = port_info->udma_mask; 1235 - ap->flags |= port_info->flags; 1236 - ap->ops = port_info->port_ops; 1237 - ap->cbl = ATA_CBL_SATA; 1238 - ap->print_id = atomic_inc_return(&ata_print_id); 1239 - 1240 - return ap; 1241 - } 1242 - EXPORT_SYMBOL_GPL(ata_sas_port_alloc); 1243 - 1244 - int ata_sas_tport_add(struct device *parent, struct ata_port *ap) 1245 - { 1246 - return ata_tport_add(parent, ap); 1247 - } 1248 - EXPORT_SYMBOL_GPL(ata_sas_tport_add); 1249 - 1250 - void ata_sas_tport_delete(struct ata_port *ap) 1251 - { 1252 - ata_tport_delete(ap); 1253 - } 1254 - EXPORT_SYMBOL_GPL(ata_sas_tport_delete); 1255 - 1256 - /** 1257 1208 * ata_sas_device_configure - Default device_configure routine for libata 1258 1209 * devices 1259 1210 * @sdev: SCSI device to configure
+118 -91
drivers/ata/libata-scsi.c
··· 230 230 SCSI_SENSE_BUFFERSIZE, information); 231 231 } 232 232 233 + /** 234 + * ata_scsi_set_passthru_sense_fields - Set ATA fields in sense buffer 235 + * @qc: ATA PASS-THROUGH command. 236 + * 237 + * Populates "ATA Status Return sense data descriptor" / "Fixed format 238 + * sense data" with ATA taskfile fields. 239 + * 240 + * LOCKING: 241 + * None. 242 + */ 243 + static void ata_scsi_set_passthru_sense_fields(struct ata_queued_cmd *qc) 244 + { 245 + struct ata_device *dev = qc->dev; 246 + struct scsi_cmnd *cmd = qc->scsicmd; 247 + struct ata_taskfile *tf = &qc->result_tf; 248 + unsigned char *sb = cmd->sense_buffer; 249 + 250 + if (!(qc->flags & ATA_QCFLAG_RTF_FILLED)) { 251 + ata_dev_dbg(dev, 252 + "missing result TF: can't set ATA PT sense fields\n"); 253 + return; 254 + } 255 + 256 + if ((sb[0] & 0x7f) >= 0x72) { 257 + unsigned char *desc; 258 + u8 len; 259 + 260 + /* descriptor format */ 261 + len = sb[7]; 262 + desc = (char *)scsi_sense_desc_find(sb, len + 8, 9); 263 + if (!desc) { 264 + if (SCSI_SENSE_BUFFERSIZE < len + 14) 265 + return; 266 + sb[7] = len + 14; 267 + desc = sb + 8 + len; 268 + } 269 + desc[0] = 9; 270 + desc[1] = 12; 271 + /* 272 + * Copy registers into sense buffer. 273 + */ 274 + desc[2] = 0x00; 275 + desc[3] = tf->error; 276 + desc[5] = tf->nsect; 277 + desc[7] = tf->lbal; 278 + desc[9] = tf->lbam; 279 + desc[11] = tf->lbah; 280 + desc[12] = tf->device; 281 + desc[13] = tf->status; 282 + 283 + /* 284 + * Fill in Extend bit, and the high order bytes 285 + * if applicable. 286 + */ 287 + if (tf->flags & ATA_TFLAG_LBA48) { 288 + desc[2] |= 0x01; 289 + desc[4] = tf->hob_nsect; 290 + desc[6] = tf->hob_lbal; 291 + desc[8] = tf->hob_lbam; 292 + desc[10] = tf->hob_lbah; 293 + } 294 + } else { 295 + /* Fixed sense format */ 296 + sb[0] |= 0x80; 297 + sb[3] = tf->error; 298 + sb[4] = tf->status; 299 + sb[5] = tf->device; 300 + sb[6] = tf->nsect; 301 + if (tf->flags & ATA_TFLAG_LBA48) { 302 + sb[8] |= 0x80; 303 + if (tf->hob_nsect) 304 + sb[8] |= 0x40; 305 + if (tf->hob_lbal || tf->hob_lbam || tf->hob_lbah) 306 + sb[8] |= 0x20; 307 + } 308 + sb[9] = tf->lbal; 309 + sb[10] = tf->lbam; 310 + sb[11] = tf->lbah; 311 + } 312 + } 313 + 233 314 static void ata_scsi_set_invalid_field(struct ata_device *dev, 234 315 struct scsi_cmnd *cmd, u16 field, u8 bit) 235 316 { ··· 792 711 793 712 /** 794 713 * ata_to_sense_error - convert ATA error to SCSI error 795 - * @id: ATA device number 796 714 * @drv_stat: value contained in ATA status register 797 715 * @drv_err: value contained in ATA error register 798 716 * @sk: the sense key we'll fill out ··· 805 725 * LOCKING: 806 726 * spin_lock_irqsave(host lock) 807 727 */ 808 - static void ata_to_sense_error(unsigned id, u8 drv_stat, u8 drv_err, u8 *sk, 809 - u8 *asc, u8 *ascq) 728 + static void ata_to_sense_error(u8 drv_stat, u8 drv_err, u8 *sk, u8 *asc, 729 + u8 *ascq) 810 730 { 811 731 int i; 812 732 ··· 917 837 * ata_gen_passthru_sense - Generate check condition sense block. 918 838 * @qc: Command that completed. 919 839 * 920 - * This function is specific to the ATA descriptor format sense 921 - * block specified for the ATA pass through commands. Regardless 922 - * of whether the command errored or not, return a sense 923 - * block. Copy all controller registers into the sense 840 + * This function is specific to the ATA pass through commands. 841 + * Regardless of whether the command errored or not, return a sense 924 842 * block. If there was no error, we get the request from an ATA 925 843 * passthrough command, so we use the following sense data: 926 844 * sk = RECOVERED ERROR ··· 930 852 */ 931 853 static void ata_gen_passthru_sense(struct ata_queued_cmd *qc) 932 854 { 855 + struct ata_device *dev = qc->dev; 933 856 struct scsi_cmnd *cmd = qc->scsicmd; 934 857 struct ata_taskfile *tf = &qc->result_tf; 935 - unsigned char *sb = cmd->sense_buffer; 936 - unsigned char *desc = sb + 8; 937 858 u8 sense_key, asc, ascq; 938 859 939 - memset(sb, 0, SCSI_SENSE_BUFFERSIZE); 860 + if (!(qc->flags & ATA_QCFLAG_RTF_FILLED)) { 861 + ata_dev_dbg(dev, 862 + "missing result TF: can't generate ATA PT sense data\n"); 863 + return; 864 + } 940 865 941 866 /* 942 867 * Use ata_to_sense_error() to map status register bits ··· 947 866 */ 948 867 if (qc->err_mask || 949 868 tf->status & (ATA_BUSY | ATA_DF | ATA_ERR | ATA_DRQ)) { 950 - ata_to_sense_error(qc->ap->print_id, tf->status, tf->error, 869 + ata_to_sense_error(tf->status, tf->error, 951 870 &sense_key, &asc, &ascq); 952 871 ata_scsi_set_sense(qc->dev, cmd, sense_key, asc, ascq); 953 872 } else { 954 - /* 955 - * ATA PASS-THROUGH INFORMATION AVAILABLE 956 - * Always in descriptor format sense. 957 - */ 958 - scsi_build_sense(cmd, 1, RECOVERED_ERROR, 0, 0x1D); 959 - } 960 - 961 - if ((cmd->sense_buffer[0] & 0x7f) >= 0x72) { 962 - u8 len; 963 - 964 - /* descriptor format */ 965 - len = sb[7]; 966 - desc = (char *)scsi_sense_desc_find(sb, len + 8, 9); 967 - if (!desc) { 968 - if (SCSI_SENSE_BUFFERSIZE < len + 14) 969 - return; 970 - sb[7] = len + 14; 971 - desc = sb + 8 + len; 972 - } 973 - desc[0] = 9; 974 - desc[1] = 12; 975 - /* 976 - * Copy registers into sense buffer. 977 - */ 978 - desc[2] = 0x00; 979 - desc[3] = tf->error; 980 - desc[5] = tf->nsect; 981 - desc[7] = tf->lbal; 982 - desc[9] = tf->lbam; 983 - desc[11] = tf->lbah; 984 - desc[12] = tf->device; 985 - desc[13] = tf->status; 986 - 987 - /* 988 - * Fill in Extend bit, and the high order bytes 989 - * if applicable. 990 - */ 991 - if (tf->flags & ATA_TFLAG_LBA48) { 992 - desc[2] |= 0x01; 993 - desc[4] = tf->hob_nsect; 994 - desc[6] = tf->hob_lbal; 995 - desc[8] = tf->hob_lbam; 996 - desc[10] = tf->hob_lbah; 997 - } 998 - } else { 999 - /* Fixed sense format */ 1000 - desc[0] = tf->error; 1001 - desc[1] = tf->status; 1002 - desc[2] = tf->device; 1003 - desc[3] = tf->nsect; 1004 - desc[7] = 0; 1005 - if (tf->flags & ATA_TFLAG_LBA48) { 1006 - desc[8] |= 0x80; 1007 - if (tf->hob_nsect) 1008 - desc[8] |= 0x40; 1009 - if (tf->hob_lbal || tf->hob_lbam || tf->hob_lbah) 1010 - desc[8] |= 0x20; 1011 - } 1012 - desc[9] = tf->lbal; 1013 - desc[10] = tf->lbam; 1014 - desc[11] = tf->lbah; 873 + /* ATA PASS-THROUGH INFORMATION AVAILABLE */ 874 + ata_scsi_set_sense(qc->dev, cmd, RECOVERED_ERROR, 0, 0x1D); 1015 875 } 1016 876 } 1017 877 ··· 975 953 u64 block; 976 954 u8 sense_key, asc, ascq; 977 955 978 - memset(sb, 0, SCSI_SENSE_BUFFERSIZE); 979 - 980 956 if (ata_dev_disabled(dev)) { 981 957 /* Device disabled after error recovery */ 982 958 /* LOGICAL UNIT NOT READY, HARD RESET REQUIRED */ 983 959 ata_scsi_set_sense(dev, cmd, NOT_READY, 0x04, 0x21); 984 960 return; 985 961 } 962 + 963 + if (!(qc->flags & ATA_QCFLAG_RTF_FILLED)) { 964 + ata_dev_dbg(dev, 965 + "missing result TF: can't generate sense data\n"); 966 + return; 967 + } 968 + 986 969 /* Use ata_to_sense_error() to map status register bits 987 970 * onto sense key, asc & ascq. 988 971 */ 989 972 if (qc->err_mask || 990 973 tf->status & (ATA_BUSY | ATA_DF | ATA_ERR | ATA_DRQ)) { 991 - ata_to_sense_error(qc->ap->print_id, tf->status, tf->error, 974 + ata_to_sense_error(tf->status, tf->error, 992 975 &sense_key, &asc, &ascq); 993 976 ata_scsi_set_sense(dev, cmd, sense_key, asc, ascq); 994 977 } else { ··· 1658 1631 { 1659 1632 struct scsi_cmnd *cmd = qc->scsicmd; 1660 1633 u8 *cdb = cmd->cmnd; 1661 - int need_sense = (qc->err_mask != 0) && 1662 - !(qc->flags & ATA_QCFLAG_SENSE_VALID); 1634 + bool have_sense = qc->flags & ATA_QCFLAG_SENSE_VALID; 1635 + bool is_ata_passthru = cdb[0] == ATA_16 || cdb[0] == ATA_12; 1636 + bool is_ck_cond_request = cdb[2] & 0x20; 1637 + bool is_error = qc->err_mask != 0; 1663 1638 1664 1639 /* For ATA pass thru (SAT) commands, generate a sense block if 1665 1640 * user mandated it or if there's an error. Note that if we 1666 - * generate because the user forced us to [CK_COND =1], a check 1641 + * generate because the user forced us to [CK_COND=1], a check 1667 1642 * condition is generated and the ATA register values are returned 1668 1643 * whether the command completed successfully or not. If there 1669 - * was no error, we use the following sense data: 1644 + * was no error, and CK_COND=1, we use the following sense data: 1670 1645 * sk = RECOVERED ERROR 1671 1646 * asc,ascq = ATA PASS-THROUGH INFORMATION AVAILABLE 1672 1647 */ 1673 - if (((cdb[0] == ATA_16) || (cdb[0] == ATA_12)) && 1674 - ((cdb[2] & 0x20) || need_sense)) 1675 - ata_gen_passthru_sense(qc); 1676 - else if (need_sense) 1648 + if (is_ata_passthru && (is_ck_cond_request || is_error || have_sense)) { 1649 + if (!have_sense) 1650 + ata_gen_passthru_sense(qc); 1651 + ata_scsi_set_passthru_sense_fields(qc); 1652 + if (is_ck_cond_request) 1653 + set_status_byte(qc->scsicmd, SAM_STAT_CHECK_CONDITION); 1654 + } else if (is_error && !have_sense) { 1677 1655 ata_gen_ata_sense(qc); 1678 - else 1656 + } else { 1679 1657 /* Keep the SCSI ML and status byte, clear host byte. */ 1680 1658 cmd->result &= 0x0000ffff; 1659 + } 1681 1660 1682 1661 ata_qc_done(qc); 1683 1662 } ··· 2622 2589 /* handle completion from EH */ 2623 2590 if (unlikely(err_mask || qc->flags & ATA_QCFLAG_SENSE_VALID)) { 2624 2591 2625 - if (!(qc->flags & ATA_QCFLAG_SENSE_VALID)) { 2626 - /* FIXME: not quite right; we don't want the 2627 - * translation of taskfile registers into a 2628 - * sense descriptors, since that's only 2629 - * correct for ATA, not ATAPI 2630 - */ 2592 + if (!(qc->flags & ATA_QCFLAG_SENSE_VALID)) 2631 2593 ata_gen_passthru_sense(qc); 2632 - } 2633 2594 2634 2595 /* SCSI EH automatically locks door if sdev->locked is 2635 2596 * set. Sometimes door lock request continues to
+4 -1
drivers/ata/libata-transport.c
··· 217 217 218 218 ata_port_simple_attr(nr_pmp_links, nr_pmp_links, "%d\n", int); 219 219 ata_port_simple_attr(stats.idle_irq, idle_irq, "%ld\n", unsigned long); 220 - ata_port_simple_attr(local_port_no, port_no, "%u\n", unsigned int); 220 + /* We want the port_no sysfs attibute to start at 1 (ap->port_no starts at 0) */ 221 + ata_port_simple_attr(port_no + 1, port_no, "%u\n", unsigned int); 221 222 222 223 static DECLARE_TRANSPORT_CLASS(ata_port_class, 223 224 "ata_port", NULL, NULL, NULL); ··· 266 265 transport_destroy_device(dev); 267 266 put_device(dev); 268 267 } 268 + EXPORT_SYMBOL_GPL(ata_tport_delete); 269 269 270 270 static const struct device_type ata_port_sas_type = { 271 271 .name = ATA_PORT_TYPE_NAME, ··· 331 329 put_device(dev); 332 330 return error; 333 331 } 332 + EXPORT_SYMBOL_GPL(ata_tport_add); 334 333 335 334 /** 336 335 * ata_port_classify - determine device type based on ATA-spec signature
-3
drivers/ata/libata-transport.h
··· 8 8 int ata_tlink_add(struct ata_link *link); 9 9 void ata_tlink_delete(struct ata_link *link); 10 10 11 - int ata_tport_add(struct device *parent, struct ata_port *ap); 12 - void ata_tport_delete(struct ata_port *ap); 13 - 14 11 struct scsi_transport_template *ata_attach_transport(void); 15 12 void ata_release_transport(struct scsi_transport_template *t); 16 13
-2
drivers/ata/libata.h
··· 32 32 33 33 #define ATA_PORT_TYPE_NAME "ata_port" 34 34 35 - extern atomic_t ata_print_id; 36 35 extern int atapi_passthru16; 37 36 extern int libata_fua; 38 37 extern int libata_noacpi; ··· 81 82 extern int sata_link_init_spd(struct ata_link *link); 82 83 extern int ata_task_ioctl(struct scsi_device *scsidev, void __user *arg); 83 84 extern int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg); 84 - extern struct ata_port *ata_port_alloc(struct ata_host *host); 85 85 extern const char *sata_spd_string(unsigned int spd); 86 86 extern unsigned int ata_read_log_page(struct ata_device *dev, u8 log, 87 87 u8 page, void *buf, unsigned int sectors);
+10 -12
drivers/scsi/libsas/sas_ata.c
··· 572 572 .end_eh = sas_ata_end_eh, 573 573 }; 574 574 575 - static struct ata_port_info sata_port_info = { 576 - .flags = ATA_FLAG_SATA | ATA_FLAG_PIO_DMA | ATA_FLAG_NCQ | 577 - ATA_FLAG_SAS_HOST | ATA_FLAG_FPDMA_AUX, 578 - .pio_mask = ATA_PIO4, 579 - .mwdma_mask = ATA_MWDMA2, 580 - .udma_mask = ATA_UDMA6, 581 - .port_ops = &sas_sata_ops 582 - }; 583 - 584 575 int sas_ata_init(struct domain_device *found_dev) 585 576 { 586 577 struct sas_ha_struct *ha = found_dev->port->ha; ··· 588 597 589 598 ata_host_init(ata_host, ha->dev, &sas_sata_ops); 590 599 591 - ap = ata_sas_port_alloc(ata_host, &sata_port_info, shost); 600 + ap = ata_port_alloc(ata_host); 592 601 if (!ap) { 593 - pr_err("ata_sas_port_alloc failed.\n"); 602 + pr_err("ata_port_alloc failed.\n"); 594 603 rc = -ENODEV; 595 604 goto free_host; 596 605 } 597 606 607 + ap->port_no = 0; 608 + ap->pio_mask = ATA_PIO4; 609 + ap->mwdma_mask = ATA_MWDMA2; 610 + ap->udma_mask = ATA_UDMA6; 611 + ap->flags |= ATA_FLAG_SATA | ATA_FLAG_PIO_DMA | ATA_FLAG_NCQ | 612 + ATA_FLAG_SAS_HOST | ATA_FLAG_FPDMA_AUX; 613 + ap->ops = &sas_sata_ops; 598 614 ap->private_data = found_dev; 599 615 ap->cbl = ATA_CBL_SATA; 600 616 ap->scsi_host = shost; 601 617 602 - rc = ata_sas_tport_add(ata_host->dev, ap); 618 + rc = ata_tport_add(ata_host->dev, ap); 603 619 if (rc) 604 620 goto free_port; 605 621
+1 -1
drivers/scsi/libsas/sas_discover.c
··· 300 300 kfree(dev->ex_dev.ex_phy); 301 301 302 302 if (dev_is_sata(dev) && dev->sata_dev.ap) { 303 - ata_sas_tport_delete(dev->sata_dev.ap); 303 + ata_tport_delete(dev->sata_dev.ap); 304 304 ata_port_free(dev->sata_dev.ap); 305 305 ata_host_put(dev->sata_dev.ata_host); 306 306 dev->sata_dev.ata_host = NULL;
+4 -7
include/linux/libata.h
··· 814 814 /* Flags that change dynamically, protected by ap->lock */ 815 815 unsigned int pflags; /* ATA_PFLAG_xxx */ 816 816 unsigned int print_id; /* user visible unique port ID */ 817 - unsigned int local_port_no; /* host local port num */ 818 817 unsigned int port_no; /* 0 based port no. inside the host */ 819 818 820 819 #ifdef CONFIG_ATA_SFF ··· 1068 1069 unsigned long deadline); 1069 1070 extern void ata_std_postreset(struct ata_link *link, unsigned int *classes); 1070 1071 1071 - extern struct ata_host *ata_host_alloc(struct device *dev, int max_ports); 1072 + extern struct ata_host *ata_host_alloc(struct device *dev, int n_ports); 1072 1073 extern struct ata_host *ata_host_alloc_pinfo(struct device *dev, 1073 1074 const struct ata_port_info * const * ppi, int n_ports); 1074 1075 extern void ata_host_get(struct ata_host *host); ··· 1081 1082 const struct scsi_host_template *sht); 1082 1083 extern void ata_host_detach(struct ata_host *host); 1083 1084 extern void ata_host_init(struct ata_host *, struct device *, struct ata_port_operations *); 1084 - extern int ata_scsi_detect(struct scsi_host_template *sht); 1085 1085 extern int ata_scsi_ioctl(struct scsi_device *dev, unsigned int cmd, 1086 1086 void __user *arg); 1087 1087 #ifdef CONFIG_COMPAT ··· 1244 1246 extern int sata_link_scr_lpm(struct ata_link *link, enum ata_lpm_policy policy, 1245 1247 bool spm_wakeup); 1246 1248 extern int ata_slave_link_init(struct ata_port *ap); 1247 - extern struct ata_port *ata_sas_port_alloc(struct ata_host *, 1248 - struct ata_port_info *, struct Scsi_Host *); 1249 1249 extern void ata_port_probe(struct ata_port *ap); 1250 + extern struct ata_port *ata_port_alloc(struct ata_host *host); 1250 1251 extern void ata_port_free(struct ata_port *ap); 1251 - extern int ata_sas_tport_add(struct device *parent, struct ata_port *ap); 1252 - extern void ata_sas_tport_delete(struct ata_port *ap); 1252 + extern int ata_tport_add(struct device *parent, struct ata_port *ap); 1253 + extern void ata_tport_delete(struct ata_port *ap); 1253 1254 int ata_sas_device_configure(struct scsi_device *sdev, struct queue_limits *lim, 1254 1255 struct ata_port *ap); 1255 1256 extern int ata_sas_queuecmd(struct scsi_cmnd *cmd, struct ata_port *ap);