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-7.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/libata/linux

Pull ata updates from Niklas Cassel:

- Misc code cleanups related to tag checking and tag command completion
(Damien)

- Remove Baikal bt1-ahci DT binding since the upstreaming for this SoC
is not going to be finalized (Andy)

- Only call the libata port error handler from the SCSI error handler
if there were command timeouts or if EH was scheduled for the port
(Damien)

- Refactor ata_scsiop_maint_in() to more clearly show that there is
only one service action implemented for the MAINTENANCE IN command
(me)

- Clean up the handling of sysfs attributes exposed by libata (Heiner)

- Let libahci_platform use a flexible array member for platform PHYs to
avoid multiple allocations (Rosen)

- Do not retry reset if the device has been removed/hot-unplugged
(Igor)

- Add missing newlines to error prints in pata_arasan_cf driver (Haoyu)

- Use the correct SCSI host byte when completing deferred ATA
PASS-THROUGH commands, to avoid the SCSI mid-layer from failing the
commands instead of requeuing (Igor)

* tag 'ata-7.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/libata/linux:
ata: libata-scsi: fix requeue of deferred ATA PASS-THROUGH commands
ata: pata_arasan_cf: fix missing newline in dev_err() messages
ata: libata-transport: remove static variable ata_scsi_transport_template
ata: libata-transport: split struct ata_internal
ata: libata-transport: use static struct ata_transport_internal to simplify match functions
ata: libata-transport: inline ata_attach|release_transport
ata: libata-transport: instantiate struct ata_internal statically
ata: libata-eh: Do not retry reset if the device is gone
ata: libahci_platform: use flex array for platform PHYs
ata: libata-transport: remove redundant dynamic sysfs attributes
ata: libata-scsi: refactor ata_scsiop_maint_in()
ata: libata-eh: avoid unnecessary calls to ata_scsi_port_error_handler()
ata: ahci-dwc: Remove not-going-to-be-supported code for Baikal SoC
ata: libata-scsi: rename and improve ata_qc_done()
ata: libata-scsi: make ata_scsi_simulate() static
ata: libata-scsi: simplify ata_scsi_requeue_deferred_qc()
ata: libata-sata: simplify ata_sas_queuecmd()
ata: libata-core: improve tag checks in ata_qc_issue()

+265 -484
-115
Documentation/devicetree/bindings/ata/baikal,bt1-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/baikal,bt1-ahci.yaml# 5 - $schema: http://devicetree.org/meta-schemas/core.yaml# 6 - 7 - title: Baikal-T1 SoC AHCI SATA controller 8 - 9 - maintainers: 10 - - Serge Semin <fancer.lancer@gmail.com> 11 - 12 - description: 13 - AHCI SATA controller embedded into the Baikal-T1 SoC is based on the 14 - DWC AHCI SATA v4.10a IP-core. 15 - 16 - allOf: 17 - - $ref: snps,dwc-ahci-common.yaml# 18 - 19 - properties: 20 - compatible: 21 - const: baikal,bt1-ahci 22 - 23 - clocks: 24 - items: 25 - - description: Peripheral APB bus clock 26 - - description: Application AXI BIU clock 27 - - description: SATA Ports reference clock 28 - 29 - clock-names: 30 - items: 31 - - const: pclk 32 - - const: aclk 33 - - const: ref 34 - 35 - resets: 36 - items: 37 - - description: Application AXI BIU domain reset 38 - - description: SATA Ports clock domain reset 39 - 40 - reset-names: 41 - items: 42 - - const: arst 43 - - const: ref 44 - 45 - ports-implemented: 46 - maximum: 0x3 47 - 48 - patternProperties: 49 - "^sata-port@[0-1]$": 50 - $ref: /schemas/ata/snps,dwc-ahci-common.yaml#/$defs/dwc-ahci-port 51 - 52 - properties: 53 - reg: 54 - minimum: 0 55 - maximum: 1 56 - 57 - snps,tx-ts-max: 58 - $ref: /schemas/types.yaml#/definitions/uint32 59 - description: 60 - Due to having AXI3 bus interface utilized the maximum Tx DMA 61 - transaction size can't exceed 16 beats (AxLEN[3:0]). 62 - enum: [ 1, 2, 4, 8, 16 ] 63 - 64 - snps,rx-ts-max: 65 - $ref: /schemas/types.yaml#/definitions/uint32 66 - description: 67 - Due to having AXI3 bus interface utilized the maximum Rx DMA 68 - transaction size can't exceed 16 beats (AxLEN[3:0]). 69 - enum: [ 1, 2, 4, 8, 16 ] 70 - 71 - unevaluatedProperties: false 72 - 73 - required: 74 - - compatible 75 - - reg 76 - - interrupts 77 - - clocks 78 - - clock-names 79 - - resets 80 - 81 - unevaluatedProperties: false 82 - 83 - examples: 84 - - | 85 - sata@1f050000 { 86 - compatible = "baikal,bt1-ahci"; 87 - reg = <0x1f050000 0x2000>; 88 - #address-cells = <1>; 89 - #size-cells = <0>; 90 - 91 - interrupts = <0 64 4>; 92 - 93 - clocks = <&ccu_sys 1>, <&ccu_axi 2>, <&sata_ref_clk>; 94 - clock-names = "pclk", "aclk", "ref"; 95 - 96 - resets = <&ccu_axi 2>, <&ccu_sys 0>; 97 - reset-names = "arst", "ref"; 98 - 99 - ports-implemented = <0x3>; 100 - 101 - sata-port@0 { 102 - reg = <0>; 103 - 104 - snps,tx-ts-max = <4>; 105 - snps,rx-ts-max = <4>; 106 - }; 107 - 108 - sata-port@1 { 109 - reg = <1>; 110 - 111 - snps,tx-ts-max = <4>; 112 - snps,rx-ts-max = <4>; 113 - }; 114 - }; 115 - ...
-1
drivers/ata/Kconfig
··· 194 194 config AHCI_DWC 195 195 tristate "Synopsys DWC AHCI SATA support" 196 196 select SATA_HOST 197 - select MFD_SYSCON if (MIPS_BAIKAL_T1 || COMPILE_TEST) 198 197 help 199 198 This option enables support for the Synopsys DWC AHCI SATA 200 199 controller implementation.
+2 -1
drivers/ata/ahci.h
··· 357 357 * If platform uses PHYs. There is a 1:1 relation between the port number and 358 358 * the PHY position in this array. 359 359 */ 360 - struct phy **phys; 361 360 unsigned nports; /* Number of ports */ 362 361 void *plat_data; /* Other platform data */ 363 362 unsigned int irq; /* interrupt line */ ··· 378 379 /* only required for per-port MSI(-X) support */ 379 380 int (*get_irq_vector)(struct ata_host *host, 380 381 int port); 382 + 383 + struct phy *phys[] __counted_by(nports); 381 384 }; 382 385 383 386 /*
-55
drivers/ata/ahci_dwc.c
··· 13 13 #include <linux/kernel.h> 14 14 #include <linux/libata.h> 15 15 #include <linux/log2.h> 16 - #include <linux/mfd/syscon.h> 17 16 #include <linux/module.h> 18 17 #include <linux/of.h> 19 18 #include <linux/platform_device.h> 20 19 #include <linux/pm.h> 21 - #include <linux/regmap.h> 22 20 23 21 #include "ahci.h" 24 22 ··· 90 92 #define AHCI_DWC_PORT_PHYCR 0x74 91 93 #define AHCI_DWC_PORT_PHYSR 0x78 92 94 93 - /* Baikal-T1 AHCI SATA specific registers */ 94 - #define AHCI_BT1_HOST_PHYCR AHCI_DWC_HOST_GPCR 95 - #define AHCI_BT1_HOST_MPLM_MASK GENMASK(29, 23) 96 - #define AHCI_BT1_HOST_LOSDT_MASK GENMASK(22, 20) 97 - #define AHCI_BT1_HOST_CRR BIT(19) 98 - #define AHCI_BT1_HOST_CRW BIT(18) 99 - #define AHCI_BT1_HOST_CRCD BIT(17) 100 - #define AHCI_BT1_HOST_CRCA BIT(16) 101 - #define AHCI_BT1_HOST_CRDI_MASK GENMASK(15, 0) 102 - 103 - #define AHCI_BT1_HOST_PHYSR AHCI_DWC_HOST_GPSR 104 - #define AHCI_BT1_HOST_CRA BIT(16) 105 - #define AHCI_BT1_HOST_CRDO_MASK GENMASK(15, 0) 106 - 107 95 struct ahci_dwc_plat_data { 108 96 unsigned int pflags; 109 97 unsigned int hflags; ··· 105 121 u32 timv; 106 122 u32 dmacr[AHCI_MAX_PORTS]; 107 123 }; 108 - 109 - static int ahci_bt1_init(struct ahci_host_priv *hpriv) 110 - { 111 - struct ahci_dwc_host_priv *dpriv = hpriv->plat_data; 112 - int ret; 113 - 114 - /* APB, application and reference clocks are required */ 115 - if (!ahci_platform_find_clk(hpriv, "pclk") || 116 - !ahci_platform_find_clk(hpriv, "aclk") || 117 - !ahci_platform_find_clk(hpriv, "ref")) { 118 - dev_err(&dpriv->pdev->dev, "No system clocks specified\n"); 119 - return -EINVAL; 120 - } 121 - 122 - /* 123 - * Fully reset the SATA AXI and ref clocks domain to ensure the state 124 - * machine is working from scratch especially if the reference clocks 125 - * source has been changed. 126 - */ 127 - ret = ahci_platform_assert_rsts(hpriv); 128 - if (ret) { 129 - dev_err(&dpriv->pdev->dev, "Couldn't assert the resets\n"); 130 - return ret; 131 - } 132 - 133 - ret = ahci_platform_deassert_rsts(hpriv); 134 - if (ret) { 135 - dev_err(&dpriv->pdev->dev, "Couldn't de-assert the resets\n"); 136 - return ret; 137 - } 138 - 139 - return 0; 140 - } 141 124 142 125 static struct ahci_host_priv *ahci_dwc_get_resources(struct platform_device *pdev) 143 126 { ··· 408 457 .pflags = AHCI_PLATFORM_GET_RESETS, 409 458 }; 410 459 411 - static struct ahci_dwc_plat_data ahci_bt1_plat = { 412 - .pflags = AHCI_PLATFORM_GET_RESETS | AHCI_PLATFORM_RST_TRIGGER, 413 - .init = ahci_bt1_init, 414 - }; 415 - 416 460 static const struct of_device_id ahci_dwc_of_match[] = { 417 461 { .compatible = "snps,dwc-ahci", &ahci_dwc_plat }, 418 462 { .compatible = "snps,spear-ahci", &ahci_dwc_plat }, 419 - { .compatible = "baikal,bt1-ahci", &ahci_bt1_plat }, 420 463 {}, 421 464 }; 422 465 MODULE_DEVICE_TABLE(of, ahci_dwc_of_match);
+15 -18
drivers/ata/libahci_platform.c
··· 482 482 struct ahci_host_priv *hpriv; 483 483 u32 mask_port_map = 0; 484 484 u32 max_port; 485 + int nports; 485 486 486 487 if (!devres_open_group(dev, NULL, GFP_KERNEL)) 487 488 return ERR_PTR(-ENOMEM); 488 489 489 - hpriv = devres_alloc(ahci_platform_put_resources, sizeof(*hpriv), 490 + /* find maximum port id for allocating structures */ 491 + max_port = ahci_platform_find_max_port_id(dev); 492 + /* 493 + * Set nports according to maximum port id. Clamp at 494 + * AHCI_MAX_PORTS, warning message for invalid port id 495 + * is generated later. 496 + * When DT has no sub-nodes max_port is 0, nports is 1, 497 + * in order to be able to use the 498 + * ahci_platform_[en|dis]able_[phys|regulators] functions. 499 + */ 500 + nports = min(AHCI_MAX_PORTS, max_port + 1); 501 + hpriv = devres_alloc(ahci_platform_put_resources, struct_size(hpriv, phys, nports), 490 502 GFP_KERNEL); 491 503 if (!hpriv) 492 504 goto err_out; 505 + 506 + hpriv->nports = nports; 493 507 494 508 devres_add(dev, hpriv); 495 509 ··· 587 573 goto err_out; 588 574 } 589 575 590 - /* find maximum port id for allocating structures */ 591 - max_port = ahci_platform_find_max_port_id(dev); 592 - /* 593 - * Set nports according to maximum port id. Clamp at 594 - * AHCI_MAX_PORTS, warning message for invalid port id 595 - * is generated later. 596 - * When DT has no sub-nodes max_port is 0, nports is 1, 597 - * in order to be able to use the 598 - * ahci_platform_[en|dis]able_[phys|regulators] functions. 599 - */ 600 - hpriv->nports = min(AHCI_MAX_PORTS, max_port + 1); 601 - 602 - hpriv->phys = devm_kcalloc(dev, hpriv->nports, sizeof(*hpriv->phys), GFP_KERNEL); 603 - if (!hpriv->phys) { 604 - rc = -ENOMEM; 605 - goto err_out; 606 - } 607 576 /* 608 577 * We cannot use devm_ here, since ahci_platform_put_resources() uses 609 578 * target_pwrs after devm_ have freed memory
+8 -12
drivers/ata/libata-core.c
··· 5151 5151 struct ata_link *link = qc->dev->link; 5152 5152 u8 prot = qc->tf.protocol; 5153 5153 5154 - /* Make sure only one non-NCQ command is outstanding. */ 5155 - WARN_ON_ONCE(ata_tag_valid(link->active_tag)); 5154 + /* 5155 + * Make sure we have a valid tag and that only one non-NCQ command is 5156 + * outstanding. 5157 + */ 5158 + if (WARN_ON_ONCE(!ata_tag_valid(qc->tag)) || 5159 + WARN_ON_ONCE(ata_tag_valid(link->active_tag))) 5160 + goto sys_err; 5156 5161 5157 5162 if (ata_is_ncq(prot)) { 5158 5163 WARN_ON_ONCE(link->sactive & (1 << qc->hw_tag)); ··· 6778 6773 } 6779 6774 6780 6775 libata_transport_init(); 6781 - ata_scsi_transport_template = ata_attach_transport(); 6782 - if (!ata_scsi_transport_template) { 6783 - ata_sff_exit(); 6784 - rc = -ENOMEM; 6785 - goto err_out; 6786 - } 6787 6776 6788 6777 printk(KERN_DEBUG "libata version " DRV_VERSION " loaded.\n"); 6789 - return 0; 6790 6778 6791 - err_out: 6792 - return rc; 6779 + return 0; 6793 6780 } 6794 6781 6795 6782 static void __exit ata_exit(void) 6796 6783 { 6797 - ata_release_transport(ata_scsi_transport_template); 6798 6784 libata_transport_exit(); 6799 6785 ata_sff_exit(); 6800 6786 ata_free_force_param();
+20 -10
drivers/ata/libata-eh.c
··· 560 560 { 561 561 struct ata_port *ap = ata_shost_to_port(host); 562 562 unsigned long flags; 563 + int nr_timedout; 563 564 LIST_HEAD(eh_work_q); 564 565 565 566 spin_lock_irqsave(host->host_lock, flags); 566 567 list_splice_init(&host->eh_cmd_q, &eh_work_q); 567 568 spin_unlock_irqrestore(host->host_lock, flags); 568 569 569 - ata_scsi_cmd_error_handler(host, ap, &eh_work_q); 570 + /* 571 + * First check what errors we got with ata_scsi_cmd_error_handler(). 572 + * If we had no command timeouts and EH is not scheduled for this port, 573 + * meaning that we do not have any failed command, then there is no 574 + * need to go through the full port error handling. We only need to 575 + * flush the completed commands we have. 576 + */ 577 + nr_timedout = ata_scsi_cmd_error_handler(host, ap, &eh_work_q); 578 + if (nr_timedout || ata_port_eh_scheduled(ap)) 579 + ata_scsi_port_error_handler(host, ap); 580 + else 581 + scsi_eh_flush_done_q(&ap->eh_done_q); 570 582 571 - /* If we timed raced normal completion and there is nothing to 572 - recover nr_timedout == 0 why exactly are we doing error recovery ? */ 573 - ata_scsi_port_error_handler(host, ap); 574 - 575 - /* finish or retry handled scmd's and clean up */ 576 583 WARN_ON(!list_empty(&eh_work_q)); 577 - 578 584 } 579 585 580 586 /** ··· 592 586 * process the given list of commands and return those finished to the 593 587 * ap->eh_done_q. This function is the first part of the libata error 594 588 * handler which processes a given list of failed commands. 589 + * 590 + * Return the number of commands that timed out. 595 591 */ 596 - void ata_scsi_cmd_error_handler(struct Scsi_Host *host, struct ata_port *ap, 597 - struct list_head *eh_work_q) 592 + int ata_scsi_cmd_error_handler(struct Scsi_Host *host, struct ata_port *ap, 593 + struct list_head *eh_work_q) 598 594 { 599 595 int i; 600 596 unsigned long flags; ··· 703 695 ap->eh_tries = ATA_EH_MAX_TRIES; 704 696 705 697 spin_unlock_irqrestore(ap->lock, flags); 698 + 699 + return nr_timedout; 706 700 } 707 701 EXPORT_SYMBOL(ata_scsi_cmd_error_handler); 708 702 ··· 3181 3171 sata_scr_read(link, SCR_STATUS, &sstatus)) 3182 3172 rc = -ERESTART; 3183 3173 3184 - if (try >= max_tries) { 3174 + if (try >= max_tries || rc == -ENODEV) { 3185 3175 /* 3186 3176 * Thaw host port even if reset failed, so that the port 3187 3177 * can be retried on the next phy event. This risks
+6 -8
drivers/ata/libata-sata.c
··· 1378 1378 1379 1379 int ata_sas_queuecmd(struct scsi_cmnd *cmd, struct ata_port *ap) 1380 1380 { 1381 - int rc = 0; 1382 - 1383 1381 if (likely(ata_dev_enabled(ap->link.device))) 1384 - rc = __ata_scsi_queuecmd(cmd, ap->link.device); 1385 - else { 1386 - cmd->result = (DID_BAD_TARGET << 16); 1387 - scsi_done(cmd); 1388 - } 1389 - return rc; 1382 + return __ata_scsi_queuecmd(cmd, ap->link.device); 1383 + 1384 + cmd->result = (DID_BAD_TARGET << 16); 1385 + scsi_done(cmd); 1386 + 1387 + return 0; 1390 1388 } 1391 1389 EXPORT_SYMBOL_GPL(ata_sas_queuecmd); 1392 1390
+117 -110
drivers/ata/libata-scsi.c
··· 1649 1649 return 1; 1650 1650 } 1651 1651 1652 - static void ata_qc_done(struct ata_queued_cmd *qc) 1652 + static void ata_scsi_qc_done(struct ata_queued_cmd *qc, bool set_result, 1653 + u32 scmd_result) 1653 1654 { 1654 1655 struct scsi_cmnd *cmd = qc->scsicmd; 1655 1656 void (*done)(struct scsi_cmnd *) = qc->scsidone; 1656 1657 1657 1658 ata_qc_free(qc); 1659 + 1660 + if (set_result) 1661 + cmd->result = scmd_result; 1658 1662 done(cmd); 1659 1663 } 1660 1664 ··· 1689 1685 void ata_scsi_requeue_deferred_qc(struct ata_port *ap) 1690 1686 { 1691 1687 struct ata_queued_cmd *qc = ap->deferred_qc; 1692 - struct scsi_cmnd *scmd; 1693 1688 1694 1689 lockdep_assert_held(ap->lock); 1695 1690 1696 1691 /* 1697 1692 * If we have a deferred qc when a reset occurs or NCQ commands fail, 1698 1693 * do not try to be smart about what to do with this deferred command 1699 - * and simply retry it by completing it with DID_SOFT_ERROR. 1694 + * and simply requeue it by completing it with DID_REQUEUE. 1700 1695 */ 1701 - if (!qc) 1702 - return; 1703 - 1704 - scmd = qc->scsicmd; 1705 - ap->deferred_qc = NULL; 1706 - cancel_work(&ap->deferred_qc_work); 1707 - ata_qc_free(qc); 1708 - scmd->result = (DID_SOFT_ERROR << 16); 1709 - scsi_done(scmd); 1696 + if (qc) { 1697 + ap->deferred_qc = NULL; 1698 + cancel_work(&ap->deferred_qc_work); 1699 + ata_scsi_qc_done(qc, true, DID_REQUEUE << 16); 1700 + } 1710 1701 } 1711 1702 1712 1703 static void ata_scsi_schedule_deferred_qc(struct ata_port *ap) ··· 1757 1758 ata_scsi_set_sense_information(qc); 1758 1759 } 1759 1760 1760 - ata_qc_done(qc); 1761 + ata_scsi_qc_done(qc, false, 0); 1761 1762 1762 1763 ata_scsi_schedule_deferred_qc(ap); 1763 1764 } ··· 2916 2917 if (qc->cdb[0] == ALLOW_MEDIUM_REMOVAL && qc->dev->sdev) 2917 2918 qc->dev->sdev->locked = 0; 2918 2919 2919 - qc->scsicmd->result = SAM_STAT_CHECK_CONDITION; 2920 - ata_qc_done(qc); 2920 + ata_scsi_qc_done(qc, true, SAM_STAT_CHECK_CONDITION); 2921 2921 return; 2922 2922 } 2923 2923 2924 2924 /* successful completion path */ 2925 2925 if (cmd->cmnd[0] == INQUIRY && (cmd->cmnd[1] & 0x03) == 0) 2926 2926 atapi_fixup_inquiry(cmd); 2927 - cmd->result = SAM_STAT_GOOD; 2928 2927 2929 - ata_qc_done(qc); 2928 + ata_scsi_qc_done(qc, true, SAM_STAT_GOOD); 2930 2929 } 2931 2930 /** 2932 2931 * atapi_xlat - Initialize PACKET taskfile ··· 3573 3576 return 1; 3574 3577 } 3575 3578 3576 - /** 3577 - * ata_scsiop_maint_in - Simulate a subset of MAINTENANCE_IN 3578 - * @dev: Target device. 3579 - * @cmd: SCSI command of interest. 3580 - * @rbuf: Response buffer, to which simulated SCSI cmd output is sent. 3581 - * 3582 - * Yields a subset to satisfy scsi_report_opcode() 3583 - * 3584 - * LOCKING: 3585 - * spin_lock_irqsave(host lock) 3586 - */ 3587 - static unsigned int ata_scsiop_maint_in(struct ata_device *dev, 3588 - struct scsi_cmnd *cmd, u8 *rbuf) 3579 + static unsigned int ata_scsi_report_supported_opcodes(struct ata_device *dev, 3580 + struct scsi_cmnd *cmd, 3581 + u8 *rbuf) 3589 3582 { 3590 3583 u8 *cdb = cmd->cmnd; 3591 3584 u8 supported = 0, cdlp = 0, rwcdlp = 0; 3592 - 3593 - if ((cdb[1] & 0x1f) != MI_REPORT_SUPPORTED_OPERATION_CODES) { 3594 - ata_scsi_set_invalid_field(dev, cmd, 1, 0xff); 3595 - return 0; 3596 - } 3597 3585 3598 3586 if (cdb[2] != 1 && cdb[2] != 3) { 3599 3587 ata_dev_warn(dev, "invalid command format %d\n", cdb[2]); ··· 3657 3675 rbuf[1] = cdlp | supported; 3658 3676 3659 3677 return 4; 3678 + } 3679 + 3680 + /** 3681 + * ata_scsiop_maint_in - Simulate a subset of MAINTENANCE_IN 3682 + * @dev: Target device. 3683 + * @cmd: SCSI command of interest. 3684 + * @rbuf: Response buffer, to which simulated SCSI cmd output is sent. 3685 + * 3686 + * Yields a subset to satisfy scsi_report_opcode() 3687 + * 3688 + * LOCKING: 3689 + * spin_lock_irqsave(host lock) 3690 + */ 3691 + static unsigned int ata_scsiop_maint_in(struct ata_device *dev, 3692 + struct scsi_cmnd *cmd, u8 *rbuf) 3693 + { 3694 + u8 *cdb = cmd->cmnd; 3695 + u8 service_action = cdb[1] & 0x1f; 3696 + 3697 + switch (service_action) { 3698 + case MI_REPORT_SUPPORTED_OPERATION_CODES: 3699 + return ata_scsi_report_supported_opcodes(dev, cmd, rbuf); 3700 + default: 3701 + ata_scsi_set_invalid_field(dev, cmd, 1, 0xff); 3702 + return 0; 3703 + } 3660 3704 } 3661 3705 3662 3706 /** ··· 4432 4424 return NULL; 4433 4425 } 4434 4426 4427 + /** 4428 + * ata_scsi_simulate - simulate SCSI command on ATA device 4429 + * @dev: the target device 4430 + * @cmd: SCSI command being sent to device. 4431 + * 4432 + * Interprets and directly executes a select list of SCSI commands 4433 + * that can be handled internally. 4434 + * 4435 + * LOCKING: 4436 + * spin_lock_irqsave(host lock) 4437 + */ 4438 + static void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd) 4439 + { 4440 + const u8 *scsicmd = cmd->cmnd; 4441 + u8 tmp8; 4442 + 4443 + switch (scsicmd[0]) { 4444 + case INQUIRY: 4445 + ata_scsi_rbuf_fill(dev, cmd, ata_scsiop_inquiry); 4446 + break; 4447 + 4448 + case MODE_SENSE: 4449 + case MODE_SENSE_10: 4450 + ata_scsi_rbuf_fill(dev, cmd, ata_scsiop_mode_sense); 4451 + break; 4452 + 4453 + case READ_CAPACITY: 4454 + case SERVICE_ACTION_IN_16: 4455 + ata_scsi_rbuf_fill(dev, cmd, ata_scsiop_read_cap); 4456 + break; 4457 + 4458 + case REPORT_LUNS: 4459 + ata_scsi_rbuf_fill(dev, cmd, ata_scsiop_report_luns); 4460 + break; 4461 + 4462 + case REQUEST_SENSE: 4463 + ata_scsi_set_sense(dev, cmd, 0, 0, 0); 4464 + break; 4465 + 4466 + /* if we reach this, then writeback caching is disabled, 4467 + * turning this into a no-op. 4468 + */ 4469 + case SYNCHRONIZE_CACHE: 4470 + case SYNCHRONIZE_CACHE_16: 4471 + fallthrough; 4472 + 4473 + /* no-op's, complete with success */ 4474 + case REZERO_UNIT: 4475 + case SEEK_6: 4476 + case SEEK_10: 4477 + case TEST_UNIT_READY: 4478 + break; 4479 + 4480 + case SEND_DIAGNOSTIC: 4481 + tmp8 = scsicmd[1] & ~(1 << 3); 4482 + if (tmp8 != 0x4 || scsicmd[3] || scsicmd[4]) 4483 + ata_scsi_set_invalid_field(dev, cmd, 1, 0xff); 4484 + break; 4485 + 4486 + case MAINTENANCE_IN: 4487 + ata_scsi_rbuf_fill(dev, cmd, ata_scsiop_maint_in); 4488 + break; 4489 + 4490 + /* all other commands */ 4491 + default: 4492 + ata_scsi_set_sense(dev, cmd, ILLEGAL_REQUEST, 0x20, 0x0); 4493 + /* "Invalid command operation code" */ 4494 + break; 4495 + } 4496 + 4497 + scsi_done(cmd); 4498 + } 4499 + 4435 4500 enum scsi_qc_status __ata_scsi_queuecmd(struct scsi_cmnd *scmd, 4436 4501 struct ata_device *dev) 4437 4502 { ··· 4607 4526 } 4608 4527 EXPORT_SYMBOL_GPL(ata_scsi_queuecmd); 4609 4528 4610 - /** 4611 - * ata_scsi_simulate - simulate SCSI command on ATA device 4612 - * @dev: the target device 4613 - * @cmd: SCSI command being sent to device. 4614 - * 4615 - * Interprets and directly executes a select list of SCSI commands 4616 - * that can be handled internally. 4617 - * 4618 - * LOCKING: 4619 - * spin_lock_irqsave(host lock) 4620 - */ 4621 - 4622 - void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd) 4623 - { 4624 - const u8 *scsicmd = cmd->cmnd; 4625 - u8 tmp8; 4626 - 4627 - switch(scsicmd[0]) { 4628 - case INQUIRY: 4629 - ata_scsi_rbuf_fill(dev, cmd, ata_scsiop_inquiry); 4630 - break; 4631 - 4632 - case MODE_SENSE: 4633 - case MODE_SENSE_10: 4634 - ata_scsi_rbuf_fill(dev, cmd, ata_scsiop_mode_sense); 4635 - break; 4636 - 4637 - case READ_CAPACITY: 4638 - case SERVICE_ACTION_IN_16: 4639 - ata_scsi_rbuf_fill(dev, cmd, ata_scsiop_read_cap); 4640 - break; 4641 - 4642 - case REPORT_LUNS: 4643 - ata_scsi_rbuf_fill(dev, cmd, ata_scsiop_report_luns); 4644 - break; 4645 - 4646 - case REQUEST_SENSE: 4647 - ata_scsi_set_sense(dev, cmd, 0, 0, 0); 4648 - break; 4649 - 4650 - /* if we reach this, then writeback caching is disabled, 4651 - * turning this into a no-op. 4652 - */ 4653 - case SYNCHRONIZE_CACHE: 4654 - case SYNCHRONIZE_CACHE_16: 4655 - fallthrough; 4656 - 4657 - /* no-op's, complete with success */ 4658 - case REZERO_UNIT: 4659 - case SEEK_6: 4660 - case SEEK_10: 4661 - case TEST_UNIT_READY: 4662 - break; 4663 - 4664 - case SEND_DIAGNOSTIC: 4665 - tmp8 = scsicmd[1] & ~(1 << 3); 4666 - if (tmp8 != 0x4 || scsicmd[3] || scsicmd[4]) 4667 - ata_scsi_set_invalid_field(dev, cmd, 1, 0xff); 4668 - break; 4669 - 4670 - case MAINTENANCE_IN: 4671 - ata_scsi_rbuf_fill(dev, cmd, ata_scsiop_maint_in); 4672 - break; 4673 - 4674 - /* all other commands */ 4675 - default: 4676 - ata_scsi_set_sense(dev, cmd, ILLEGAL_REQUEST, 0x20, 0x0); 4677 - /* "Invalid command operation code" */ 4678 - break; 4679 - } 4680 - 4681 - scsi_done(cmd); 4682 - } 4683 - 4684 4529 int ata_scsi_add_hosts(struct ata_host *host, const struct scsi_host_template *sht) 4685 4530 { 4686 4531 int i, rc; ··· 4624 4617 *(struct ata_port **)&shost->hostdata[0] = ap; 4625 4618 ap->scsi_host = shost; 4626 4619 4627 - shost->transportt = ata_scsi_transport_template; 4620 + shost->transportt = &ata_scsi_transportt; 4628 4621 shost->unique_id = ap->print_id; 4629 4622 shost->max_id = 16; 4630 4623 shost->max_lun = 1;
+92 -146
drivers/ata/libata-transport.c
··· 37 37 #include "libata.h" 38 38 #include "libata-transport.h" 39 39 40 - #define ATA_PORT_ATTRS 3 41 - #define ATA_LINK_ATTRS 3 42 - #define ATA_DEV_ATTRS 9 43 - 44 - struct scsi_transport_template; 45 - struct scsi_transport_template *ata_scsi_transport_template; 46 - 47 - struct ata_internal { 48 - struct scsi_transport_template t; 49 - 50 - struct device_attribute private_port_attrs[ATA_PORT_ATTRS]; 51 - struct device_attribute private_link_attrs[ATA_LINK_ATTRS]; 52 - struct device_attribute private_dev_attrs[ATA_DEV_ATTRS]; 53 - 54 - struct transport_container link_attr_cont; 55 - struct transport_container dev_attr_cont; 56 - 57 - /* 58 - * The array of null terminated pointers to attributes 59 - * needed by scsi_sysfs.c 60 - */ 61 - struct device_attribute *link_attrs[ATA_LINK_ATTRS + 1]; 62 - struct device_attribute *port_attrs[ATA_PORT_ATTRS + 1]; 63 - struct device_attribute *dev_attrs[ATA_DEV_ATTRS + 1]; 64 - }; 65 - #define to_ata_internal(tmpl) container_of(tmpl, struct ata_internal, t) 66 - 40 + static int ata_tlink_match(struct attribute_container *cont, 41 + struct device *dev); 42 + static int ata_tdev_match(struct attribute_container *cont, 43 + struct device *dev); 67 44 68 45 #define tdev_to_device(d) \ 69 46 container_of((d), struct ata_device, tdev) ··· 56 79 container_of((d), struct ata_port, tdev) 57 80 #define transport_class_to_port(dev) \ 58 81 tdev_to_port((dev)->parent) 59 - 60 - /* 61 - * Hack to allow attributes of the same name in different objects. 62 - */ 63 - #define ATA_DEVICE_ATTR(_prefix,_name,_mode,_show,_store) \ 64 - struct device_attribute device_attr_##_prefix##_##_name = \ 65 - __ATTR(_name,_mode,_show,_store) 66 82 67 83 #define ata_bitfield_name_match(title, table) \ 68 84 static ssize_t \ ··· 184 214 /* We want the port_no sysfs attibute to start at 1 (ap->port_no starts at 0) */ 185 215 ata_port_simple_attr(port_no + 1, port_no, "%u\n", unsigned int); 186 216 217 + static const struct attribute *const ata_port_attr_attrs[] = { 218 + &dev_attr_nr_pmp_links.attr, 219 + &dev_attr_idle_irq.attr, 220 + &dev_attr_port_no.attr, 221 + NULL 222 + }; 223 + 224 + static const struct attribute_group ata_port_attr_group = { 225 + .attrs_const = ata_port_attr_attrs, 226 + }; 227 + 187 228 static DECLARE_TRANSPORT_CLASS(ata_port_class, 188 229 "ata_port", NULL, NULL, NULL); 189 230 ··· 221 240 { 222 241 if (!ata_is_port(dev)) 223 242 return 0; 224 - return &ata_scsi_transport_template->host_attrs.ac == cont; 243 + return &ata_scsi_transportt.host_attrs.ac == cont; 225 244 } 226 245 227 246 /** ··· 477 496 478 497 static DEVICE_ATTR(trim, S_IRUGO, show_ata_dev_trim, NULL); 479 498 499 + static const struct attribute *const ata_device_attr_attrs[] = { 500 + &dev_attr_class.attr, 501 + &dev_attr_pio_mode.attr, 502 + &dev_attr_dma_mode.attr, 503 + &dev_attr_xfer_mode.attr, 504 + &dev_attr_spdn_cnt.attr, 505 + &dev_attr_ering.attr, 506 + &dev_attr_id.attr, 507 + &dev_attr_gscr.attr, 508 + &dev_attr_trim.attr, 509 + NULL 510 + }; 511 + 512 + static const struct attribute_group ata_device_attr_group = { 513 + .attrs_const = ata_device_attr_attrs, 514 + }; 515 + 480 516 static DECLARE_TRANSPORT_CLASS(ata_dev_class, 481 517 "ata_device", NULL, NULL, NULL); 482 518 ··· 511 513 static bool ata_is_ata_dev(const struct device *dev) 512 514 { 513 515 return dev->release == ata_tdev_release; 514 - } 515 - 516 - static int ata_tdev_match(struct attribute_container *cont, 517 - struct device *dev) 518 - { 519 - struct ata_internal *i = to_ata_internal(ata_scsi_transport_template); 520 - 521 - if (!ata_is_ata_dev(dev)) 522 - return 0; 523 - return &i->dev_attr_cont.ac == cont; 524 516 } 525 517 526 518 /** ··· 614 626 ata_link_linkspeed_attr(sata_spd_limit, fls); 615 627 ata_link_linkspeed_attr(sata_spd, noop); 616 628 629 + static const struct attribute *const ata_link_attr_attrs[] = { 630 + &dev_attr_hw_sata_spd_limit.attr, 631 + &dev_attr_sata_spd_limit.attr, 632 + &dev_attr_sata_spd.attr, 633 + NULL 634 + }; 635 + 636 + static const struct attribute_group ata_link_attr_group = { 637 + .attrs_const = ata_link_attr_attrs, 638 + }; 639 + 617 640 static DECLARE_TRANSPORT_CLASS(ata_link_class, 618 641 "ata_link", NULL, NULL, NULL); 619 642 ··· 642 643 static bool ata_is_link(const struct device *dev) 643 644 { 644 645 return dev->release == ata_tlink_release; 645 - } 646 - 647 - static int ata_tlink_match(struct attribute_container *cont, 648 - struct device *dev) 649 - { 650 - struct ata_internal *i = to_ata_internal(ata_scsi_transport_template); 651 - 652 - if (!ata_is_link(dev)) 653 - return 0; 654 - return &i->link_attr_cont.ac == cont; 655 646 } 656 647 657 648 /** ··· 719 730 return error; 720 731 } 721 732 733 + struct scsi_transport_template ata_scsi_transportt = { 734 + .eh_strategy_handler = ata_scsi_error, 735 + .user_scan = ata_scsi_user_scan, 736 + 737 + .host_attrs.ac.class = &ata_port_class.class, 738 + .host_attrs.ac.grp = &ata_port_attr_group, 739 + .host_attrs.ac.match = ata_tport_match, 740 + }; 741 + 742 + static struct transport_container ata_link_attr_cont = { 743 + .ac.class = &ata_link_class.class, 744 + .ac.grp = &ata_link_attr_group, 745 + .ac.match = ata_tlink_match, 746 + }; 747 + 748 + static struct transport_container ata_dev_attr_cont = { 749 + .ac.class = &ata_dev_class.class, 750 + .ac.grp = &ata_device_attr_group, 751 + .ac.match = ata_tdev_match, 752 + }; 753 + 754 + static int ata_tlink_match(struct attribute_container *cont, 755 + struct device *dev) 756 + { 757 + if (!ata_is_link(dev)) 758 + return 0; 759 + 760 + return &ata_link_attr_cont.ac == cont; 761 + } 762 + 763 + static int ata_tdev_match(struct attribute_container *cont, 764 + struct device *dev) 765 + { 766 + if (!ata_is_ata_dev(dev)) 767 + return 0; 768 + 769 + return &ata_dev_attr_cont.ac == cont; 770 + } 771 + 722 772 /* 723 773 * Setup / Teardown code 724 774 */ 725 - 726 - #define SETUP_TEMPLATE(attrb, field, perm, test) \ 727 - i->private_##attrb[count] = dev_attr_##field; \ 728 - i->private_##attrb[count].attr.mode = perm; \ 729 - i->attrb[count] = &i->private_##attrb[count]; \ 730 - if (test) \ 731 - count++ 732 - 733 - #define SETUP_LINK_ATTRIBUTE(field) \ 734 - SETUP_TEMPLATE(link_attrs, field, S_IRUGO, 1) 735 - 736 - #define SETUP_PORT_ATTRIBUTE(field) \ 737 - SETUP_TEMPLATE(port_attrs, field, S_IRUGO, 1) 738 - 739 - #define SETUP_DEV_ATTRIBUTE(field) \ 740 - SETUP_TEMPLATE(dev_attrs, field, S_IRUGO, 1) 741 - 742 - /** 743 - * ata_attach_transport -- instantiate ATA transport template 744 - */ 745 - struct scsi_transport_template *ata_attach_transport(void) 746 - { 747 - struct ata_internal *i; 748 - int count; 749 - 750 - i = kzalloc_obj(struct ata_internal); 751 - if (!i) 752 - return NULL; 753 - 754 - i->t.eh_strategy_handler = ata_scsi_error; 755 - i->t.user_scan = ata_scsi_user_scan; 756 - 757 - i->t.host_attrs.ac.attrs = &i->port_attrs[0]; 758 - i->t.host_attrs.ac.class = &ata_port_class.class; 759 - i->t.host_attrs.ac.match = ata_tport_match; 760 - transport_container_register(&i->t.host_attrs); 761 - 762 - i->link_attr_cont.ac.class = &ata_link_class.class; 763 - i->link_attr_cont.ac.attrs = &i->link_attrs[0]; 764 - i->link_attr_cont.ac.match = ata_tlink_match; 765 - transport_container_register(&i->link_attr_cont); 766 - 767 - i->dev_attr_cont.ac.class = &ata_dev_class.class; 768 - i->dev_attr_cont.ac.attrs = &i->dev_attrs[0]; 769 - i->dev_attr_cont.ac.match = ata_tdev_match; 770 - transport_container_register(&i->dev_attr_cont); 771 - 772 - count = 0; 773 - SETUP_PORT_ATTRIBUTE(nr_pmp_links); 774 - SETUP_PORT_ATTRIBUTE(idle_irq); 775 - SETUP_PORT_ATTRIBUTE(port_no); 776 - BUG_ON(count > ATA_PORT_ATTRS); 777 - i->port_attrs[count] = NULL; 778 - 779 - count = 0; 780 - SETUP_LINK_ATTRIBUTE(hw_sata_spd_limit); 781 - SETUP_LINK_ATTRIBUTE(sata_spd_limit); 782 - SETUP_LINK_ATTRIBUTE(sata_spd); 783 - BUG_ON(count > ATA_LINK_ATTRS); 784 - i->link_attrs[count] = NULL; 785 - 786 - count = 0; 787 - SETUP_DEV_ATTRIBUTE(class); 788 - SETUP_DEV_ATTRIBUTE(pio_mode); 789 - SETUP_DEV_ATTRIBUTE(dma_mode); 790 - SETUP_DEV_ATTRIBUTE(xfer_mode); 791 - SETUP_DEV_ATTRIBUTE(spdn_cnt); 792 - SETUP_DEV_ATTRIBUTE(ering); 793 - SETUP_DEV_ATTRIBUTE(id); 794 - SETUP_DEV_ATTRIBUTE(gscr); 795 - SETUP_DEV_ATTRIBUTE(trim); 796 - BUG_ON(count > ATA_DEV_ATTRS); 797 - i->dev_attrs[count] = NULL; 798 - 799 - return &i->t; 800 - } 801 - 802 - /** 803 - * ata_release_transport -- release ATA transport template instance 804 - * @t: transport template instance 805 - */ 806 - void ata_release_transport(struct scsi_transport_template *t) 807 - { 808 - struct ata_internal *i = to_ata_internal(t); 809 - 810 - transport_container_unregister(&i->t.host_attrs); 811 - transport_container_unregister(&i->link_attr_cont); 812 - transport_container_unregister(&i->dev_attr_cont); 813 - 814 - kfree(i); 815 - } 816 775 817 776 __init int libata_transport_init(void) 818 777 { ··· 775 838 error = transport_class_register(&ata_dev_class); 776 839 if (error) 777 840 goto out_unregister_port; 841 + 842 + transport_container_register(&ata_scsi_transportt.host_attrs); 843 + transport_container_register(&ata_link_attr_cont); 844 + transport_container_register(&ata_dev_attr_cont); 845 + 778 846 return 0; 779 847 780 848 out_unregister_port: ··· 793 851 794 852 void __exit libata_transport_exit(void) 795 853 { 854 + transport_container_unregister(&ata_scsi_transportt.host_attrs); 855 + transport_container_unregister(&ata_link_attr_cont); 856 + transport_container_unregister(&ata_dev_attr_cont); 857 + 796 858 transport_class_unregister(&ata_link_class); 797 859 transport_class_unregister(&ata_port_class); 798 860 transport_class_unregister(&ata_dev_class);
+1 -4
drivers/ata/libata-transport.h
··· 3 3 #define _LIBATA_TRANSPORT_H 4 4 5 5 6 - extern struct scsi_transport_template *ata_scsi_transport_template; 6 + extern struct scsi_transport_template ata_scsi_transportt; 7 7 8 8 int ata_tlink_add(struct ata_link *link); 9 9 void ata_tlink_delete(struct ata_link *link); 10 - 11 - struct scsi_transport_template *ata_attach_transport(void); 12 - void ata_release_transport(struct scsi_transport_template *t); 13 10 14 11 __init int libata_transport_init(void); 15 12 void __exit libata_transport_exit(void);
+2 -2
drivers/ata/pata_arasan_cf.c
··· 380 380 if (!wait_for_completion_timeout(&acdev->cf_completion, TIMEOUT)) { 381 381 u32 rw = acdev->qc->tf.flags & ATA_TFLAG_WRITE; 382 382 383 - dev_err(acdev->host->dev, "%s TimeOut", rw ? "write" : "read"); 383 + dev_err(acdev->host->dev, "%s TimeOut\n", rw ? "write" : "read"); 384 384 return -ETIMEDOUT; 385 385 } 386 386 ··· 474 474 dma_len = min(xfer_cnt, FIFO_SIZE); 475 475 ret = dma_xfer(acdev, src, dest, dma_len); 476 476 if (ret) { 477 - dev_err(acdev->host->dev, "dma failed"); 477 + dev_err(acdev->host->dev, "dma failed\n"); 478 478 goto fail; 479 479 } 480 480
+2 -2
include/linux/libata.h
··· 1205 1205 struct ata_taskfile *tf, __le16 *id); 1206 1206 extern void ata_qc_complete(struct ata_queued_cmd *qc); 1207 1207 extern u64 ata_qc_get_active(struct ata_port *ap); 1208 - extern void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd); 1209 1208 extern int ata_std_bios_param(struct scsi_device *sdev, 1210 1209 struct gendisk *unused, 1211 1210 sector_t capacity, int geom[]); ··· 1225 1226 extern struct ata_device *ata_dev_pair(struct ata_device *adev); 1226 1227 int ata_set_mode(struct ata_link *link, struct ata_device **r_failed_dev); 1227 1228 extern void ata_scsi_port_error_handler(struct Scsi_Host *host, struct ata_port *ap); 1228 - extern void ata_scsi_cmd_error_handler(struct Scsi_Host *host, struct ata_port *ap, struct list_head *eh_q); 1229 + int ata_scsi_cmd_error_handler(struct Scsi_Host *host, struct ata_port *ap, 1230 + struct list_head *eh_q); 1229 1231 1230 1232 /* 1231 1233 * SATA specific code - drivers/ata/libata-sata.c