Lines Matching +full:hba +full:- +full:cap

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * libahci.c - Common AHCI SATA low-level routines
6 * Please ALWAYS copy linux-ide@vger.kernel.org
9 * Copyright 2004-2005 Red Hat, Inc.
12 * as Documentation/driver-api/libata.rst
27 #include <linux/dma-mapping.h>
236 * ahci_rpm_get_port - Make sure the port is powered on
245 return pm_runtime_get_sync(ap->dev); in ahci_rpm_get_port()
249 * ahci_rpm_put_port - Undoes ahci_rpm_get_port()
257 pm_runtime_put(ap->dev); in ahci_rpm_put_port()
265 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_show_host_caps()
267 return sprintf(buf, "%x\n", hpriv->cap); in ahci_show_host_caps()
275 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_show_host_cap2()
277 return sprintf(buf, "%x\n", hpriv->cap2); in ahci_show_host_cap2()
285 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_show_host_version()
287 return sprintf(buf, "%x\n", hpriv->version); in ahci_show_host_version()
310 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_read_em_buffer()
311 void __iomem *mmio = hpriv->mmio; in ahci_read_em_buffer()
312 void __iomem *em_mmio = mmio + hpriv->em_loc; in ahci_read_em_buffer()
319 spin_lock_irqsave(ap->lock, flags); in ahci_read_em_buffer()
322 if (!(ap->flags & ATA_FLAG_EM) || em_ctl & EM_CTL_XMT || in ahci_read_em_buffer()
323 !(hpriv->em_msg_type & EM_MSG_TYPE_SGPIO)) { in ahci_read_em_buffer()
324 spin_unlock_irqrestore(ap->lock, flags); in ahci_read_em_buffer()
326 return -EINVAL; in ahci_read_em_buffer()
330 spin_unlock_irqrestore(ap->lock, flags); in ahci_read_em_buffer()
332 return -EAGAIN; in ahci_read_em_buffer()
336 em_mmio += hpriv->em_buf_sz; in ahci_read_em_buffer()
338 count = hpriv->em_buf_sz; in ahci_read_em_buffer()
346 hpriv->em_buf_sz, PAGE_SIZE); in ahci_read_em_buffer()
358 spin_unlock_irqrestore(ap->lock, flags); in ahci_read_em_buffer()
370 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_store_em_buffer()
371 void __iomem *mmio = hpriv->mmio; in ahci_store_em_buffer()
372 void __iomem *em_mmio = mmio + hpriv->em_loc; in ahci_store_em_buffer()
379 if (!(ap->flags & ATA_FLAG_EM) || in ahci_store_em_buffer()
380 !(hpriv->em_msg_type & EM_MSG_TYPE_SGPIO) || in ahci_store_em_buffer()
381 size % 4 || size > hpriv->em_buf_sz) in ahci_store_em_buffer()
382 return -EINVAL; in ahci_store_em_buffer()
385 spin_lock_irqsave(ap->lock, flags); in ahci_store_em_buffer()
389 spin_unlock_irqrestore(ap->lock, flags); in ahci_store_em_buffer()
391 return -EBUSY; in ahci_store_em_buffer()
402 spin_unlock_irqrestore(ap->lock, flags); in ahci_store_em_buffer()
413 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_show_em_supported()
414 void __iomem *mmio = hpriv->mmio; in ahci_show_em_supported()
423 em_ctl & EM_CTL_SAFTE ? "saf-te " : "", in ahci_show_em_supported()
424 em_ctl & EM_CTL_SES ? "ses-2 " : "", in ahci_show_em_supported()
429 * ahci_save_initial_config - Save and fixup initial config values
440 * If it is not set already this function sets hpriv->start_engine to
448 void __iomem *mmio = hpriv->mmio; in ahci_save_initial_config()
451 u32 cap, cap2, vers; in ahci_save_initial_config() local
454 /* make sure AHCI mode is enabled before accessing CAP */ in ahci_save_initial_config()
458 * Values prefixed with saved_ are written back to the HBA and ports in ahci_save_initial_config()
463 * Override HW-init HBA capability fields with the platform-specific in ahci_save_initial_config()
464 * values. The rest of the HBA capabilities are defined as Read-only in ahci_save_initial_config()
467 cap = readl(mmio + HOST_CAP); in ahci_save_initial_config()
468 if (hpriv->saved_cap) in ahci_save_initial_config()
469 cap = (cap & ~(HOST_CAP_SSS | HOST_CAP_MPS)) | hpriv->saved_cap; in ahci_save_initial_config()
470 hpriv->saved_cap = cap; in ahci_save_initial_config()
476 hpriv->saved_cap2 = cap2 = readl(mmio + HOST_CAP2); in ahci_save_initial_config()
478 hpriv->saved_cap2 = cap2 = 0; in ahci_save_initial_config()
481 if ((cap & HOST_CAP_64) && (hpriv->flags & AHCI_HFLAG_32BIT_ONLY)) { in ahci_save_initial_config()
483 cap &= ~HOST_CAP_64; in ahci_save_initial_config()
486 if ((cap & HOST_CAP_NCQ) && (hpriv->flags & AHCI_HFLAG_NO_NCQ)) { in ahci_save_initial_config()
488 cap &= ~HOST_CAP_NCQ; in ahci_save_initial_config()
491 if (!(cap & HOST_CAP_NCQ) && (hpriv->flags & AHCI_HFLAG_YES_NCQ)) { in ahci_save_initial_config()
493 cap |= HOST_CAP_NCQ; in ahci_save_initial_config()
496 if ((cap & HOST_CAP_PMP) && (hpriv->flags & AHCI_HFLAG_NO_PMP)) { in ahci_save_initial_config()
498 cap &= ~HOST_CAP_PMP; in ahci_save_initial_config()
501 if ((cap & HOST_CAP_SNTF) && (hpriv->flags & AHCI_HFLAG_NO_SNTF)) { in ahci_save_initial_config()
504 cap &= ~HOST_CAP_SNTF; in ahci_save_initial_config()
507 if ((cap2 & HOST_CAP2_SDS) && (hpriv->flags & AHCI_HFLAG_NO_DEVSLP)) { in ahci_save_initial_config()
514 if (!(cap & HOST_CAP_FBS) && (hpriv->flags & AHCI_HFLAG_YES_FBS)) { in ahci_save_initial_config()
516 cap |= HOST_CAP_FBS; in ahci_save_initial_config()
519 if ((cap & HOST_CAP_FBS) && (hpriv->flags & AHCI_HFLAG_NO_FBS)) { in ahci_save_initial_config()
521 cap &= ~HOST_CAP_FBS; in ahci_save_initial_config()
524 if (!(cap & HOST_CAP_ALPM) && (hpriv->flags & AHCI_HFLAG_YES_ALPM)) { in ahci_save_initial_config()
526 cap |= HOST_CAP_ALPM; in ahci_save_initial_config()
529 if ((cap & HOST_CAP_SXS) && (hpriv->flags & AHCI_HFLAG_NO_SXS)) { in ahci_save_initial_config()
531 cap &= ~HOST_CAP_SXS; in ahci_save_initial_config()
534 /* Override the HBA ports mapping if the platform needs it */ in ahci_save_initial_config()
536 if (hpriv->saved_port_map && port_map != hpriv->saved_port_map) { in ahci_save_initial_config()
537 dev_info(dev, "forcing port_map 0x%lx -> 0x%x\n", in ahci_save_initial_config()
538 port_map, hpriv->saved_port_map); in ahci_save_initial_config()
539 port_map = hpriv->saved_port_map; in ahci_save_initial_config()
541 hpriv->saved_port_map = port_map; in ahci_save_initial_config()
544 if (hpriv->mask_port_map) { in ahci_save_initial_config()
545 dev_warn(dev, "masking port_map 0x%lx -> 0x%lx\n", in ahci_save_initial_config()
547 port_map & hpriv->mask_port_map); in ahci_save_initial_config()
548 port_map &= hpriv->mask_port_map; in ahci_save_initial_config()
551 /* cross check port_map and cap.n_ports */ in ahci_save_initial_config()
562 if (map_ports > ahci_nr_ports(cap)) { in ahci_save_initial_config()
565 port_map, ahci_nr_ports(cap)); in ahci_save_initial_config()
570 /* fabricate port_map from cap.nr_ports for < AHCI 1.3 */ in ahci_save_initial_config()
572 port_map = (1 << ahci_nr_ports(cap)) - 1; in ahci_save_initial_config()
576 hpriv->saved_port_map = port_map; in ahci_save_initial_config()
585 if (hpriv->saved_port_cap[i]) in ahci_save_initial_config()
589 hpriv->saved_port_cap[i] = in ahci_save_initial_config()
594 hpriv->cap = cap; in ahci_save_initial_config()
595 hpriv->cap2 = cap2; in ahci_save_initial_config()
596 hpriv->version = vers; in ahci_save_initial_config()
597 hpriv->port_map = port_map; in ahci_save_initial_config()
599 if (!hpriv->start_engine) in ahci_save_initial_config()
600 hpriv->start_engine = ahci_start_engine; in ahci_save_initial_config()
602 if (!hpriv->stop_engine) in ahci_save_initial_config()
603 hpriv->stop_engine = ahci_stop_engine; in ahci_save_initial_config()
605 if (!hpriv->irq_handler) in ahci_save_initial_config()
606 hpriv->irq_handler = ahci_single_level_irq_intr; in ahci_save_initial_config()
611 * ahci_restore_initial_config - Restore initial config
621 struct ahci_host_priv *hpriv = host->private_data; in ahci_restore_initial_config()
622 unsigned long port_map = hpriv->port_map; in ahci_restore_initial_config()
623 void __iomem *mmio = hpriv->mmio; in ahci_restore_initial_config()
627 writel(hpriv->saved_cap, mmio + HOST_CAP); in ahci_restore_initial_config()
628 if (hpriv->saved_cap2) in ahci_restore_initial_config()
629 writel(hpriv->saved_cap2, mmio + HOST_CAP2); in ahci_restore_initial_config()
630 writel(hpriv->saved_port_map, mmio + HOST_PORTS_IMPL); in ahci_restore_initial_config()
635 writel(hpriv->saved_port_cap[i], port_mmio + PORT_CMD); in ahci_restore_initial_config()
648 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_scr_offset()
651 (sc_reg != SCR_NOTIFICATION || (hpriv->cap & HOST_CAP_SNTF))) in ahci_scr_offset()
658 void __iomem *port_mmio = ahci_port_base(link->ap); in ahci_scr_read()
659 int offset = ahci_scr_offset(link->ap, sc_reg); in ahci_scr_read()
665 return -EINVAL; in ahci_scr_read()
670 void __iomem *port_mmio = ahci_port_base(link->ap); in ahci_scr_write()
671 int offset = ahci_scr_offset(link->ap, sc_reg); in ahci_scr_write()
677 return -EINVAL; in ahci_scr_write()
696 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_stop_engine()
705 if ((hpriv->flags & AHCI_HFLAG_WAKE_BEFORE_STOP) && in ahci_stop_engine()
706 (ap->link.lpm_policy > ATA_LPM_MAX_POWER) && in ahci_stop_engine()
707 ahci_set_lpm(&ap->link, ATA_LPM_MAX_POWER, ATA_LPM_WAKE_ONLY)) { in ahci_stop_engine()
708 dev_err(ap->host->dev, "Failed to wake up port before engine stop\n"); in ahci_stop_engine()
709 return -EIO; in ahci_stop_engine()
714 /* check if the HBA is idle */ in ahci_stop_engine()
724 dev_err(ap->host->dev, "AHCI controller unavailable!\n"); in ahci_stop_engine()
725 return -ENODEV; in ahci_stop_engine()
728 /* setting HBA to idle */ in ahci_stop_engine()
736 return -EIO; in ahci_stop_engine()
745 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_start_fis_rx()
746 struct ahci_port_priv *pp = ap->private_data; in ahci_start_fis_rx()
750 if (hpriv->cap & HOST_CAP_64) in ahci_start_fis_rx()
751 writel((pp->cmd_slot_dma >> 16) >> 16, in ahci_start_fis_rx()
753 writel(pp->cmd_slot_dma & 0xffffffff, port_mmio + PORT_LST_ADDR); in ahci_start_fis_rx()
755 if (hpriv->cap & HOST_CAP_64) in ahci_start_fis_rx()
756 writel((pp->rx_fis_dma >> 16) >> 16, in ahci_start_fis_rx()
758 writel(pp->rx_fis_dma & 0xffffffff, port_mmio + PORT_FIS_ADDR); in ahci_start_fis_rx()
784 return -EBUSY; in ahci_stop_fis_rx()
791 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_power_up()
798 if (hpriv->cap & HOST_CAP_SSS) { in ahci_power_up()
810 struct ata_port *ap = link->ap; in ahci_set_lpm()
811 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_set_lpm()
812 struct ahci_port_priv *pp = ap->private_data; in ahci_set_lpm()
824 pp->intr_mask &= ~PORT_IRQ_PHYRDY; in ahci_set_lpm()
825 writel(pp->intr_mask, port_mmio + PORT_IRQ_MASK); in ahci_set_lpm()
830 if (hpriv->cap & HOST_CAP_ALPM) { in ahci_set_lpm()
859 if ((hpriv->cap2 & HOST_CAP2_SDS) && in ahci_set_lpm()
860 (hpriv->cap2 & HOST_CAP2_SADM) && in ahci_set_lpm()
861 (link->device->flags & ATA_DFLAG_DEVSLP)) { in ahci_set_lpm()
873 pp->intr_mask |= PORT_IRQ_PHYRDY; in ahci_set_lpm()
874 writel(pp->intr_mask, port_mmio + PORT_IRQ_MASK); in ahci_set_lpm()
883 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_power_down()
887 if (!(hpriv->cap & HOST_CAP_SSS)) in ahci_power_down()
904 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_start_port()
905 struct ahci_port_priv *pp = ap->private_data; in ahci_start_port()
915 if (!(hpriv->flags & AHCI_HFLAG_DELAY_ENGINE)) in ahci_start_port()
916 hpriv->start_engine(ap); in ahci_start_port()
919 if (ap->flags & ATA_FLAG_EM) { in ahci_start_port()
921 emp = &pp->em_priv[link->pmp]; in ahci_start_port()
925 rc = ap->ops->transmit_led_message(ap, in ahci_start_port()
926 emp->led_state, in ahci_start_port()
936 if (rc == -EBUSY) in ahci_start_port()
944 if (ap->flags & ATA_FLAG_SW_ACTIVITY) in ahci_start_port()
953 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_deinit_port()
956 rc = hpriv->stop_engine(ap); in ahci_deinit_port()
974 struct ahci_host_priv *hpriv = host->private_data; in ahci_reset_controller()
975 void __iomem *mmio = hpriv->mmio; in ahci_reset_controller()
979 * We must be in AHCI mode, before using anything AHCI-specific, such in ahci_reset_controller()
986 dev_info(host->dev, "Skipping global host reset\n"); in ahci_reset_controller()
1004 dev_err(host->dev, "Controller reset failed (0x%x)\n", in ahci_reset_controller()
1006 return -EIO; in ahci_reset_controller()
1013 if (!(hpriv->flags & AHCI_HFLAG_NO_WRITE_TO_RO)) in ahci_reset_controller()
1022 struct ata_port *ap = link->ap; in ahci_sw_activity()
1023 struct ahci_port_priv *pp = ap->private_data; in ahci_sw_activity()
1024 struct ahci_em_priv *emp = &pp->em_priv[link->pmp]; in ahci_sw_activity()
1026 if (!(link->flags & ATA_LFLAG_SW_ACTIVITY)) in ahci_sw_activity()
1029 emp->activity++; in ahci_sw_activity()
1030 if (!timer_pending(&emp->timer)) in ahci_sw_activity()
1031 mod_timer(&emp->timer, jiffies + msecs_to_jiffies(10)); in ahci_sw_activity()
1037 struct ata_link *link = emp->link; in ahci_sw_activity_blink()
1038 struct ata_port *ap = link->ap; in ahci_sw_activity_blink()
1040 unsigned long led_message = emp->led_state; in ahci_sw_activity_blink()
1045 led_message |= ap->port_no | (link->pmp << 8); in ahci_sw_activity_blink()
1051 spin_lock_irqsave(ap->lock, flags); in ahci_sw_activity_blink()
1052 if (emp->saved_activity != emp->activity) { in ahci_sw_activity_blink()
1053 emp->saved_activity = emp->activity; in ahci_sw_activity_blink()
1067 mod_timer(&emp->timer, jiffies + msecs_to_jiffies(100)); in ahci_sw_activity_blink()
1071 if (emp->blink_policy == BLINK_OFF) in ahci_sw_activity_blink()
1074 spin_unlock_irqrestore(ap->lock, flags); in ahci_sw_activity_blink()
1075 ap->ops->transmit_led_message(ap, led_message, 4); in ahci_sw_activity_blink()
1080 struct ata_port *ap = link->ap; in ahci_init_sw_activity()
1081 struct ahci_port_priv *pp = ap->private_data; in ahci_init_sw_activity()
1082 struct ahci_em_priv *emp = &pp->em_priv[link->pmp]; in ahci_init_sw_activity()
1085 emp->saved_activity = emp->activity = 0; in ahci_init_sw_activity()
1086 emp->link = link; in ahci_init_sw_activity()
1087 timer_setup(&emp->timer, ahci_sw_activity_blink, 0); in ahci_init_sw_activity()
1090 if (emp->blink_policy) in ahci_init_sw_activity()
1091 link->flags |= ATA_LFLAG_SW_ACTIVITY; in ahci_init_sw_activity()
1096 struct ahci_host_priv *hpriv = host->private_data; in ahci_reset_em()
1097 void __iomem *mmio = hpriv->mmio; in ahci_reset_em()
1102 return -EINVAL; in ahci_reset_em()
1112 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_transmit_led_message()
1113 struct ahci_port_priv *pp = ap->private_data; in ahci_transmit_led_message()
1114 void __iomem *mmio = hpriv->mmio; in ahci_transmit_led_message()
1124 emp = &pp->em_priv[pmp]; in ahci_transmit_led_message()
1126 return -EINVAL; in ahci_transmit_led_message()
1129 spin_lock_irqsave(ap->lock, flags); in ahci_transmit_led_message()
1137 spin_unlock_irqrestore(ap->lock, flags); in ahci_transmit_led_message()
1139 return -EBUSY; in ahci_transmit_led_message()
1142 if (hpriv->em_msg_type & EM_MSG_TYPE_LED) { in ahci_transmit_led_message()
1144 * create message header - this is all zero except for in ahci_transmit_led_message()
1150 message[1] = ((state & ~EM_MSG_LED_HBA_PORT) | ap->port_no); in ahci_transmit_led_message()
1153 writel(message[0], mmio + hpriv->em_loc); in ahci_transmit_led_message()
1154 writel(message[1], mmio + hpriv->em_loc+4); in ahci_transmit_led_message()
1163 emp->led_state = state; in ahci_transmit_led_message()
1165 spin_unlock_irqrestore(ap->lock, flags); in ahci_transmit_led_message()
1173 struct ahci_port_priv *pp = ap->private_data; in ahci_led_show()
1179 emp = &pp->em_priv[link->pmp]; in ahci_led_show()
1180 rc += sprintf(buf, "%lx\n", emp->led_state); in ahci_led_show()
1190 struct ahci_port_priv *pp = ap->private_data; in ahci_led_store()
1194 return -EINVAL; in ahci_led_store()
1200 emp = &pp->em_priv[pmp]; in ahci_led_store()
1202 return -EINVAL; in ahci_led_store()
1209 if (emp->blink_policy) in ahci_led_store()
1212 return ap->ops->transmit_led_message(ap, state, size); in ahci_led_store()
1217 struct ata_link *link = dev->link; in ahci_activity_store()
1218 struct ata_port *ap = link->ap; in ahci_activity_store()
1219 struct ahci_port_priv *pp = ap->private_data; in ahci_activity_store()
1220 struct ahci_em_priv *emp = &pp->em_priv[link->pmp]; in ahci_activity_store()
1221 u32 port_led_state = emp->led_state; in ahci_activity_store()
1226 link->flags &= ~(ATA_LFLAG_SW_ACTIVITY); in ahci_activity_store()
1230 port_led_state |= (ap->port_no | (link->pmp << 8)); in ahci_activity_store()
1231 ap->ops->transmit_led_message(ap, port_led_state, 4); in ahci_activity_store()
1233 link->flags |= ATA_LFLAG_SW_ACTIVITY; in ahci_activity_store()
1237 port_led_state |= (ap->port_no | (link->pmp << 8)); in ahci_activity_store()
1239 ap->ops->transmit_led_message(ap, port_led_state, 4); in ahci_activity_store()
1242 emp->blink_policy = val; in ahci_activity_store()
1248 struct ata_link *link = dev->link; in ahci_activity_show()
1249 struct ata_port *ap = link->ap; in ahci_activity_show()
1250 struct ahci_port_priv *pp = ap->private_data; in ahci_activity_show()
1251 struct ahci_em_priv *emp = &pp->em_priv[link->pmp]; in ahci_activity_show()
1256 return sprintf(buf, "%d\n", emp->blink_policy); in ahci_activity_show()
1261 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_port_clear_pending_irq()
1267 dev_dbg(ap->host->dev, "PORT_SCR_ERR 0x%x\n", tmp); in ahci_port_clear_pending_irq()
1272 dev_dbg(ap->host->dev, "PORT_IRQ_STAT 0x%x\n", tmp); in ahci_port_clear_pending_irq()
1276 writel(1 << ap->port_no, hpriv->mmio + HOST_IRQ_STAT); in ahci_port_clear_pending_irq()
1283 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_port_init()
1297 if ((tmp & PORT_CMD_ESP) && (hpriv->cap & HOST_CAP_SXS)) in ahci_port_init()
1298 ap->pflags |= ATA_PFLAG_EXTERNAL; in ahci_port_init()
1303 struct ahci_host_priv *hpriv = host->private_data; in ahci_init_controller()
1304 void __iomem *mmio = hpriv->mmio; in ahci_init_controller()
1309 for (i = 0; i < host->n_ports; i++) { in ahci_init_controller()
1310 struct ata_port *ap = host->ports[i]; in ahci_init_controller()
1316 ahci_port_init(host->dev, ap, i, mmio, port_mmio); in ahci_init_controller()
1320 dev_dbg(host->dev, "HOST_CTL 0x%x\n", tmp); in ahci_init_controller()
1323 dev_dbg(host->dev, "HOST_CTL 0x%x\n", tmp); in ahci_init_controller()
1329 struct ahci_host_priv *hpriv = dev->link->ap->host->private_data; in ahci_dev_config()
1331 if (hpriv->flags & AHCI_HFLAG_SECT255) { in ahci_dev_config()
1332 dev->max_sectors = 255; in ahci_dev_config()
1359 cmd_tbl_dma = pp->cmd_tbl_dma + tag * AHCI_CMD_TBL_SZ; in ahci_fill_cmd_slot()
1361 pp->cmd_slot[tag].opts = cpu_to_le32(opts); in ahci_fill_cmd_slot()
1362 pp->cmd_slot[tag].status = 0; in ahci_fill_cmd_slot()
1363 pp->cmd_slot[tag].tbl_addr = cpu_to_le32(cmd_tbl_dma & 0xffffffff); in ahci_fill_cmd_slot()
1364 pp->cmd_slot[tag].tbl_addr_hi = cpu_to_le32((cmd_tbl_dma >> 16) >> 16); in ahci_fill_cmd_slot()
1371 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_kick_engine()
1377 rc = hpriv->stop_engine(ap); in ahci_kick_engine()
1382 * always do CLO if PMP is attached (AHCI-1.3 9.2) in ahci_kick_engine()
1390 if (!(hpriv->cap & HOST_CAP_CLO)) { in ahci_kick_engine()
1391 rc = -EOPNOTSUPP; in ahci_kick_engine()
1404 rc = -EIO; in ahci_kick_engine()
1408 hpriv->start_engine(ap); in ahci_kick_engine()
1418 struct ahci_port_priv *pp = ap->private_data; in ahci_exec_polled_cmd()
1420 u8 *fis = pp->cmd_tbl; in ahci_exec_polled_cmd()
1428 if (pp->fbs_enabled && pp->fbs_last_dev != pmp) { in ahci_exec_polled_cmd()
1433 pp->fbs_last_dev = pmp; in ahci_exec_polled_cmd()
1444 return -EBUSY; in ahci_exec_polled_cmd()
1456 struct ata_port *ap = link->ap; in ahci_do_softreset()
1457 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_do_softreset()
1458 struct ahci_port_priv *pp = ap->private_data; in ahci_do_softreset()
1466 /* prepare for SRST (AHCI-1.1 10.4.1) */ in ahci_do_softreset()
1468 if (rc && rc != -EOPNOTSUPP) in ahci_do_softreset()
1472 * According to AHCI-1.2 9.3.9: if FBS is enable, software shall in ahci_do_softreset()
1476 if (!ata_is_host_link(link) && pp->fbs_enabled) { in ahci_do_softreset()
1481 ata_tf_init(link->device, &tf); in ahci_do_softreset()
1487 msecs = jiffies_to_msecs(deadline - now); in ahci_do_softreset()
1492 rc = -EIO; in ahci_do_softreset()
1506 if (rc == -EBUSY && hpriv->flags & AHCI_HFLAG_SRST_TOUT_IS_OFFLINE) { in ahci_do_softreset()
1515 /* link occupied, -ENODEV too is an error */ in ahci_do_softreset()
1521 /* re-enable FBS if disabled before */ in ahci_do_softreset()
1534 void __iomem *port_mmio = ahci_port_base(link->ap); in ahci_check_ready()
1552 void __iomem *port_mmio = ahci_port_base(link->ap); in ahci_bad_pmp_check_ready()
1561 return -EIO; in ahci_bad_pmp_check_ready()
1569 struct ata_port *ap = link->ap; in ahci_pmp_retry_softreset()
1583 if (rc == -EIO) { in ahci_pmp_retry_softreset()
1600 const unsigned int *timing = sata_ehc_deb_timing(&link->eh_context); in ahci_do_hardreset()
1601 struct ata_port *ap = link->ap; in ahci_do_hardreset()
1602 struct ahci_port_priv *pp = ap->private_data; in ahci_do_hardreset()
1603 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_do_hardreset()
1604 u8 *d2h_fis = pp->rx_fis + RX_FIS_D2H_REG; in ahci_do_hardreset()
1608 hpriv->stop_engine(ap); in ahci_do_hardreset()
1611 ata_tf_init(link->device, &tf); in ahci_do_hardreset()
1620 hpriv->start_engine(ap); in ahci_do_hardreset()
1639 struct ata_port *ap = link->ap; in ahci_postreset()
1666 for_each_sg(qc->sg, sg, qc->n_elem, si) { in ahci_fill_sg()
1672 ahci_sg[si].flags_size = cpu_to_le32(sg_len - 1); in ahci_fill_sg()
1680 struct ata_port *ap = qc->ap; in ahci_pmp_qc_defer()
1681 struct ahci_port_priv *pp = ap->private_data; in ahci_pmp_qc_defer()
1683 if (!sata_pmp_attached(ap) || pp->fbs_enabled) in ahci_pmp_qc_defer()
1691 struct ata_port *ap = qc->ap; in ahci_qc_prep()
1692 struct ahci_port_priv *pp = ap->private_data; in ahci_qc_prep()
1693 int is_atapi = ata_is_atapi(qc->tf.protocol); in ahci_qc_prep()
1701 * a SATA Register - Host to Device command FIS. in ahci_qc_prep()
1703 cmd_tbl = pp->cmd_tbl + qc->hw_tag * AHCI_CMD_TBL_SZ; in ahci_qc_prep()
1705 ata_tf_to_fis(&qc->tf, qc->dev->link->pmp, 1, cmd_tbl); in ahci_qc_prep()
1708 memcpy(cmd_tbl + AHCI_CMD_TBL_CDB, qc->cdb, qc->dev->cdb_len); in ahci_qc_prep()
1712 if (qc->flags & ATA_QCFLAG_DMAMAP) in ahci_qc_prep()
1718 opts = cmd_fis_len | n_elem << 16 | (qc->dev->link->pmp << 12); in ahci_qc_prep()
1719 if (qc->tf.flags & ATA_TFLAG_WRITE) in ahci_qc_prep()
1724 ahci_fill_cmd_slot(pp, qc->hw_tag, opts); in ahci_qc_prep()
1731 struct ahci_port_priv *pp = ap->private_data; in ahci_fbs_dec_intr()
1736 BUG_ON(!pp->fbs_enabled); in ahci_fbs_dec_intr()
1743 while ((fbs & PORT_FBS_DEC) && retries--) { in ahci_fbs_dec_intr()
1749 dev_err(ap->host->dev, "failed to clear device error\n"); in ahci_fbs_dec_intr()
1754 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_error_intr()
1755 struct ahci_port_priv *pp = ap->private_data; in ahci_error_intr()
1756 struct ata_eh_info *host_ehi = &ap->link.eh_info; in ahci_error_intr()
1764 if (pp->fbs_enabled) { in ahci_error_intr()
1769 if ((fbs & PORT_FBS_SDE) && (pmp < ap->nr_pmp_links)) { in ahci_error_intr()
1770 link = &ap->pmp_link[pmp]; in ahci_error_intr()
1780 link = &ap->link; in ahci_error_intr()
1782 active_qc = ata_qc_from_tag(ap, link->active_tag); in ahci_error_intr()
1783 active_ehi = &link->eh_info; in ahci_error_intr()
1790 ahci_scr_read(&ap->link, SCR_ERROR, &serror); in ahci_error_intr()
1791 ahci_scr_write(&ap->link, SCR_ERROR, serror); in ahci_error_intr()
1792 host_ehi->serror |= serror; in ahci_error_intr()
1795 if (hpriv->flags & AHCI_HFLAG_IGN_IRQ_IF_ERR) in ahci_error_intr()
1804 active_qc->err_mask |= AC_ERR_DEV; in ahci_error_intr()
1806 active_ehi->err_mask |= AC_ERR_DEV; in ahci_error_intr()
1808 if (hpriv->flags & AHCI_HFLAG_IGN_SERR_INTERNAL) in ahci_error_intr()
1809 host_ehi->serror &= ~SERR_INTERNAL; in ahci_error_intr()
1813 u32 *unk = pp->rx_fis + RX_FIS_UNK; in ahci_error_intr()
1815 active_ehi->err_mask |= AC_ERR_HSM; in ahci_error_intr()
1816 active_ehi->action |= ATA_EH_RESET; in ahci_error_intr()
1823 active_ehi->err_mask |= AC_ERR_HSM; in ahci_error_intr()
1824 active_ehi->action |= ATA_EH_RESET; in ahci_error_intr()
1829 host_ehi->err_mask |= AC_ERR_HOST_BUS; in ahci_error_intr()
1830 host_ehi->action |= ATA_EH_RESET; in ahci_error_intr()
1836 active_ehi->err_mask |= AC_ERR_DEV; in ahci_error_intr()
1838 host_ehi->err_mask |= AC_ERR_ATA_BUS; in ahci_error_intr()
1839 host_ehi->action |= ATA_EH_RESET; in ahci_error_intr()
1865 struct ata_eh_info *ehi = &ap->link.eh_info; in ahci_qc_complete()
1866 struct ahci_port_priv *pp = ap->private_data; in ahci_qc_complete()
1871 * pp->active_link is not reliable once FBS is enabled, both in ahci_qc_complete()
1873 * NCQ and non-NCQ commands may be in flight at the same time. in ahci_qc_complete()
1875 if (pp->fbs_enabled) { in ahci_qc_complete()
1876 if (ap->qc_active) { in ahci_qc_complete()
1881 /* pp->active_link is valid iff any command is in flight */ in ahci_qc_complete()
1882 if (ap->qc_active && pp->active_link->sactive) in ahci_qc_complete()
1889 if (unlikely(rc < 0 && !(ap->pflags & ATA_PFLAG_RESETTING))) { in ahci_qc_complete()
1890 ehi->err_mask |= AC_ERR_HSM; in ahci_qc_complete()
1891 ehi->action |= ATA_EH_RESET; in ahci_qc_complete()
1899 struct ahci_port_priv *pp = ap->private_data; in ahci_handle_port_interrupt()
1900 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_handle_port_interrupt()
1903 if (unlikely(ap->pflags & ATA_PFLAG_RESETTING)) in ahci_handle_port_interrupt()
1906 if (sata_lpm_ignore_phy_events(&ap->link)) { in ahci_handle_port_interrupt()
1908 ahci_scr_write(&ap->link, SCR_ERROR, SERR_PHYRDY_CHG); in ahci_handle_port_interrupt()
1932 if (hpriv->cap & HOST_CAP_SNTF) in ahci_handle_port_interrupt()
1943 if (pp->fbs_enabled) in ahci_handle_port_interrupt()
1946 const __le32 *f = pp->rx_fis + RX_FIS_SDB; in ahci_handle_port_interrupt()
1978 spin_lock(ap->lock); in ahci_multi_irqs_intr_hard()
1980 spin_unlock(ap->lock); in ahci_multi_irqs_intr_hard()
1989 for (i = 0; i < host->n_ports; i++) { in ahci_handle_port_intr()
1995 ap = host->ports[i]; in ahci_handle_port_intr()
2000 dev_warn(host->dev, in ahci_handle_port_intr()
2019 hpriv = host->private_data; in ahci_single_level_irq_intr()
2020 mmio = hpriv->mmio; in ahci_single_level_irq_intr()
2027 irq_masked = irq_stat & hpriv->port_map; in ahci_single_level_irq_intr()
2029 spin_lock(&host->lock); in ahci_single_level_irq_intr()
2044 spin_unlock(&host->lock); in ahci_single_level_irq_intr()
2051 struct ata_port *ap = qc->ap; in ahci_qc_issue()
2053 struct ahci_port_priv *pp = ap->private_data; in ahci_qc_issue()
2059 pp->active_link = qc->dev->link; in ahci_qc_issue()
2061 if (ata_is_ncq(qc->tf.protocol)) in ahci_qc_issue()
2062 writel(1 << qc->hw_tag, port_mmio + PORT_SCR_ACT); in ahci_qc_issue()
2064 if (pp->fbs_enabled && pp->fbs_last_dev != qc->dev->link->pmp) { in ahci_qc_issue()
2067 fbs |= qc->dev->link->pmp << PORT_FBS_DEV_OFFSET; in ahci_qc_issue()
2069 pp->fbs_last_dev = qc->dev->link->pmp; in ahci_qc_issue()
2072 writel(1 << qc->hw_tag, port_mmio + PORT_CMD_ISSUE); in ahci_qc_issue()
2074 ahci_sw_activity(qc->dev->link); in ahci_qc_issue()
2082 struct ahci_port_priv *pp = qc->ap->private_data; in ahci_qc_fill_rtf()
2083 u8 *rx_fis = pp->rx_fis; in ahci_qc_fill_rtf()
2089 if (qc->flags & ATA_QCFLAG_RTF_FILLED) in ahci_qc_fill_rtf()
2092 if (pp->fbs_enabled) in ahci_qc_fill_rtf()
2093 rx_fis += qc->dev->link->pmp * AHCI_RX_FIS_SZ; in ahci_qc_fill_rtf()
2096 * After a successful execution of an ATA PIO data-in command, in ahci_qc_fill_rtf()
2101 if (qc->tf.protocol == ATA_PROT_PIO && qc->dma_dir == DMA_FROM_DEVICE && in ahci_qc_fill_rtf()
2102 !(qc->flags & ATA_QCFLAG_EH)) { in ahci_qc_fill_rtf()
2103 ata_tf_from_fis(rx_fis + RX_FIS_PIO_SETUP, &qc->result_tf); in ahci_qc_fill_rtf()
2104 qc->result_tf.status = (rx_fis + RX_FIS_PIO_SETUP)[15]; in ahci_qc_fill_rtf()
2105 qc->flags |= ATA_QCFLAG_RTF_FILLED; in ahci_qc_fill_rtf()
2117 if (ata_is_ncq(qc->tf.protocol)) { in ahci_qc_fill_rtf()
2126 qc->result_tf.status = fis[2]; in ahci_qc_fill_rtf()
2127 qc->result_tf.error = fis[3]; in ahci_qc_fill_rtf()
2128 qc->flags |= ATA_QCFLAG_RTF_FILLED; in ahci_qc_fill_rtf()
2132 ata_tf_from_fis(rx_fis + RX_FIS_D2H_REG, &qc->result_tf); in ahci_qc_fill_rtf()
2133 qc->flags |= ATA_QCFLAG_RTF_FILLED; in ahci_qc_fill_rtf()
2138 struct ahci_port_priv *pp = ap->private_data; in ahci_qc_ncq_fill_rtf()
2142 if (!ap->qc_active) in ahci_qc_ncq_fill_rtf()
2149 if (!pp->fbs_enabled) { in ahci_qc_ncq_fill_rtf()
2153 if (!pp->active_link->sactive) in ahci_qc_ncq_fill_rtf()
2156 fis = pp->rx_fis + RX_FIS_SDB; in ahci_qc_ncq_fill_rtf()
2165 if (qc && ata_is_ncq(qc->tf.protocol)) { in ahci_qc_ncq_fill_rtf()
2166 qc->result_tf.status = status; in ahci_qc_ncq_fill_rtf()
2167 qc->result_tf.error = error; in ahci_qc_ncq_fill_rtf()
2168 qc->flags |= ATA_QCFLAG_RTF_FILLED; in ahci_qc_ncq_fill_rtf()
2186 if (qc && ata_is_ncq(qc->tf.protocol)) { in ahci_qc_ncq_fill_rtf()
2187 fis = pp->rx_fis; in ahci_qc_ncq_fill_rtf()
2188 fis += qc->dev->link->pmp * AHCI_RX_FIS_SZ; in ahci_qc_ncq_fill_rtf()
2190 qc->result_tf.status = fis[2]; in ahci_qc_ncq_fill_rtf()
2191 qc->result_tf.error = fis[3]; in ahci_qc_ncq_fill_rtf()
2192 qc->flags |= ATA_QCFLAG_RTF_FILLED; in ahci_qc_ncq_fill_rtf()
2208 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_thaw()
2209 void __iomem *mmio = hpriv->mmio; in ahci_thaw()
2212 struct ahci_port_priv *pp = ap->private_data; in ahci_thaw()
2217 writel(1 << ap->port_no, mmio + HOST_IRQ_STAT); in ahci_thaw()
2220 writel(pp->intr_mask, port_mmio + PORT_IRQ_MASK); in ahci_thaw()
2225 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_error_handler()
2229 hpriv->stop_engine(ap); in ahci_error_handler()
2230 hpriv->start_engine(ap); in ahci_error_handler()
2235 if (!ata_dev_enabled(ap->link.device)) in ahci_error_handler()
2236 hpriv->stop_engine(ap); in ahci_error_handler()
2242 struct ata_port *ap = qc->ap; in ahci_post_internal_cmd()
2245 if (qc->flags & ATA_QCFLAG_EH) in ahci_post_internal_cmd()
2251 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_set_aggressive_devslp()
2253 struct ata_device *dev = ap->link.device; in ahci_set_aggressive_devslp()
2260 dev_info(ap->host->dev, "port does not support device sleep\n"); in ahci_set_aggressive_devslp()
2290 rc = hpriv->stop_engine(ap); in ahci_set_aggressive_devslp()
2297 if (dev->devslp_timing[ATA_LOG_DEVSLP_VALID] & in ahci_set_aggressive_devslp()
2299 mdat = dev->devslp_timing[ATA_LOG_DEVSLP_MDAT] & in ahci_set_aggressive_devslp()
2303 deto = dev->devslp_timing[ATA_LOG_DEVSLP_DETO]; in ahci_set_aggressive_devslp()
2319 hpriv->start_engine(ap); in ahci_set_aggressive_devslp()
2331 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_enable_fbs()
2332 struct ahci_port_priv *pp = ap->private_data; in ahci_enable_fbs()
2337 if (!pp->fbs_supported) in ahci_enable_fbs()
2342 pp->fbs_enabled = true; in ahci_enable_fbs()
2343 pp->fbs_last_dev = -1; /* initialization */ in ahci_enable_fbs()
2347 rc = hpriv->stop_engine(ap); in ahci_enable_fbs()
2354 dev_info(ap->host->dev, "FBS is enabled\n"); in ahci_enable_fbs()
2355 pp->fbs_enabled = true; in ahci_enable_fbs()
2356 pp->fbs_last_dev = -1; /* initialization */ in ahci_enable_fbs()
2358 dev_err(ap->host->dev, "Failed to enable FBS\n"); in ahci_enable_fbs()
2360 hpriv->start_engine(ap); in ahci_enable_fbs()
2365 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_disable_fbs()
2366 struct ahci_port_priv *pp = ap->private_data; in ahci_disable_fbs()
2371 if (!pp->fbs_supported) in ahci_disable_fbs()
2376 pp->fbs_enabled = false; in ahci_disable_fbs()
2380 rc = hpriv->stop_engine(ap); in ahci_disable_fbs()
2387 dev_err(ap->host->dev, "Failed to disable FBS\n"); in ahci_disable_fbs()
2389 dev_info(ap->host->dev, "FBS is disabled\n"); in ahci_disable_fbs()
2390 pp->fbs_enabled = false; in ahci_disable_fbs()
2393 hpriv->start_engine(ap); in ahci_disable_fbs()
2399 struct ahci_port_priv *pp = ap->private_data; in ahci_pmp_attach()
2408 pp->intr_mask |= PORT_IRQ_BAD_PMP; in ahci_pmp_attach()
2412 * port is marked frozen, the value in pp->intr_mask will be in ahci_pmp_attach()
2419 writel(pp->intr_mask, port_mmio + PORT_IRQ_MASK); in ahci_pmp_attach()
2425 struct ahci_port_priv *pp = ap->private_data; in ahci_pmp_detach()
2434 pp->intr_mask &= ~PORT_IRQ_BAD_PMP; in ahci_pmp_detach()
2438 writel(pp->intr_mask, port_mmio + PORT_IRQ_MASK); in ahci_pmp_detach()
2483 if (acpi_storage_d3(ap->host->dev)) in ahci_port_suspend()
2493 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_port_start()
2494 struct device *dev = ap->host->dev; in ahci_port_start()
2502 return -ENOMEM; in ahci_port_start()
2504 if (ap->host->n_ports > 1) { in ahci_port_start()
2505 pp->irq_desc = devm_kzalloc(dev, 8, GFP_KERNEL); in ahci_port_start()
2506 if (!pp->irq_desc) { in ahci_port_start()
2508 return -ENOMEM; in ahci_port_start()
2510 snprintf(pp->irq_desc, 8, in ahci_port_start()
2511 "%s%d", dev_driver_string(dev), ap->port_no); in ahci_port_start()
2515 if ((hpriv->cap & HOST_CAP_FBS) && sata_pmp_supported(ap)) { in ahci_port_start()
2519 pp->fbs_supported = true; in ahci_port_start()
2520 else if (hpriv->flags & AHCI_HFLAG_YES_FBS) { in ahci_port_start()
2522 ap->port_no); in ahci_port_start()
2523 pp->fbs_supported = true; in ahci_port_start()
2526 ap->port_no); in ahci_port_start()
2529 if (pp->fbs_supported) { in ahci_port_start()
2539 return -ENOMEM; in ahci_port_start()
2542 * First item in chunk of DMA memory: 32-slot command table, in ahci_port_start()
2545 pp->cmd_slot = mem; in ahci_port_start()
2546 pp->cmd_slot_dma = mem_dma; in ahci_port_start()
2552 * Second item: Received-FIS area in ahci_port_start()
2554 pp->rx_fis = mem; in ahci_port_start()
2555 pp->rx_fis_dma = mem_dma; in ahci_port_start()
2562 * and its scatter-gather table in ahci_port_start()
2564 pp->cmd_tbl = mem; in ahci_port_start()
2565 pp->cmd_tbl_dma = mem_dma; in ahci_port_start()
2571 pp->intr_mask = DEF_PORT_IRQ; in ahci_port_start()
2574 * Switch to per-port locking in case each port has its own MSI vector. in ahci_port_start()
2576 if (hpriv->flags & AHCI_HFLAG_MULTI_MSI) { in ahci_port_start()
2577 spin_lock_init(&pp->lock); in ahci_port_start()
2578 ap->lock = &pp->lock; in ahci_port_start()
2581 ap->private_data = pp; in ahci_port_start()
2590 struct ahci_host_priv *hpriv = ap->host->private_data; in ahci_port_stop()
2591 void __iomem *host_mmio = hpriv->mmio; in ahci_port_stop()
2594 /* de-initialize port */ in ahci_port_stop()
2601 * re-enabling INTx. in ahci_port_stop()
2603 writel(1 << ap->port_no, host_mmio + HOST_IRQ_STAT); in ahci_port_stop()
2610 struct ahci_host_priv *hpriv = host->private_data; in ahci_print_info()
2611 u32 vers, cap, cap2, impl, speed; in ahci_print_info() local
2614 vers = hpriv->version; in ahci_print_info()
2615 cap = hpriv->cap; in ahci_print_info()
2616 cap2 = hpriv->cap2; in ahci_print_info()
2617 impl = hpriv->port_map; in ahci_print_info()
2619 speed = (cap >> 20) & 0xf; in ahci_print_info()
2629 dev_info(host->dev, in ahci_print_info()
2639 ((cap >> 8) & 0x1f) + 1, in ahci_print_info()
2640 (cap & 0x1f) + 1, in ahci_print_info()
2645 dev_info(host->dev, in ahci_print_info()
2653 cap & HOST_CAP_64 ? "64bit " : "", in ahci_print_info()
2654 cap & HOST_CAP_NCQ ? "ncq " : "", in ahci_print_info()
2655 cap & HOST_CAP_SNTF ? "sntf " : "", in ahci_print_info()
2656 cap & HOST_CAP_MPS ? "ilck " : "", in ahci_print_info()
2657 cap & HOST_CAP_SSS ? "stag " : "", in ahci_print_info()
2658 cap & HOST_CAP_ALPM ? "pm " : "", in ahci_print_info()
2659 cap & HOST_CAP_LED ? "led " : "", in ahci_print_info()
2660 cap & HOST_CAP_CLO ? "clo " : "", in ahci_print_info()
2661 cap & HOST_CAP_ONLY ? "only " : "", in ahci_print_info()
2662 cap & HOST_CAP_PMP ? "pmp " : "", in ahci_print_info()
2663 cap & HOST_CAP_FBS ? "fbs " : "", in ahci_print_info()
2664 cap & HOST_CAP_PIO_MULTI ? "pio " : "", in ahci_print_info()
2665 cap & HOST_CAP_SSC ? "slum " : "", in ahci_print_info()
2666 cap & HOST_CAP_PART ? "part " : "", in ahci_print_info()
2667 cap & HOST_CAP_CCC ? "ccc " : "", in ahci_print_info()
2668 cap & HOST_CAP_EMS ? "ems " : "", in ahci_print_info()
2669 cap & HOST_CAP_SXS ? "sxs " : "", in ahci_print_info()
2684 void __iomem *mmio = hpriv->mmio; in ahci_set_em_messages()
2688 if (!ahci_em_messages || !(hpriv->cap & HOST_CAP_EMS)) in ahci_set_em_messages()
2695 hpriv->em_loc = ((em_loc >> 16) * 4); in ahci_set_em_messages()
2696 hpriv->em_buf_sz = ((em_loc & 0xff) * 4); in ahci_set_em_messages()
2697 hpriv->em_msg_type = messages; in ahci_set_em_messages()
2698 pi->flags |= ATA_FLAG_EM; in ahci_set_em_messages()
2700 pi->flags |= ATA_FLAG_SW_ACTIVITY; in ahci_set_em_messages()
2708 struct ahci_host_priv *hpriv = host->private_data; in ahci_host_activate_multi_irqs()
2715 * Requests IRQs according to AHCI-1.1 when multiple MSIs were in ahci_host_activate_multi_irqs()
2718 for (i = 0; i < host->n_ports; i++) { in ahci_host_activate_multi_irqs()
2719 struct ahci_port_priv *pp = host->ports[i]->private_data; in ahci_host_activate_multi_irqs()
2720 int irq = hpriv->get_irq_vector(host, i); in ahci_host_activate_multi_irqs()
2728 rc = devm_request_irq(host->dev, irq, ahci_multi_irqs_intr_hard, in ahci_host_activate_multi_irqs()
2729 0, pp->irq_desc, host->ports[i]); in ahci_host_activate_multi_irqs()
2733 ata_port_desc(host->ports[i], "irq %d", irq); in ahci_host_activate_multi_irqs()
2740 * ahci_host_activate - start AHCI host, request IRQs and register it
2748 * 0 on success, -errno otherwise.
2752 struct ahci_host_priv *hpriv = host->private_data; in ahci_host_activate()
2753 int irq = hpriv->irq; in ahci_host_activate()
2756 if (hpriv->flags & AHCI_HFLAG_MULTI_MSI) { in ahci_host_activate()
2757 if (hpriv->irq_handler && in ahci_host_activate()
2758 hpriv->irq_handler != ahci_single_level_irq_intr) in ahci_host_activate()
2759 dev_warn(host->dev, in ahci_host_activate()
2761 if (!hpriv->get_irq_vector) { in ahci_host_activate()
2762 dev_err(host->dev, in ahci_host_activate()
2763 "AHCI_HFLAG_MULTI_MSI requires ->get_irq_vector!\n"); in ahci_host_activate()
2764 return -EIO; in ahci_host_activate()
2769 rc = ata_host_activate(host, irq, hpriv->irq_handler, in ahci_host_activate()
2779 MODULE_DESCRIPTION("Common AHCI SATA low-level routines");