Pull ata updates from Damien Le Moal: - Some code cleanups to rename the function used to identify ZAC devices and declare some local functions static (me) - Refactoring and improvement of the translation of the SCSI REPORT SUPPORTED OPCODES command to allow users access to the entire list of supported commands (me) - Fix the translation of the WRITE SAME command with UNMAP bit set (DSM TRIM) for devices with a sector size larger than 2K and devices that support multiple TRIM segments (Niklas) - Add support detecting support for and translating the SCSI commands related to the storage elements depopulation feature (GET PHYSICAL ELEMENT STATUS, REMOVE ELEMENT AND TRUCATE, REMOVE ELEMENT AND MODIFY ZONES and RESTORE ELEMENTS AND REBUILD) (me) - Improvements to the sata_mv driver probe code (clocks and IRQ initialization) (Rosen) - Improve resource initialization in the pata_rb532_cf, pata_pxa, sata_highbank and ahci_da850 drivers (Rosen) - Improve PIO data-in command completions to better hndle slow devices, e.g. CF cards (Richard) - Improve the DMA channel management using device resources in the pata_pxa driver (Rosen) - Fix the pata_ep93xx driver to correctly fallback to PIO mode if DMA initialization fails (Rosen) - Use named initializers to define the match tables of the ahci_xgene, ahci_qoriq and ahci_platform drivers (Pawel) * tag 'ata-7.3' of git://git.kernel.org/pub/scm/linux/kernel/git/libata/linux: (28 commits) ata: use named initializers for acpi_device_id ata: pata_ep93xx: fix PIO fallback when DMA init fails ata: pata_pxa: use devres for DMA channel management ata: libata-sff: don't busy-wait for PIO data-in command completion ata: ahci_da850: use devm_platform_ioremap_resource() ata: sata_highbank: use devm_platform_ioremap_resource ata: pata_pxa: use devm_platform_ioremap_resource ata: pata_rb532_cf: use devm_platform_ioremap_resource() ata: sata_mv: use devm clock helpers ata: sata_mv: Use platform_get_irq() to get interrupt ata: pata_mpc52xx: Remove redundant dev_err() ata: libata-eh: make ata_eh_qc_complete() and ata_eh_qc_retry() static ata: libata-scsi: add support for the REMOVE ELEMENT AND MODIFY ZONES command ata: libata-scsi: add support for the RESTORE ELEMENTS AND REBUILD command ata: libata-scsi: add support for the REMOVE ELEMENT AND TRUNCATE command ata: libata-scsi: add support for the GET PHYSICAL ELEMENT STATUS command ata: libata-core: detect support for depopulation capabilities ata: libata-scsi: improve ata_get_xlat_func ata: libata: improve the definition of device flags scsi: define depopulation capabilities related service actions ...
Unified · Split
| @@ -162,7 +162,6 @@ static int ahci_da850_probe(struct platform_device *pdev) · 161 unmodified lines | |||
| 162 | struct device *dev = &pdev->dev; | 162 | struct device *dev = &pdev->dev; |
| 163 | struct ahci_host_priv *hpriv; | 163 | struct ahci_host_priv *hpriv; |
| 164 | void __iomem *pwrdn_reg; | 164 | void __iomem *pwrdn_reg; |
| 165 | struct resource *res; | ||
| 166 | u32 mpy; | 165 | u32 mpy; |
| 167 | int rc; | 166 | int rc; |
| 168 | 167 | ||
| @@ -198,22 +197,14 @@ static int ahci_da850_probe(struct platform_device *pdev) · 29 unmodified lines | |||
| 198 | return -EINVAL; | 197 | return -EINVAL; |
| 199 | } | 198 | } |
| 200 | 199 | ||
| 200 | pwrdn_reg = devm_platform_ioremap_resource(pdev, 1); | ||
| 201 | if (IS_ERR(pwrdn_reg)) | ||
| 202 | return PTR_ERR(pwrdn_reg); | ||
| 203 | |||
| 201 | rc = ahci_platform_enable_resources(hpriv); | 204 | rc = ahci_platform_enable_resources(hpriv); |
| 202 | if (rc) | 205 | if (rc) |
| 203 | return rc; | 206 | return rc; |
| 204 | 207 | ||
| 205 | res = platform_get_resource(pdev, IORESOURCE_MEM, 1); | ||
| 206 | if (!res) { | ||
| 207 | rc = -ENODEV; | ||
| 208 | goto disable_resources; | ||
| 209 | } | ||
| 210 | |||
| 211 | pwrdn_reg = devm_ioremap(dev, res->start, resource_size(res)); | ||
| 212 | if (!pwrdn_reg) { | ||
| 213 | rc = -ENOMEM; | ||
| 214 | goto disable_resources; | ||
| 215 | } | ||
| 216 | |||
| 217 | da850_sata_init(dev, pwrdn_reg, hpriv->mmio, mpy); | 208 | da850_sata_init(dev, pwrdn_reg, hpriv->mmio, mpy); |
| 218 | 209 | ||
| 219 | rc = ahci_platform_init_host(pdev, hpriv, &ahci_da850_port_info, | 210 | rc = ahci_platform_init_host(pdev, hpriv, &ahci_da850_port_info, |
| @@ -87,9 +87,9 @@ static const struct of_device_id ahci_of_match[] = { · 86 unmodified lines | |||
| 87 | MODULE_DEVICE_TABLE(of, ahci_of_match); | 87 | MODULE_DEVICE_TABLE(of, ahci_of_match); |
| 88 | 88 | ||
| 89 | static const struct acpi_device_id ahci_acpi_match[] = { | 89 | static const struct acpi_device_id ahci_acpi_match[] = { |
| 90 | { "APMC0D33", (unsigned long)&ahci_port_info_nolpm }, | 90 | { .id = "APMC0D33", .driver_data = (unsigned long)&ahci_port_info_nolpm }, |
| 91 | { ACPI_DEVICE_CLASS(PCI_CLASS_STORAGE_SATA_AHCI, 0xffffff) }, | 91 | { ACPI_DEVICE_CLASS(PCI_CLASS_STORAGE_SATA_AHCI, 0xffffff) }, |
| 92 | {}, | 92 | { } |
| 93 | }; | 93 | }; |
| 94 | MODULE_DEVICE_TABLE(acpi, ahci_acpi_match); | 94 | MODULE_DEVICE_TABLE(acpi, ahci_acpi_match); |
| 95 | 95 | ||
| @@ -80,7 +80,7 @@ static const struct of_device_id ahci_qoriq_of_match[] = { · 79 unmodified lines | |||
| 80 | MODULE_DEVICE_TABLE(of, ahci_qoriq_of_match); | 80 | MODULE_DEVICE_TABLE(of, ahci_qoriq_of_match); |
| 81 | 81 | ||
| 82 | static const struct acpi_device_id ahci_qoriq_acpi_match[] = { | 82 | static const struct acpi_device_id ahci_qoriq_acpi_match[] = { |
| 83 | {"NXP0004", .driver_data = (kernel_ulong_t)AHCI_LX2160A}, | 83 | { .id = "NXP0004", .driver_data = (kernel_ulong_t)AHCI_LX2160A }, |
| 84 | { } | 84 | { } |
| 85 | }; | 85 | }; |
| 86 | MODULE_DEVICE_TABLE(acpi, ahci_qoriq_acpi_match); | 86 | MODULE_DEVICE_TABLE(acpi, ahci_qoriq_acpi_match); |
| @@ -178,8 +178,8 @@ static SIMPLE_DEV_PM_OPS(ahci_pm_ops, ahci_platform_suspend, · 177 unmodified lines | |||
| 178 | ahci_platform_resume); | 178 | ahci_platform_resume); |
| 179 | 179 | ||
| 180 | static const struct acpi_device_id ahci_acpi_match[] = { | 180 | static const struct acpi_device_id ahci_acpi_match[] = { |
| 181 | { "AMDI0600", 0 }, | 181 | { .id = "AMDI0600" }, |
| 182 | {} | 182 | { } |
| 183 | }; | 183 | }; |
| 184 | MODULE_DEVICE_TABLE(acpi, ahci_acpi_match); | 184 | MODULE_DEVICE_TABLE(acpi, ahci_acpi_match); |
| 185 | 185 | ||
| @@ -710,9 +710,9 @@ static const struct scsi_host_template ahci_platform_sht = { · 709 unmodified lines | |||
| 710 | 710 | ||
| 711 | #ifdef CONFIG_ACPI | 711 | #ifdef CONFIG_ACPI |
| 712 | static const struct acpi_device_id xgene_ahci_acpi_match[] = { | 712 | static const struct acpi_device_id xgene_ahci_acpi_match[] = { |
| 713 | { "APMC0D0D", XGENE_AHCI_V1}, | 713 | { .id = "APMC0D0D", .driver_data = XGENE_AHCI_V1 }, |
| 714 | { "APMC0D32", XGENE_AHCI_V2}, | 714 | { .id = "APMC0D32", .driver_data = XGENE_AHCI_V2 }, |
| 715 | {}, | 715 | { } |
| 716 | }; | 716 | }; |
| 717 | MODULE_DEVICE_TABLE(acpi, xgene_ahci_acpi_match); | 717 | MODULE_DEVICE_TABLE(acpi, xgene_ahci_acpi_match); |
| 718 | #endif | 718 | #endif |
| @@ -2488,7 +2488,7 @@ static void ata_dev_config_sense_reporting(struct ata_device *dev) · 2487 unmodified lines | |||
| 2488 | } | 2488 | } |
| 2489 | } | 2489 | } |
| 2490 | 2490 | ||
| 2491 | static void ata_dev_config_zac(struct ata_device *dev) | 2491 | static void ata_dev_config_zoned(struct ata_device *dev) |
| 2492 | { | 2492 | { |
| 2493 | unsigned int err_mask; | 2493 | unsigned int err_mask; |
| 2494 | u8 *identify_buf = dev->sector_buf; | 2494 | u8 *identify_buf = dev->sector_buf; |
| @@ -2497,7 +2497,7 @@ static void ata_dev_config_zac(struct ata_device *dev) · 2 unmodified lines | |||
| 2497 | dev->zac_zones_optimal_nonseq = U32_MAX; | 2497 | dev->zac_zones_optimal_nonseq = U32_MAX; |
| 2498 | dev->zac_zones_max_open = U32_MAX; | 2498 | dev->zac_zones_max_open = U32_MAX; |
| 2499 | 2499 | ||
| 2500 | if (!ata_dev_is_zac(dev)) | 2500 | if (!ata_dev_is_zoned(dev)) |
| 2501 | return; | 2501 | return; |
| 2502 | 2502 | ||
| 2503 | if (!ata_identify_page_supported(dev, ATA_LOG_ZONED_INFORMATION)) { | 2503 | if (!ata_identify_page_supported(dev, ATA_LOG_ZONED_INFORMATION)) { |
| @@ -2705,6 +2705,71 @@ not_supported: · 201 unmodified lines | |||
| 2705 | ata_dev_cleanup_cdl_resources(dev); | 2705 | ata_dev_cleanup_cdl_resources(dev); |
| 2706 | } | 2706 | } |
| 2707 | 2707 | ||
| 2708 | static void ata_dev_config_depop(struct ata_device *dev) | ||
| 2709 | { | ||
| 2710 | unsigned int err_mask; | ||
| 2711 | u64 val; | ||
| 2712 | |||
| 2713 | /* Ignore old drives. */ | ||
| 2714 | if (ata_id_major_version(dev->id) < 11) | ||
| 2715 | goto not_supported; | ||
| 2716 | |||
| 2717 | /* NCQ Autosense is required. */ | ||
| 2718 | if (!ata_identify_page_supported(dev, ATA_LOG_SUPPORTED_CAPABILITIES) || | ||
| 2719 | !ata_id_has_ncq_autosense(dev->id)) | ||
| 2720 | goto not_supported; | ||
| 2721 | |||
| 2722 | err_mask = ata_read_log_page(dev, ATA_LOG_IDENTIFY_DEVICE, | ||
| 2723 | ATA_LOG_SUPPORTED_CAPABILITIES, | ||
| 2724 | dev->sector_buf, 1); | ||
| 2725 | if (err_mask) | ||
| 2726 | goto not_supported; | ||
| 2727 | |||
| 2728 | /* Check depopulation capabilities bits. */ | ||
| 2729 | val = get_unaligned_le64(&dev->sector_buf[152]); | ||
| 2730 | if (!(val & BIT_ULL(63))) | ||
| 2731 | goto not_supported; | ||
| 2732 | |||
| 2733 | /* | ||
| 2734 | * Support for at least the GET PHYSICAL ELEMENT STATUS and | ||
| 2735 | * REMOVE ELEMENT AND TRUNCATE commands is mandated. | ||
| 2736 | */ | ||
| 2737 | if (!(val & BIT_ULL(0)) || !(val & BIT_ULL(1))) | ||
| 2738 | goto not_supported; | ||
| 2739 | |||
| 2740 | dev->flags |= ATA_DFLAG_DEPOP; | ||
| 2741 | |||
| 2742 | /* Check if RESTORE ELEMENTS AND REBUILD is supported. */ | ||
| 2743 | if (val & BIT_ULL(2)) | ||
| 2744 | dev->flags |= ATA_DFLAG_DEPOP_RESTORE; | ||
| 2745 | |||
| 2746 | /* | ||
| 2747 | * For ZAC devices, check if REMOVE ELEMENT AND MODIFY ZONES is | ||
| 2748 | * supported. | ||
| 2749 | */ | ||
| 2750 | if (dev->class != ATA_DEV_ZAC) | ||
| 2751 | return; | ||
| 2752 | |||
| 2753 | err_mask = ata_read_log_page(dev, ATA_LOG_IDENTIFY_DEVICE, | ||
| 2754 | ATA_LOG_ZONED_INFORMATION, | ||
| 2755 | dev->sector_buf, 1); | ||
| 2756 | if (err_mask) | ||
| 2757 | return; | ||
| 2758 | |||
| 2759 | val = get_unaligned_le64(&dev->sector_buf[8]); | ||
| 2760 | if (!(val & BIT_ULL(63))) | ||
| 2761 | return; | ||
| 2762 | |||
| 2763 | if (val & BIT_ULL(1)) | ||
| 2764 | dev->flags |= ATA_DFLAG_DEPOP_MODIFY; | ||
| 2765 | |||
| 2766 | return; | ||
| 2767 | |||
| 2768 | not_supported: | ||
| 2769 | dev->flags &= ~(ATA_DFLAG_DEPOP | ATA_DFLAG_DEPOP_RESTORE | | ||
| 2770 | ATA_DFLAG_DEPOP_MODIFY); | ||
| 2771 | } | ||
| 2772 | |||
| 2708 | static int ata_dev_config_lba(struct ata_device *dev) | 2773 | static int ata_dev_config_lba(struct ata_device *dev) |
| 2709 | { | 2774 | { |
| 2710 | const u16 *id = dev->id; | 2775 | const u16 *id = dev->id; |
| @@ -2942,7 +3007,7 @@ static void ata_dev_print_features(struct ata_device *dev) · 231 unmodified lines | |||
| 2942 | return; | 3007 | return; |
| 2943 | 3008 | ||
| 2944 | ata_dev_info(dev, | 3009 | ata_dev_info(dev, |
| 2945 | "Features:%s%s%s%s%s%s%s%s%s%s\n", | 3010 | "Features:%s%s%s%s%s%s%s%s%s%s%s%s%s\n", |
| 2946 | dev->flags & ATA_DFLAG_FUA ? " FUA" : "", | 3011 | dev->flags & ATA_DFLAG_FUA ? " FUA" : "", |
| 2947 | dev->flags & ATA_DFLAG_TRUSTED ? " Trust" : "", | 3012 | dev->flags & ATA_DFLAG_TRUSTED ? " Trust" : "", |
| 2948 | dev->flags & ATA_DFLAG_DA ? " Dev-Attention" : "", | 3013 | dev->flags & ATA_DFLAG_DA ? " Dev-Attention" : "", |
| @@ -2952,7 +3017,10 @@ static void ata_dev_print_features(struct ata_device *dev) · 3 unmodified lines | |||
| 2952 | dev->flags & ATA_DFLAG_NCQ_SEND_RECV ? " NCQ-sndrcv" : "", | 3017 | dev->flags & ATA_DFLAG_NCQ_SEND_RECV ? " NCQ-sndrcv" : "", |
| 2953 | dev->flags & ATA_DFLAG_NCQ_PRIO ? " NCQ-prio" : "", | 3018 | dev->flags & ATA_DFLAG_NCQ_PRIO ? " NCQ-prio" : "", |
| 2954 | dev->flags & ATA_DFLAG_CDL ? " CDL" : "", | 3019 | dev->flags & ATA_DFLAG_CDL ? " CDL" : "", |
| 2955 | dev->cpr_log ? " CPR" : ""); | 3020 | dev->cpr_log ? " CPR" : "", |
| 3021 | dev->flags & ATA_DFLAG_DEPOP ? " Depop" : "", | ||
| 3022 | dev->flags & ATA_DFLAG_DEPOP_RESTORE ? " Depop-Restore" : "", | ||
| 3023 | dev->flags & ATA_DFLAG_DEPOP_MODIFY ? " Depop-Modify" : ""); | ||
| 2956 | } | 3024 | } |
| 2957 | 3025 | ||
| 2958 | /** | 3026 | /** |
| @@ -3111,10 +3179,11 @@ int ata_dev_configure(struct ata_device *dev) · 152 unmodified lines | |||
| 3111 | ata_dev_config_fua(dev); | 3179 | ata_dev_config_fua(dev); |
| 3112 | ata_dev_config_devslp(dev); | 3180 | ata_dev_config_devslp(dev); |
| 3113 | ata_dev_config_sense_reporting(dev); | 3181 | ata_dev_config_sense_reporting(dev); |
| 3114 | ata_dev_config_zac(dev); | 3182 | ata_dev_config_zoned(dev); |
| 3115 | ata_dev_config_trusted(dev); | 3183 | ata_dev_config_trusted(dev); |
| 3116 | ata_dev_config_cpr(dev); | 3184 | ata_dev_config_cpr(dev); |
| 3117 | ata_dev_config_cdl(dev); | 3185 | ata_dev_config_cdl(dev); |
| 3186 | ata_dev_config_depop(dev); | ||
| 3118 | dev->cdb_len = 32; | 3187 | dev->cdb_len = 32; |
| 3119 | 3188 | ||
| 3120 | if (print_info) | 3189 | if (print_info) |
| @@ -1221,9 +1221,10 @@ static void __ata_eh_qc_complete(struct ata_queued_cmd *qc) · 1220 unmodified lines | |||
| 1221 | * Indicate to the mid and upper layers that an ATA command has | 1221 | * Indicate to the mid and upper layers that an ATA command has |
| 1222 | * completed. To be used from EH. | 1222 | * completed. To be used from EH. |
| 1223 | */ | 1223 | */ |
| 1224 | void ata_eh_qc_complete(struct ata_queued_cmd *qc) | 1224 | static void ata_eh_qc_complete(struct ata_queued_cmd *qc) |
| 1225 | { | 1225 | { |
| 1226 | struct scsi_cmnd *scmd = qc->scsicmd; | 1226 | struct scsi_cmnd *scmd = qc->scsicmd; |
| 1227 | |||
| 1227 | scmd->retries = scmd->allowed; | 1228 | scmd->retries = scmd->allowed; |
| 1228 | __ata_eh_qc_complete(qc); | 1229 | __ata_eh_qc_complete(qc); |
| 1229 | } | 1230 | } |
| @@ -1239,9 +1240,10 @@ void ata_eh_qc_complete(struct ata_queued_cmd *qc) · 9 unmodified lines | |||
| 1239 | * scmd->allowed is incremented for commands which get retried | 1240 | * scmd->allowed is incremented for commands which get retried |
| 1240 | * due to unrelated failures (qc->err_mask is zero). | 1241 | * due to unrelated failures (qc->err_mask is zero). |
| 1241 | */ | 1242 | */ |
| 1242 | void ata_eh_qc_retry(struct ata_queued_cmd *qc) | 1243 | static void ata_eh_qc_retry(struct ata_queued_cmd *qc) |
| 1243 | { | 1244 | { |
| 1244 | struct scsi_cmnd *scmd = qc->scsicmd; | 1245 | struct scsi_cmnd *scmd = qc->scsicmd; |
| 1246 | |||
| 1245 | if (!qc->err_mask) | 1247 | if (!qc->err_mask) |
| 1246 | scmd->allowed++; | 1248 | scmd->allowed++; |
| 1247 | __ata_eh_qc_complete(qc); | 1249 | __ata_eh_qc_complete(qc); |
| @@ -2106,7 +2106,7 @@ static unsigned int ata_scsiop_inq_std(struct ata_device *dev, · 2105 unmodified lines | |||
| 2106 | if (rbuf[32] == 0 || rbuf[32] == ' ') | 2106 | if (rbuf[32] == 0 || rbuf[32] == ' ') |
| 2107 | memcpy(&rbuf[32], "n/a ", 4); | 2107 | memcpy(&rbuf[32], "n/a ", 4); |
| 2108 | 2108 | ||
| 2109 | if (ata_id_zoned_cap(dev->id) || dev->class == ATA_DEV_ZAC) | 2109 | if (ata_dev_is_zoned(dev)) |
| 2110 | memcpy(rbuf + 58, versions_zbc, sizeof(versions_zbc)); | 2110 | memcpy(rbuf + 58, versions_zbc, sizeof(versions_zbc)); |
| 2111 | else | 2111 | else |
| 2112 | memcpy(rbuf + 58, versions, sizeof(versions)); | 2112 | memcpy(rbuf + 58, versions, sizeof(versions)); |
| @@ -2146,7 +2146,7 @@ static unsigned int ata_scsiop_inq_00(struct ata_device *dev, · 33 unmodified lines | |||
| 2146 | }; | 2146 | }; |
| 2147 | 2147 | ||
| 2148 | for (i = 0; i < sizeof(pages); i++) { | 2148 | for (i = 0; i < sizeof(pages); i++) { |
| 2149 | if (pages[i] == 0xb6 && !ata_dev_is_zac(dev)) | 2149 | if (pages[i] == 0xb6 && !ata_dev_is_zoned(dev)) |
| 2150 | continue; | 2150 | continue; |
| 2151 | rbuf[num_pages + 4] = pages[i]; | 2151 | rbuf[num_pages + 4] = pages[i]; |
| 2152 | num_pages++; | 2152 | num_pages++; |
| @@ -2284,6 +2284,39 @@ static unsigned int ata_scsiop_inq_89(struct ata_device *dev, · 131 unmodified lines | |||
| 2284 | return get_unaligned_be16(&rbuf[2]) + 4; | 2284 | return get_unaligned_be16(&rbuf[2]) + 4; |
| 2285 | } | 2285 | } |
| 2286 | 2286 | ||
| 2287 | /** | ||
| 2288 | * ata_dsm_trim_pages - maximum DSM TRIM payload for a device, in 512-byte pages | ||
| 2289 | * @dev: ATA device the DATA SET MANAGEMENT TRIM command will be sent to | ||
| 2290 | * | ||
| 2291 | * A DATA SET MANAGEMENT TRIM payload is a list of 512-byte pages, each holding | ||
| 2292 | * up to ATA_MAX_TRIM_RNUM (64) LBA Range Entries; the format is page-based and | ||
| 2293 | * unrelated to the logical sector size. | ||
| 2294 | * | ||
| 2295 | * The logical sector size still bounds it, though: the descriptor is written | ||
| 2296 | * directly into the WRITE SAME data-out buffer, which sd sizes to a single | ||
| 2297 | * logical block, so it can hold at most sector_size / 512 pages. | ||
| 2298 | * | ||
| 2299 | * Return: the maximum number of 512-byte pages a single translated WRITE SAME | ||
| 2300 | * command may send to @dev (never less than one), that is the smaller of: | ||
| 2301 | * - MAX PAGES PER DSM COMMAND (IDENTIFY DEVICE word 105), when the device | ||
| 2302 | * reports a non-zero limit; and | ||
| 2303 | * - the logical sector size expressed in 512-byte pages (see above). | ||
| 2304 | */ | ||
| 2305 | static unsigned int ata_dsm_trim_pages(struct ata_device *dev) | ||
| 2306 | { | ||
| 2307 | unsigned int sector_size = ata_id_logical_sector_size(dev->id); | ||
| 2308 | unsigned int max_pages = ata_id_dsm_max_pages(dev->id); | ||
| 2309 | unsigned int pages = sector_size / ATA_SECT_SIZE; | ||
| 2310 | |||
| 2311 | /* If the device does not specify a limit, assume only a single page. */ | ||
| 2312 | if (!max_pages) | ||
| 2313 | max_pages = 1; | ||
| 2314 | |||
| 2315 | pages = min_not_zero(pages, max_pages); | ||
| 2316 | |||
| 2317 | return pages; | ||
| 2318 | } | ||
| 2319 | |||
| 2287 | /** | 2320 | /** |
| 2288 | * ata_scsiop_inq_b0 - Simulate INQUIRY VPD page B0, Block Limits | 2321 | * ata_scsiop_inq_b0 - Simulate INQUIRY VPD page B0, Block Limits |
| 2289 | * @dev: Target device. | 2322 | * @dev: Target device. |
| @@ -2323,7 +2356,8 @@ static unsigned int ata_scsiop_inq_b0(struct ata_device *dev, · 33 unmodified lines | |||
| 2323 | * with the unmap bit set. | 2356 | * with the unmap bit set. |
| 2324 | */ | 2357 | */ |
| 2325 | if (ata_id_has_trim(dev->id)) { | 2358 | if (ata_id_has_trim(dev->id)) { |
| 2326 | u64 max_blocks = 65535 * ATA_MAX_TRIM_RNUM; | 2359 | unsigned int max_pages = ata_dsm_trim_pages(dev); |
| 2360 | u64 max_blocks = max_pages * ATA_MAX_TRIM_RNUM * (u64)U16_MAX; | ||
| 2327 | 2361 | ||
| 2328 | if (dev->quirks & ATA_QUIRK_MAX_TRIM_128M) | 2362 | if (dev->quirks & ATA_QUIRK_MAX_TRIM_128M) |
| 2329 | max_blocks = 128 << (20 - SECTOR_SHIFT); | 2363 | max_blocks = 128 << (20 - SECTOR_SHIFT); |
| @@ -2403,7 +2437,7 @@ static unsigned int ata_scsiop_inq_b2(struct ata_device *dev, · 73 unmodified lines | |||
| 2403 | static unsigned int ata_scsiop_inq_b6(struct ata_device *dev, | 2437 | static unsigned int ata_scsiop_inq_b6(struct ata_device *dev, |
| 2404 | struct scsi_cmnd *cmd, u8 *rbuf) | 2438 | struct scsi_cmnd *cmd, u8 *rbuf) |
| 2405 | { | 2439 | { |
| 2406 | if (!ata_dev_is_zac(dev)) { | 2440 | if (!ata_dev_is_zoned(dev)) { |
| 2407 | ata_scsi_set_invalid_field(dev, cmd, 2, 0xff); | 2441 | ata_scsi_set_invalid_field(dev, cmd, 2, 0xff); |
| 2408 | return 0; | 2442 | return 0; |
| 2409 | } | 2443 | } |
| @@ -2934,7 +2968,7 @@ static unsigned int ata_scsiop_read_cap(struct ata_device *dev, · 524 unmodified lines | |||
| 2934 | rbuf[10] = sector_size >> (8 * 1); | 2968 | rbuf[10] = sector_size >> (8 * 1); |
| 2935 | rbuf[11] = sector_size; | 2969 | rbuf[11] = sector_size; |
| 2936 | 2970 | ||
| 2937 | if (ata_id_zoned_cap(dev->id) || dev->class == ATA_DEV_ZAC) | 2971 | if (ata_dev_is_zoned(dev)) |
| 2938 | rbuf[12] = (1 << 4); /* RC_BASIS */ | 2972 | rbuf[12] = (1 << 4); /* RC_BASIS */ |
| 2939 | rbuf[13] = log2_per_phys; | 2973 | rbuf[13] = log2_per_phys; |
| 2940 | rbuf[14] = (lowest_aligned >> 8) & 0x3f; | 2974 | rbuf[14] = (lowest_aligned >> 8) & 0x3f; |
| @@ -3524,14 +3558,14 @@ static unsigned int ata_scsi_pass_thru(struct ata_queued_cmd *qc) · 583 unmodified lines | |||
| 3524 | /** | 3558 | /** |
| 3525 | * ata_format_dsm_trim_descr() - SATL Write Same to DSM Trim | 3559 | * ata_format_dsm_trim_descr() - SATL Write Same to DSM Trim |
| 3526 | * @cmd: SCSI command being translated | 3560 | * @cmd: SCSI command being translated |
| 3527 | * @trmax: Maximum number of entries that will fit in sector_size bytes. | 3561 | * @size: DSM TRIM payload size in bytes (a multiple of 512) |
| 3528 | * @sector: Starting sector | 3562 | * @sector: Starting sector |
| 3529 | * @count: Total Range of request in logical sectors | 3563 | * @count: Total Range of request in logical sectors |
| 3530 | * | 3564 | * |
| 3531 | * Rewrite the WRITE SAME descriptor to be a DSM TRIM little-endian formatted | 3565 | * Rewrite the WRITE SAME descriptor to be a DSM TRIM little-endian formatted |
| 3532 | * descriptor. | 3566 | * descriptor. |
| 3533 | * | 3567 | * |
| 3534 | * Upto 64 entries of the format: | 3568 | * The payload is a list of @size / 8 entries of the format: |
| 3535 | * 63:48 Range Length | 3569 | * 63:48 Range Length |
| 3536 | * 47:0 LBA | 3570 | * 47:0 LBA |
| 3537 | * | 3571 | * |
| @@ -3540,39 +3574,45 @@ static unsigned int ata_scsi_pass_thru(struct ata_queued_cmd *qc) · 2 unmodified lines | |||
| 3540 | * | 3574 | * |
| 3541 | * NOTE: this is the same format as ADD LBA(S) TO NV CACHE PINNED SET | 3575 | * NOTE: this is the same format as ADD LBA(S) TO NV CACHE PINNED SET |
| 3542 | * | 3576 | * |
| 3543 | * Return: Number of bytes copied into sglist. | 3577 | * The descriptor is written straight into the WRITE SAME data-out buffer; |
| 3578 | * ata_dsm_trim_pages() guarantees @size does not exceed that buffer (one | ||
| 3579 | * logical block). An atomic sg_miter mapping is used so this works from the | ||
| 3580 | * command submission path and, unlike page_address(), copes with a high | ||
| 3581 | * memory payload. | ||
| 3582 | * | ||
| 3583 | * Return: Number of bytes written into the data-out buffer. | ||
| 3544 | */ | 3584 | */ |
| 3545 | static size_t ata_format_dsm_trim_descr(struct scsi_cmnd *cmd, u32 trmax, | 3585 | static size_t ata_format_dsm_trim_descr(struct scsi_cmnd *cmd, size_t size, |
| 3546 | u64 sector, u32 count) | 3586 | u64 sector, u32 count) |
| 3547 | { | 3587 | { |
| 3548 | struct scsi_device *sdp = cmd->device; | 3588 | struct sg_mapping_iter miter; |
| 3549 | size_t len = sdp->sector_size; | 3589 | size_t offset = 0; |
| 3550 | size_t r; | 3590 | |
| 3551 | __le64 *buf; | 3591 | sg_miter_start(&miter, scsi_sglist(cmd), scsi_sg_count(cmd), |
| 3552 | u32 i = 0; | 3592 | SG_MITER_TO_SG | SG_MITER_ATOMIC); |
| 3553 | unsigned long flags; | 3593 | while (offset < size && sg_miter_next(&miter)) { |
| 3594 | __le64 *buf = miter.addr; | ||
| 3595 | size_t chunk = min_t(size_t, miter.length, size - offset); | ||
| 3596 | unsigned int n = chunk / sizeof(__le64); | ||
| 3597 | unsigned int i; | ||
| 3554 | 3598 | ||
| 3555 | WARN_ON(len > ATA_SCSI_RBUF_SIZE); | 3599 | for (i = 0; i < n; i++) { |
| 3600 | u64 entry = 0; | ||
| 3556 | 3601 | ||
| 3557 | if (len > ATA_SCSI_RBUF_SIZE) | 3602 | if (count) { |
| 3558 | len = ATA_SCSI_RBUF_SIZE; | 3603 | u32 rlen = min_t(u32, count, 0xffff); |
| 3559 | 3604 | ||
| 3560 | spin_lock_irqsave(&ata_scsi_rbuf_lock, flags); | 3605 | entry = sector | ((u64)rlen << 48); |
| 3561 | buf = ((void *)ata_scsi_rbuf); | 3606 | sector += rlen; |
| 3562 | memset(buf, 0, len); | 3607 | count -= rlen; |
| 3563 | while (i < trmax) { | 3608 | } |
| 3564 | u64 entry = sector | | 3609 | buf[i] = cpu_to_le64(entry); |
| 3565 | ((u64)(count > 0xffff ? 0xffff : count) << 48); | 3610 | } |
| 3566 | buf[i++] = __cpu_to_le64(entry); | 3611 | offset += n * sizeof(__le64); |
| 3567 | if (count <= 0xffff) | ||
| 3568 | break; | ||
| 3569 | count -= 0xffff; | ||
| 3570 | sector += 0xffff; | ||
| 3571 | } | 3612 | } |
| 3572 | r = sg_copy_from_buffer(scsi_sglist(cmd), scsi_sg_count(cmd), buf, len); | 3613 | sg_miter_stop(&miter); |
| 3573 | spin_unlock_irqrestore(&ata_scsi_rbuf_lock, flags); | ||
| 3574 | 3614 | ||
| 3575 | return r; | 3615 | return offset; |
| 3576 | } | 3616 | } |
| 3577 | 3617 | ||
| 3578 | /** | 3618 | /** |
| @@ -3590,14 +3630,13 @@ static unsigned int ata_scsi_write_same_xlat(struct ata_queued_cmd *qc) · 11 unmodified lines | |||
| 3590 | { | 3630 | { |
| 3591 | struct ata_taskfile *tf = &qc->tf; | 3631 | struct ata_taskfile *tf = &qc->tf; |
| 3592 | struct scsi_cmnd *scmd = qc->scsicmd; | 3632 | struct scsi_cmnd *scmd = qc->scsicmd; |
| 3593 | struct scsi_device *sdp = scmd->device; | ||
| 3594 | size_t len = sdp->sector_size; | ||
| 3595 | struct ata_device *dev = qc->dev; | 3633 | struct ata_device *dev = qc->dev; |
| 3596 | const u8 *cdb = scmd->cmnd; | 3634 | const u8 *cdb = scmd->cmnd; |
| 3635 | unsigned int max_pages = ata_dsm_trim_pages(dev); | ||
| 3636 | unsigned int n_pages; | ||
| 3637 | size_t size; | ||
| 3597 | u64 block; | 3638 | u64 block; |
| 3598 | u32 n_block; | 3639 | u32 n_block; |
| 3599 | const u32 trmax = len >> 3; | ||
| 3600 | u32 size; | ||
| 3601 | u16 fp; | 3640 | u16 fp; |
| 3602 | u8 bp = 0xff; | 3641 | u8 bp = 0xff; |
| 3603 | u8 unmap = cdb[1] & 0x8; | 3642 | u8 unmap = cdb[1] & 0x8; |
| @@ -3627,7 +3666,7 @@ static unsigned int ata_scsi_write_same_xlat(struct ata_queued_cmd *qc) · 23 unmodified lines | |||
| 3627 | goto invalid_fld; | 3666 | goto invalid_fld; |
| 3628 | } | 3667 | } |
| 3629 | /* If the request is too large the cmd is invalid */ | 3668 | /* If the request is too large the cmd is invalid */ |
| 3630 | if (n_block > 0xffff * trmax) { | 3669 | if (n_block > max_pages * ATA_MAX_TRIM_RNUM * (u64)U16_MAX) { |
| 3631 | fp = 2; | 3670 | fp = 2; |
| 3632 | goto invalid_fld; | 3671 | goto invalid_fld; |
| 3633 | } | 3672 | } |
| @@ -3640,31 +3679,39 @@ static unsigned int ata_scsi_write_same_xlat(struct ata_queued_cmd *qc) · 6 unmodified lines | |||
| 3640 | goto invalid_param_len; | 3679 | goto invalid_param_len; |
| 3641 | 3680 | ||
| 3642 | /* | 3681 | /* |
| 3643 | * size must match sector size in bytes | 3682 | * The DATA SET MANAGEMENT TRIM payload is a whole number of 512-byte |
| 3644 | * For DATA SET MANAGEMENT TRIM in ACS-2 nsect (aka count) | 3683 | * pages (each holding up to ATA_MAX_TRIM_RNUM LBA Range Entries), |
| 3645 | * is defined as number of 512 byte blocks to be transferred. | 3684 | * independent of the logical sector size. Only use as many pages as |
| 3685 | * are needed to describe the request, capped at max_pages. | ||
| 3646 | */ | 3686 | */ |
| 3687 | n_pages = DIV_ROUND_UP(DIV_ROUND_UP(n_block, U16_MAX), | ||
| 3688 | ATA_MAX_TRIM_RNUM); | ||
| 3689 | n_pages = clamp(n_pages, 1U, max_pages); | ||
| 3690 | size = (size_t)n_pages * ATA_SECT_SIZE; | ||
| 3647 | 3691 | ||
| 3648 | size = ata_format_dsm_trim_descr(scmd, trmax, block, n_block); | 3692 | if (ata_format_dsm_trim_descr(scmd, size, block, n_block) != size) |
| 3649 | if (size != len) | ||
| 3650 | goto invalid_param_len; | 3693 | goto invalid_param_len; |
| 3651 | 3694 | ||
| 3695 | /* | ||
| 3696 | * For DATA SET MANAGEMENT TRIM the COUNT field (aka nsect) is the | ||
| 3697 | * number of 512-byte pages to be transferred. | ||
| 3698 | */ | ||
| 3652 | if (ata_ncq_enabled(dev) && ata_fpdma_dsm_supported(dev)) { | 3699 | if (ata_ncq_enabled(dev) && ata_fpdma_dsm_supported(dev)) { |
| 3653 | /* Newer devices support queued TRIM commands */ | 3700 | /* Newer devices support queued TRIM commands */ |
| 3654 | tf->protocol = ATA_PROT_NCQ; | 3701 | tf->protocol = ATA_PROT_NCQ; |
| 3655 | tf->command = ATA_CMD_FPDMA_SEND; | 3702 | tf->command = ATA_CMD_FPDMA_SEND; |
| 3656 | tf->hob_nsect = ATA_SUBCMD_FPDMA_SEND_DSM & 0x1f; | 3703 | tf->hob_nsect = ATA_SUBCMD_FPDMA_SEND_DSM & 0x1f; |
| 3657 | tf->nsect = qc->hw_tag << 3; | 3704 | tf->nsect = qc->hw_tag << 3; |
| 3658 | tf->hob_feature = (size / 512) >> 8; | 3705 | tf->hob_feature = n_pages >> 8; |
| 3659 | tf->feature = size / 512; | 3706 | tf->feature = n_pages; |
| 3660 | 3707 | ||
| 3661 | tf->auxiliary = 1; | 3708 | tf->auxiliary = 1; |
| 3662 | } else { | 3709 | } else { |
| 3663 | tf->protocol = ATA_PROT_DMA; | 3710 | tf->protocol = ATA_PROT_DMA; |
| 3664 | tf->hob_feature = 0; | 3711 | tf->hob_feature = 0; |
| 3665 | tf->feature = ATA_DSM_TRIM; | 3712 | tf->feature = ATA_DSM_TRIM; |
| 3666 | tf->hob_nsect = (size / 512) >> 8; | 3713 | tf->hob_nsect = n_pages >> 8; |
| 3667 | tf->nsect = size / 512; | 3714 | tf->nsect = n_pages; |
| 3668 | tf->command = ATA_CMD_DSM; | 3715 | tf->command = ATA_CMD_DSM; |
| 3669 | } | 3716 | } |
| 3670 | 3717 | ||
| @@ -3672,6 +3719,12 @@ static unsigned int ata_scsi_write_same_xlat(struct ata_queued_cmd *qc) · 1 unmodified line | |||
| 3672 | ATA_TFLAG_WRITE; | 3719 | ATA_TFLAG_WRITE; |
| 3673 | 3720 | ||
| 3674 | ata_qc_set_pc_nbytes(qc); | 3721 | ata_qc_set_pc_nbytes(qc); |
| 3722 | /* | ||
| 3723 | * The DSM TRIM payload (size) may be smaller than the WRITE SAME | ||
| 3724 | * data-out buffer (one logical block); only transfer the pages that | ||
| 3725 | * were actually built so the transfer length matches the COUNT field. | ||
| 3726 | */ | ||
| 3727 | qc->nbytes = size; | ||
| 3675 | 3728 | ||
| 3676 | return 0; | 3729 | return 0; |
| 3677 | 3730 | ||
| @@ -3688,88 +3741,286 @@ invalid_opcode: · 10 unmodified lines | |||
| 3688 | return 1; | 3741 | return 1; |
| 3689 | } | 3742 | } |
| 3690 | 3743 | ||
| 3691 | static unsigned int ata_scsi_report_supported_opcodes(struct ata_device *dev, | 3744 | struct ata_scsi_cmd { |
| 3692 | struct scsi_cmnd *cmd, | 3745 | u8 op; |
| 3693 | u8 *rbuf) | 3746 | u8 cdb_len; |
| 3747 | bool sa_valid; | ||
| 3748 | u16 sa; | ||
| 3749 | }; | ||
| 3750 | |||
| 3751 | /* | ||
| 3752 | * Array of commands supported with translation or emulation, sorted in | ||
| 3753 | * ascending opcode and service action order. All of these commands are | ||
| 3754 | * processed either in ata_xlat_func() or in ata_scsi_simulate(); | ||
| 3755 | * | ||
| 3756 | * Note: commands that are not fully supported may be left out of this array | ||
| 3757 | * so that they are not reported as supported for passthrough but still | ||
| 3758 | * available through the block layer. For now, this includes the following | ||
| 3759 | * commands: | ||
| 3760 | * - WRITE_SAME_16: ata_scsi_write_same_xlat() forbids passthrough commands | ||
| 3761 | */ | ||
| 3762 | static const struct ata_scsi_cmd ata_supported_cmds[] = { | ||
| 3763 | { .op = TEST_UNIT_READY, .cdb_len = 6 }, | ||
| 3764 | { .op = REZERO_UNIT, .cdb_len = 6 }, | ||
| 3765 | { .op = REQUEST_SENSE, .cdb_len = 6 }, | ||
| 3766 | { .op = READ_6, .cdb_len = 6 }, | ||
| 3767 | { .op = WRITE_6, .cdb_len = 6 }, | ||
| 3768 | { .op = SEEK_6, .cdb_len = 6 }, | ||
| 3769 | { .op = INQUIRY, .cdb_len = 6 }, | ||
| 3770 | { .op = MODE_SELECT, .cdb_len = 6 }, | ||
| 3771 | { .op = MODE_SENSE, .cdb_len = 6 }, | ||
| 3772 | { .op = START_STOP, .cdb_len = 6 }, | ||
| 3773 | { .op = SEND_DIAGNOSTIC, .cdb_len = 6 }, | ||
| 3774 | { .op = READ_CAPACITY, .cdb_len = 10 }, | ||
| 3775 | { .op = READ_10, .cdb_len = 10 }, | ||
| 3776 | { .op = WRITE_10, .cdb_len = 10 }, | ||
| 3777 | { .op = SEEK_10, .cdb_len = 10 }, | ||
| 3778 | { .op = VERIFY, .cdb_len = 10 }, | ||
| 3779 | { .op = SYNCHRONIZE_CACHE, .cdb_len = 10 }, | ||
| 3780 | { .op = MODE_SELECT_10, .cdb_len = 10 }, | ||
| 3781 | { .op = MODE_SENSE_10, .cdb_len = 10 }, | ||
| 3782 | { | ||
| 3783 | .op = VARIABLE_LENGTH_CMD, .cdb_len = 32, | ||
| 3784 | .sa_valid = true, | ||
| 3785 | .sa = ATA_32 | ||
| 3786 | }, | ||
| 3787 | { .op = ATA_16, .cdb_len = 16 }, | ||
| 3788 | { .op = READ_16, .cdb_len = 16 }, | ||
| 3789 | { .op = WRITE_16, .cdb_len = 16 }, | ||
| 3790 | { .op = VERIFY_16, .cdb_len = 16 }, | ||
| 3791 | { .op = SYNCHRONIZE_CACHE_16, .cdb_len = 16 }, | ||
| 3792 | { | ||
| 3793 | .op = ZBC_OUT, .cdb_len = 16, | ||
| 3794 | .sa_valid = true, | ||
| 3795 | .sa = ZO_CLOSE_ZONE | ||
| 3796 | }, | ||
| 3797 | { | ||
| 3798 | .op = ZBC_OUT, .cdb_len = 16, | ||
| 3799 | .sa_valid = true, | ||
| 3800 | .sa = ZO_FINISH_ZONE | ||
| 3801 | }, | ||
| 3802 | { | ||
| 3803 | .op = ZBC_OUT, .cdb_len = 16, | ||
| 3804 | .sa_valid = true, | ||
| 3805 | .sa = ZO_OPEN_ZONE | ||
| 3806 | }, | ||
| 3807 | { | ||
| 3808 | .op = ZBC_OUT, .cdb_len = 16, | ||
| 3809 | .sa_valid = true, | ||
| 3810 | .sa = ZO_RESET_WRITE_POINTER | ||
| 3811 | }, | ||
| 3812 | { | ||
| 3813 | .op = ZBC_IN, .cdb_len = 16, | ||
| 3814 | .sa_valid = true, | ||
| 3815 | .sa = ZI_REPORT_ZONES | ||
| 3816 | }, | ||
| 3817 | { | ||
| 3818 | .op = SERVICE_ACTION_IN_16, .cdb_len = 16, | ||
| 3819 | .sa_valid = true, | ||
| 3820 | .sa = SAI_READ_CAPACITY_16 | ||
| 3821 | }, | ||
| 3822 | { | ||
| 3823 | .op = SERVICE_ACTION_IN_16, .cdb_len = 16, | ||
| 3824 | .sa_valid = true, | ||
| 3825 | .sa = SAI_GET_PHYSICAL_ELEMENT_STATUS | ||
| 3826 | }, | ||
| 3827 | { | ||
| 3828 | .op = SERVICE_ACTION_IN_16, .cdb_len = 16, | ||
| 3829 | .sa_valid = true, | ||
| 3830 | .sa = SAI_REMOVE_ELEMENT_AND_TRUNCATE | ||
| 3831 | }, | ||
| 3832 | { | ||
| 3833 | .op = SERVICE_ACTION_IN_16, .cdb_len = 16, | ||
| 3834 | .sa_valid = true, | ||
| 3835 | .sa = SAI_RESTORE_ELEMENTS_AND_REBUILD | ||
| 3836 | }, | ||
| 3837 | { | ||
| 3838 | .op = SERVICE_ACTION_IN_16, .cdb_len = 16, | ||
| 3839 | .sa_valid = true, | ||
| 3840 | .sa = SAI_REMOVE_ELEMENT_AND_MODIFY_ZONES | ||
| 3841 | }, | ||
| 3842 | { .op = REPORT_LUNS, .cdb_len = 12 }, | ||
| 3843 | { .op = ATA_12, .cdb_len = 12 }, | ||
| 3844 | { .op = SECURITY_PROTOCOL_IN, .cdb_len = 12 }, | ||
| 3845 | { | ||
| 3846 | .op = MAINTENANCE_IN, .cdb_len = 12, | ||
| 3847 | .sa_valid = true, | ||
| 3848 | .sa = MI_REPORT_SUPPORTED_OPERATION_CODES | ||
| 3849 | }, | ||
| 3850 | { .op = SECURITY_PROTOCOL_OUT, .cdb_len = 12 }, | ||
| 3851 | }; | ||
| 3852 | |||
| 3853 | static const struct ata_scsi_cmd *ata_scsi_get_supported_cmd(u8 op, u16 sa) | ||
| 3694 | { | 3854 | { |
| 3695 | u8 *cdb = cmd->cmnd; | 3855 | const struct ata_scsi_cmd *cmd; |
| 3696 | u8 supported = 0, cdlp = 0, rwcdlp = 0; | 3856 | int i; |
| 3697 | 3857 | ||
| 3698 | if (cdb[2] != 1 && cdb[2] != 3) { | 3858 | for (i = 0; i < ARRAY_SIZE(ata_supported_cmds); i++) { |
| 3699 | ata_dev_warn(dev, "invalid command format %d\n", cdb[2]); | 3859 | cmd = &ata_supported_cmds[i]; |
| 3700 | ata_scsi_set_invalid_field(dev, cmd, 2, 0xff); | 3860 | if (cmd->op == op && cmd->sa == sa) |
| 3701 | return 0; | 3861 | return cmd; |
| 3702 | } | 3862 | } |
| 3703 | 3863 | ||
| 3704 | switch (cdb[3]) { | 3864 | return NULL; |
| 3705 | case INQUIRY: | 3865 | } |
| 3706 | case MODE_SENSE: | 3866 | |
| 3707 | case MODE_SENSE_10: | 3867 | static bool ata_scsi_supported_cmd_use_sa(u8 op) |
| 3708 | case READ_CAPACITY: | 3868 | { |
| 3709 | case SERVICE_ACTION_IN_16: | 3869 | const struct ata_scsi_cmd *cmd; |
| 3710 | case REPORT_LUNS: | 3870 | int i; |
| 3711 | case REQUEST_SENSE: | 3871 | |
| 3712 | case SYNCHRONIZE_CACHE: | 3872 | for (i = 0; i < ARRAY_SIZE(ata_supported_cmds); i++) { |
| 3713 | case SYNCHRONIZE_CACHE_16: | 3873 | cmd = &ata_supported_cmds[i]; |
| 3714 | case REZERO_UNIT: | 3874 | if (cmd->op == op) |
| 3715 | case SEEK_6: | 3875 | return cmd->sa_valid; |
| 3716 | case SEEK_10: | 3876 | } |
| 3717 | case TEST_UNIT_READY: | 3877 | |
| 3718 | case SEND_DIAGNOSTIC: | 3878 | return false; |
| 3719 | case MAINTENANCE_IN: | 3879 | } |
| 3720 | case READ_6: | 3880 | |
| 3721 | case READ_10: | 3881 | struct ata_scsi_cmd_support { |
| 3722 | case WRITE_6: | 3882 | u8 cdlp; |
| 3723 | case WRITE_10: | 3883 | u8 rwcdlp; |
| 3724 | case ATA_12: | 3884 | }; |
| 3725 | case ATA_16: | 3885 | |
| 3726 | case VERIFY: | 3886 | static bool ata_scsi_cmd_is_supported(struct ata_device *dev, u8 op, u16 sa, |
| 3727 | case VERIFY_16: | 3887 | struct ata_scsi_cmd_support *sup) |
| 3728 | case MODE_SELECT: | 3888 | { |
| 3729 | case MODE_SELECT_10: | 3889 | const struct ata_scsi_cmd *cmd; |
| 3730 | case START_STOP: | 3890 | |
| 3731 | supported = 3; | 3891 | /* First, see if we support the command. */ |
| 3732 | break; | 3892 | cmd = ata_scsi_get_supported_cmd(op, sa); |
| 3893 | if (!cmd) | ||
| 3894 | return false; | ||
| 3895 | |||
| 3896 | /* Now refine the support report depending on the device features. */ | ||
| 3897 | memset(sup, 0, sizeof(*sup)); | ||
| 3898 | switch (op) { | ||
| 3733 | case READ_16: | 3899 | case READ_16: |
| 3734 | supported = 3; | ||
| 3735 | if (dev->flags & ATA_DFLAG_CDL) { | 3900 | if (dev->flags & ATA_DFLAG_CDL) { |
| 3736 | /* | 3901 | /* |
| 3737 | * CDL read descriptors map to the T2A page, that is, | 3902 | * CDL read descriptors map to the T2A page, that is, |
| 3738 | * rwcdlp = 0x01 and cdlp = 0x01 | 3903 | * rwcdlp = 0x01 and cdlp = 0x01 |
| 3739 | */ | 3904 | */ |
| 3740 | rwcdlp = 0x01; | 3905 | sup->rwcdlp = 0x01; |
| 3741 | cdlp = 0x01 << 3; | 3906 | sup->cdlp = 0x01; |
| 3742 | } | 3907 | } |
| 3743 | break; | 3908 | break; |
| 3744 | case WRITE_16: | 3909 | case WRITE_16: |
| 3745 | supported = 3; | ||
| 3746 | if (dev->flags & ATA_DFLAG_CDL) { | 3910 | if (dev->flags & ATA_DFLAG_CDL) { |
| 3747 | /* | 3911 | /* |
| 3748 | * CDL write descriptors map to the T2B page, that is, | 3912 | * CDL write descriptors map to the T2B page, that is, |
| 3749 | * rwcdlp = 0x01 and cdlp = 0x02 | 3913 | * rwcdlp = 0x01 and cdlp = 0x02 |
| 3750 | */ | 3914 | */ |
| 3751 | rwcdlp = 0x01; | 3915 | sup->rwcdlp = 0x01; |
| 3752 | cdlp = 0x02 << 3; | 3916 | sup->cdlp = 0x02; |
| 3753 | } | 3917 | } |
| 3754 | break; | 3918 | break; |
| 3755 | case ZBC_IN: | 3919 | case ZBC_IN: |
| 3756 | case ZBC_OUT: | 3920 | case ZBC_OUT: |
| 3757 | if (ata_id_zoned_cap(dev->id) || | 3921 | return ata_dev_is_zoned(dev); |
| 3758 | dev->class == ATA_DEV_ZAC) | 3922 | case SERVICE_ACTION_IN_16: |
| 3759 | supported = 3; | 3923 | switch (sa) { |
| 3924 | case SAI_GET_PHYSICAL_ELEMENT_STATUS: | ||
| 3925 | case SAI_REMOVE_ELEMENT_AND_TRUNCATE: | ||
| 3926 | return dev->flags & ATA_DFLAG_DEPOP; | ||
| 3927 | case SAI_RESTORE_ELEMENTS_AND_REBUILD: | ||
| 3928 | return dev->flags & ATA_DFLAG_DEPOP_RESTORE; | ||
| 3929 | case SAI_REMOVE_ELEMENT_AND_MODIFY_ZONES: | ||
| 3930 | return dev->flags & ATA_DFLAG_DEPOP_MODIFY; | ||
| 3931 | default: | ||
| 3932 | return true; | ||
| 3933 | } | ||
| 3760 | break; | 3934 | break; |
| 3761 | case SECURITY_PROTOCOL_IN: | 3935 | case SECURITY_PROTOCOL_IN: |
| 3762 | case SECURITY_PROTOCOL_OUT: | 3936 | case SECURITY_PROTOCOL_OUT: |
| 3763 | if (dev->flags & ATA_DFLAG_TRUSTED) | 3937 | return dev->flags & ATA_DFLAG_TRUSTED; |
| 3764 | supported = 3; | ||
| 3765 | break; | ||
| 3766 | default: | 3938 | default: |
| 3767 | break; | 3939 | break; |
| 3768 | } | 3940 | } |
| 3769 | 3941 | ||
| 3942 | return true; | ||
| 3943 | } | ||
| 3944 | |||
| 3945 | static unsigned int | ||
| 3946 | ata_scsi_report_all_supported_opcodes(struct ata_device *dev, u8 *rbuf) | ||
| 3947 | { | ||
| 3948 | struct ata_scsi_cmd_support sup; | ||
| 3949 | const struct ata_scsi_cmd *cmd; | ||
| 3950 | unsigned int len = 4; | ||
| 3951 | u8 *buf = &rbuf[len]; | ||
| 3952 | int i; | ||
| 3953 | |||
| 3954 | for (i = 0; i < ARRAY_SIZE(ata_supported_cmds); i++) { | ||
| 3955 | if (len > ATA_SCSI_RBUF_SIZE - 8) | ||
| 3956 | break; | ||
| 3957 | |||
| 3958 | cmd = &ata_supported_cmds[i]; | ||
| 3959 | |||
| 3960 | /* All command format */ | ||
| 3961 | if (!ata_scsi_cmd_is_supported(dev, cmd->op, cmd->sa, &sup)) | ||
| 3962 | continue; | ||
| 3963 | |||
| 3964 | buf[0] = cmd->op; | ||
| 3965 | put_unaligned_be16(cmd->sa, &buf[2]); | ||
| 3966 | buf[5] = (sup.rwcdlp << 6) | (sup.cdlp << 2); | ||
| 3967 | if (cmd->sa_valid) | ||
| 3968 | buf[5] |= 0x01; | ||
| 3969 | put_unaligned_be16(cmd->cdb_len, &buf[6]); | ||
| 3970 | |||
| 3971 | /* CTDP == 0 */ | ||
| 3972 | len += 8; | ||
| 3973 | buf += 8; | ||
| 3974 | } | ||
| 3975 | |||
| 3976 | put_unaligned_be32(len - 4, &rbuf[0]); | ||
| 3977 | |||
| 3978 | return len; | ||
| 3979 | } | ||
| 3980 | |||
| 3981 | static unsigned int ata_scsi_report_supported_opcodes(struct ata_device *dev, | ||
| 3982 | struct scsi_cmnd *cmd, | ||
| 3983 | u8 *rbuf) | ||
| 3984 | { | ||
| 3985 | struct ata_scsi_cmd_support sup; | ||
| 3986 | u8 *cdb = cmd->cmnd; | ||
| 3987 | u16 sa = 0; | ||
| 3988 | |||
| 3989 | switch (cdb[2]) { | ||
| 3990 | case 0: | ||
| 3991 | /* All command format */ | ||
| 3992 | return ata_scsi_report_all_supported_opcodes(dev, rbuf); | ||
| 3993 | case 1: | ||
| 3994 | /* One command format with command support data, ignore sa. */ | ||
| 3995 | if (ata_scsi_supported_cmd_use_sa(cdb[3])) { | ||
| 3996 | ata_scsi_set_invalid_field(dev, cmd, 3, 0xff); | ||
| 3997 | return 0; | ||
| 3998 | } | ||
| 3999 | break; | ||
| 4000 | case 2: | ||
| 4001 | /* One command format, must have sa. */ | ||
| 4002 | if (!ata_scsi_supported_cmd_use_sa(cdb[3])) { | ||
| 4003 | ata_scsi_set_invalid_field(dev, cmd, 3, 0xff); | ||
| 4004 | return 0; | ||
| 4005 | } | ||
| 4006 | fallthrough; | ||
| 4007 | case 3: | ||
| 4008 | /* One command format */ | ||
| 4009 | sa = get_unaligned_be16(&cdb[4]); | ||
| 4010 | break; | ||
| 4011 | default: | ||
| 4012 | ata_dev_warn(dev, "invalid command format %d\n", cdb[2]); | ||
| 4013 | ata_scsi_set_invalid_field(dev, cmd, 2, 0xff); | ||
| 4014 | return 0; | ||
| 4015 | } | ||
| 4016 | |||
| 3770 | /* One command format */ | 4017 | /* One command format */ |
| 3771 | rbuf[0] = rwcdlp; | 4018 | if (ata_scsi_cmd_is_supported(dev, cdb[3], sa, &sup)) { |
| 3772 | rbuf[1] = cdlp | supported; | 4019 | rbuf[0] = sup.rwcdlp; |
| 4020 | rbuf[1] = (sup.cdlp << 3) | 0x03; | ||
| 4021 | } else { | ||
| 4022 | rbuf[1] = 0x01; | ||
| 4023 | } | ||
| 3773 | 4024 | ||
| 3774 | return 4; | 4025 | return 4; |
| 3775 | } | 4026 | } |
| @@ -4452,6 +4703,245 @@ static unsigned int ata_scsi_security_inout_xlat(struct ata_queued_cmd *qc) · 676 unmodified lines | |||
| 4452 | return 0; | 4703 | return 0; |
| 4453 | } | 4704 | } |
| 4454 | 4705 | ||
| 4706 | /* | ||
| 4707 | * Convert T-13 little-endian field representation of GET PHYSICAL ELEMENT | ||
| 4708 | * STATUS DMA command reply into T-10 big-endian field representation. | ||
| 4709 | */ | ||
| 4710 | static void ata_scsi_get_phys_element_status_complete(struct ata_queued_cmd *qc) | ||
| 4711 | { | ||
| 4712 | struct scsi_cmnd *scmd = qc->scsicmd; | ||
| 4713 | struct sg_mapping_iter miter; | ||
| 4714 | unsigned int bytes = 0; | ||
| 4715 | |||
| 4716 | lockdep_assert_held(qc->ap->lock); | ||
| 4717 | |||
| 4718 | sg_miter_start(&miter, scsi_sglist(scmd), scsi_sg_count(scmd), | ||
| 4719 | SG_MITER_TO_SG | SG_MITER_ATOMIC); | ||
| 4720 | |||
| 4721 | while (sg_miter_next(&miter)) { | ||
| 4722 | unsigned int offset = 0; | ||
| 4723 | |||
| 4724 | if (bytes == 0) { | ||
| 4725 | u32 num_desc, num_desc_returned, id; | ||
| 4726 | u16 max_depop, cur_depop; | ||
| 4727 | char *hdr; | ||
| 4728 | |||
| 4729 | /* Swizzle the header */ | ||
| 4730 | hdr = miter.addr; | ||
| 4731 | num_desc = get_unaligned_le32(&hdr[0]); | ||
| 4732 | num_desc_returned = get_unaligned_le32(&hdr[4]); | ||
| 4733 | id = get_unaligned_le32(&hdr[8]); | ||
| 4734 | max_depop = get_unaligned_le16(&hdr[12]); | ||
| 4735 | cur_depop = get_unaligned_le16(&hdr[14]); | ||
| 4736 | |||
| 4737 | put_unaligned_be32(num_desc, &hdr[0]); | ||
| 4738 | put_unaligned_be32(num_desc_returned, &hdr[4]); | ||
| 4739 | put_unaligned_be32(id, &hdr[8]); | ||
| 4740 | put_unaligned_be16(max_depop, &hdr[12]); | ||
| 4741 | put_unaligned_be16(cur_depop, &hdr[14]); | ||
| 4742 | |||
| 4743 | offset += 32; | ||
| 4744 | bytes += 32; | ||
| 4745 | } | ||
| 4746 | |||
| 4747 | /* Swizzle the descriptors. */ | ||
| 4748 | while (offset < miter.length) { | ||
| 4749 | char *desc; | ||
| 4750 | u32 id; | ||
| 4751 | u8 type; | ||
| 4752 | |||
| 4753 | desc = miter.addr + offset; | ||
| 4754 | id = get_unaligned_le32(&desc[4]); | ||
| 4755 | put_unaligned_be32(id, &desc[4]); | ||
| 4756 | |||
| 4757 | type = desc[14]; | ||
| 4758 | if (type == SCSI_PHYS_ELEM_TYPE_ALL_ACCESS_STORAGE) { | ||
| 4759 | u64 capacity = get_unaligned_le64(&desc[16]); | ||
| 4760 | |||
| 4761 | put_unaligned_be64(capacity, &desc[16]); | ||
| 4762 | } else { | ||
| 4763 | u64 num_zones; | ||
| 4764 | |||
| 4765 | id = get_unaligned_le32(&desc[16]); | ||
| 4766 | num_zones = get_unaligned_le64(&desc[24]); | ||
| 4767 | |||
| 4768 | put_unaligned_be32(id, &desc[16]); | ||
| 4769 | put_unaligned_be64(num_zones, &desc[24]); | ||
| 4770 | } | ||
| 4771 | |||
| 4772 | offset += 32; | ||
| 4773 | bytes += 32; | ||
| 4774 | } | ||
| 4775 | } | ||
| 4776 | sg_miter_stop(&miter); | ||
| 4777 | |||
| 4778 | ata_scsi_qc_complete(qc); | ||
| 4779 | } | ||
| 4780 | |||
| 4781 | static unsigned int | ||
| 4782 | ata_scsi_get_phys_element_status_xlat(struct ata_queued_cmd *qc) | ||
| 4783 | { | ||
| 4784 | struct scsi_cmnd *scmd = qc->scsicmd; | ||
| 4785 | const u8 *cdb = scmd->cmnd; | ||
| 4786 | struct ata_device *dev = qc->dev; | ||
| 4787 | struct ata_taskfile *tf = &qc->tf; | ||
| 4788 | u32 starting_element, len; | ||
| 4789 | |||
| 4790 | /* ATA_CMD_GET_PHYS_ELEMENT_STATUS is a DMA command. */ | ||
| 4791 | if (!(dev->flags & ATA_DFLAG_DEPOP) || !ata_dma_enabled(dev)) { | ||
| 4792 | ata_scsi_set_sense(dev, scmd, ILLEGAL_REQUEST, 0x20, 0x0); | ||
| 4793 | return 1; | ||
| 4794 | } | ||
| 4795 | |||
| 4796 | len = get_unaligned_be32(&cdb[10]) / ATA_SECT_SIZE; | ||
| 4797 | if (!len || len > U16_MAX) { | ||
| 4798 | ata_scsi_set_invalid_field(dev, scmd, 10, 0); | ||
| 4799 | return 1; | ||
| 4800 | } | ||
| 4801 | |||
| 4802 | tf->protocol = ATA_PROT_DMA; | ||
| 4803 | tf->command = ATA_CMD_GET_PHYS_ELEMENT_STATUS; | ||
| 4804 | tf->hob_feature = cdb[14]; | ||
| 4805 | tf->hob_nsect = (len >> 8) & 0xff; | ||
| 4806 | tf->nsect = len & 0xff; | ||
| 4807 | |||
| 4808 | starting_element = get_unaligned_be32(&cdb[6]); | ||
| 4809 | if (starting_element) { | ||
| 4810 | tf->hob_lbal = (starting_element >> 24) & 0xff; | ||
| 4811 | tf->lbah = (starting_element >> 16) & 0xff; | ||
| 4812 | tf->lbam = (starting_element >> 8) & 0xff; | ||
| 4813 | tf->lbal = starting_element & 0xff; | ||
| 4814 | } | ||
| 4815 | tf->device = ATA_LBA; | ||
| 4816 | tf->flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE | ATA_TFLAG_LBA48; | ||
| 4817 | |||
| 4818 | ata_qc_set_pc_nbytes(qc); | ||
| 4819 | |||
| 4820 | qc->flags |= ATA_QCFLAG_RESULT_TF; | ||
| 4821 | qc->complete_fn = ata_scsi_get_phys_element_status_complete; | ||
| 4822 | |||
| 4823 | return 0; | ||
| 4824 | } | ||
| 4825 | |||
| 4826 | static void ata_scsi_depop_ua_cap_changed_complete(struct ata_queued_cmd *qc) | ||
| 4827 | { | ||
| 4828 | struct scsi_cmnd *scmd = qc->scsicmd; | ||
| 4829 | u8 *cdb = scmd->cmnd; | ||
| 4830 | bool is_ata_passthru = cdb[0] == ATA_16 || cdb[0] == ATA_12; | ||
| 4831 | bool is_success = qc->err_mask == 0; | ||
| 4832 | |||
| 4833 | /* | ||
| 4834 | * For successful non-passthrough commands, raise a UNIT ATTENTION with | ||
| 4835 | * the additional sense code set to CAPACITY DATA HAS CHANGED to be | ||
| 4836 | * raised. Note that this should be done only if the capacity has | ||
| 4837 | * actually changed, which may not be the case if the element that was | ||
| 4838 | * specified for depopulation was already depopulated, or we did not | ||
| 4839 | * restore any removed element. But a capacity change unit attention is | ||
| 4840 | * harmless, so always raise the unit attention. | ||
| 4841 | */ | ||
| 4842 | if (is_success && !is_ata_passthru) | ||
| 4843 | ata_scsi_set_sense(qc->dev, scmd, UNIT_ATTENTION, | ||
| 4844 | UA_CHANGED_ASC, CAPACITY_CHANGED_ASCQ); | ||
| 4845 | ata_scsi_qc_complete(qc); | ||
| 4846 | } | ||
| 4847 | |||
| 4848 | static unsigned int | ||
| 4849 | ata_scsi_remove_element_and_truncate_xlat(struct ata_queued_cmd *qc) | ||
| 4850 | { | ||
| 4851 | struct scsi_cmnd *scmd = qc->scsicmd; | ||
| 4852 | const u8 *cdb = scmd->cmnd; | ||
| 4853 | struct ata_device *dev = qc->dev; | ||
| 4854 | struct ata_taskfile *tf = &qc->tf; | ||
| 4855 | u64 req_capacity; | ||
| 4856 | u32 id; | ||
| 4857 | |||
| 4858 | if (!(dev->flags & ATA_DFLAG_DEPOP)) { | ||
| 4859 | ata_scsi_set_sense(dev, scmd, ILLEGAL_REQUEST, 0x20, 0x0); | ||
| 4860 | return 1; | ||
| 4861 | } | ||
| 4862 | |||
| 4863 | req_capacity = get_unaligned_be64(&cdb[2]); | ||
| 4864 | if (req_capacity == 1) { | ||
| 4865 | ata_scsi_set_invalid_field(dev, scmd, 2, 0); | ||
| 4866 | return 1; | ||
| 4867 | } | ||
| 4868 | |||
| 4869 | id = get_unaligned_be32(&cdb[10]); | ||
| 4870 | |||
| 4871 | tf->protocol = ATA_PROT_NODATA; | ||
| 4872 | tf->command = ATA_CMD_REMOVE_ELEMENT_AND_TRUNCATE; | ||
| 4873 | tf->hob_feature = (id >> 24) & 0xff; | ||
| 4874 | tf->feature = (id >> 16) & 0xff; | ||
| 4875 | tf->hob_nsect = (id >> 8) & 0xff; | ||
| 4876 | tf->nsect = id & 0xff; | ||
| 4877 | tf->hob_lbah = (req_capacity >> 40) & 0xff; | ||
| 4878 | tf->hob_lbam = (req_capacity >> 32) & 0xff; | ||
| 4879 | tf->hob_lbal = (req_capacity >> 24) & 0xff; | ||
| 4880 | tf->lbah = (req_capacity >> 16) & 0xff; | ||
| 4881 | tf->lbam = (req_capacity >> 8) & 0xff; | ||
| 4882 | tf->lbal = req_capacity & 0xff; | ||
| 4883 | tf->device = ATA_LBA; | ||
| 4884 | tf->flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE | ATA_TFLAG_LBA48; | ||
| 4885 | |||
| 4886 | qc->flags |= ATA_QCFLAG_RESULT_TF; | ||
| 4887 | qc->complete_fn = ata_scsi_depop_ua_cap_changed_complete; | ||
| 4888 | |||
| 4889 | return 0; | ||
| 4890 | } | ||
| 4891 | |||
| 4892 | static unsigned int | ||
| 4893 | ata_scsi_remove_element_and_modify_zones_xlat(struct ata_queued_cmd *qc) | ||
| 4894 | { | ||
| 4895 | struct scsi_cmnd *scmd = qc->scsicmd; | ||
| 4896 | const u8 *cdb = scmd->cmnd; | ||
| 4897 | struct ata_device *dev = qc->dev; | ||
| 4898 | struct ata_taskfile *tf = &qc->tf; | ||
| 4899 | u32 id; | ||
| 4900 | |||
| 4901 | if (!(dev->flags & ATA_DFLAG_DEPOP_MODIFY)) { | ||
| 4902 | ata_scsi_set_sense(dev, scmd, ILLEGAL_REQUEST, 0x20, 0x0); | ||
| 4903 | return 1; | ||
| 4904 | } | ||
| 4905 | |||
| 4906 | id = get_unaligned_be32(&cdb[10]); | ||
| 4907 | |||
| 4908 | tf->protocol = ATA_PROT_NODATA; | ||
| 4909 | tf->command = ATA_CMD_REMOVE_ELEMENT_AND_MODIFY_ZONES; | ||
| 4910 | tf->hob_feature = (id >> 24) & 0xff; | ||
| 4911 | tf->feature = (id >> 16) & 0xff; | ||
| 4912 | tf->hob_nsect = (id >> 8) & 0xff; | ||
| 4913 | tf->nsect = id & 0xff; | ||
| 4914 | tf->device = ATA_LBA; | ||
| 4915 | tf->flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE | ATA_TFLAG_LBA48; | ||
| 4916 | |||
| 4917 | qc->flags |= ATA_QCFLAG_RESULT_TF; | ||
| 4918 | |||
| 4919 | return 0; | ||
| 4920 | } | ||
| 4921 | |||
| 4922 | static unsigned int | ||
| 4923 | ata_scsi_restore_elements_and_rebuild_xlat(struct ata_queued_cmd *qc) | ||
| 4924 | { | ||
| 4925 | struct scsi_cmnd *scmd = qc->scsicmd; | ||
| 4926 | struct ata_device *dev = qc->dev; | ||
| 4927 | struct ata_taskfile *tf = &qc->tf; | ||
| 4928 | |||
| 4929 | if (!(dev->flags & ATA_DFLAG_DEPOP_RESTORE)) { | ||
| 4930 | ata_scsi_set_sense(dev, scmd, ILLEGAL_REQUEST, 0x20, 0x0); | ||
| 4931 | return 1; | ||
| 4932 | } | ||
| 4933 | |||
| 4934 | tf->protocol = ATA_PROT_NODATA; | ||
| 4935 | tf->command = ATA_CMD_RESTORE_ELEMENTS_AND_REBUILD; | ||
| 4936 | tf->device = ATA_LBA; | ||
| 4937 | tf->flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE | ATA_TFLAG_LBA48; | ||
| 4938 | |||
| 4939 | qc->flags |= ATA_QCFLAG_RESULT_TF; | ||
| 4940 | qc->complete_fn = ata_scsi_depop_ua_cap_changed_complete; | ||
| 4941 | |||
| 4942 | return 0; | ||
| 4943 | } | ||
| 4944 | |||
| 4455 | /** | 4945 | /** |
| 4456 | * ata_scsi_var_len_cdb_xlat - SATL variable length CDB to Handler | 4946 | * ata_scsi_var_len_cdb_xlat - SATL variable length CDB to Handler |
| 4457 | * @qc: Command to be translated | 4947 | * @qc: Command to be translated |
| @@ -4483,7 +4973,7 @@ static unsigned int ata_scsi_var_len_cdb_xlat(struct ata_queued_cmd *qc) · 25 unmodified lines | |||
| 4483 | /** | 4973 | /** |
| 4484 | * ata_get_xlat_func - check if SCSI to ATA translation is possible | 4974 | * ata_get_xlat_func - check if SCSI to ATA translation is possible |
| 4485 | * @dev: ATA device | 4975 | * @dev: ATA device |
| 4486 | * @cmd: SCSI command opcode to consider | 4976 | * @cdb: CDB of the SCSI command to consider |
| 4487 | * | 4977 | * |
| 4488 | * Look up the SCSI command given, and determine whether the | 4978 | * Look up the SCSI command given, and determine whether the |
| 4489 | * SCSI command is to be translated or simulated. | 4979 | * SCSI command is to be translated or simulated. |
| @@ -4492,9 +4982,12 @@ static unsigned int ata_scsi_var_len_cdb_xlat(struct ata_queued_cmd *qc) · 2 unmodified lines | |||
| 4492 | * Pointer to translation function if possible, %NULL if not. | 4982 | * Pointer to translation function if possible, %NULL if not. |
| 4493 | */ | 4983 | */ |
| 4494 | 4984 | ||
| 4495 | static inline ata_xlat_func_t ata_get_xlat_func(struct ata_device *dev, u8 cmd) | 4985 | static inline ata_xlat_func_t ata_get_xlat_func(struct ata_device *dev, |
| 4986 | u8 *cdb) | ||
| 4496 | { | 4987 | { |
| 4497 | switch (cmd) { | 4988 | u8 sa; |
| 4989 | |||
| 4990 | switch (cdb[0]) { | ||
| 4498 | case READ_6: | 4991 | case READ_6: |
| 4499 | case READ_10: | 4992 | case READ_10: |
| 4500 | case READ_16: | 4993 | case READ_16: |
| @@ -4528,6 +5021,18 @@ static inline ata_xlat_func_t ata_get_xlat_func(struct ata_device *dev, u8 cmd) · 27 unmodified lines | |||
| 4528 | case MODE_SELECT_10: | 5021 | case MODE_SELECT_10: |
| 4529 | return ata_scsi_mode_select_xlat; | 5022 | return ata_scsi_mode_select_xlat; |
| 4530 | 5023 | ||
| 5024 | case SERVICE_ACTION_IN_16: | ||
| 5025 | sa = cdb[1] & 0x1f; | ||
| 5026 | if (sa == SAI_GET_PHYSICAL_ELEMENT_STATUS) | ||
| 5027 | return ata_scsi_get_phys_element_status_xlat; | ||
| 5028 | if (sa == SAI_REMOVE_ELEMENT_AND_TRUNCATE) | ||
| 5029 | return ata_scsi_remove_element_and_truncate_xlat; | ||
| 5030 | if (sa == SAI_REMOVE_ELEMENT_AND_MODIFY_ZONES) | ||
| 5031 | return ata_scsi_remove_element_and_modify_zones_xlat; | ||
| 5032 | if (sa == SAI_RESTORE_ELEMENTS_AND_REBUILD) | ||
| 5033 | return ata_scsi_restore_elements_and_rebuild_xlat; | ||
| 5034 | break; | ||
| 5035 | |||
| 4531 | case ZBC_IN: | 5036 | case ZBC_IN: |
| 4532 | return ata_scsi_zbc_in_xlat; | 5037 | return ata_scsi_zbc_in_xlat; |
| 4533 | 5038 | ||
| @@ -4625,7 +5130,8 @@ enum scsi_qc_status __ata_scsi_queuecmd(struct scsi_cmnd *scmd, · 91 unmodified lines | |||
| 4625 | struct ata_port *ap) | 5130 | struct ata_port *ap) |
| 4626 | __must_hold(ap->lock) | 5131 | __must_hold(ap->lock) |
| 4627 | { | 5132 | { |
| 4628 | u8 scsi_op = scmd->cmnd[0]; | 5133 | u8 *cdb = scmd->cmnd; |
| 5134 | u8 scsi_op = cdb[0]; | ||
| 4629 | ata_xlat_func_t xlat_func; | 5135 | ata_xlat_func_t xlat_func; |
| 4630 | 5136 | ||
| 4631 | /* | 5137 | /* |
| @@ -4645,7 +5151,7 @@ enum scsi_qc_status __ata_scsi_queuecmd(struct scsi_cmnd *scmd, · 13 unmodified lines | |||
| 4645 | if (unlikely(scmd->cmd_len > dev->cdb_len)) | 5151 | if (unlikely(scmd->cmd_len > dev->cdb_len)) |
| 4646 | goto bad_cdb_len; | 5152 | goto bad_cdb_len; |
| 4647 | 5153 | ||
| 4648 | xlat_func = ata_get_xlat_func(dev, scsi_op); | 5154 | xlat_func = ata_get_xlat_func(dev, cdb); |
| 4649 | } else if (likely((scsi_op != ATA_16) || !atapi_passthru16)) { | 5155 | } else if (likely((scsi_op != ATA_16) || !atapi_passthru16)) { |
| 4650 | /* relay SCSI command to ATAPI device */ | 5156 | /* relay SCSI command to ATAPI device */ |
| 4651 | int len = COMMAND_SIZE(scsi_op); | 5157 | int len = COMMAND_SIZE(scsi_op); |
| @@ -4661,7 +5167,7 @@ enum scsi_qc_status __ata_scsi_queuecmd(struct scsi_cmnd *scmd, · 9 unmodified lines | |||
| 4661 | if (unlikely(scmd->cmd_len > 16)) | 5167 | if (unlikely(scmd->cmd_len > 16)) |
| 4662 | goto bad_cdb_len; | 5168 | goto bad_cdb_len; |
| 4663 | 5169 | ||
| 4664 | xlat_func = ata_get_xlat_func(dev, scsi_op); | 5170 | xlat_func = ata_get_xlat_func(dev, cdb); |
| 4665 | } | 5171 | } |
| 4666 | 5172 | ||
| 4667 | if (xlat_func) | 5173 | if (xlat_func) |
| @@ -1114,8 +1114,14 @@ fsm_start: · 1113 unmodified lines | |||
| 1114 | 1114 | ||
| 1115 | if (ap->hsm_task_state == HSM_ST_LAST && | 1115 | if (ap->hsm_task_state == HSM_ST_LAST && |
| 1116 | (!(qc->tf.flags & ATA_TFLAG_WRITE))) { | 1116 | (!(qc->tf.flags & ATA_TFLAG_WRITE))) { |
| 1117 | /* all data read */ | 1117 | status = ata_sff_busy_wait(ap, |
| 1118 | status = ata_wait_idle(ap); | 1118 | ATA_BUSY | ATA_DRQ, 10); |
| 1119 | if (status != 0xff && | ||
| 1120 | (status & (ATA_BUSY | ATA_DRQ))) { | ||
| 1121 | qc->tf.flags |= ATA_TFLAG_POLLING; | ||
| 1122 | ata_sff_queue_pio_task(link, 0); | ||
| 1123 | return 0; | ||
| 1124 | } | ||
| 1119 | goto fsm_start; | 1125 | goto fsm_start; |
| 1120 | } | 1126 | } |
| 1121 | } | 1127 | } |
| @@ -1213,7 +1219,7 @@ static void ata_sff_pio_task(struct work_struct *work) · 91 unmodified lines | |||
| 1213 | container_of(work, struct ata_port, sff_pio_task.work); | 1219 | container_of(work, struct ata_port, sff_pio_task.work); |
| 1214 | struct ata_link *link = ap->sff_pio_task_link; | 1220 | struct ata_link *link = ap->sff_pio_task_link; |
| 1215 | struct ata_queued_cmd *qc; | 1221 | struct ata_queued_cmd *qc; |
| 1216 | u8 status; | 1222 | u8 status, wait_mask; |
| 1217 | int poll_next; | 1223 | int poll_next; |
| 1218 | 1224 | ||
| 1219 | spin_lock_irq(ap->lock); | 1225 | spin_lock_irq(ap->lock); |
| @@ -1229,6 +1235,10 @@ static void ata_sff_pio_task(struct work_struct *work) · 9 unmodified lines | |||
| 1229 | fsm_start: | 1235 | fsm_start: |
| 1230 | WARN_ON_ONCE(ap->hsm_task_state == HSM_ST_IDLE); | 1236 | WARN_ON_ONCE(ap->hsm_task_state == HSM_ST_IDLE); |
| 1231 | 1237 | ||
| 1238 | wait_mask = ATA_BUSY; | ||
| 1239 | if (ap->hsm_task_state == HSM_ST_LAST) | ||
| 1240 | wait_mask |= ATA_DRQ; | ||
| 1241 | |||
| 1232 | /* | 1242 | /* |
| 1233 | * This is purely heuristic. This is a fast path. | 1243 | * This is purely heuristic. This is a fast path. |
| 1234 | * Sometimes when we enter, BSY will be cleared in | 1244 | * Sometimes when we enter, BSY will be cleared in |
| @@ -1236,14 +1246,14 @@ fsm_start: · 1 unmodified line | |||
| 1236 | * or something. Snooze for a couple msecs, then | 1246 | * or something. Snooze for a couple msecs, then |
| 1237 | * chk-status again. If still busy, queue delayed work. | 1247 | * chk-status again. If still busy, queue delayed work. |
| 1238 | */ | 1248 | */ |
| 1239 | status = ata_sff_busy_wait(ap, ATA_BUSY, 5); | 1249 | status = ata_sff_busy_wait(ap, wait_mask, 5); |
| 1240 | if (status & ATA_BUSY) { | 1250 | if (status & wait_mask) { |
| 1241 | spin_unlock_irq(ap->lock); | 1251 | spin_unlock_irq(ap->lock); |
| 1242 | ata_msleep(ap, 2); | 1252 | ata_msleep(ap, 2); |
| 1243 | spin_lock_irq(ap->lock); | 1253 | spin_lock_irq(ap->lock); |
| 1244 | 1254 | ||
| 1245 | status = ata_sff_busy_wait(ap, ATA_BUSY, 10); | 1255 | status = ata_sff_busy_wait(ap, wait_mask, 10); |
| 1246 | if (status & ATA_BUSY) { | 1256 | if (status & wait_mask) { |
| 1247 | ata_sff_queue_pio_task(link, ATA_SHORT_PAUSE); | 1257 | ata_sff_queue_pio_task(link, ATA_SHORT_PAUSE); |
| 1248 | goto out_unlock; | 1258 | goto out_unlock; |
| 1249 | } | 1259 | } |
| @@ -44,7 +44,7 @@ static inline bool ata_sstatus_online(u32 sstatus) · 43 unmodified lines | |||
| 44 | return (sstatus & 0xf) == 0x3; | 44 | return (sstatus & 0xf) == 0x3; |
| 45 | } | 45 | } |
| 46 | 46 | ||
| 47 | static inline bool ata_dev_is_zac(struct ata_device *dev) | 47 | static inline bool ata_dev_is_zoned(struct ata_device *dev) |
| 48 | { | 48 | { |
| 49 | /* Host managed device or host aware device */ | 49 | /* Host managed device or host aware device */ |
| 50 | return dev->class == ATA_DEV_ZAC || | 50 | return dev->class == ATA_DEV_ZAC || |
| @@ -656,14 +656,22 @@ static int ep93xx_pata_dma_init(struct ep93xx_pata_data *drv_data) · 655 unmodified lines | |||
| 656 | * start of new transfer. | 656 | * start of new transfer. |
| 657 | */ | 657 | */ |
| 658 | drv_data->dma_rx_channel = dma_request_chan(dev, "rx"); | 658 | drv_data->dma_rx_channel = dma_request_chan(dev, "rx"); |
| 659 | if (IS_ERR(drv_data->dma_rx_channel)) | 659 | if (IS_ERR(drv_data->dma_rx_channel)) { |
| 660 | return dev_err_probe(dev, PTR_ERR(drv_data->dma_rx_channel), | 660 | ret = PTR_ERR(drv_data->dma_rx_channel); |
| 661 | "rx DMA setup failed\n"); | 661 | drv_data->dma_rx_channel = NULL; |
| 662 | if (ret == -EPROBE_DEFER) | ||
| 663 | return ret; | ||
| 664 | dev_warn(dev, "rx DMA unavailable, using PIO\n"); | ||
| 665 | return 0; | ||
| 666 | } | ||
| 662 | 667 | ||
| 663 | drv_data->dma_tx_channel = dma_request_chan(&pdev->dev, "tx"); | 668 | drv_data->dma_tx_channel = dma_request_chan(&pdev->dev, "tx"); |
| 664 | if (IS_ERR(drv_data->dma_tx_channel)) { | 669 | if (IS_ERR(drv_data->dma_tx_channel)) { |
| 665 | ret = dev_err_probe(dev, PTR_ERR(drv_data->dma_tx_channel), | 670 | ret = PTR_ERR(drv_data->dma_tx_channel); |
| 666 | "tx DMA setup failed\n"); | 671 | drv_data->dma_tx_channel = NULL; |
| 672 | if (ret == -EPROBE_DEFER) | ||
| 673 | goto fail_release_rx; | ||
| 674 | dev_warn(dev, "tx DMA unavailable, using PIO\n"); | ||
| 667 | goto fail_release_rx; | 675 | goto fail_release_rx; |
| 668 | } | 676 | } |
| 669 | 677 | ||
| @@ -674,7 +682,7 @@ static int ep93xx_pata_dma_init(struct ep93xx_pata_data *drv_data) · 4 unmodified lines | |||
| 674 | conf.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; | 682 | conf.src_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; |
| 675 | ret = dmaengine_slave_config(drv_data->dma_rx_channel, &conf); | 683 | ret = dmaengine_slave_config(drv_data->dma_rx_channel, &conf); |
| 676 | if (ret) { | 684 | if (ret) { |
| 677 | dev_err_probe(dev, ret, "failed to configure rx dma channel"); | 685 | dev_warn(dev, "failed to configure rx dma channel, using PIO\n"); |
| 678 | goto fail_release_dma; | 686 | goto fail_release_dma; |
| 679 | } | 687 | } |
| 680 | 688 | ||
| @@ -685,7 +693,7 @@ static int ep93xx_pata_dma_init(struct ep93xx_pata_data *drv_data) · 4 unmodified lines | |||
| 685 | conf.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; | 693 | conf.dst_addr_width = DMA_SLAVE_BUSWIDTH_4_BYTES; |
| 686 | ret = dmaengine_slave_config(drv_data->dma_tx_channel, &conf); | 694 | ret = dmaengine_slave_config(drv_data->dma_tx_channel, &conf); |
| 687 | if (ret) { | 695 | if (ret) { |
| 688 | dev_err_probe(dev, ret, "failed to configure tx dma channel"); | 696 | dev_warn(dev, "failed to configure tx dma channel, using PIO\n"); |
| 689 | goto fail_release_dma; | 697 | goto fail_release_dma; |
| 690 | } | 698 | } |
| 691 | 699 | ||
| @@ -693,10 +701,14 @@ static int ep93xx_pata_dma_init(struct ep93xx_pata_data *drv_data) · 1 unmodified line | |||
| 693 | 701 | ||
| 694 | fail_release_rx: | 702 | fail_release_rx: |
| 695 | dma_release_channel(drv_data->dma_rx_channel); | 703 | dma_release_channel(drv_data->dma_rx_channel); |
| 704 | drv_data->dma_rx_channel = NULL; | ||
| 705 | if (ret == -EPROBE_DEFER) | ||
| 706 | return ret; | ||
| 707 | return 0; | ||
| 708 | |||
| 696 | fail_release_dma: | 709 | fail_release_dma: |
| 697 | ep93xx_pata_release_dma(drv_data); | 710 | ep93xx_pata_release_dma(drv_data); |
| 698 | 711 | return 0; | |
| 699 | return ret; | ||
| 700 | } | 712 | } |
| 701 | 713 | ||
| 702 | static void ep93xx_pata_dma_start(struct ata_queued_cmd *qc) | 714 | static void ep93xx_pata_dma_start(struct ata_queued_cmd *qc) |
| @@ -769,10 +769,8 @@ static int mpc52xx_ata_probe(struct platform_device *op) · 768 unmodified lines | |||
| 769 | task_irq = bcom_get_task_irq(dmatsk); | 769 | task_irq = bcom_get_task_irq(dmatsk); |
| 770 | rv = devm_request_irq(&op->dev, task_irq, &mpc52xx_ata_task_irq, 0, | 770 | rv = devm_request_irq(&op->dev, task_irq, &mpc52xx_ata_task_irq, 0, |
| 771 | "ATA task", priv); | 771 | "ATA task", priv); |
| 772 | if (rv) { | 772 | if (rv) |
| 773 | dev_err(&op->dev, "error requesting DMA IRQ\n"); | ||
| 774 | goto err2; | 773 | goto err2; |
| 775 | } | ||
| 776 | priv->dmatsk = dmatsk; | 774 | priv->dmatsk = dmatsk; |
| 777 | 775 | ||
| 778 | /* Init the hw */ | 776 | /* Init the hw */ |
| @@ -161,8 +161,6 @@ static int pxa_ata_probe(struct platform_device *pdev) · 160 unmodified lines | |||
| 161 | struct ata_host *host; | 161 | struct ata_host *host; |
| 162 | struct ata_port *ap; | 162 | struct ata_port *ap; |
| 163 | struct pata_pxa_data *data; | 163 | struct pata_pxa_data *data; |
| 164 | struct resource *cmd_res; | ||
| 165 | struct resource *ctl_res; | ||
| 166 | struct resource *dma_res; | 164 | struct resource *dma_res; |
| 167 | struct pata_pxa_pdata *pdata = dev_get_platdata(&pdev->dev); | 165 | struct pata_pxa_pdata *pdata = dev_get_platdata(&pdev->dev); |
| 168 | struct dma_slave_config config; | 166 | struct dma_slave_config config; |
| @@ -181,20 +179,6 @@ static int pxa_ata_probe(struct platform_device *pdev) · 12 unmodified lines | |||
| 181 | return -EINVAL; | 179 | return -EINVAL; |
| 182 | } | 180 | } |
| 183 | 181 | ||
| 184 | /* | ||
| 185 | * CMD port base address | ||
| 186 | */ | ||
| 187 | cmd_res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
| 188 | if (unlikely(cmd_res == NULL)) | ||
| 189 | return -EINVAL; | ||
| 190 | |||
| 191 | /* | ||
| 192 | * CTL port base address | ||
| 193 | */ | ||
| 194 | ctl_res = platform_get_resource(pdev, IORESOURCE_MEM, 1); | ||
| 195 | if (unlikely(ctl_res == NULL)) | ||
| 196 | return -EINVAL; | ||
| 197 | |||
| 198 | /* | 182 | /* |
| 199 | * DMA port base address | 183 | * DMA port base address |
| 200 | */ | 184 | */ |
| @@ -221,14 +205,12 @@ static int pxa_ata_probe(struct platform_device *pdev) · 20 unmodified lines | |||
| 221 | ap->pio_mask = ATA_PIO4; | 205 | ap->pio_mask = ATA_PIO4; |
| 222 | ap->mwdma_mask = ATA_MWDMA2; | 206 | ap->mwdma_mask = ATA_MWDMA2; |
| 223 | 207 | ||
| 224 | ap->ioaddr.cmd_addr = devm_ioremap(&pdev->dev, cmd_res->start, | 208 | ap->ioaddr.cmd_addr = devm_platform_ioremap_resource(pdev, 0); |
| 225 | resource_size(cmd_res)); | 209 | if (IS_ERR(ap->ioaddr.cmd_addr)) |
| 226 | if (!ap->ioaddr.cmd_addr) | 210 | return PTR_ERR(ap->ioaddr.cmd_addr); |
| 227 | return -ENOMEM; | 211 | ap->ioaddr.ctl_addr = devm_platform_ioremap_resource(pdev, 1); |
| 228 | ap->ioaddr.ctl_addr = devm_ioremap(&pdev->dev, ctl_res->start, | 212 | if (IS_ERR(ap->ioaddr.ctl_addr)) |
| 229 | resource_size(ctl_res)); | 213 | return PTR_ERR(ap->ioaddr.ctl_addr); |
| 230 | if (!ap->ioaddr.ctl_addr) | ||
| 231 | return -ENOMEM; | ||
| 232 | ap->ioaddr.bmdma_addr = devm_ioremap(&pdev->dev, dma_res->start, | 214 | ap->ioaddr.bmdma_addr = devm_ioremap(&pdev->dev, dma_res->start, |
| 233 | resource_size(dma_res)); | 215 | resource_size(dma_res)); |
| 234 | if (!ap->ioaddr.bmdma_addr) | 216 | if (!ap->ioaddr.bmdma_addr) |
| @@ -280,40 +262,26 @@ static int pxa_ata_probe(struct platform_device *pdev) · 45 unmodified lines | |||
| 280 | /* | 262 | /* |
| 281 | * Request the DMA channel | 263 | * Request the DMA channel |
| 282 | */ | 264 | */ |
| 283 | data->dma_chan = dma_request_chan(&pdev->dev, "data"); | 265 | data->dma_chan = devm_dma_request_chan(&pdev->dev, "data"); |
| 284 | if (IS_ERR(data->dma_chan)) | 266 | if (IS_ERR(data->dma_chan)) |
| 285 | return PTR_ERR(data->dma_chan); | 267 | return PTR_ERR(data->dma_chan); |
| 268 | |||
| 286 | ret = dmaengine_slave_config(data->dma_chan, &config); | 269 | ret = dmaengine_slave_config(data->dma_chan, &config); |
| 287 | if (ret < 0) { | 270 | if (ret < 0) { |
| 288 | dev_err(&pdev->dev, "dma configuration failed: %d\n", ret); | 271 | dev_err(&pdev->dev, "dma configuration failed: %d\n", ret); |
| 289 | dma_release_channel(data->dma_chan); | ||
| 290 | return ret; | 272 | return ret; |
| 291 | } | 273 | } |
| 292 | 274 | ||
| 293 | /* | 275 | /* |
| 294 | * Activate the ATA host | 276 | * Activate the ATA host |
| 295 | */ | 277 | */ |
| 296 | ret = ata_host_activate(host, irq, ata_sff_interrupt, | 278 | return ata_host_activate(host, irq, ata_sff_interrupt, |
| 297 | pdata->irq_flags, &pxa_ata_sht); | 279 | pdata->irq_flags, &pxa_ata_sht); |
| 298 | if (ret) | ||
| 299 | dma_release_channel(data->dma_chan); | ||
| 300 | |||
| 301 | return ret; | ||
| 302 | } | ||
| 303 | |||
| 304 | static void pxa_ata_remove(struct platform_device *pdev) | ||
| 305 | { | ||
| 306 | struct ata_host *host = platform_get_drvdata(pdev); | ||
| 307 | struct pata_pxa_data *data = host->ports[0]->private_data; | ||
| 308 | |||
| 309 | dma_release_channel(data->dma_chan); | ||
| 310 | |||
| 311 | ata_host_detach(host); | ||
| 312 | } | 280 | } |
| 313 | 281 | ||
| 314 | static struct platform_driver pxa_ata_driver = { | 282 | static struct platform_driver pxa_ata_driver = { |
| 315 | .probe = pxa_ata_probe, | 283 | .probe = pxa_ata_probe, |
| 316 | .remove = pxa_ata_remove, | 284 | .remove = ata_platform_remove_one, |
| 317 | .driver = { | 285 | .driver = { |
| 318 | .name = DRV_NAME, | 286 | .name = DRV_NAME, |
| 319 | }, | 287 | }, |
| @@ -103,16 +103,14 @@ static int rb532_pata_driver_probe(struct platform_device *pdev) · 102 unmodified lines | |||
| 103 | { | 103 | { |
| 104 | int irq; | 104 | int irq; |
| 105 | struct gpio_desc *gpiod; | 105 | struct gpio_desc *gpiod; |
| 106 | struct resource *res; | ||
| 107 | struct ata_host *ah; | 106 | struct ata_host *ah; |
| 108 | struct rb532_cf_info *info; | 107 | struct rb532_cf_info *info; |
| 108 | void __iomem *iobase; | ||
| 109 | int ret; | 109 | int ret; |
| 110 | 110 | ||
| 111 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 111 | iobase = devm_platform_ioremap_resource(pdev, 0); |
| 112 | if (!res) { | 112 | if (IS_ERR(iobase)) |
| 113 | dev_err(&pdev->dev, "no IOMEM resource found\n"); | 113 | return PTR_ERR(iobase); |
| 114 | return -EINVAL; | ||
| 115 | } | ||
| 116 | 114 | ||
| 117 | irq = platform_get_irq(pdev, 0); | 115 | irq = platform_get_irq(pdev, 0); |
| 118 | if (irq < 0) | 116 | if (irq < 0) |
| @@ -139,11 +137,7 @@ static int rb532_pata_driver_probe(struct platform_device *pdev) · 20 unmodified lines | |||
| 139 | ah->private_data = info; | 137 | ah->private_data = info; |
| 140 | info->gpio_line = gpiod; | 138 | info->gpio_line = gpiod; |
| 141 | info->irq = irq; | 139 | info->irq = irq; |
| 142 | 140 | info->iobase = iobase; | |
| 143 | info->iobase = devm_ioremap(&pdev->dev, res->start, | ||
| 144 | resource_size(res)); | ||
| 145 | if (!info->iobase) | ||
| 146 | return -ENOMEM; | ||
| 147 | 141 | ||
| 148 | rb532_pata_setup_ports(ah); | 142 | rb532_pata_setup_ports(ah); |
| 149 | 143 | ||
| @@ -455,7 +455,7 @@ static int ahci_highbank_probe(struct platform_device *pdev) · 454 unmodified lines | |||
| 455 | struct ahci_host_priv *hpriv; | 455 | struct ahci_host_priv *hpriv; |
| 456 | struct ecx_plat_data *pdata; | 456 | struct ecx_plat_data *pdata; |
| 457 | struct ata_host *host; | 457 | struct ata_host *host; |
| 458 | struct resource *mem; | 458 | void __iomem *mmio; |
| 459 | int irq; | 459 | int irq; |
| 460 | int i; | 460 | int i; |
| 461 | int rc; | 461 | int rc; |
| @@ -463,11 +463,9 @@ static int ahci_highbank_probe(struct platform_device *pdev) · 1 unmodified line | |||
| 463 | struct ata_port_info pi = ahci_highbank_port_info; | 463 | struct ata_port_info pi = ahci_highbank_port_info; |
| 464 | const struct ata_port_info *ppi[] = { &pi, NULL }; | 464 | const struct ata_port_info *ppi[] = { &pi, NULL }; |
| 465 | 465 | ||
| 466 | mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 466 | mmio = devm_platform_ioremap_resource(pdev, 0); |
| 467 | if (!mem) { | 467 | if (IS_ERR(mmio)) |
| 468 | dev_err(dev, "no mmio space\n"); | 468 | return PTR_ERR(mmio); |
| 469 | return -EINVAL; | ||
| 470 | } | ||
| 471 | 469 | ||
| 472 | irq = platform_get_irq(pdev, 0); | 470 | irq = platform_get_irq(pdev, 0); |
| 473 | if (irq < 0) | 471 | if (irq < 0) |
| @@ -488,12 +486,7 @@ static int ahci_highbank_probe(struct platform_device *pdev) · 14 unmodified lines | |||
| 488 | 486 | ||
| 489 | hpriv->irq = irq; | 487 | hpriv->irq = irq; |
| 490 | hpriv->flags |= (unsigned long)pi.private_data; | 488 | hpriv->flags |= (unsigned long)pi.private_data; |
| 491 | 489 | hpriv->mmio = mmio; | |
| 492 | hpriv->mmio = devm_ioremap(dev, mem->start, resource_size(mem)); | ||
| 493 | if (!hpriv->mmio) { | ||
| 494 | dev_err(dev, "can't map %pR\n", mem); | ||
| 495 | return -ENOMEM; | ||
| 496 | } | ||
| 497 | 490 | ||
| 498 | rc = highbank_initialize_phys(dev, hpriv->mmio); | 491 | rc = highbank_initialize_phys(dev, hpriv->mmio); |
| 499 | if (rc) | 492 | if (rc) |
| @@ -537,7 +530,6 @@ static int ahci_highbank_probe(struct platform_device *pdev) · 37 unmodified lines | |||
| 537 | for (i = 0; i < host->n_ports; i++) { | 530 | for (i = 0; i < host->n_ports; i++) { |
| 538 | struct ata_port *ap = host->ports[i]; | 531 | struct ata_port *ap = host->ports[i]; |
| 539 | 532 | ||
| 540 | ata_port_desc(ap, "mmio %pR", mem); | ||
| 541 | ata_port_desc(ap, "port 0x%x", 0x100 + ap->port_no * 0x80); | 533 | ata_port_desc(ap, "port 0x%x", 0x100 + ap->port_no * 0x80); |
| 542 | 534 | ||
| 543 | /* set enclosure management message type */ | 535 | /* set enclosure management message type */ |
| @@ -4054,17 +4054,13 @@ static int mv_platform_probe(struct platform_device *pdev) · 4053 unmodified lines | |||
| 4054 | n_ports); | 4054 | n_ports); |
| 4055 | return -EINVAL; | 4055 | return -EINVAL; |
| 4056 | } | 4056 | } |
| 4057 | |||
| 4058 | irq = irq_of_parse_and_map(pdev->dev.of_node, 0); | ||
| 4059 | } else { | 4057 | } else { |
| 4060 | mv_platform_data = dev_get_platdata(&pdev->dev); | 4058 | mv_platform_data = dev_get_platdata(&pdev->dev); |
| 4061 | n_ports = mv_platform_data->n_ports; | 4059 | n_ports = mv_platform_data->n_ports; |
| 4062 | irq = platform_get_irq(pdev, 0); | ||
| 4063 | } | 4060 | } |
| 4061 | irq = platform_get_irq(pdev, 0); | ||
| 4064 | if (irq < 0) | 4062 | if (irq < 0) |
| 4065 | return irq; | 4063 | return irq; |
| 4066 | if (!irq) | ||
| 4067 | return -EINVAL; | ||
| 4068 | 4064 | ||
| 4069 | host = ata_host_alloc_pinfo(&pdev->dev, ppi, n_ports); | 4065 | host = ata_host_alloc_pinfo(&pdev->dev, ppi, n_ports); |
| 4070 | hpriv = devm_kzalloc(&pdev->dev, sizeof(*hpriv), GFP_KERNEL); | 4066 | hpriv = devm_kzalloc(&pdev->dev, sizeof(*hpriv), GFP_KERNEL); |
| @@ -4092,21 +4088,19 @@ static int mv_platform_probe(struct platform_device *pdev) · 21 unmodified lines | |||
| 4092 | 4088 | ||
| 4093 | hpriv->base -= SATAHC0_REG_BASE; | 4089 | hpriv->base -= SATAHC0_REG_BASE; |
| 4094 | 4090 | ||
| 4095 | hpriv->clk = clk_get(&pdev->dev, NULL); | 4091 | hpriv->clk = devm_clk_get_optional_enabled(&pdev->dev, NULL); |
| 4096 | if (IS_ERR(hpriv->clk)) { | 4092 | if (IS_ERR(hpriv->clk)) |
| 4097 | dev_notice(&pdev->dev, "cannot get optional clkdev\n"); | 4093 | return PTR_ERR(hpriv->clk); |
| 4098 | } else { | ||
| 4099 | rc = clk_prepare_enable(hpriv->clk); | ||
| 4100 | if (rc) | ||
| 4101 | goto err; | ||
| 4102 | } | ||
| 4103 | 4094 | ||
| 4104 | for (port = 0; port < n_ports; port++) { | 4095 | for (port = 0; port < n_ports; port++) { |
| 4105 | char port_number[16]; | 4096 | char port_number[16]; |
| 4106 | sprintf(port_number, "%d", port); | 4097 | sprintf(port_number, "%d", port); |
| 4107 | hpriv->port_clks[port] = clk_get(&pdev->dev, port_number); | 4098 | hpriv->port_clks[port] = devm_clk_get_optional_enabled(&pdev->dev, port_number); |
| 4108 | if (!IS_ERR(hpriv->port_clks[port])) | 4099 | if (IS_ERR(hpriv->port_clks[port])) { |
| 4109 | clk_prepare_enable(hpriv->port_clks[port]); | 4100 | rc = PTR_ERR(hpriv->port_clks[port]); |
| 4101 | hpriv->n_ports = port; | ||
| 4102 | goto err; | ||
| 4103 | } | ||
| 4110 | 4104 | ||
| 4111 | sprintf(port_number, "port%d", port); | 4105 | sprintf(port_number, "port%d", port); |
| 4112 | hpriv->port_phys[port] = devm_phy_optional_get(&pdev->dev, | 4106 | hpriv->port_phys[port] = devm_phy_optional_get(&pdev->dev, |
| @@ -4120,8 +4114,8 @@ static int mv_platform_probe(struct platform_device *pdev) · 7 unmodified lines | |||
| 4120 | /* Cleanup only the initialized ports */ | 4114 | /* Cleanup only the initialized ports */ |
| 4121 | hpriv->n_ports = port; | 4115 | hpriv->n_ports = port; |
| 4122 | goto err; | 4116 | goto err; |
| 4123 | } else | 4117 | } |
| 4124 | phy_power_on(hpriv->port_phys[port]); | 4118 | phy_power_on(hpriv->port_phys[port]); |
| 4125 | } | 4119 | } |
| 4126 | 4120 | ||
| 4127 | /* All the ports have been initialized */ | 4121 | /* All the ports have been initialized */ |
| @@ -4160,17 +4154,8 @@ static int mv_platform_probe(struct platform_device *pdev) · 32 unmodified lines | |||
| 4160 | return 0; | 4154 | return 0; |
| 4161 | 4155 | ||
| 4162 | err: | 4156 | err: |
| 4163 | if (!IS_ERR(hpriv->clk)) { | 4157 | for (port = 0; port < hpriv->n_ports; port++) |
| 4164 | clk_disable_unprepare(hpriv->clk); | ||
| 4165 | clk_put(hpriv->clk); | ||
| 4166 | } | ||
| 4167 | for (port = 0; port < hpriv->n_ports; port++) { | ||
| 4168 | if (!IS_ERR(hpriv->port_clks[port])) { | ||
| 4169 | clk_disable_unprepare(hpriv->port_clks[port]); | ||
| 4170 | clk_put(hpriv->port_clks[port]); | ||
| 4171 | } | ||
| 4172 | phy_power_off(hpriv->port_phys[port]); | 4158 | phy_power_off(hpriv->port_phys[port]); |
| 4173 | } | ||
| 4174 | 4159 | ||
| 4175 | return rc; | 4160 | return rc; |
| 4176 | } | 4161 | } |
| @@ -4190,17 +4175,8 @@ static void mv_platform_remove(struct platform_device *pdev) · 13 unmodified lines | |||
| 4190 | int port; | 4175 | int port; |
| 4191 | ata_host_detach(host); | 4176 | ata_host_detach(host); |
| 4192 | 4177 | ||
| 4193 | if (!IS_ERR(hpriv->clk)) { | 4178 | for (port = 0; port < host->n_ports; port++) |
| 4194 | clk_disable_unprepare(hpriv->clk); | ||
| 4195 | clk_put(hpriv->clk); | ||
| 4196 | } | ||
| 4197 | for (port = 0; port < host->n_ports; port++) { | ||
| 4198 | if (!IS_ERR(hpriv->port_clks[port])) { | ||
| 4199 | clk_disable_unprepare(hpriv->port_clks[port]); | ||
| 4200 | clk_put(hpriv->port_clks[port]); | ||
| 4201 | } | ||
| 4202 | phy_power_off(hpriv->port_phys[port]); | 4179 | phy_power_off(hpriv->port_phys[port]); |
| 4203 | } | ||
| 4204 | } | 4180 | } |
| 4205 | 4181 | ||
| 4206 | #ifdef CONFIG_PM_SLEEP | 4182 | #ifdef CONFIG_PM_SLEEP |
| @@ -67,52 +67,6 @@ static const char *sdebug_version_date = "20210520"; · 66 unmodified lines | |||
| 67 | 67 | ||
| 68 | #define MY_NAME "scsi_debug" | 68 | #define MY_NAME "scsi_debug" |
| 69 | 69 | ||
| 70 | /* Additional Sense Code (ASC) */ | ||
| 71 | #define NO_ADDITIONAL_SENSE 0x0 | ||
| 72 | #define OVERLAP_ATOMIC_COMMAND_ASC 0x0 | ||
| 73 | #define OVERLAP_ATOMIC_COMMAND_ASCQ 0x23 | ||
| 74 | #define FILEMARK_DETECTED_ASCQ 0x1 | ||
| 75 | #define EOP_EOM_DETECTED_ASCQ 0x2 | ||
| 76 | #define BEGINNING_OF_P_M_DETECTED_ASCQ 0x4 | ||
| 77 | #define EOD_DETECTED_ASCQ 0x5 | ||
| 78 | #define LOGICAL_UNIT_NOT_READY 0x4 | ||
| 79 | #define LOGICAL_UNIT_COMMUNICATION_FAILURE 0x8 | ||
| 80 | #define UNRECOVERED_READ_ERR 0x11 | ||
| 81 | #define PARAMETER_LIST_LENGTH_ERR 0x1a | ||
| 82 | #define INVALID_OPCODE 0x20 | ||
| 83 | #define LBA_OUT_OF_RANGE 0x21 | ||
| 84 | #define INVALID_FIELD_IN_CDB 0x24 | ||
| 85 | #define INVALID_FIELD_IN_PARAM_LIST 0x26 | ||
| 86 | #define WRITE_PROTECTED 0x27 | ||
| 87 | #define UA_READY_ASC 0x28 | ||
| 88 | #define UA_RESET_ASC 0x29 | ||
| 89 | #define UA_CHANGED_ASC 0x2a | ||
| 90 | #define TOO_MANY_IN_PARTITION_ASC 0x3b | ||
| 91 | #define TARGET_CHANGED_ASC 0x3f | ||
| 92 | #define LUNS_CHANGED_ASCQ 0x0e | ||
| 93 | #define INSUFF_RES_ASC 0x55 | ||
| 94 | #define INSUFF_RES_ASCQ 0x3 | ||
| 95 | #define POWER_ON_RESET_ASCQ 0x0 | ||
| 96 | #define POWER_ON_OCCURRED_ASCQ 0x1 | ||
| 97 | #define BUS_RESET_ASCQ 0x2 /* scsi bus reset occurred */ | ||
| 98 | #define MODE_CHANGED_ASCQ 0x1 /* mode parameters changed */ | ||
| 99 | #define CAPACITY_CHANGED_ASCQ 0x9 | ||
| 100 | #define SAVING_PARAMS_UNSUP 0x39 | ||
| 101 | #define TRANSPORT_PROBLEM 0x4b | ||
| 102 | #define THRESHOLD_EXCEEDED 0x5d | ||
| 103 | #define LOW_POWER_COND_ON 0x5e | ||
| 104 | #define MISCOMPARE_VERIFY_ASC 0x1d | ||
| 105 | #define MICROCODE_CHANGED_ASCQ 0x1 /* with TARGET_CHANGED_ASC */ | ||
| 106 | #define MICROCODE_CHANGED_WO_RESET_ASCQ 0x16 | ||
| 107 | #define WRITE_ERROR_ASC 0xc | ||
| 108 | #define UNALIGNED_WRITE_ASCQ 0x4 | ||
| 109 | #define WRITE_BOUNDARY_ASCQ 0x5 | ||
| 110 | #define READ_INVDATA_ASCQ 0x6 | ||
| 111 | #define READ_BOUNDARY_ASCQ 0x7 | ||
| 112 | #define ATTEMPT_ACCESS_GAP 0x9 | ||
| 113 | #define INSUFF_ZONE_ASCQ 0xe | ||
| 114 | /* see drivers/scsi/sense_codes.h */ | ||
| 115 | |||
| 116 | /* Additional Sense Code Qualifier (ASCQ) */ | 70 | /* Additional Sense Code Qualifier (ASCQ) */ |
| 117 | #define ACK_NAK_TO 0x3 | 71 | #define ACK_NAK_TO 0x3 |
| 118 | 72 | ||
| @@ -75,6 +75,7 @@ enum { · 74 unmodified lines | |||
| 75 | ATA_ID_HW_CONFIG = 93, | 75 | ATA_ID_HW_CONFIG = 93, |
| 76 | ATA_ID_SPG = 98, | 76 | ATA_ID_SPG = 98, |
| 77 | ATA_ID_LBA_CAPACITY_2 = 100, | 77 | ATA_ID_LBA_CAPACITY_2 = 100, |
| 78 | ATA_ID_MAX_PAGES_PER_DSM = 105, | ||
| 78 | ATA_ID_SECTOR_SIZE = 106, | 79 | ATA_ID_SECTOR_SIZE = 106, |
| 79 | ATA_ID_WWN = 108, | 80 | ATA_ID_WWN = 108, |
| 80 | ATA_ID_LOGICAL_SECTOR_SIZE = 117, /* and 118 */ | 81 | ATA_ID_LOGICAL_SECTOR_SIZE = 117, /* and 118 */ |
| @@ -288,6 +289,10 @@ enum { · 207 unmodified lines | |||
| 288 | ATA_CMD_SANITIZE_DEVICE = 0xB4, | 289 | ATA_CMD_SANITIZE_DEVICE = 0xB4, |
| 289 | ATA_CMD_ZAC_MGMT_IN = 0x4A, | 290 | ATA_CMD_ZAC_MGMT_IN = 0x4A, |
| 290 | ATA_CMD_ZAC_MGMT_OUT = 0x9F, | 291 | ATA_CMD_ZAC_MGMT_OUT = 0x9F, |
| 292 | ATA_CMD_GET_PHYS_ELEMENT_STATUS = 0x12, | ||
| 293 | ATA_CMD_REMOVE_ELEMENT_AND_TRUNCATE = 0x7c, | ||
| 294 | ATA_CMD_RESTORE_ELEMENTS_AND_REBUILD = 0x7d, | ||
| 295 | ATA_CMD_REMOVE_ELEMENT_AND_MODIFY_ZONES = 0x7e, | ||
| 291 | 296 | ||
| 292 | /* marked obsolete in the ATA/ATAPI-7 spec */ | 297 | /* marked obsolete in the ATA/ATAPI-7 spec */ |
| 293 | ATA_CMD_RESTORE = 0x10, | 298 | ATA_CMD_RESTORE = 0x10, |
| @@ -928,6 +933,18 @@ static inline bool ata_id_has_trim(const u16 *id) · 634 unmodified lines | |||
| 928 | return false; | 933 | return false; |
| 929 | } | 934 | } |
| 930 | 935 | ||
| 936 | static inline u16 ata_id_dsm_max_pages(const u16 *id) | ||
| 937 | { | ||
| 938 | /* | ||
| 939 | * IDENTIFY DEVICE word 105: MAX PAGES PER DSM COMMAND. Maximum number | ||
| 940 | * of 512-byte pages of LBA Range Entries the device accepts in a | ||
| 941 | * single DATA SET MANAGEMENT command. Zero means the device does not | ||
| 942 | * specify a limit. The field is reserved unless TRIM is supported, so | ||
| 943 | * callers must gate on ata_id_has_trim(). | ||
| 944 | */ | ||
| 945 | return id[ATA_ID_MAX_PAGES_PER_DSM]; | ||
| 946 | } | ||
| 947 | |||
| 931 | static inline bool ata_id_has_zero_after_trim(const u16 *id) | 948 | static inline bool ata_id_has_zero_after_trim(const u16 *id) |
| 932 | { | 949 | { |
| 933 | /* DSM supported, deterministic read, and read zero after trim set */ | 950 | /* DSM supported, deterministic read, and read zero after trim set */ |
| @@ -121,6 +121,55 @@ enum { · 120 unmodified lines | |||
| 121 | ATA_QUIRK_NO_FUA = BIT_ULL(__ATA_QUIRK_NO_FUA), | 121 | ATA_QUIRK_NO_FUA = BIT_ULL(__ATA_QUIRK_NO_FUA), |
| 122 | }; | 122 | }; |
| 123 | 123 | ||
| 124 | /* | ||
| 125 | * struct ata_device flags | ||
| 126 | */ | ||
| 127 | enum { | ||
| 128 | ATA_DFLAG_LBA = (1UL << 0), /* device supports LBA */ | ||
| 129 | ATA_DFLAG_LBA48 = (1UL << 1), /* device supports LBA48 */ | ||
| 130 | ATA_DFLAG_CDB_INTR = (1UL << 2), /* device asserts INTRQ when ready for CDB */ | ||
| 131 | ATA_DFLAG_NCQ = (1UL << 3), /* device supports NCQ */ | ||
| 132 | ATA_DFLAG_FLUSH_EXT = (1UL << 4), /* do FLUSH_EXT instead of FLUSH */ | ||
| 133 | ATA_DFLAG_ACPI_PENDING = (1UL << 5), /* ACPI resume action pending */ | ||
| 134 | ATA_DFLAG_ACPI_FAILED = (1UL << 6), /* ACPI on devcfg has failed */ | ||
| 135 | ATA_DFLAG_AN = (1UL << 7), /* AN configured */ | ||
| 136 | ATA_DFLAG_TRUSTED = (1UL << 8), /* device supports trusted send/recv */ | ||
| 137 | ATA_DFLAG_FUA = (1UL << 9), /* device supports FUA */ | ||
| 138 | ATA_DFLAG_DMADIR = (1UL << 10), /* device requires DMADIR */ | ||
| 139 | ATA_DFLAG_NCQ_SEND_RECV = (1UL << 11), /* device supports NCQ SEND and RECV */ | ||
| 140 | ATA_DFLAG_NCQ_PRIO = (1UL << 12), /* device supports NCQ priority */ | ||
| 141 | ATA_DFLAG_CDL = (1UL << 13), /* supports cmd duration limits */ | ||
| 142 | ATA_DFLAG_DEPOP = (1UL << 14), /* supports depopulation capability */ | ||
| 143 | ATA_DFLAG_DEPOP_RESTORE = (1UL << 15), /* supports depopulation restoration */ | ||
| 144 | ATA_DFLAG_DEPOP_MODIFY = (1UL << 16), /* supports zoned depopulation */ | ||
| 145 | ATA_DFLAG_CFG_MASK = (1UL << 17) - 1, | ||
| 146 | |||
| 147 | ATA_DFLAG_PIO = (1UL << 17), /* device limited to PIO mode */ | ||
| 148 | ATA_DFLAG_NCQ_OFF = (1UL << 18), /* device limited to non-NCQ mode */ | ||
| 149 | ATA_DFLAG_SLEEPING = (1UL << 19), /* device is sleeping */ | ||
| 150 | ATA_DFLAG_DUBIOUS_XFER = (1UL << 20), /* data transfer not verified */ | ||
| 151 | ATA_DFLAG_NO_UNLOAD = (1UL << 21), /* device doesn't support unload */ | ||
| 152 | ATA_DFLAG_UNLOCK_HPA = (1UL << 22), /* unlock HPA */ | ||
| 153 | ATA_DFLAG_INIT_MASK = (1UL << 23) - 1, | ||
| 154 | |||
| 155 | ATA_DFLAG_NCQ_PRIO_ENABLED = (1UL << 23), /* Priority cmds sent to dev */ | ||
| 156 | ATA_DFLAG_CDL_ENABLED = (1UL << 24), /* cmd duration limits is enabled */ | ||
| 157 | ATA_DFLAG_RESUMING = (1UL << 25), /* Device is resuming */ | ||
| 158 | ATA_DFLAG_DETACH = (1UL << 26), | ||
| 159 | ATA_DFLAG_DETACHED = (1UL << 27), | ||
| 160 | ATA_DFLAG_DA = (1UL << 28), /* device supports Device Attention */ | ||
| 161 | ATA_DFLAG_DEVSLP = (1UL << 29), /* device supports Device Sleep */ | ||
| 162 | ATA_DFLAG_ACPI_DISABLED = (1UL << 30), /* ACPI for the device is disabled */ | ||
| 163 | ATA_DFLAG_D_SENSE = (1UL << 31), /* Descriptor sense requested */ | ||
| 164 | |||
| 165 | ATA_DFLAG_FEATURES_MASK = (ATA_DFLAG_TRUSTED | ATA_DFLAG_DA | \ | ||
| 166 | ATA_DFLAG_DEVSLP | ATA_DFLAG_NCQ_SEND_RECV | \ | ||
| 167 | ATA_DFLAG_NCQ_PRIO | ATA_DFLAG_FUA | \ | ||
| 168 | ATA_DFLAG_CDL | ATA_DFLAG_DEPOP | \ | ||
| 169 | ATA_DFLAG_DEPOP_RESTORE | | ||
| 170 | ATA_DFLAG_DEPOP_MODIFY) | ||
| 171 | }; | ||
| 172 | |||
| 124 | enum { | 173 | enum { |
| 125 | /* various global constants */ | 174 | /* various global constants */ |
| 126 | LIBATA_MAX_PRD = ATA_MAX_PRD / 2, | 175 | LIBATA_MAX_PRD = ATA_MAX_PRD / 2, |
| @@ -146,46 +195,7 @@ enum { · 19 unmodified lines | |||
| 146 | ATA_TFLAG_FUA = (1 << 5), /* enable FUA */ | 195 | ATA_TFLAG_FUA = (1 << 5), /* enable FUA */ |
| 147 | ATA_TFLAG_POLLING = (1 << 6), /* set nIEN to 1 and use polling */ | 196 | ATA_TFLAG_POLLING = (1 << 6), /* set nIEN to 1 and use polling */ |
| 148 | 197 | ||
| 149 | /* struct ata_device stuff */ | 198 | /* sturct ata_device class. */ |
| 150 | ATA_DFLAG_LBA = (1 << 0), /* device supports LBA */ | ||
| 151 | ATA_DFLAG_LBA48 = (1 << 1), /* device supports LBA48 */ | ||
| 152 | ATA_DFLAG_CDB_INTR = (1 << 2), /* device asserts INTRQ when ready for CDB */ | ||
| 153 | ATA_DFLAG_NCQ = (1 << 3), /* device supports NCQ */ | ||
| 154 | ATA_DFLAG_FLUSH_EXT = (1 << 4), /* do FLUSH_EXT instead of FLUSH */ | ||
| 155 | ATA_DFLAG_ACPI_PENDING = (1 << 5), /* ACPI resume action pending */ | ||
| 156 | ATA_DFLAG_ACPI_FAILED = (1 << 6), /* ACPI on devcfg has failed */ | ||
| 157 | ATA_DFLAG_AN = (1 << 7), /* AN configured */ | ||
| 158 | ATA_DFLAG_TRUSTED = (1 << 8), /* device supports trusted send/recv */ | ||
| 159 | ATA_DFLAG_FUA = (1 << 9), /* device supports FUA */ | ||
| 160 | ATA_DFLAG_DMADIR = (1 << 10), /* device requires DMADIR */ | ||
| 161 | ATA_DFLAG_NCQ_SEND_RECV = (1 << 11), /* device supports NCQ SEND and RECV */ | ||
| 162 | ATA_DFLAG_NCQ_PRIO = (1 << 12), /* device supports NCQ priority */ | ||
| 163 | ATA_DFLAG_CDL = (1 << 13), /* supports cmd duration limits */ | ||
| 164 | ATA_DFLAG_CFG_MASK = (1 << 14) - 1, | ||
| 165 | |||
| 166 | ATA_DFLAG_PIO = (1 << 14), /* device limited to PIO mode */ | ||
| 167 | ATA_DFLAG_NCQ_OFF = (1 << 15), /* device limited to non-NCQ mode */ | ||
| 168 | ATA_DFLAG_SLEEPING = (1 << 16), /* device is sleeping */ | ||
| 169 | ATA_DFLAG_DUBIOUS_XFER = (1 << 17), /* data transfer not verified */ | ||
| 170 | ATA_DFLAG_NO_UNLOAD = (1 << 18), /* device doesn't support unload */ | ||
| 171 | ATA_DFLAG_UNLOCK_HPA = (1 << 19), /* unlock HPA */ | ||
| 172 | ATA_DFLAG_INIT_MASK = (1 << 20) - 1, | ||
| 173 | |||
| 174 | ATA_DFLAG_NCQ_PRIO_ENABLED = (1 << 20), /* Priority cmds sent to dev */ | ||
| 175 | ATA_DFLAG_CDL_ENABLED = (1 << 21), /* cmd duration limits is enabled */ | ||
| 176 | ATA_DFLAG_RESUMING = (1 << 22), /* Device is resuming */ | ||
| 177 | ATA_DFLAG_DETACH = (1 << 24), | ||
| 178 | ATA_DFLAG_DETACHED = (1 << 25), | ||
| 179 | ATA_DFLAG_DA = (1 << 26), /* device supports Device Attention */ | ||
| 180 | ATA_DFLAG_DEVSLP = (1 << 27), /* device supports Device Sleep */ | ||
| 181 | ATA_DFLAG_ACPI_DISABLED = (1 << 28), /* ACPI for the device is disabled */ | ||
| 182 | ATA_DFLAG_D_SENSE = (1 << 29), /* Descriptor sense requested */ | ||
| 183 | |||
| 184 | ATA_DFLAG_FEATURES_MASK = (ATA_DFLAG_TRUSTED | ATA_DFLAG_DA | \ | ||
| 185 | ATA_DFLAG_DEVSLP | ATA_DFLAG_NCQ_SEND_RECV | \ | ||
| 186 | ATA_DFLAG_NCQ_PRIO | ATA_DFLAG_FUA | \ | ||
| 187 | ATA_DFLAG_CDL), | ||
| 188 | |||
| 189 | ATA_DEV_UNKNOWN = 0, /* unknown device */ | 199 | ATA_DEV_UNKNOWN = 0, /* unknown device */ |
| 190 | ATA_DEV_ATA = 1, /* ATA device */ | 200 | ATA_DEV_ATA = 1, /* ATA device */ |
| 191 | ATA_DEV_ATA_UNSUP = 2, /* ATA device (unsupported) */ | 201 | ATA_DEV_ATA_UNSUP = 2, /* ATA device (unsupported) */ |
| @@ -1421,9 +1431,6 @@ extern int ata_port_freeze(struct ata_port *ap); · 1229 unmodified lines | |||
| 1421 | extern void ata_eh_freeze_port(struct ata_port *ap); | 1431 | extern void ata_eh_freeze_port(struct ata_port *ap); |
| 1422 | extern void ata_eh_thaw_port(struct ata_port *ap); | 1432 | extern void ata_eh_thaw_port(struct ata_port *ap); |
| 1423 | 1433 | ||
| 1424 | extern void ata_eh_qc_complete(struct ata_queued_cmd *qc); | ||
| 1425 | extern void ata_eh_qc_retry(struct ata_queued_cmd *qc); | ||
| 1426 | |||
| 1427 | extern void ata_std_error_handler(struct ata_port *ap) | 1434 | extern void ata_std_error_handler(struct ata_port *ap) |
| 1428 | __must_hold(&ap->host->eh_mutex); | 1435 | __must_hold(&ap->host->eh_mutex); |
| 1429 | extern void ata_std_sched_eh(struct ata_port *ap); | 1436 | extern void ata_std_sched_eh(struct ata_port *ap); |
| @@ -129,6 +129,10 @@ · 128 unmodified lines | |||
| 129 | #define SAI_GET_LBA_STATUS 0x12 | 129 | #define SAI_GET_LBA_STATUS 0x12 |
| 130 | #define SAI_REPORT_REFERRALS 0x13 | 130 | #define SAI_REPORT_REFERRALS 0x13 |
| 131 | #define SAI_GET_STREAM_STATUS 0x16 | 131 | #define SAI_GET_STREAM_STATUS 0x16 |
| 132 | #define SAI_GET_PHYSICAL_ELEMENT_STATUS 0x17 | ||
| 133 | #define SAI_REMOVE_ELEMENT_AND_TRUNCATE 0x18 | ||
| 134 | #define SAI_RESTORE_ELEMENTS_AND_REBUILD 0x19 | ||
| 135 | #define SAI_REMOVE_ELEMENT_AND_MODIFY_ZONES 0x1a | ||
| 132 | /* values for maintenance in */ | 136 | /* values for maintenance in */ |
| 133 | #define MI_REPORT_IDENTIFYING_INFORMATION 0x05 | 137 | #define MI_REPORT_IDENTIFYING_INFORMATION 0x05 |
| 134 | #define MI_REPORT_TARGET_PGS 0x0a | 138 | #define MI_REPORT_TARGET_PGS 0x0a |
| @@ -233,6 +237,57 @@ enum sam_status { · 98 unmodified lines | |||
| 233 | #define MISCOMPARE 0x0e | 237 | #define MISCOMPARE 0x0e |
| 234 | #define COMPLETED 0x0f | 238 | #define COMPLETED 0x0f |
| 235 | 239 | ||
| 240 | /* | ||
| 241 | * Additional Sense Codes (ASC). | ||
| 242 | */ | ||
| 243 | #define NO_ADDITIONAL_SENSE 0x00 | ||
| 244 | #define OVERLAP_ATOMIC_COMMAND_ASC 0x00 | ||
| 245 | #define LOGICAL_UNIT_NOT_READY 0x04 | ||
| 246 | #define LOGICAL_UNIT_COMMUNICATION_FAILURE 0x8 | ||
| 247 | #define WRITE_ERROR_ASC 0x0c | ||
| 248 | #define UNRECOVERED_READ_ERR 0x11 | ||
| 249 | #define PARAMETER_LIST_LENGTH_ERR 0x1a | ||
| 250 | #define MISCOMPARE_VERIFY_ASC 0x1d | ||
| 251 | #define INVALID_OPCODE 0x20 | ||
| 252 | #define LBA_OUT_OF_RANGE 0x21 | ||
| 253 | #define INVALID_FIELD_IN_CDB 0x24 | ||
| 254 | #define INVALID_FIELD_IN_PARAM_LIST 0x26 | ||
| 255 | #define WRITE_PROTECTED 0x27 | ||
| 256 | #define UA_READY_ASC 0x28 | ||
| 257 | #define UA_RESET_ASC 0x29 | ||
| 258 | #define UA_CHANGED_ASC 0x2a | ||
| 259 | #define TOO_MANY_IN_PARTITION_ASC 0x3b | ||
| 260 | #define TARGET_CHANGED_ASC 0x3f | ||
| 261 | #define SAVING_PARAMS_UNSUP 0x39 | ||
| 262 | #define TRANSPORT_PROBLEM 0x4b | ||
| 263 | #define INSUFF_RES_ASC 0x55 | ||
| 264 | #define LOW_POWER_COND_ON 0x5e | ||
| 265 | #define THRESHOLD_EXCEEDED 0x5d | ||
| 266 | |||
| 267 | /* | ||
| 268 | * Additional Sense Code Qualifiers (ASCQ). | ||
| 269 | */ | ||
| 270 | #define POWER_ON_RESET_ASCQ 0x00 | ||
| 271 | #define MODE_CHANGED_ASCQ 0x01 /* mode parameters changed */ | ||
| 272 | #define FILEMARK_DETECTED_ASCQ 0x01 | ||
| 273 | #define POWER_ON_OCCURRED_ASCQ 0x01 | ||
| 274 | #define MICROCODE_CHANGED_ASCQ 0x01 /* with TARGET_CHANGED_ASC */ | ||
| 275 | #define BUS_RESET_ASCQ 0x02 /* scsi bus reset occurred */ | ||
| 276 | #define EOP_EOM_DETECTED_ASCQ 0x02 | ||
| 277 | #define INSUFF_RES_ASCQ 0x03 | ||
| 278 | #define BEGINNING_OF_P_M_DETECTED_ASCQ 0x04 | ||
| 279 | #define UNALIGNED_WRITE_ASCQ 0x04 | ||
| 280 | #define EOD_DETECTED_ASCQ 0x05 | ||
| 281 | #define WRITE_BOUNDARY_ASCQ 0x05 | ||
| 282 | #define READ_INVDATA_ASCQ 0x06 | ||
| 283 | #define READ_BOUNDARY_ASCQ 0x07 | ||
| 284 | #define CAPACITY_CHANGED_ASCQ 0x09 | ||
| 285 | #define ATTEMPT_ACCESS_GAP 0x09 | ||
| 286 | #define LUNS_CHANGED_ASCQ 0x0e | ||
| 287 | #define INSUFF_ZONE_ASCQ 0x0e | ||
| 288 | #define MICROCODE_CHANGED_WO_RESET_ASCQ 0x16 | ||
| 289 | #define OVERLAP_ATOMIC_COMMAND_ASCQ 0x23 | ||
| 290 | |||
| 236 | /* | 291 | /* |
| 237 | * DEVICE TYPES | 292 | * DEVICE TYPES |
| 238 | * Please keep them in 0x%02x format for $MODALIAS to work | 293 | * Please keep them in 0x%02x format for $MODALIAS to work |
| @@ -413,6 +468,25 @@ enum zbc_zone_alignment_method { · 174 unmodified lines | |||
| 413 | ZBC_CONSTANT_ZONE_START_OFFSET = 0x8, | 468 | ZBC_CONSTANT_ZONE_START_OFFSET = 0x8, |
| 414 | }; | 469 | }; |
| 415 | 470 | ||
| 471 | /* SCSI physical element types */ | ||
| 472 | enum scsi_phys_element_type { | ||
| 473 | SCSI_PHYS_ELEM_TYPE_ALL_ACCESS_STORAGE = 0x1, | ||
| 474 | SCSI_PHYS_ELEM_TYPE_FRAC_ACCESS_STORAGE = 0x2, | ||
| 475 | }; | ||
| 476 | |||
| 477 | /* SCSI physical element health. */ | ||
| 478 | enum scsi_phys_element_health { | ||
| 479 | SCSI_PHYS_ELEM_HEALTH_NOT_REPORTED = 0x00, | ||
| 480 | SCSI_PHYS_ELEM_HEALTH_WITHIN_SPEC_LIMITS = 0x01, | ||
| 481 | SCSI_PHYS_ELEM_HEALTH_AT_SPEC_LIMITS = 0x64, | ||
| 482 | SCSI_PHYS_ELEM_HEALTH_OUTSIDE_SPEC_LIMITS = 0x65, | ||
| 483 | SCSI_PHYS_ELEM_HEALTH_DEPOP_REVOKE_ERR = 0xFB, | ||
| 484 | SCSI_PHYS_ELEM_HEALTH_DEPOP_REVOKE_IN_PROGRESS = 0xFC, | ||
| 485 | SCSI_PHYS_ELEM_HEALTH_DEPOP_ERR = 0xFD, | ||
| 486 | SCSI_PHYS_ELEM_HEALTH_DEPOP_IN_PROGRESS = 0xFE, | ||
| 487 | SCSI_PHYS_ELEM_HEALTH_DEPOP_OK = 0xFF, | ||
| 488 | }; | ||
| 489 | |||
| 416 | /* Version descriptor values for INQUIRY */ | 490 | /* Version descriptor values for INQUIRY */ |
| 417 | enum scsi_version_descriptor { | 491 | enum scsi_version_descriptor { |
| 418 | SCSI_VERSION_DESCRIPTOR_FCP4 = 0x0a40, | 492 | SCSI_VERSION_DESCRIPTOR_FCP4 = 0x0a40, |