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 branch 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jgarzik/libata-dev

* 'upstream-linus' of ssh://master.kernel.org/pub/scm/linux/kernel/git/jgarzik/libata-dev:
libata: Media rotation rate and form factor heuristics
libata: Report disk alignment and physical block size
sata_fsl: Fix the command description of FSL SATA controller
sata_fsl: Fix compile warnings
[libata] sata_sx4: fixup interrupt handling
[libata] sata_sx4: convert to new exception handling methods

+191 -66
+28 -6
drivers/ata/libata-scsi.c
··· 2142 2142 2143 2143 static unsigned int ata_scsiop_inq_b1(struct ata_scsi_args *args, u8 *rbuf) 2144 2144 { 2145 + int form_factor = ata_id_form_factor(args->id); 2146 + int media_rotation_rate = ata_id_rotation_rate(args->id); 2147 + 2145 2148 rbuf[1] = 0xb1; 2146 2149 rbuf[3] = 0x3c; 2147 - if (ata_id_major_version(args->id) > 7) { 2148 - rbuf[4] = args->id[217] >> 8; 2149 - rbuf[5] = args->id[217]; 2150 - rbuf[7] = args->id[168] & 0xf; 2151 - } 2150 + rbuf[4] = media_rotation_rate >> 8; 2151 + rbuf[5] = media_rotation_rate; 2152 + rbuf[7] = form_factor; 2152 2153 2153 2154 return 0; 2154 2155 } ··· 2377 2376 */ 2378 2377 static unsigned int ata_scsiop_read_cap(struct ata_scsi_args *args, u8 *rbuf) 2379 2378 { 2380 - u64 last_lba = args->dev->n_sectors - 1; /* LBA of the last block */ 2379 + struct ata_device *dev = args->dev; 2380 + u64 last_lba = dev->n_sectors - 1; /* LBA of the last block */ 2381 + u8 log_per_phys = 0; 2382 + u16 lowest_aligned = 0; 2383 + u16 word_106 = dev->id[106]; 2384 + u16 word_209 = dev->id[209]; 2385 + 2386 + if ((word_106 & 0xc000) == 0x4000) { 2387 + /* Number and offset of logical sectors per physical sector */ 2388 + if (word_106 & (1 << 13)) 2389 + log_per_phys = word_106 & 0xf; 2390 + if ((word_209 & 0xc000) == 0x4000) { 2391 + u16 first = dev->id[209] & 0x3fff; 2392 + if (first > 0) 2393 + lowest_aligned = (1 << log_per_phys) - first; 2394 + } 2395 + } 2381 2396 2382 2397 VPRINTK("ENTER\n"); 2383 2398 ··· 2424 2407 /* sector size */ 2425 2408 rbuf[10] = ATA_SECT_SIZE >> 8; 2426 2409 rbuf[11] = ATA_SECT_SIZE & 0xff; 2410 + 2411 + rbuf[12] = 0; 2412 + rbuf[13] = log_per_phys; 2413 + rbuf[14] = (lowest_aligned >> 8) & 0x3f; 2414 + rbuf[15] = lowest_aligned; 2427 2415 } 2428 2416 2429 2417 return 0;
+9 -6
drivers/ata/sata_fsl.c
··· 205 205 * Description information bitdefs 206 206 */ 207 207 enum { 208 + CMD_DESC_RES = (1 << 11), 208 209 VENDOR_SPECIFIC_BIST = (1 << 10), 209 210 CMD_DESC_SNOOP_ENABLE = (1 << 9), 210 211 FPDMA_QUEUED_CMD = (1 << 8), ··· 333 332 dma_addr_t sg_addr = sg_dma_address(sg); 334 333 u32 sg_len = sg_dma_len(sg); 335 334 336 - VPRINTK("SATA FSL : fill_sg, sg_addr = 0x%x, sg_len = %d\n", 337 - sg_addr, sg_len); 335 + VPRINTK("SATA FSL : fill_sg, sg_addr = 0x%llx, sg_len = %d\n", 336 + (unsigned long long)sg_addr, sg_len); 338 337 339 338 /* warn if each s/g element is not dword aligned */ 340 339 if (sg_addr & 0x03) 341 340 ata_port_printk(qc->ap, KERN_ERR, 342 - "s/g addr unaligned : 0x%x\n", sg_addr); 341 + "s/g addr unaligned : 0x%llx\n", 342 + (unsigned long long)sg_addr); 343 343 if (sg_len & 0x03) 344 344 ata_port_printk(qc->ap, KERN_ERR, 345 345 "s/g len unaligned : 0x%x\n", sg_len); ··· 389 387 void __iomem *hcr_base = host_priv->hcr_base; 390 388 unsigned int tag = sata_fsl_tag(qc->tag, hcr_base); 391 389 struct command_desc *cd; 392 - u32 desc_info = CMD_DESC_SNOOP_ENABLE; 390 + u32 desc_info = CMD_DESC_RES | CMD_DESC_SNOOP_ENABLE; 393 391 u32 num_prde = 0; 394 392 u32 ttl_dwords = 0; 395 393 dma_addr_t cd_paddr; ··· 842 840 843 841 /* device reset/SRST is a control register update FIS, uses tag0 */ 844 842 sata_fsl_setup_cmd_hdr_entry(pp, 0, 845 - SRST_CMD | CMD_DESC_SNOOP_ENABLE, 0, 0, 5); 843 + SRST_CMD | CMD_DESC_RES | CMD_DESC_SNOOP_ENABLE, 0, 0, 5); 846 844 847 845 tf.ctl |= ATA_SRST; /* setup SRST bit in taskfile control reg */ 848 846 ata_tf_to_fis(&tf, pmp, 0, cfis); ··· 888 886 * using ATA signature D2H register FIS to the host controller. 889 887 */ 890 888 891 - sata_fsl_setup_cmd_hdr_entry(pp, 0, CMD_DESC_SNOOP_ENABLE, 0, 0, 5); 889 + sata_fsl_setup_cmd_hdr_entry(pp, 0, CMD_DESC_RES | CMD_DESC_SNOOP_ENABLE, 890 + 0, 0, 5); 892 891 893 892 tf.ctl &= ~ATA_SRST; /* 2nd H2D Ctl. register FIS */ 894 893 ata_tf_to_fis(&tf, pmp, 0, cfis);
+126 -54
drivers/ata/sata_sx4.c
··· 213 213 214 214 215 215 static int pdc_sata_init_one(struct pci_dev *pdev, const struct pci_device_id *ent); 216 - static void pdc_eng_timeout(struct ata_port *ap); 217 - static void pdc_20621_phy_reset(struct ata_port *ap); 216 + static void pdc_error_handler(struct ata_port *ap); 217 + static void pdc_freeze(struct ata_port *ap); 218 + static void pdc_thaw(struct ata_port *ap); 218 219 static int pdc_port_start(struct ata_port *ap); 219 220 static void pdc20621_qc_prep(struct ata_queued_cmd *qc); 220 221 static void pdc_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf); ··· 234 233 void *psource, u32 offset, u32 size); 235 234 static void pdc20621_irq_clear(struct ata_port *ap); 236 235 static unsigned int pdc20621_qc_issue(struct ata_queued_cmd *qc); 236 + static int pdc_softreset(struct ata_link *link, unsigned int *class, 237 + unsigned long deadline); 238 + static void pdc_post_internal_cmd(struct ata_queued_cmd *qc); 239 + static int pdc_check_atapi_dma(struct ata_queued_cmd *qc); 237 240 238 241 239 242 static struct scsi_host_template pdc_sata_sht = { ··· 248 243 249 244 /* TODO: inherit from base port_ops after converting to new EH */ 250 245 static struct ata_port_operations pdc_20621_ops = { 251 - .sff_tf_load = pdc_tf_load_mmio, 252 - .sff_tf_read = ata_sff_tf_read, 253 - .sff_check_status = ata_sff_check_status, 254 - .sff_exec_command = pdc_exec_command_mmio, 255 - .sff_dev_select = ata_sff_dev_select, 256 - .phy_reset = pdc_20621_phy_reset, 246 + .inherits = &ata_sff_port_ops, 247 + 248 + .check_atapi_dma = pdc_check_atapi_dma, 257 249 .qc_prep = pdc20621_qc_prep, 258 250 .qc_issue = pdc20621_qc_issue, 259 - .qc_fill_rtf = ata_sff_qc_fill_rtf, 260 - .sff_data_xfer = ata_sff_data_xfer, 261 - .eng_timeout = pdc_eng_timeout, 262 - .sff_irq_clear = pdc20621_irq_clear, 263 - .sff_irq_on = ata_sff_irq_on, 251 + 252 + .freeze = pdc_freeze, 253 + .thaw = pdc_thaw, 254 + .softreset = pdc_softreset, 255 + .error_handler = pdc_error_handler, 256 + .lost_interrupt = ATA_OP_NULL, 257 + .post_internal_cmd = pdc_post_internal_cmd, 258 + 264 259 .port_start = pdc_port_start, 260 + 261 + .sff_tf_load = pdc_tf_load_mmio, 262 + .sff_exec_command = pdc_exec_command_mmio, 263 + .sff_irq_clear = pdc20621_irq_clear, 265 264 }; 266 265 267 266 static const struct ata_port_info pdc_port_info[] = { ··· 317 308 ap->private_data = pp; 318 309 319 310 return 0; 320 - } 321 - 322 - static void pdc_20621_phy_reset(struct ata_port *ap) 323 - { 324 - VPRINTK("ENTER\n"); 325 - ap->cbl = ATA_CBL_SATA; 326 - ata_port_probe(ap); 327 - ata_bus_reset(ap); 328 311 } 329 312 330 313 static inline void pdc20621_ata_sg(struct ata_taskfile *tf, u8 *buf, ··· 687 686 static unsigned int pdc20621_qc_issue(struct ata_queued_cmd *qc) 688 687 { 689 688 switch (qc->tf.protocol) { 690 - case ATA_PROT_DMA: 691 689 case ATA_PROT_NODATA: 690 + if (qc->tf.flags & ATA_TFLAG_POLLING) 691 + break; 692 + /*FALLTHROUGH*/ 693 + case ATA_PROT_DMA: 692 694 pdc20621_packet_start(qc); 693 695 return 0; 694 696 ··· 790 786 791 787 static void pdc20621_irq_clear(struct ata_port *ap) 792 788 { 793 - struct ata_host *host = ap->host; 794 - void __iomem *mmio = host->iomap[PDC_MMIO_BAR]; 795 - 796 - mmio += PDC_CHIP0_OFS; 797 - 798 - readl(mmio + PDC_20621_SEQMASK); 789 + ioread8(ap->ioaddr.status_addr); 799 790 } 800 791 801 792 static irqreturn_t pdc20621_interrupt(int irq, void *dev_instance) ··· 858 859 return IRQ_RETVAL(handled); 859 860 } 860 861 861 - static void pdc_eng_timeout(struct ata_port *ap) 862 + static void pdc_freeze(struct ata_port *ap) 862 863 { 863 - u8 drv_stat; 864 - struct ata_host *host = ap->host; 865 - struct ata_queued_cmd *qc; 866 - unsigned long flags; 864 + void __iomem *mmio = ap->ioaddr.cmd_addr; 865 + u32 tmp; 867 866 868 - DPRINTK("ENTER\n"); 867 + /* FIXME: if all 4 ATA engines are stopped, also stop HDMA engine */ 869 868 870 - spin_lock_irqsave(&host->lock, flags); 869 + tmp = readl(mmio + PDC_CTLSTAT); 870 + tmp |= PDC_MASK_INT; 871 + tmp &= ~PDC_DMA_ENABLE; 872 + writel(tmp, mmio + PDC_CTLSTAT); 873 + readl(mmio + PDC_CTLSTAT); /* flush */ 874 + } 871 875 872 - qc = ata_qc_from_tag(ap, ap->link.active_tag); 876 + static void pdc_thaw(struct ata_port *ap) 877 + { 878 + void __iomem *mmio = ap->ioaddr.cmd_addr; 879 + u32 tmp; 873 880 874 - switch (qc->tf.protocol) { 875 - case ATA_PROT_DMA: 876 - case ATA_PROT_NODATA: 877 - ata_port_printk(ap, KERN_ERR, "command timeout\n"); 878 - qc->err_mask |= __ac_err_mask(ata_wait_idle(ap)); 879 - break; 881 + /* FIXME: start HDMA engine, if zero ATA engines running */ 880 882 881 - default: 882 - drv_stat = ata_sff_busy_wait(ap, ATA_BUSY | ATA_DRQ, 1000); 883 + /* clear IRQ */ 884 + ioread8(ap->ioaddr.status_addr); 883 885 884 - ata_port_printk(ap, KERN_ERR, 885 - "unknown timeout, cmd 0x%x stat 0x%x\n", 886 - qc->tf.command, drv_stat); 886 + /* turn IRQ back on */ 887 + tmp = readl(mmio + PDC_CTLSTAT); 888 + tmp &= ~PDC_MASK_INT; 889 + writel(tmp, mmio + PDC_CTLSTAT); 890 + readl(mmio + PDC_CTLSTAT); /* flush */ 891 + } 887 892 888 - qc->err_mask |= ac_err_mask(drv_stat); 889 - break; 893 + static void pdc_reset_port(struct ata_port *ap) 894 + { 895 + void __iomem *mmio = ap->ioaddr.cmd_addr + PDC_CTLSTAT; 896 + unsigned int i; 897 + u32 tmp; 898 + 899 + /* FIXME: handle HDMA copy engine */ 900 + 901 + for (i = 11; i > 0; i--) { 902 + tmp = readl(mmio); 903 + if (tmp & PDC_RESET) 904 + break; 905 + 906 + udelay(100); 907 + 908 + tmp |= PDC_RESET; 909 + writel(tmp, mmio); 890 910 } 891 911 892 - spin_unlock_irqrestore(&host->lock, flags); 893 - ata_eh_qc_complete(qc); 894 - DPRINTK("EXIT\n"); 912 + tmp &= ~PDC_RESET; 913 + writel(tmp, mmio); 914 + readl(mmio); /* flush */ 915 + } 916 + 917 + static int pdc_softreset(struct ata_link *link, unsigned int *class, 918 + unsigned long deadline) 919 + { 920 + pdc_reset_port(link->ap); 921 + return ata_sff_softreset(link, class, deadline); 922 + } 923 + 924 + static void pdc_error_handler(struct ata_port *ap) 925 + { 926 + if (!(ap->pflags & ATA_PFLAG_FROZEN)) 927 + pdc_reset_port(ap); 928 + 929 + ata_std_error_handler(ap); 930 + } 931 + 932 + static void pdc_post_internal_cmd(struct ata_queued_cmd *qc) 933 + { 934 + struct ata_port *ap = qc->ap; 935 + 936 + /* make DMA engine forget about the failed command */ 937 + if (qc->flags & ATA_QCFLAG_FAILED) 938 + pdc_reset_port(ap); 939 + } 940 + 941 + static int pdc_check_atapi_dma(struct ata_queued_cmd *qc) 942 + { 943 + u8 *scsicmd = qc->scsicmd->cmnd; 944 + int pio = 1; /* atapi dma off by default */ 945 + 946 + /* Whitelist commands that may use DMA. */ 947 + switch (scsicmd[0]) { 948 + case WRITE_12: 949 + case WRITE_10: 950 + case WRITE_6: 951 + case READ_12: 952 + case READ_10: 953 + case READ_6: 954 + case 0xad: /* READ_DVD_STRUCTURE */ 955 + case 0xbe: /* READ_CD */ 956 + pio = 0; 957 + } 958 + /* -45150 (FFFF4FA2) to -1 (FFFFFFFF) shall use PIO mode */ 959 + if (scsicmd[0] == WRITE_10) { 960 + unsigned int lba = 961 + (scsicmd[2] << 24) | 962 + (scsicmd[3] << 16) | 963 + (scsicmd[4] << 8) | 964 + scsicmd[5]; 965 + if (lba >= 0xFFFF4FA2) 966 + pio = 1; 967 + } 968 + return pio; 895 969 } 896 970 897 971 static void pdc_tf_load_mmio(struct ata_port *ap, const struct ata_taskfile *tf) 898 972 { 899 973 WARN_ON(tf->protocol == ATA_PROT_DMA || 900 - tf->protocol == ATA_PROT_NODATA); 974 + tf->protocol == ATAPI_PROT_DMA); 901 975 ata_sff_tf_load(ap, tf); 902 976 } 903 977 ··· 978 906 static void pdc_exec_command_mmio(struct ata_port *ap, const struct ata_taskfile *tf) 979 907 { 980 908 WARN_ON(tf->protocol == ATA_PROT_DMA || 981 - tf->protocol == ATA_PROT_NODATA); 909 + tf->protocol == ATAPI_PROT_DMA); 982 910 ata_sff_exec_command(ap, tf); 983 911 } 984 912
+28
include/linux/ata.h
··· 730 730 return 0; 731 731 } 732 732 733 + static inline int ata_id_form_factor(const u16 *id) 734 + { 735 + u16 val = id[168]; 736 + 737 + if (ata_id_major_version(id) < 7 || val == 0 || val == 0xffff) 738 + return 0; 739 + 740 + val &= 0xf; 741 + 742 + if (val > 5) 743 + return 0; 744 + 745 + return val; 746 + } 747 + 748 + static inline int ata_id_rotation_rate(const u16 *id) 749 + { 750 + u16 val = id[217]; 751 + 752 + if (ata_id_major_version(id) < 7 || val == 0 || val == 0xffff) 753 + return 0; 754 + 755 + if (val > 1 && val < 0x401) 756 + return 0; 757 + 758 + return val; 759 + } 760 + 733 761 static inline int ata_id_has_trim(const u16 *id) 734 762 { 735 763 if (ata_id_major_version(id) >= 7 &&