Lines Matching +full:sata +full:- +full:port
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Aic94xx SAS/SATA DDB management
16 #define FIND_FREE_DDB(_ha) find_first_zero_bit((_ha)->hw_prof.ddb_bitmap, \
17 (_ha)->hw_prof.max_ddbs)
18 #define SET_DDB(_ddb, _ha) set_bit(_ddb, (_ha)->hw_prof.ddb_bitmap)
19 #define CLEAR_DDB(_ddb, _ha) clear_bit(_ddb, (_ha)->hw_prof.ddb_bitmap)
26 if (ddb >= asd_ha->hw_prof.max_ddbs) { in asd_get_ddb()
27 ddb = -ENOMEM; in asd_get_ddb()
67 struct asd_ha_struct *asd_ha = dev->port->ha->lldd_ha; in asd_set_ddb_type()
68 int ddb = (int) (unsigned long) dev->lldd_dev; in asd_set_ddb_type()
70 if (dev->dev_type == SAS_SATA_PM_PORT) in asd_set_ddb_type()
72 else if (dev->tproto) in asd_set_ddb_type()
80 struct asd_ha_struct *asd_ha = dev->port->ha->lldd_ha; in asd_init_sata_tag_ddb()
90 asd_ddbsite_write_word(asd_ha, (int) (unsigned long) dev->lldd_dev, in asd_init_sata_tag_ddb()
97 struct asd_ha_struct *asd_ha = dev->port->ha->lldd_ha; in asd_set_dmamode()
99 int ddb = (int) (unsigned long) dev->lldd_dev; in asd_set_dmamode()
102 if (dev->dev_type == SAS_SATA_DEV || dev->dev_type == SAS_SATA_PM_PORT) { in asd_set_dmamode()
103 if (ata_id_has_ncq(ata_dev->id)) in asd_set_dmamode()
104 qdepth = ata_id_queue_depth(ata_dev->id); in asd_set_dmamode()
106 (1ULL<<qdepth)-1); in asd_set_dmamode()
114 spin_lock_irqsave(dev->sata_dev.ap->lock, flags); in asd_set_dmamode()
115 ata_dev->flags |= ATA_DFLAG_NCQ_OFF; in asd_set_dmamode()
116 spin_unlock_irqrestore(dev->sata_dev.ap->lock, flags); in asd_set_dmamode()
122 struct asd_ha_struct *asd_ha = dev->port->ha->lldd_ha; in asd_init_sata()
123 int ddb = (int) (unsigned long) dev->lldd_dev; in asd_init_sata()
126 if (dev->dev_type == SAS_SATA_DEV || dev->dev_type == SAS_SATA_PM || in asd_init_sata()
127 dev->dev_type == SAS_SATA_PM_PORT) { in asd_init_sata()
129 dev->frame_rcvd; in asd_init_sata()
130 asd_ddbsite_write_byte(asd_ha, ddb, SATA_STATUS, fis->status); in asd_init_sata()
140 struct asd_ha_struct *asd_ha = dev->port->ha->lldd_ha; in asd_init_target_ddb()
147 dev->lldd_dev = (void *) (unsigned long) ddb; in asd_init_target_ddb()
154 dev->sas_addr[i]); in asd_init_target_ddb()
157 asd_ddbsite_write_byte(asd_ha, ddb, CONN_MASK, dev->port->phy_mask); in asd_init_target_ddb()
158 if (dev->port->oob_mode != SATA_OOB_MODE) { in asd_init_target_ddb()
160 if ((dev->dev_type == SAS_SATA_DEV) || in asd_init_target_ddb()
161 (dev->tproto & SAS_PROTOCOL_STP)) { in asd_init_target_ddb()
162 struct smp_rps_resp *rps_resp = &dev->sata_dev.rps_resp; in asd_init_target_ddb()
163 if (rps_resp->frame_type == SMP_RESPONSE && in asd_init_target_ddb()
164 rps_resp->function == SMP_REPORT_PHY_SATA && in asd_init_target_ddb()
165 rps_resp->result == SMP_RESP_FUNC_ACC) { in asd_init_target_ddb()
166 if (rps_resp->rps.affil_valid) in asd_init_target_ddb()
168 if (rps_resp->rps.affil_supp) in asd_init_target_ddb()
173 if (!dev->parent && dev_is_expander(dev->dev_type)) in asd_init_target_ddb()
178 dev->pathways); in asd_init_target_ddb()
182 if (dev->dev_type == SAS_SATA_PM) in asd_init_target_ddb()
187 if (dev->tproto & SAS_PROTOCOL_STP) in asd_init_target_ddb()
195 if (dev->dev_type == SAS_SATA_DEV || (dev->tproto & SAS_PROTOCOL_STP)) { in asd_init_target_ddb()
203 if (dev->dev_type == SAS_END_DEVICE) { in asd_init_target_ddb()
204 struct sas_end_device *rdev = rphy_to_end_device(dev->rphy); in asd_init_target_ddb()
205 if (rdev->I_T_nexus_loss_timeout > 0) in asd_init_target_ddb()
207 min(rdev->I_T_nexus_loss_timeout, in asd_init_target_ddb()
218 struct asd_ha_struct *asd_ha = dev->port->ha->lldd_ha; in asd_init_sata_pm_table_ddb()
228 asd_ddbsite_write_word(asd_ha, (int) (unsigned long) dev->lldd_dev, in asd_init_sata_pm_table_ddb()
238 * asd_init_sata_pm_port_ddb -- SATA Port Multiplier Port
241 * For SATA Port Multiplier Ports we need to allocate one SATA Port
242 * Multiplier Port DDB and depending on whether the target on it
243 * supports SATA II NCQ, one SATA Tag DDB.
248 struct asd_ha_struct *asd_ha = dev->port->ha->lldd_ha; in asd_init_sata_pm_port_ddb()
256 flags = (dev->sata_dev.port_no << 4) | PM_PORT_SET; in asd_init_sata_pm_port_ddb()
262 parent_ddb = (int) (unsigned long) dev->parent->lldd_dev; in asd_init_sata_pm_port_ddb()
265 asd_ddbsite_write_word(asd_ha, pmtable_ddb, dev->sata_dev.port_no,ddb); in asd_init_sata_pm_port_ddb()
279 return -ENODEV; in asd_init_initiator_ddb()
283 * asd_init_sata_pm_ddb -- SATA Port Multiplier
286 * For STP and direct-attached SATA Port Multipliers we need
287 * one target port DDB entry and one SATA PM table DDB entry.
298 asd_free_ddb(dev->port->ha->lldd_ha, in asd_init_sata_pm_ddb()
299 (int) (unsigned long) dev->lldd_dev); in asd_init_sata_pm_ddb()
308 struct asd_ha_struct *asd_ha = dev->port->ha->lldd_ha; in asd_dev_found()
310 spin_lock_irqsave(&asd_ha->hw_prof.ddb_lock, flags); in asd_dev_found()
311 switch (dev->dev_type) { in asd_dev_found()
319 if (dev->tproto) in asd_dev_found()
324 spin_unlock_irqrestore(&asd_ha->hw_prof.ddb_lock, flags); in asd_dev_found()
333 struct asd_ha_struct *asd_ha = dev->port->ha->lldd_ha; in asd_dev_gone()
335 spin_lock_irqsave(&asd_ha->hw_prof.ddb_lock, flags); in asd_dev_gone()
336 ddb = (int) (unsigned long) dev->lldd_dev; in asd_dev_gone()
342 dev->lldd_dev = NULL; in asd_dev_gone()
343 spin_unlock_irqrestore(&asd_ha->hw_prof.ddb_lock, flags); in asd_dev_gone()