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

+162 -38
+2 -1
drivers/scsi/sata_mv.c
··· 2 2 * sata_mv.c - Marvell SATA support 3 3 * 4 4 * Copyright 2005: EMC Corporation, all rights reserved. 5 + * Copyright 2005 Red Hat, Inc. All rights reserved. 5 6 * 6 7 * Please ALWAYS copy linux-ide@vger.kernel.org on emails. 7 8 * ··· 37 36 #include <asm/io.h> 38 37 39 38 #define DRV_NAME "sata_mv" 40 - #define DRV_VERSION "0.25" 39 + #define DRV_VERSION "0.5" 41 40 42 41 enum { 43 42 /* BAR's are enumerated in terms of pci_resource_start() terms */
+160 -37
drivers/scsi/sata_sil24.c
··· 5 5 * 6 6 * Based on preview driver from Silicon Image. 7 7 * 8 - * NOTE: No NCQ/ATAPI support yet. The preview driver didn't support 9 - * NCQ nor ATAPI, and, unfortunately, I couldn't find out how to make 10 - * those work. Enabling those shouldn't be difficult. Basic 11 - * structure is all there (in libata-dev tree). If you have any 12 - * information about this hardware, please contact me or linux-ide. 13 - * Info is needed on... 14 - * 15 - * - How to issue tagged commands and turn on sactive on issue accordingly. 16 - * - Where to put an ATAPI command and how to tell the device to send it. 17 - * - How to enable/use 64bit. 18 - * 19 8 * This program is free software; you can redistribute it and/or modify it 20 9 * under the terms of the GNU General Public License as published by the 21 10 * Free Software Foundation; either version 2, or (at your option) any ··· 31 42 #include <asm/io.h> 32 43 33 44 #define DRV_NAME "sata_sil24" 34 - #define DRV_VERSION "0.22" /* Silicon Image's preview driver was 0.10 */ 45 + #define DRV_VERSION "0.23" 35 46 36 47 /* 37 48 * Port request block (PRB) 32 bytes ··· 210 221 IRQ_STAT_4PORTS = 0xf, 211 222 }; 212 223 213 - struct sil24_cmd_block { 224 + struct sil24_ata_block { 214 225 struct sil24_prb prb; 215 226 struct sil24_sge sge[LIBATA_MAX_PRD]; 227 + }; 228 + 229 + struct sil24_atapi_block { 230 + struct sil24_prb prb; 231 + u8 cdb[16]; 232 + struct sil24_sge sge[LIBATA_MAX_PRD - 1]; 233 + }; 234 + 235 + union sil24_cmd_block { 236 + struct sil24_ata_block ata; 237 + struct sil24_atapi_block atapi; 216 238 }; 217 239 218 240 /* ··· 233 233 * here from the previous interrupt. 234 234 */ 235 235 struct sil24_port_priv { 236 - struct sil24_cmd_block *cmd_block; /* 32 cmd blocks */ 236 + union sil24_cmd_block *cmd_block; /* 32 cmd blocks */ 237 237 dma_addr_t cmd_block_dma; /* DMA base addr for them */ 238 238 struct ata_taskfile tf; /* Cached taskfile registers */ 239 239 }; ··· 244 244 void __iomem *port_base; /* port registers (4 * 8192 bytes @BAR2) */ 245 245 }; 246 246 247 + static void sil24_dev_config(struct ata_port *ap, struct ata_device *dev); 247 248 static u8 sil24_check_status(struct ata_port *ap); 248 249 static u32 sil24_scr_read(struct ata_port *ap, unsigned sc_reg); 249 250 static void sil24_scr_write(struct ata_port *ap, unsigned sc_reg, u32 val); ··· 298 297 static const struct ata_port_operations sil24_ops = { 299 298 .port_disable = ata_port_disable, 300 299 300 + .dev_config = sil24_dev_config, 301 + 301 302 .check_status = sil24_check_status, 302 303 .check_altstatus = sil24_check_status, 303 304 .dev_select = ata_noop_dev_select, ··· 336 333 { 337 334 .sht = &sil24_sht, 338 335 .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 339 - ATA_FLAG_SATA_RESET | ATA_FLAG_MMIO | 336 + ATA_FLAG_SRST | ATA_FLAG_MMIO | 340 337 ATA_FLAG_PIO_DMA | SIL24_NPORTS2FLAG(4), 341 338 .pio_mask = 0x1f, /* pio0-4 */ 342 339 .mwdma_mask = 0x07, /* mwdma0-2 */ ··· 347 344 { 348 345 .sht = &sil24_sht, 349 346 .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 350 - ATA_FLAG_SATA_RESET | ATA_FLAG_MMIO | 347 + ATA_FLAG_SRST | ATA_FLAG_MMIO | 351 348 ATA_FLAG_PIO_DMA | SIL24_NPORTS2FLAG(2), 352 349 .pio_mask = 0x1f, /* pio0-4 */ 353 350 .mwdma_mask = 0x07, /* mwdma0-2 */ ··· 358 355 { 359 356 .sht = &sil24_sht, 360 357 .host_flags = ATA_FLAG_SATA | ATA_FLAG_NO_LEGACY | 361 - ATA_FLAG_SATA_RESET | ATA_FLAG_MMIO | 358 + ATA_FLAG_SRST | ATA_FLAG_MMIO | 362 359 ATA_FLAG_PIO_DMA | SIL24_NPORTS2FLAG(1), 363 360 .pio_mask = 0x1f, /* pio0-4 */ 364 361 .mwdma_mask = 0x07, /* mwdma0-2 */ ··· 366 363 .port_ops = &sil24_ops, 367 364 }, 368 365 }; 366 + 367 + static void sil24_dev_config(struct ata_port *ap, struct ata_device *dev) 368 + { 369 + void __iomem *port = (void __iomem *)ap->ioaddr.cmd_addr; 370 + 371 + if (ap->cdb_len == 16) 372 + writel(PORT_CS_CDB16, port + PORT_CTRL_STAT); 373 + else 374 + writel(PORT_CS_CDB16, port + PORT_CTRL_CLR); 375 + } 369 376 370 377 static inline void sil24_update_tf(struct ata_port *ap) 371 378 { ··· 428 415 *tf = pp->tf; 429 416 } 430 417 418 + static int sil24_issue_SRST(struct ata_port *ap) 419 + { 420 + void __iomem *port = (void __iomem *)ap->ioaddr.cmd_addr; 421 + struct sil24_port_priv *pp = ap->private_data; 422 + struct sil24_prb *prb = &pp->cmd_block[0].ata.prb; 423 + dma_addr_t paddr = pp->cmd_block_dma; 424 + u32 irq_enable, irq_stat; 425 + int cnt; 426 + 427 + /* temporarily turn off IRQs during SRST */ 428 + irq_enable = readl(port + PORT_IRQ_ENABLE_SET); 429 + writel(irq_enable, port + PORT_IRQ_ENABLE_CLR); 430 + 431 + /* 432 + * XXX: Not sure whether the following sleep is needed or not. 433 + * The original driver had it. So.... 434 + */ 435 + msleep(10); 436 + 437 + prb->ctrl = PRB_CTRL_SRST; 438 + prb->fis[1] = 0; /* no PM yet */ 439 + 440 + writel((u32)paddr, port + PORT_CMD_ACTIVATE); 441 + 442 + for (cnt = 0; cnt < 100; cnt++) { 443 + irq_stat = readl(port + PORT_IRQ_STAT); 444 + writel(irq_stat, port + PORT_IRQ_STAT); /* clear irq */ 445 + 446 + irq_stat >>= PORT_IRQ_RAW_SHIFT; 447 + if (irq_stat & (PORT_IRQ_COMPLETE | PORT_IRQ_ERROR)) 448 + break; 449 + 450 + msleep(1); 451 + } 452 + 453 + /* restore IRQs */ 454 + writel(irq_enable, port + PORT_IRQ_ENABLE_SET); 455 + 456 + if (!(irq_stat & PORT_IRQ_COMPLETE)) 457 + return -1; 458 + 459 + /* update TF */ 460 + sil24_update_tf(ap); 461 + return 0; 462 + } 463 + 431 464 static void sil24_phy_reset(struct ata_port *ap) 432 465 { 466 + struct sil24_port_priv *pp = ap->private_data; 467 + 433 468 __sata_phy_reset(ap); 434 - /* 435 - * No ATAPI yet. Just unconditionally indicate ATA device. 436 - * If ATAPI device is attached, it will fail ATA_CMD_ID_ATA 437 - * and libata core will ignore the device. 438 - */ 439 - if (!(ap->flags & ATA_FLAG_PORT_DISABLED)) 440 - ap->device[0].class = ATA_DEV_ATA; 469 + if (ap->flags & ATA_FLAG_PORT_DISABLED) 470 + return; 471 + 472 + if (sil24_issue_SRST(ap) < 0) { 473 + printk(KERN_ERR DRV_NAME 474 + " ata%u: SRST failed, disabling port\n", ap->id); 475 + ap->ops->port_disable(ap); 476 + return; 477 + } 478 + 479 + ap->device->class = ata_dev_classify(&pp->tf); 441 480 } 442 481 443 482 static inline void sil24_fill_sg(struct ata_queued_cmd *qc, 444 - struct sil24_cmd_block *cb) 483 + struct sil24_sge *sge) 445 484 { 446 - struct sil24_sge *sge = cb->sge; 447 485 struct scatterlist *sg; 448 486 unsigned int idx = 0; 449 487 ··· 515 451 { 516 452 struct ata_port *ap = qc->ap; 517 453 struct sil24_port_priv *pp = ap->private_data; 518 - struct sil24_cmd_block *cb = pp->cmd_block + qc->tag; 519 - struct sil24_prb *prb = &cb->prb; 454 + union sil24_cmd_block *cb = pp->cmd_block + qc->tag; 455 + struct sil24_prb *prb; 456 + struct sil24_sge *sge; 520 457 521 458 switch (qc->tf.protocol) { 522 459 case ATA_PROT_PIO: 523 460 case ATA_PROT_DMA: 524 461 case ATA_PROT_NODATA: 462 + prb = &cb->ata.prb; 463 + sge = cb->ata.sge; 464 + prb->ctrl = 0; 525 465 break; 466 + 467 + case ATA_PROT_ATAPI: 468 + case ATA_PROT_ATAPI_DMA: 469 + case ATA_PROT_ATAPI_NODATA: 470 + prb = &cb->atapi.prb; 471 + sge = cb->atapi.sge; 472 + memset(cb->atapi.cdb, 0, 32); 473 + memcpy(cb->atapi.cdb, qc->cdb, ap->cdb_len); 474 + 475 + if (qc->tf.protocol != ATA_PROT_ATAPI_NODATA) { 476 + if (qc->tf.flags & ATA_TFLAG_WRITE) 477 + prb->ctrl = PRB_CTRL_PACKET_WRITE; 478 + else 479 + prb->ctrl = PRB_CTRL_PACKET_READ; 480 + } else 481 + prb->ctrl = 0; 482 + 483 + break; 484 + 526 485 default: 527 - /* ATAPI isn't supported yet */ 486 + prb = NULL; /* shut up, gcc */ 487 + sge = NULL; 528 488 BUG(); 529 489 } 530 490 531 491 ata_tf_to_fis(&qc->tf, prb->fis, 0); 532 492 533 493 if (qc->flags & ATA_QCFLAG_DMAMAP) 534 - sil24_fill_sg(qc, cb); 494 + sil24_fill_sg(qc, sge); 535 495 } 536 496 537 497 static int sil24_qc_issue(struct ata_queued_cmd *qc) ··· 572 484 static void sil24_irq_clear(struct ata_port *ap) 573 485 { 574 486 /* unused */ 487 + } 488 + 489 + static int __sil24_restart_controller(void __iomem *port) 490 + { 491 + u32 tmp; 492 + int cnt; 493 + 494 + writel(PORT_CS_INIT, port + PORT_CTRL_STAT); 495 + 496 + /* Max ~10ms */ 497 + for (cnt = 0; cnt < 10000; cnt++) { 498 + tmp = readl(port + PORT_CTRL_STAT); 499 + if (tmp & PORT_CS_RDY) 500 + return 0; 501 + udelay(1); 502 + } 503 + 504 + return -1; 505 + } 506 + 507 + static void sil24_restart_controller(struct ata_port *ap) 508 + { 509 + if (__sil24_restart_controller((void __iomem *)ap->ioaddr.cmd_addr)) 510 + printk(KERN_ERR DRV_NAME 511 + " ata%u: failed to restart controller\n", ap->id); 575 512 } 576 513 577 514 static int __sil24_reset_controller(void __iomem *port) ··· 618 505 619 506 if (tmp & PORT_CS_DEV_RST) 620 507 return -1; 621 - return 0; 508 + 509 + if (tmp & PORT_CS_RDY) 510 + return 0; 511 + 512 + return __sil24_restart_controller(port); 622 513 } 623 514 624 515 static void sil24_reset_controller(struct ata_port *ap) ··· 684 567 if (serror) 685 568 writel(serror, port + PORT_SERROR); 686 569 687 - printk(KERN_ERR DRV_NAME " ata%u: error interrupt on port%d\n" 688 - " stat=0x%x irq=0x%x cmd_err=%d sstatus=0x%x serror=0x%x\n", 689 - ap->id, ap->port_no, slot_stat, irq_stat, cmd_err, sstatus, serror); 570 + /* 571 + * Don't log ATAPI device errors. They're supposed to happen 572 + * and any serious errors will be logged using sense data by 573 + * the SCSI layer. 574 + */ 575 + if (ap->device[0].class != ATA_DEV_ATAPI || cmd_err > PORT_CERR_SDB) 576 + printk("ata%u: error interrupt on port%d\n" 577 + " stat=0x%x irq=0x%x cmd_err=%d sstatus=0x%x serror=0x%x\n", 578 + ap->id, ap->port_no, slot_stat, irq_stat, cmd_err, sstatus, serror); 690 579 691 580 if (cmd_err == PORT_CERR_DEV || cmd_err == PORT_CERR_SDB) { 692 581 /* ··· 700 577 */ 701 578 sil24_update_tf(ap); 702 579 err_mask = ac_err_mask(pp->tf.command); 580 + sil24_restart_controller(ap); 703 581 } else { 704 582 /* 705 583 * Other errors. libata currently doesn't have any ··· 708 584 * ATA_ERR. 709 585 */ 710 586 err_mask = AC_ERR_OTHER; 587 + sil24_reset_controller(ap); 711 588 } 712 589 713 590 if (qc) 714 591 ata_qc_complete(qc, err_mask); 715 - 716 - sil24_reset_controller(ap); 717 592 } 718 593 719 594 static inline void sil24_host_intr(struct ata_port *ap) ··· 788 665 { 789 666 struct device *dev = ap->host_set->dev; 790 667 struct sil24_port_priv *pp; 791 - struct sil24_cmd_block *cb; 668 + union sil24_cmd_block *cb; 792 669 size_t cb_size = sizeof(*cb); 793 670 dma_addr_t cb_dma; 794 671 int rc = -ENOMEM;