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

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

Pull ata updates from Damien Le Moal:

- Convert the bindings for the imx-pata and ahci-da850 drivers to DT
schemas (from Animesh)

- Correct the code to handle HAS_IOPORT dependencies and conditionally
compile drivers as needed (from Niklas)

- Correct the legacy_exit() function in the pata_legacy driver to
properly handle cleanups on driver exit (from Sergey)

- Small code simplification removing the ata_exec_internal_sg()
function and folding it into its only caller (from me)

* tag 'ata-6.10-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/libata/linux:
ata: pata_legacy: make legacy_exit() work again
ata: libata-core: Remove ata_exec_internal_sg()
ata: add HAS_IOPORT dependencies
dt-bindings: ata: ahci-da850: Convert to dtschema
dt-bindings: ata: imx-pata: Convert to dtschema

+139 -132
-18
Documentation/devicetree/bindings/ata/ahci-da850.txt
··· 1 - Device tree binding for the TI DA850 AHCI SATA Controller 2 - --------------------------------------------------------- 3 - 4 - Required properties: 5 - - compatible: must be "ti,da850-ahci" 6 - - reg: physical base addresses and sizes of the two register regions 7 - used by the controller: the register map as defined by the 8 - AHCI 1.1 standard and the Power Down Control Register (PWRDN) 9 - for enabling/disabling the SATA clock receiver 10 - - interrupts: interrupt specifier (refer to the interrupt binding) 11 - 12 - Example: 13 - 14 - sata: sata@218000 { 15 - compatible = "ti,da850-ahci"; 16 - reg = <0x218000 0x2000>, <0x22c018 0x4>; 17 - interrupts = <67>; 18 - };
+42
Documentation/devicetree/bindings/ata/fsl,imx-pata.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,imx-pata.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Freescale i.MX PATA Controller 8 + 9 + maintainers: 10 + - Animesh Agarwal <animeshagarwal28@gmail.com> 11 + 12 + properties: 13 + compatible: 14 + oneOf: 15 + - items: 16 + - enum: 17 + - fsl,imx31-pata 18 + - fsl,imx51-pata 19 + - const: fsl,imx27-pata 20 + - const: fsl,imx27-pata 21 + 22 + reg: 23 + maxItems: 1 24 + 25 + interrupts: 26 + items: 27 + - description: PATA Controller interrupts 28 + 29 + clocks: 30 + items: 31 + - description: PATA Controller clocks 32 + 33 + additionalProperties: false 34 + 35 + examples: 36 + - | 37 + pata: pata@83fe0000 { 38 + compatible = "fsl,imx51-pata", "fsl,imx27-pata"; 39 + reg = <0x83fe0000 0x4000>; 40 + interrupts = <70>; 41 + clocks = <&clks 161>; 42 + };
-16
Documentation/devicetree/bindings/ata/imx-pata.txt
··· 1 - * Freescale i.MX PATA Controller 2 - 3 - Required properties: 4 - - compatible: "fsl,imx27-pata" 5 - - reg: Address range of the PATA Controller 6 - - interrupts: The interrupt of the PATA Controller 7 - - clocks: the clocks for the PATA Controller 8 - 9 - Example: 10 - 11 - pata: pata@83fe0000 { 12 - compatible = "fsl,imx51-pata", "fsl,imx27-pata"; 13 - reg = <0x83fe0000 0x4000>; 14 - interrupts = <70>; 15 - clocks = <&clks 161>; 16 - };
+39
Documentation/devicetree/bindings/ata/ti,da850-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/ti,da850-ahci.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: TI DA850 AHCI SATA Controller 8 + 9 + maintainers: 10 + - Animesh Agarwal <animeshagarwal28@gmail.com> 11 + 12 + properties: 13 + compatible: 14 + const: ti,da850-ahci 15 + 16 + reg: 17 + items: 18 + - description: Address and size of the register map as defined by the AHCI 1.1 standard. 19 + - description: 20 + Address and size of Power Down Control Register (PWRDN) for enabling/disabling the SATA clock 21 + receiver. 22 + 23 + interrupts: 24 + maxItems: 1 25 + 26 + required: 27 + - compatible 28 + - reg 29 + - interrupts 30 + 31 + additionalProperties: false 32 + 33 + examples: 34 + - | 35 + sata@218000 { 36 + compatible = "ti,da850-ahci"; 37 + reg = <0x218000 0x2000>, <0x22c018 0x4>; 38 + interrupts = <67>; 39 + };
+14 -14
drivers/ata/Kconfig
··· 556 556 557 557 config PATA_ALI 558 558 tristate "ALi PATA support" 559 - depends on PCI 559 + depends on PCI && HAS_IOPORT 560 560 select PATA_TIMINGS 561 561 help 562 562 This option enables support for the ALi ATA interfaces ··· 566 566 567 567 config PATA_AMD 568 568 tristate "AMD/NVidia PATA support" 569 - depends on PCI 569 + depends on PCI && HAS_IOPORT 570 570 select PATA_TIMINGS 571 571 help 572 572 This option enables support for the AMD and NVidia PATA ··· 584 584 585 585 config PATA_ARTOP 586 586 tristate "ARTOP 6210/6260 PATA support" 587 - depends on PCI 587 + depends on PCI && HAS_IOPORT 588 588 help 589 589 This option enables support for ARTOP PATA controllers. 590 590 ··· 611 611 612 612 config PATA_CMD64X 613 613 tristate "CMD64x PATA support" 614 - depends on PCI 614 + depends on PCI && HAS_IOPORT 615 615 select PATA_TIMINGS 616 616 help 617 617 This option enables support for the CMD64x series chips ··· 658 658 659 659 config PATA_CYPRESS 660 660 tristate "Cypress CY82C693 PATA support (Very Experimental)" 661 - depends on PCI 661 + depends on PCI && HAS_IOPORT 662 662 select PATA_TIMINGS 663 663 help 664 664 This option enables support for the Cypress/Contaq CY82C693 ··· 706 706 707 707 config PATA_HPT37X 708 708 tristate "HPT 370/370A/371/372/374/302 PATA support" 709 - depends on PCI 709 + depends on PCI && HAS_IOPORT 710 710 help 711 711 This option enables support for the majority of the later HPT 712 712 PATA controllers via the new ATA layer. ··· 715 715 716 716 config PATA_HPT3X2N 717 717 tristate "HPT 371N/372N/302N PATA support" 718 - depends on PCI 718 + depends on PCI && HAS_IOPORT 719 719 help 720 720 This option enables support for the N variant HPT PATA 721 721 controllers via the new ATA layer. ··· 818 818 819 819 config PATA_NETCELL 820 820 tristate "NETCELL Revolution RAID support" 821 - depends on PCI 821 + depends on PCI && HAS_IOPORT 822 822 help 823 823 This option enables support for the Netcell Revolution RAID 824 824 PATA controller. ··· 854 854 855 855 config PATA_OPTIDMA 856 856 tristate "OPTI FireStar PATA support (Very Experimental)" 857 - depends on PCI 857 + depends on PCI && HAS_IOPORT 858 858 help 859 859 This option enables DMA/PIO support for the later OPTi 860 860 controllers found on some old motherboards and in some ··· 864 864 865 865 config PATA_PDC2027X 866 866 tristate "Promise PATA 2027x support" 867 - depends on PCI 867 + depends on PCI && HAS_IOPORT 868 868 help 869 869 This option enables support for Promise PATA pdc20268 to pdc20277 host adapters. 870 870 ··· 872 872 873 873 config PATA_PDC_OLD 874 874 tristate "Older Promise PATA controller support" 875 - depends on PCI 875 + depends on PCI && HAS_IOPORT 876 876 help 877 877 This option enables support for the Promise 20246, 20262, 20263, 878 878 20265 and 20267 adapters. ··· 900 900 901 901 config PATA_SC1200 902 902 tristate "SC1200 PATA support" 903 - depends on PCI && (X86_32 || COMPILE_TEST) 903 + depends on PCI && (X86_32 || COMPILE_TEST) && HAS_IOPORT 904 904 help 905 905 This option enables support for the NatSemi/AMD SC1200 SoC 906 906 companion chip used with the Geode processor family. ··· 918 918 919 919 config PATA_SERVERWORKS 920 920 tristate "SERVERWORKS OSB4/CSB5/CSB6/HT1000 PATA support" 921 - depends on PCI 921 + depends on PCI && HAS_IOPORT 922 922 help 923 923 This option enables support for the Serverworks OSB4/CSB5/CSB6 and 924 924 HT1000 PATA controllers, via the new ATA layer. ··· 1182 1182 1183 1183 config PATA_LEGACY 1184 1184 tristate "Legacy ISA PATA support (Experimental)" 1185 - depends on (ISA || PCI) 1185 + depends on (ISA || PCI) && HAS_IOPORT 1186 1186 select PATA_TIMINGS 1187 1187 help 1188 1188 This option enables support for ISA/VLB/PCI bus legacy PATA
+32 -76
drivers/ata/libata-core.c
··· 1480 1480 } 1481 1481 1482 1482 /** 1483 - * ata_exec_internal_sg - execute libata internal command 1483 + * ata_exec_internal - execute libata internal command 1484 1484 * @dev: Device to which the command is sent 1485 1485 * @tf: Taskfile registers for the command and the result 1486 1486 * @cdb: CDB for packet command 1487 1487 * @dma_dir: Data transfer direction of the command 1488 - * @sgl: sg list for the data buffer of the command 1489 - * @n_elem: Number of sg entries 1488 + * @buf: Data buffer of the command 1489 + * @buflen: Length of data buffer 1490 1490 * @timeout: Timeout in msecs (0 for default) 1491 1491 * 1492 - * Executes libata internal command with timeout. @tf contains 1493 - * command on entry and result on return. Timeout and error 1494 - * conditions are reported via return value. No recovery action 1495 - * is taken after a command times out. It's caller's duty to 1492 + * Executes libata internal command with timeout. @tf contains 1493 + * the command on entry and the result on return. Timeout and error 1494 + * conditions are reported via the return value. No recovery action 1495 + * is taken after a command times out. It is the caller's duty to 1496 1496 * clean up after timeout. 1497 1497 * 1498 1498 * LOCKING: ··· 1501 1501 * RETURNS: 1502 1502 * Zero on success, AC_ERR_* mask on failure 1503 1503 */ 1504 - static unsigned ata_exec_internal_sg(struct ata_device *dev, 1505 - struct ata_taskfile *tf, const u8 *cdb, 1506 - int dma_dir, struct scatterlist *sgl, 1507 - unsigned int n_elem, unsigned int timeout) 1504 + unsigned int ata_exec_internal(struct ata_device *dev, struct ata_taskfile *tf, 1505 + const u8 *cdb, enum dma_data_direction dma_dir, 1506 + void *buf, unsigned int buflen, 1507 + unsigned int timeout) 1508 1508 { 1509 1509 struct ata_link *link = dev->link; 1510 1510 struct ata_port *ap = link->ap; 1511 1511 u8 command = tf->command; 1512 - int auto_timeout = 0; 1513 1512 struct ata_queued_cmd *qc; 1513 + struct scatterlist sgl; 1514 1514 unsigned int preempted_tag; 1515 1515 u32 preempted_sactive; 1516 1516 u64 preempted_qc_active; 1517 1517 int preempted_nr_active_links; 1518 + bool auto_timeout = false; 1518 1519 DECLARE_COMPLETION_ONSTACK(wait); 1519 1520 unsigned long flags; 1520 1521 unsigned int err_mask; 1521 1522 int rc; 1522 1523 1524 + if (WARN_ON(dma_dir != DMA_NONE && !buf)) 1525 + return AC_ERR_INVALID; 1526 + 1523 1527 spin_lock_irqsave(ap->lock, flags); 1524 1528 1525 - /* no internal command while frozen */ 1529 + /* No internal command while frozen */ 1526 1530 if (ata_port_is_frozen(ap)) { 1527 1531 spin_unlock_irqrestore(ap->lock, flags); 1528 1532 return AC_ERR_SYSTEM; 1529 1533 } 1530 1534 1531 - /* initialize internal qc */ 1535 + /* Initialize internal qc */ 1532 1536 qc = __ata_qc_from_tag(ap, ATA_TAG_INTERNAL); 1533 1537 1534 1538 qc->tag = ATA_TAG_INTERNAL; ··· 1551 1547 ap->qc_active = 0; 1552 1548 ap->nr_active_links = 0; 1553 1549 1554 - /* prepare & issue qc */ 1550 + /* Prepare and issue qc */ 1555 1551 qc->tf = *tf; 1556 1552 if (cdb) 1557 1553 memcpy(qc->cdb, cdb, ATAPI_CDB_LEN); 1558 1554 1559 - /* some SATA bridges need us to indicate data xfer direction */ 1555 + /* Some SATA bridges need us to indicate data xfer direction */ 1560 1556 if (tf->protocol == ATAPI_PROT_DMA && (dev->flags & ATA_DFLAG_DMADIR) && 1561 1557 dma_dir == DMA_FROM_DEVICE) 1562 1558 qc->tf.feature |= ATAPI_DMADIR; ··· 1564 1560 qc->flags |= ATA_QCFLAG_RESULT_TF; 1565 1561 qc->dma_dir = dma_dir; 1566 1562 if (dma_dir != DMA_NONE) { 1567 - unsigned int i, buflen = 0; 1568 - struct scatterlist *sg; 1569 - 1570 - for_each_sg(sgl, sg, n_elem, i) 1571 - buflen += sg->length; 1572 - 1573 - ata_sg_init(qc, sgl, n_elem); 1563 + sg_init_one(&sgl, buf, buflen); 1564 + ata_sg_init(qc, &sgl, 1); 1574 1565 qc->nbytes = buflen; 1575 1566 } 1576 1567 ··· 1577 1578 spin_unlock_irqrestore(ap->lock, flags); 1578 1579 1579 1580 if (!timeout) { 1580 - if (ata_probe_timeout) 1581 + if (ata_probe_timeout) { 1581 1582 timeout = ata_probe_timeout * 1000; 1582 - else { 1583 + } else { 1583 1584 timeout = ata_internal_cmd_timeout(dev, command); 1584 - auto_timeout = 1; 1585 + auto_timeout = true; 1585 1586 } 1586 1587 } 1587 1588 ··· 1594 1595 ata_sff_flush_pio_task(ap); 1595 1596 1596 1597 if (!rc) { 1597 - spin_lock_irqsave(ap->lock, flags); 1598 - 1599 - /* We're racing with irq here. If we lose, the 1600 - * following test prevents us from completing the qc 1601 - * twice. If we win, the port is frozen and will be 1602 - * cleaned up by ->post_internal_cmd(). 1598 + /* 1599 + * We are racing with irq here. If we lose, the following test 1600 + * prevents us from completing the qc twice. If we win, the port 1601 + * is frozen and will be cleaned up by ->post_internal_cmd(). 1603 1602 */ 1603 + spin_lock_irqsave(ap->lock, flags); 1604 1604 if (qc->flags & ATA_QCFLAG_ACTIVE) { 1605 1605 qc->err_mask |= AC_ERR_TIMEOUT; 1606 - 1607 1606 ata_port_freeze(ap); 1608 - 1609 1607 ata_dev_warn(dev, "qc timeout after %u msecs (cmd 0x%x)\n", 1610 1608 timeout, command); 1611 1609 } 1612 - 1613 1610 spin_unlock_irqrestore(ap->lock, flags); 1614 1611 } 1615 1612 1616 - /* do post_internal_cmd */ 1617 1613 if (ap->ops->post_internal_cmd) 1618 1614 ap->ops->post_internal_cmd(qc); 1619 1615 1620 - /* perform minimal error analysis */ 1616 + /* Perform minimal error analysis */ 1621 1617 if (qc->flags & ATA_QCFLAG_EH) { 1622 1618 if (qc->result_tf.status & (ATA_ERR | ATA_DF)) 1623 1619 qc->err_mask |= AC_ERR_DEV; ··· 1626 1632 qc->result_tf.status |= ATA_SENSE; 1627 1633 } 1628 1634 1629 - /* finish up */ 1635 + /* Finish up */ 1630 1636 spin_lock_irqsave(ap->lock, flags); 1631 1637 1632 1638 *tf = qc->result_tf; ··· 1644 1650 ata_internal_cmd_timed_out(dev, command); 1645 1651 1646 1652 return err_mask; 1647 - } 1648 - 1649 - /** 1650 - * ata_exec_internal - execute libata internal command 1651 - * @dev: Device to which the command is sent 1652 - * @tf: Taskfile registers for the command and the result 1653 - * @cdb: CDB for packet command 1654 - * @dma_dir: Data transfer direction of the command 1655 - * @buf: Data buffer of the command 1656 - * @buflen: Length of data buffer 1657 - * @timeout: Timeout in msecs (0 for default) 1658 - * 1659 - * Wrapper around ata_exec_internal_sg() which takes simple 1660 - * buffer instead of sg list. 1661 - * 1662 - * LOCKING: 1663 - * None. Should be called with kernel context, might sleep. 1664 - * 1665 - * RETURNS: 1666 - * Zero on success, AC_ERR_* mask on failure 1667 - */ 1668 - unsigned ata_exec_internal(struct ata_device *dev, 1669 - struct ata_taskfile *tf, const u8 *cdb, 1670 - int dma_dir, void *buf, unsigned int buflen, 1671 - unsigned int timeout) 1672 - { 1673 - struct scatterlist *psg = NULL, sg; 1674 - unsigned int n_elem = 0; 1675 - 1676 - if (dma_dir != DMA_NONE) { 1677 - WARN_ON(!buf); 1678 - sg_init_one(&sg, buf, buflen); 1679 - psg = &sg; 1680 - n_elem++; 1681 - } 1682 - 1683 - return ata_exec_internal_sg(dev, tf, cdb, dma_dir, psg, n_elem, 1684 - timeout); 1685 1653 } 1686 1654 1687 1655 /**
+4
drivers/ata/libata-sff.c
··· 3032 3032 */ 3033 3033 int ata_pci_bmdma_clear_simplex(struct pci_dev *pdev) 3034 3034 { 3035 + #ifdef CONFIG_HAS_IOPORT 3035 3036 unsigned long bmdma = pci_resource_start(pdev, 4); 3036 3037 u8 simplex; 3037 3038 ··· 3045 3044 if (simplex & 0x80) 3046 3045 return -EOPNOTSUPP; 3047 3046 return 0; 3047 + #else 3048 + return -ENOENT; 3049 + #endif /* CONFIG_HAS_IOPORT */ 3048 3050 } 3049 3051 EXPORT_SYMBOL_GPL(ata_pci_bmdma_clear_simplex); 3050 3052
+4 -4
drivers/ata/libata.h
··· 50 50 unsigned int tf_flags, int dld, int class); 51 51 extern u64 ata_tf_read_block(const struct ata_taskfile *tf, 52 52 struct ata_device *dev); 53 - extern unsigned ata_exec_internal(struct ata_device *dev, 54 - struct ata_taskfile *tf, const u8 *cdb, 55 - int dma_dir, void *buf, unsigned int buflen, 56 - unsigned int timeout); 53 + unsigned int ata_exec_internal(struct ata_device *dev, struct ata_taskfile *tf, 54 + const u8 *cdb, enum dma_data_direction dma_dir, 55 + void *buf, unsigned int buflen, 56 + unsigned int timeout); 57 57 extern int ata_wait_ready(struct ata_link *link, unsigned long deadline, 58 58 int (*check_ready)(struct ata_link *link)); 59 59 extern int ata_dev_read_id(struct ata_device *dev, unsigned int *p_class,
+4 -4
drivers/ata/pata_legacy.c
··· 173 173 static struct legacy_probe probe_list[NR_HOST]; 174 174 static struct legacy_data legacy_data[NR_HOST]; 175 175 static struct ata_host *legacy_host[NR_HOST]; 176 - static int nr_legacy_host; 177 - 178 176 179 177 /** 180 178 * legacy_probe_add - Add interface to probe list ··· 1274 1276 { 1275 1277 int i; 1276 1278 1277 - for (i = 0; i < nr_legacy_host; i++) { 1279 + for (i = 0; i < NR_HOST; i++) { 1278 1280 struct legacy_data *ld = &legacy_data[i]; 1279 - ata_host_detach(legacy_host[i]); 1281 + 1282 + if (legacy_host[i]) 1283 + ata_host_detach(legacy_host[i]); 1280 1284 platform_device_unregister(ld->platform_dev); 1281 1285 } 1282 1286 }