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

Merge tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi

Pull more SCSI updates from James Bottomley:
"This is mostly fixes and cleanups and code reworks that trickled in
across the merge window and the weeks leading up. The only substantive
update is the Mediatek ufs driver which accounts for the bulk of the
additions"

* tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: (37 commits)
scsi: libsas: Use a bool for sas_deform_port() second argument
scsi: libsas: Move declarations of internal functions to sas_internal.h
scsi: libsas: Make sas_get_ata_info() static
scsi: libsas: Simplify sas_ata_wait_eh()
scsi: libsas: Refactor dev_is_sata()
scsi: sd: Make sd shutdown issue START STOP UNIT appropriately
scsi: arm64: dts: mediatek: mt8195: Add UFSHCI node
scsi: dt-bindings: mediatek,ufs: add MT8195 compatible and update clock nodes
scsi: dt-bindings: mediatek,ufs: Add ufs-disable-mcq flag for UFS host
scsi: ufs: ufs-mediatek: Add UFS host support for MT8195 SoC
scsi: ufs: ufs-pci: Remove control of UIC Completion interrupt for Intel MTL
scsi: ufs: core: Do not write interrupt enable register unnecessarily
scsi: ufs: core: Set and clear UIC Completion interrupt as needed
scsi: ufs: core: Remove duplicated code in ufshcd_send_bsg_uic_cmd()
scsi: ufs: core: Move ufshcd_enable_intr() and ufshcd_disable_intr()
scsi: ufs: ufs-pci: Remove UFS PCI driver's ->late_init() call back
scsi: ufs: ufs-pci: Fix default runtime and system PM levels
scsi: ufs: ufs-pci: Fix hibernate state transition for Intel MTL-like host controllers
scsi: ufs: host: mediatek: Support FDE (AES) clock scaling
scsi: ufs: host: mediatek: Support clock scaling with Vcore binding
...

+703 -278
+40 -6
Documentation/devicetree/bindings/ufs/mediatek,ufs.yaml
··· 9 9 maintainers: 10 10 - Stanley Chu <stanley.chu@mediatek.com> 11 11 12 - allOf: 13 - - $ref: ufs-common.yaml 14 - 15 12 properties: 16 13 compatible: 17 14 enum: 18 15 - mediatek,mt8183-ufshci 19 16 - mediatek,mt8192-ufshci 17 + - mediatek,mt8195-ufshci 20 18 21 19 clocks: 22 - maxItems: 1 20 + minItems: 1 21 + maxItems: 8 23 22 24 23 clock-names: 25 - items: 26 - - const: ufs 24 + minItems: 1 25 + maxItems: 8 27 26 28 27 phys: 29 28 maxItems: 1 ··· 31 32 maxItems: 1 32 33 33 34 vcc-supply: true 35 + 36 + mediatek,ufs-disable-mcq: 37 + $ref: /schemas/types.yaml#/definitions/flag 38 + description: The mask to disable MCQ (Multi-Circular Queue) for UFS host. 34 39 35 40 required: 36 41 - compatible ··· 45 42 - vcc-supply 46 43 47 44 unevaluatedProperties: false 45 + 46 + allOf: 47 + - $ref: ufs-common.yaml 48 + 49 + - if: 50 + properties: 51 + compatible: 52 + contains: 53 + enum: 54 + - mediatek,mt8195-ufshci 55 + then: 56 + properties: 57 + clocks: 58 + minItems: 8 59 + clock-names: 60 + items: 61 + - const: ufs 62 + - const: ufs_aes 63 + - const: ufs_tick 64 + - const: unipro_sysclk 65 + - const: unipro_tick 66 + - const: unipro_mp_bclk 67 + - const: ufs_tx_symbol 68 + - const: ufs_mem_sub 69 + else: 70 + properties: 71 + clocks: 72 + maxItems: 1 73 + clock-names: 74 + items: 75 + - const: ufs 48 76 49 77 examples: 50 78 - |
+1 -1
MAINTAINERS
··· 11100 11100 F: drivers/infiniband/hw/hns/ 11101 11101 11102 11102 HISILICON SAS Controller 11103 - M: Yihang Li <liyihang9@huawei.com> 11103 + M: Yihang Li <liyihang9@h-partners.com> 11104 11104 S: Supported 11105 11105 W: http://www.hisilicon.com 11106 11106 F: Documentation/devicetree/bindings/scsi/hisilicon-sas.txt
+25
arch/arm64/boot/dts/mediatek/mt8195.dtsi
··· 1430 1430 status = "disabled"; 1431 1431 }; 1432 1432 1433 + ufshci: ufshci@11270000 { 1434 + compatible = "mediatek,mt8195-ufshci"; 1435 + reg = <0 0x11270000 0 0x2300>; 1436 + interrupts = <GIC_SPI 137 IRQ_TYPE_LEVEL_HIGH 0>; 1437 + phys = <&ufsphy>; 1438 + clocks = <&infracfg_ao CLK_INFRA_AO_AES_UFSFDE>, 1439 + <&infracfg_ao CLK_INFRA_AO_AES>, 1440 + <&infracfg_ao CLK_INFRA_AO_UFS_TICK>, 1441 + <&infracfg_ao CLK_INFRA_AO_UNIPRO_SYS>, 1442 + <&infracfg_ao CLK_INFRA_AO_UNIPRO_TICK>, 1443 + <&infracfg_ao CLK_INFRA_AO_UFS_MP_SAP_B>, 1444 + <&infracfg_ao CLK_INFRA_AO_UFS_TX_SYMBOL>, 1445 + <&infracfg_ao CLK_INFRA_AO_PERI_UFS_MEM_SUB>; 1446 + clock-names = "ufs", "ufs_aes", "ufs_tick", 1447 + "unipro_sysclk", "unipro_tick", 1448 + "unipro_mp_bclk", "ufs_tx_symbol", 1449 + "ufs_mem_sub"; 1450 + freq-table-hz = <0 0>, <0 0>, <0 0>, 1451 + <0 0>, <0 0>, <0 0>, 1452 + <0 0>, <0 0>; 1453 + 1454 + mediatek,ufs-disable-mcq; 1455 + status = "disabled"; 1456 + }; 1457 + 1433 1458 lvts_mcu: thermal-sensor@11278000 { 1434 1459 compatible = "mediatek,mt8195-lvts-mcu"; 1435 1460 reg = <0 0x11278000 0 0x1000>;
+1 -2
drivers/scsi/aacraid/comminit.c
··· 481 481 pci_find_capability(dev->pdev, PCI_CAP_ID_MSIX)) { 482 482 min_msix = 2; 483 483 i = pci_alloc_irq_vectors(dev->pdev, 484 - min_msix, msi_count, 485 - PCI_IRQ_MSIX | PCI_IRQ_AFFINITY); 484 + min_msix, msi_count, PCI_IRQ_MSIX); 486 485 if (i > 0) { 487 486 dev->msi_enabled = 1; 488 487 msi_count = i;
+2 -8
drivers/scsi/libsas/sas_ata.c
··· 252 252 return ata_dev_classify(&tf); 253 253 } 254 254 255 - int sas_get_ata_info(struct domain_device *dev, struct ex_phy *phy) 255 + static int sas_get_ata_info(struct domain_device *dev, struct ex_phy *phy) 256 256 { 257 257 if (phy->attached_tproto & SAS_PROTOCOL_STP) 258 258 dev->tproto = phy->attached_tproto; ··· 927 927 928 928 void sas_ata_wait_eh(struct domain_device *dev) 929 929 { 930 - struct ata_port *ap; 931 - 932 - if (!dev_is_sata(dev)) 933 - return; 934 - 935 - ap = dev->sata_dev.ap; 936 - ata_port_wait_eh(ap); 930 + ata_port_wait_eh(dev->sata_dev.ap); 937 931 } 938 932 939 933 void sas_ata_device_link_abort(struct domain_device *device, bool force_reset)
+1 -1
drivers/scsi/libsas/sas_discover.c
··· 406 406 } 407 407 } 408 408 409 - void sas_unregister_domain_devices(struct asd_sas_port *port, int gone) 409 + void sas_unregister_domain_devices(struct asd_sas_port *port, bool gone) 410 410 { 411 411 struct domain_device *dev, *n; 412 412
+76 -2
drivers/scsi/libsas/sas_internal.h
··· 44 44 int sas_discover_root_expander(struct domain_device *dev); 45 45 46 46 int sas_ex_revalidate_domain(struct domain_device *dev); 47 - void sas_unregister_domain_devices(struct asd_sas_port *port, int gone); 47 + void sas_unregister_domain_devices(struct asd_sas_port *port, bool gone); 48 48 void sas_init_disc(struct sas_discovery *disc, struct asd_sas_port *port); 49 49 void sas_discover_event(struct asd_sas_port *port, enum discover_event ev); 50 50 ··· 70 70 void sas_queue_deferred_work(struct sas_ha_struct *ha); 71 71 void __sas_drain_work(struct sas_ha_struct *ha); 72 72 73 - void sas_deform_port(struct asd_sas_phy *phy, int gone); 73 + void sas_deform_port(struct asd_sas_phy *phy, bool gone); 74 74 75 75 void sas_porte_bytes_dmaed(struct work_struct *work); 76 76 void sas_porte_broadcast_rcvd(struct work_struct *work); ··· 221 221 { 222 222 kref_put(&dev->kref, sas_free_device); 223 223 } 224 + 225 + #ifdef CONFIG_SCSI_SAS_ATA 226 + 227 + int sas_ata_init(struct domain_device *dev); 228 + void sas_ata_task_abort(struct sas_task *task); 229 + int sas_discover_sata(struct domain_device *dev); 230 + int sas_ata_add_dev(struct domain_device *parent, struct ex_phy *phy, 231 + struct domain_device *child, int phy_id); 232 + void sas_ata_strategy_handler(struct Scsi_Host *shost); 233 + void sas_ata_eh(struct Scsi_Host *shost, struct list_head *work_q); 234 + void sas_ata_end_eh(struct ata_port *ap); 235 + void sas_ata_wait_eh(struct domain_device *dev); 236 + void sas_probe_sata(struct asd_sas_port *port); 237 + void sas_suspend_sata(struct asd_sas_port *port); 238 + void sas_resume_sata(struct asd_sas_port *port); 239 + 240 + #else 241 + 242 + static inline int sas_ata_init(struct domain_device *dev) 243 + { 244 + return 0; 245 + } 246 + 247 + static inline void sas_ata_task_abort(struct sas_task *task) 248 + { 249 + } 250 + 251 + static inline void sas_ata_strategy_handler(struct Scsi_Host *shost) 252 + { 253 + } 254 + 255 + static inline void sas_ata_eh(struct Scsi_Host *shost, struct list_head *work_q) 256 + { 257 + } 258 + 259 + static inline void sas_ata_end_eh(struct ata_port *ap) 260 + { 261 + } 262 + 263 + static inline void sas_ata_wait_eh(struct domain_device *dev) 264 + { 265 + } 266 + 267 + static inline void sas_probe_sata(struct asd_sas_port *port) 268 + { 269 + } 270 + 271 + static inline void sas_suspend_sata(struct asd_sas_port *port) 272 + { 273 + } 274 + 275 + static inline void sas_resume_sata(struct asd_sas_port *port) 276 + { 277 + } 278 + 279 + static inline void sas_ata_disabled_notice(void) 280 + { 281 + pr_notice_once("ATA device seen but CONFIG_SCSI_SAS_ATA=N\n"); 282 + } 283 + 284 + static inline int sas_discover_sata(struct domain_device *dev) 285 + { 286 + sas_ata_disabled_notice(); 287 + return -ENXIO; 288 + } 289 + 290 + static inline int sas_ata_add_dev(struct domain_device *parent, struct ex_phy *phy, 291 + struct domain_device *child, int phy_id) 292 + { 293 + sas_ata_disabled_notice(); 294 + return -ENODEV; 295 + } 296 + 297 + #endif 224 298 225 299 #endif /* _SAS_INTERNAL_H_ */
+3 -3
drivers/scsi/libsas/sas_phy.c
··· 20 20 struct asd_sas_phy *phy = ev->phy; 21 21 22 22 phy->error = 0; 23 - sas_deform_port(phy, 1); 23 + sas_deform_port(phy, true); 24 24 } 25 25 26 26 static void sas_phye_oob_done(struct work_struct *work) ··· 40 40 struct sas_internal *i = 41 41 to_sas_internal(sas_ha->shost->transportt); 42 42 43 - sas_deform_port(phy, 1); 43 + sas_deform_port(phy, true); 44 44 45 45 if (!port && phy->enabled && i->dft->lldd_control_phy) { 46 46 phy->error++; ··· 85 85 86 86 phy->error = 0; 87 87 phy->suspended = 0; 88 - sas_deform_port(phy, 1); 88 + sas_deform_port(phy, true); 89 89 } 90 90 91 91
+6 -7
drivers/scsi/libsas/sas_port.c
··· 113 113 114 114 if (port) { 115 115 if (!phy_is_wideport_member(port, phy)) 116 - sas_deform_port(phy, 0); 116 + sas_deform_port(phy, false); 117 117 else if (phy->suspended) { 118 118 phy->suspended = 0; 119 119 sas_resume_port(phy); ··· 206 206 * This is called when the physical link to the other phy has been 207 207 * lost (on this phy), in Event thread context. We cannot delay here. 208 208 */ 209 - void sas_deform_port(struct asd_sas_phy *phy, int gone) 209 + void sas_deform_port(struct asd_sas_phy *phy, bool gone) 210 210 { 211 211 struct sas_ha_struct *sas_ha = phy->ha; 212 212 struct asd_sas_port *port = phy->port; ··· 301 301 struct asd_sas_event *ev = to_asd_sas_event(work); 302 302 struct asd_sas_phy *phy = ev->phy; 303 303 304 - sas_deform_port(phy, 1); 304 + sas_deform_port(phy, true); 305 305 } 306 306 307 307 void sas_porte_timer_event(struct work_struct *work) ··· 309 309 struct asd_sas_event *ev = to_asd_sas_event(work); 310 310 struct asd_sas_phy *phy = ev->phy; 311 311 312 - sas_deform_port(phy, 1); 312 + sas_deform_port(phy, true); 313 313 } 314 314 315 315 void sas_porte_hard_reset(struct work_struct *work) ··· 317 317 struct asd_sas_event *ev = to_asd_sas_event(work); 318 318 struct asd_sas_phy *phy = ev->phy; 319 319 320 - sas_deform_port(phy, 1); 320 + sas_deform_port(phy, true); 321 321 } 322 322 323 323 /* ---------- SAS port registration ---------- */ ··· 358 358 359 359 for (i = 0; i < sas_ha->num_phys; i++) 360 360 if (sas_ha->sas_phy[i]->port) 361 - sas_deform_port(sas_ha->sas_phy[i], 0); 362 - 361 + sas_deform_port(sas_ha->sas_phy[i], false); 363 362 } 364 363 365 364 const work_func_t sas_port_event_fns[PORT_NUM_EVENTS] = {
+1 -2
drivers/scsi/mpt3sas/mpt3sas_scsih.c
··· 10809 10809 break; 10810 10810 case MPI2_EVENT_PCIE_TOPOLOGY_CHANGE_LIST: 10811 10811 _scsih_pcie_topology_change_event(ioc, fw_event); 10812 - ioc->current_event = NULL; 10813 - return; 10812 + break; 10814 10813 } 10815 10814 out: 10816 10815 fw_event_work_put(fw_event);
+1 -1
drivers/scsi/scsi_scan.c
··· 1900 1900 1901 1901 return 0; 1902 1902 } 1903 - 1903 + EXPORT_SYMBOL(scsi_scan_host_selected); 1904 1904 static void scsi_sysfs_add_devices(struct Scsi_Host *shost) 1905 1905 { 1906 1906 struct scsi_device *sdev;
+2
drivers/scsi/scsi_transport_iscsi.c
··· 2143 2143 return 0; 2144 2144 2145 2145 iscsi_remove_conn(iscsi_dev_to_conn(dev)); 2146 + iscsi_put_conn(iscsi_dev_to_conn(dev)); 2147 + 2146 2148 return 0; 2147 2149 } 2148 2150
+49 -13
drivers/scsi/scsi_transport_sas.c
··· 40 40 #include <scsi/scsi_transport_sas.h> 41 41 42 42 #include "scsi_sas_internal.h" 43 + #include "scsi_priv.h" 44 + 43 45 struct sas_host_attrs { 44 46 struct list_head rphy_list; 45 47 struct mutex lock; ··· 1685 1683 } 1686 1684 EXPORT_SYMBOL(scsi_is_sas_rphy); 1687 1685 1686 + static void scan_channel_zero(struct Scsi_Host *shost, uint id, u64 lun) 1687 + { 1688 + struct sas_host_attrs *sas_host = to_sas_host_attrs(shost); 1689 + struct sas_rphy *rphy; 1690 + 1691 + list_for_each_entry(rphy, &sas_host->rphy_list, list) { 1692 + if (rphy->identify.device_type != SAS_END_DEVICE || 1693 + rphy->scsi_target_id == -1) 1694 + continue; 1695 + 1696 + if (id == SCAN_WILD_CARD || id == rphy->scsi_target_id) { 1697 + scsi_scan_target(&rphy->dev, 0, rphy->scsi_target_id, 1698 + lun, SCSI_SCAN_MANUAL); 1699 + } 1700 + } 1701 + } 1688 1702 1689 1703 /* 1690 1704 * SCSI scan helper ··· 1710 1692 uint id, u64 lun) 1711 1693 { 1712 1694 struct sas_host_attrs *sas_host = to_sas_host_attrs(shost); 1713 - struct sas_rphy *rphy; 1695 + int res = 0; 1696 + int i; 1714 1697 1715 - mutex_lock(&sas_host->lock); 1716 - list_for_each_entry(rphy, &sas_host->rphy_list, list) { 1717 - if (rphy->identify.device_type != SAS_END_DEVICE || 1718 - rphy->scsi_target_id == -1) 1719 - continue; 1698 + switch (channel) { 1699 + case 0: 1700 + mutex_lock(&sas_host->lock); 1701 + scan_channel_zero(shost, id, lun); 1702 + mutex_unlock(&sas_host->lock); 1703 + break; 1720 1704 1721 - if ((channel == SCAN_WILD_CARD || channel == 0) && 1722 - (id == SCAN_WILD_CARD || id == rphy->scsi_target_id)) { 1723 - scsi_scan_target(&rphy->dev, 0, rphy->scsi_target_id, 1724 - lun, SCSI_SCAN_MANUAL); 1705 + case SCAN_WILD_CARD: 1706 + mutex_lock(&sas_host->lock); 1707 + scan_channel_zero(shost, id, lun); 1708 + mutex_unlock(&sas_host->lock); 1709 + 1710 + for (i = 1; i <= shost->max_channel; i++) { 1711 + res = scsi_scan_host_selected(shost, i, id, lun, 1712 + SCSI_SCAN_MANUAL); 1713 + if (res) 1714 + goto exit_scan; 1725 1715 } 1726 - } 1727 - mutex_unlock(&sas_host->lock); 1716 + break; 1728 1717 1729 - return 0; 1718 + default: 1719 + if (channel < shost->max_channel) { 1720 + res = scsi_scan_host_selected(shost, channel, id, lun, 1721 + SCSI_SCAN_MANUAL); 1722 + } else { 1723 + res = -EINVAL; 1724 + } 1725 + break; 1726 + } 1727 + 1728 + exit_scan: 1729 + return res; 1730 1730 } 1731 1731 1732 1732
+3 -1
drivers/scsi/sd.c
··· 4173 4173 if ((system_state != SYSTEM_RESTART && 4174 4174 sdkp->device->manage_system_start_stop) || 4175 4175 (system_state == SYSTEM_POWER_OFF && 4176 - sdkp->device->manage_shutdown)) { 4176 + sdkp->device->manage_shutdown) || 4177 + (system_state == SYSTEM_RUNNING && 4178 + sdkp->device->manage_runtime_start_stop)) { 4177 4179 sd_printk(KERN_NOTICE, sdkp, "Stopping disk\n"); 4178 4180 sd_start_stop_device(sdkp, 0); 4179 4181 }
+49 -16
drivers/target/target_core_fabric_lib.c
··· 257 257 return len; 258 258 } 259 259 260 - static char *iscsi_parse_pr_out_transport_id( 260 + static void sas_parse_pr_out_transport_id(char *buf, char *i_str) 261 + { 262 + char hex[17] = {}; 263 + 264 + bin2hex(hex, buf + 4, 8); 265 + snprintf(i_str, TRANSPORT_IQN_LEN, "naa.%s", hex); 266 + } 267 + 268 + static void srp_parse_pr_out_transport_id(char *buf, char *i_str) 269 + { 270 + char hex[33] = {}; 271 + 272 + bin2hex(hex, buf + 8, 16); 273 + snprintf(i_str, TRANSPORT_IQN_LEN, "0x%s", hex); 274 + } 275 + 276 + static void fcp_parse_pr_out_transport_id(char *buf, char *i_str) 277 + { 278 + snprintf(i_str, TRANSPORT_IQN_LEN, "%8phC", buf + 8); 279 + } 280 + 281 + static void sbp_parse_pr_out_transport_id(char *buf, char *i_str) 282 + { 283 + char hex[17] = {}; 284 + 285 + bin2hex(hex, buf + 8, 8); 286 + snprintf(i_str, TRANSPORT_IQN_LEN, "%s", hex); 287 + } 288 + 289 + static bool iscsi_parse_pr_out_transport_id( 261 290 struct se_portal_group *se_tpg, 262 291 char *buf, 263 292 u32 *out_tid_len, 264 - char **port_nexus_ptr) 293 + char **port_nexus_ptr, 294 + char *i_str) 265 295 { 266 296 char *p; 267 297 int i; ··· 312 282 if ((format_code != 0x00) && (format_code != 0x40)) { 313 283 pr_err("Illegal format code: 0x%02x for iSCSI" 314 284 " Initiator Transport ID\n", format_code); 315 - return NULL; 285 + return false; 316 286 } 317 287 /* 318 288 * If the caller wants the TransportID Length, we set that value for the ··· 336 306 pr_err("Unable to locate \",i,0x\" separator" 337 307 " for Initiator port identifier: %s\n", 338 308 &buf[4]); 339 - return NULL; 309 + return false; 340 310 } 341 311 *p = '\0'; /* Terminate iSCSI Name */ 342 312 p += 5; /* Skip over ",i,0x" separator */ ··· 369 339 } else 370 340 *port_nexus_ptr = NULL; 371 341 372 - return &buf[4]; 342 + strscpy(i_str, &buf[4], TRANSPORT_IQN_LEN); 343 + return true; 373 344 } 374 345 375 346 int target_get_pr_transport_id_len(struct se_node_acl *nacl, ··· 418 387 } 419 388 } 420 389 421 - const char *target_parse_pr_out_transport_id(struct se_portal_group *tpg, 422 - char *buf, u32 *out_tid_len, char **port_nexus_ptr) 390 + bool target_parse_pr_out_transport_id(struct se_portal_group *tpg, 391 + char *buf, u32 *out_tid_len, char **port_nexus_ptr, char *i_str) 423 392 { 424 - u32 offset; 425 - 426 393 switch (tpg->proto_id) { 427 394 case SCSI_PROTOCOL_SAS: 428 395 /* 429 396 * Assume the FORMAT CODE 00b from spc4r17, 7.5.4.7 TransportID 430 397 * for initiator ports using SCSI over SAS Serial SCSI Protocol. 431 398 */ 432 - offset = 4; 399 + sas_parse_pr_out_transport_id(buf, i_str); 400 + break; 401 + case SCSI_PROTOCOL_SRP: 402 + srp_parse_pr_out_transport_id(buf, i_str); 403 + break; 404 + case SCSI_PROTOCOL_FCP: 405 + fcp_parse_pr_out_transport_id(buf, i_str); 433 406 break; 434 407 case SCSI_PROTOCOL_SBP: 435 - case SCSI_PROTOCOL_SRP: 436 - case SCSI_PROTOCOL_FCP: 437 - offset = 8; 408 + sbp_parse_pr_out_transport_id(buf, i_str); 438 409 break; 439 410 case SCSI_PROTOCOL_ISCSI: 440 411 return iscsi_parse_pr_out_transport_id(tpg, buf, out_tid_len, 441 - port_nexus_ptr); 412 + port_nexus_ptr, i_str); 442 413 default: 443 414 pr_err("Unknown proto_id: 0x%02x\n", tpg->proto_id); 444 - return NULL; 415 + return false; 445 416 } 446 417 447 418 *port_nexus_ptr = NULL; 448 419 *out_tid_len = 24; 449 - return buf + offset; 420 + return true; 450 421 }
+28 -5
drivers/target/target_core_iblock.c
··· 64 64 pr_err("Unable to allocate struct iblock_dev\n"); 65 65 return NULL; 66 66 } 67 + ib_dev->ibd_exclusive = true; 67 68 68 69 ib_dev->ibd_plug = kcalloc(nr_cpu_ids, sizeof(*ib_dev->ibd_plug), 69 70 GFP_KERNEL); ··· 96 95 struct block_device *bd; 97 96 struct blk_integrity *bi; 98 97 blk_mode_t mode = BLK_OPEN_READ; 98 + void *holder = ib_dev; 99 99 unsigned int max_write_zeroes_sectors; 100 100 int ret; 101 101 ··· 111 109 goto out; 112 110 } 113 111 114 - pr_debug( "IBLOCK: Claiming struct block_device: %s\n", 115 - ib_dev->ibd_udev_path); 112 + pr_debug("IBLOCK: Claiming struct block_device: %s: %d\n", 113 + ib_dev->ibd_udev_path, ib_dev->ibd_exclusive); 116 114 117 115 if (!ib_dev->ibd_readonly) 118 116 mode |= BLK_OPEN_WRITE; 119 117 else 120 118 dev->dev_flags |= DF_READ_ONLY; 121 119 122 - bdev_file = bdev_file_open_by_path(ib_dev->ibd_udev_path, mode, ib_dev, 120 + if (!ib_dev->ibd_exclusive) 121 + holder = NULL; 122 + 123 + bdev_file = bdev_file_open_by_path(ib_dev->ibd_udev_path, mode, holder, 123 124 NULL); 124 125 if (IS_ERR(bdev_file)) { 125 126 ret = PTR_ERR(bdev_file); ··· 565 560 } 566 561 567 562 enum { 568 - Opt_udev_path, Opt_readonly, Opt_force, Opt_err 563 + Opt_udev_path, Opt_readonly, Opt_force, Opt_exclusive, Opt_err, 569 564 }; 570 565 571 566 static match_table_t tokens = { 572 567 {Opt_udev_path, "udev_path=%s"}, 573 568 {Opt_readonly, "readonly=%d"}, 574 569 {Opt_force, "force=%d"}, 570 + {Opt_exclusive, "exclusive=%d"}, 575 571 {Opt_err, NULL} 576 572 }; 577 573 ··· 582 576 struct iblock_dev *ib_dev = IBLOCK_DEV(dev); 583 577 char *orig, *ptr, *arg_p, *opts; 584 578 substring_t args[MAX_OPT_ARGS]; 585 - int ret = 0, token; 579 + int ret = 0, token, tmp_exclusive; 586 580 unsigned long tmp_readonly; 587 581 588 582 opts = kstrdup(page, GFP_KERNEL); ··· 629 623 ib_dev->ibd_readonly = tmp_readonly; 630 624 pr_debug("IBLOCK: readonly: %d\n", ib_dev->ibd_readonly); 631 625 break; 626 + case Opt_exclusive: 627 + arg_p = match_strdup(&args[0]); 628 + if (!arg_p) { 629 + ret = -ENOMEM; 630 + break; 631 + } 632 + ret = kstrtoint(arg_p, 0, &tmp_exclusive); 633 + kfree(arg_p); 634 + if (ret < 0) { 635 + pr_err("kstrtoul() failed for exclusive=\n"); 636 + goto out; 637 + } 638 + ib_dev->ibd_exclusive = tmp_exclusive; 639 + pr_debug("IBLOCK: exclusive: %d\n", 640 + ib_dev->ibd_exclusive); 641 + break; 632 642 case Opt_force: 633 643 break; 634 644 default: ··· 669 647 bl += sprintf(b + bl, " UDEV PATH: %s", 670 648 ib_dev->ibd_udev_path); 671 649 bl += sprintf(b + bl, " readonly: %d\n", ib_dev->ibd_readonly); 650 + bl += sprintf(b + bl, " exclusive: %d\n", ib_dev->ibd_exclusive); 672 651 673 652 bl += sprintf(b + bl, " "); 674 653 if (bd) {
+1
drivers/target/target_core_iblock.h
··· 34 34 struct block_device *ibd_bd; 35 35 struct file *ibd_bdev_file; 36 36 bool ibd_readonly; 37 + bool ibd_exclusive; 37 38 struct iblock_dev_plug *ibd_plug; 38 39 } ____cacheline_aligned; 39 40
+2 -2
drivers/target/target_core_internal.h
··· 103 103 int target_get_pr_transport_id(struct se_node_acl *nacl, 104 104 struct t10_pr_registration *pr_reg, int *format_code, 105 105 unsigned char *buf); 106 - const char *target_parse_pr_out_transport_id(struct se_portal_group *tpg, 107 - char *buf, u32 *out_tid_len, char **port_nexus_ptr); 106 + bool target_parse_pr_out_transport_id(struct se_portal_group *tpg, 107 + char *buf, u32 *out_tid_len, char **port_nexus_ptr, char *i_str); 108 108 109 109 /* target_core_hba.c */ 110 110 struct se_hba *core_alloc_hba(const char *, u32, u32);
+10 -8
drivers/target/target_core_pr.c
··· 1478 1478 LIST_HEAD(tid_dest_list); 1479 1479 struct pr_transport_id_holder *tidh_new, *tidh, *tidh_tmp; 1480 1480 unsigned char *buf, *ptr, proto_ident; 1481 - const unsigned char *i_str = NULL; 1481 + unsigned char i_str[TRANSPORT_IQN_LEN]; 1482 1482 char *iport_ptr = NULL, i_buf[PR_REG_ISID_ID_LEN]; 1483 1483 sense_reason_t ret; 1484 1484 u32 tpdl, tid_len = 0; 1485 1485 u32 dest_rtpi = 0; 1486 + bool tid_found; 1486 1487 1487 1488 /* 1488 1489 * Allocate a struct pr_transport_id_holder and setup the ··· 1572 1571 dest_rtpi = tmp_lun->lun_tpg->tpg_rtpi; 1573 1572 1574 1573 iport_ptr = NULL; 1575 - i_str = target_parse_pr_out_transport_id(tmp_tpg, 1576 - ptr, &tid_len, &iport_ptr); 1577 - if (!i_str) 1574 + tid_found = target_parse_pr_out_transport_id(tmp_tpg, 1575 + ptr, &tid_len, &iport_ptr, i_str); 1576 + if (!tid_found) 1578 1577 continue; 1579 1578 /* 1580 1579 * Determine if this SCSI device server requires that ··· 3154 3153 struct t10_pr_registration *pr_reg, *pr_res_holder, *dest_pr_reg; 3155 3154 struct t10_reservation *pr_tmpl = &dev->t10_pr; 3156 3155 unsigned char *buf; 3157 - const unsigned char *initiator_str; 3156 + unsigned char initiator_str[TRANSPORT_IQN_LEN]; 3158 3157 char *iport_ptr = NULL, i_buf[PR_REG_ISID_ID_LEN] = { }; 3159 3158 u32 tid_len, tmp_tid_len; 3160 3159 int new_reg = 0, type, scope, matching_iname; 3161 3160 sense_reason_t ret; 3162 3161 unsigned short rtpi; 3163 3162 unsigned char proto_ident; 3163 + bool tid_found; 3164 3164 3165 3165 if (!se_sess || !se_lun) { 3166 3166 pr_err("SPC-3 PR: se_sess || struct se_lun is NULL!\n"); ··· 3280 3278 ret = TCM_INVALID_PARAMETER_LIST; 3281 3279 goto out; 3282 3280 } 3283 - initiator_str = target_parse_pr_out_transport_id(dest_se_tpg, 3284 - &buf[24], &tmp_tid_len, &iport_ptr); 3285 - if (!initiator_str) { 3281 + tid_found = target_parse_pr_out_transport_id(dest_se_tpg, 3282 + &buf[24], &tmp_tid_len, &iport_ptr, initiator_str); 3283 + if (!tid_found) { 3286 3284 pr_err("SPC-3 PR REGISTER_AND_MOVE: Unable to locate" 3287 3285 " initiator_str from Transport ID\n"); 3288 3286 ret = TCM_INVALID_PARAMETER_LIST;
+2 -1
drivers/ufs/core/ufs-sysfs.c
··· 5 5 #include <linux/string.h> 6 6 #include <linux/bitfield.h> 7 7 #include <linux/unaligned.h> 8 + #include <linux/string_choices.h> 8 9 9 10 #include <ufs/ufs.h> 10 11 #include <ufs/unipro.h> ··· 1517 1516 ret = -EINVAL; \ 1518 1517 goto out; \ 1519 1518 } \ 1520 - ret = sysfs_emit(buf, "%s\n", flag ? "true" : "false"); \ 1519 + ret = sysfs_emit(buf, "%s\n", str_true_false(flag)); \ 1521 1520 out: \ 1522 1521 up(&hba->host_sem); \ 1523 1522 return ret; \
+49 -56
drivers/ufs/core/ufshcd.c
··· 364 364 } 365 365 EXPORT_SYMBOL_GPL(ufshcd_disable_irq); 366 366 367 + /** 368 + * ufshcd_enable_intr - enable interrupts 369 + * @hba: per adapter instance 370 + * @intrs: interrupt bits 371 + */ 372 + static void ufshcd_enable_intr(struct ufs_hba *hba, u32 intrs) 373 + { 374 + u32 old_val = ufshcd_readl(hba, REG_INTERRUPT_ENABLE); 375 + u32 new_val = old_val | intrs; 376 + 377 + if (new_val != old_val) 378 + ufshcd_writel(hba, new_val, REG_INTERRUPT_ENABLE); 379 + } 380 + 381 + /** 382 + * ufshcd_disable_intr - disable interrupts 383 + * @hba: per adapter instance 384 + * @intrs: interrupt bits 385 + */ 386 + static void ufshcd_disable_intr(struct ufs_hba *hba, u32 intrs) 387 + { 388 + u32 old_val = ufshcd_readl(hba, REG_INTERRUPT_ENABLE); 389 + u32 new_val = old_val & ~intrs; 390 + 391 + if (new_val != old_val) 392 + ufshcd_writel(hba, new_val, REG_INTERRUPT_ENABLE); 393 + } 394 + 367 395 static void ufshcd_configure_wb(struct ufs_hba *hba) 368 396 { 369 397 if (!ufshcd_is_wb_allowed(hba)) ··· 2624 2596 */ 2625 2597 int ufshcd_send_uic_cmd(struct ufs_hba *hba, struct uic_command *uic_cmd) 2626 2598 { 2599 + unsigned long flags; 2627 2600 int ret; 2628 2601 2629 2602 if (hba->quirks & UFSHCD_QUIRK_BROKEN_UIC_CMD) ··· 2633 2604 ufshcd_hold(hba); 2634 2605 mutex_lock(&hba->uic_cmd_mutex); 2635 2606 ufshcd_add_delay_before_dme_cmd(hba); 2607 + 2608 + spin_lock_irqsave(hba->host->host_lock, flags); 2609 + ufshcd_enable_intr(hba, UIC_COMMAND_COMPL); 2610 + spin_unlock_irqrestore(hba->host->host_lock, flags); 2636 2611 2637 2612 ret = __ufshcd_send_uic_cmd(hba, uic_cmd); 2638 2613 if (!ret) ··· 2712 2679 ufshcd_sgl_to_prdt(hba, lrbp, sg_segments, scsi_sglist(cmd)); 2713 2680 2714 2681 return ufshcd_crypto_fill_prdt(hba, lrbp); 2715 - } 2716 - 2717 - /** 2718 - * ufshcd_enable_intr - enable interrupts 2719 - * @hba: per adapter instance 2720 - * @intrs: interrupt bits 2721 - */ 2722 - static void ufshcd_enable_intr(struct ufs_hba *hba, u32 intrs) 2723 - { 2724 - u32 set = ufshcd_readl(hba, REG_INTERRUPT_ENABLE); 2725 - 2726 - set |= intrs; 2727 - ufshcd_writel(hba, set, REG_INTERRUPT_ENABLE); 2728 - } 2729 - 2730 - /** 2731 - * ufshcd_disable_intr - disable interrupts 2732 - * @hba: per adapter instance 2733 - * @intrs: interrupt bits 2734 - */ 2735 - static void ufshcd_disable_intr(struct ufs_hba *hba, u32 intrs) 2736 - { 2737 - u32 set = ufshcd_readl(hba, REG_INTERRUPT_ENABLE); 2738 - 2739 - set &= ~intrs; 2740 - ufshcd_writel(hba, set, REG_INTERRUPT_ENABLE); 2741 2682 } 2742 2683 2743 2684 /** ··· 4325 4318 unsigned long flags; 4326 4319 u8 status; 4327 4320 int ret; 4328 - bool reenable_intr = false; 4329 4321 4330 4322 mutex_lock(&hba->uic_cmd_mutex); 4331 4323 ufshcd_add_delay_before_dme_cmd(hba); ··· 4335 4329 goto out_unlock; 4336 4330 } 4337 4331 hba->uic_async_done = &uic_async_done; 4338 - if (ufshcd_readl(hba, REG_INTERRUPT_ENABLE) & UIC_COMMAND_COMPL) { 4339 - ufshcd_disable_intr(hba, UIC_COMMAND_COMPL); 4340 - /* 4341 - * Make sure UIC command completion interrupt is disabled before 4342 - * issuing UIC command. 4343 - */ 4344 - ufshcd_readl(hba, REG_INTERRUPT_ENABLE); 4345 - reenable_intr = true; 4346 - } 4332 + ufshcd_disable_intr(hba, UIC_COMMAND_COMPL); 4347 4333 spin_unlock_irqrestore(hba->host->host_lock, flags); 4348 4334 ret = __ufshcd_send_uic_cmd(hba, cmd); 4349 4335 if (ret) { ··· 4379 4381 spin_lock_irqsave(hba->host->host_lock, flags); 4380 4382 hba->active_uic_cmd = NULL; 4381 4383 hba->uic_async_done = NULL; 4382 - if (reenable_intr) 4383 - ufshcd_enable_intr(hba, UIC_COMMAND_COMPL); 4384 - if (ret) { 4384 + if (ret && !hba->pm_op_in_progress) { 4385 4385 ufshcd_set_link_broken(hba); 4386 4386 ufshcd_schedule_eh_work(hba); 4387 4387 } 4388 4388 out_unlock: 4389 4389 spin_unlock_irqrestore(hba->host->host_lock, flags); 4390 4390 mutex_unlock(&hba->uic_cmd_mutex); 4391 + 4392 + /* 4393 + * If the h8 exit fails during the runtime resume process, it becomes 4394 + * stuck and cannot be recovered through the error handler. To fix 4395 + * this, use link recovery instead of the error handler. 4396 + */ 4397 + if (ret && hba->pm_op_in_progress) 4398 + ret = ufshcd_link_recovery(hba); 4391 4399 4392 4400 return ret; 4393 4401 } ··· 4409 4405 { 4410 4406 int ret; 4411 4407 4408 + if (uic_cmd->argument1 != UIC_ARG_MIB(PA_PWRMODE) || 4409 + uic_cmd->command != UIC_CMD_DME_SET) 4410 + return ufshcd_send_uic_cmd(hba, uic_cmd); 4411 + 4412 4412 if (hba->quirks & UFSHCD_QUIRK_BROKEN_UIC_CMD) 4413 4413 return 0; 4414 4414 4415 4415 ufshcd_hold(hba); 4416 - 4417 - if (uic_cmd->argument1 == UIC_ARG_MIB(PA_PWRMODE) && 4418 - uic_cmd->command == UIC_CMD_DME_SET) { 4419 - ret = ufshcd_uic_pwr_ctrl(hba, uic_cmd); 4420 - goto out; 4421 - } 4422 - 4423 - mutex_lock(&hba->uic_cmd_mutex); 4424 - ufshcd_add_delay_before_dme_cmd(hba); 4425 - 4426 - ret = __ufshcd_send_uic_cmd(hba, uic_cmd); 4427 - if (!ret) 4428 - ret = ufshcd_wait_for_uic_cmd(hba, uic_cmd); 4429 - 4430 - mutex_unlock(&hba->uic_cmd_mutex); 4431 - 4432 - out: 4416 + ret = ufshcd_uic_pwr_ctrl(hba, uic_cmd); 4433 4417 ufshcd_release(hba); 4418 + 4434 4419 return ret; 4435 4420 } 4436 4421
+297 -33
drivers/ufs/host/ufs-mediatek.c
··· 50 50 51 51 static const struct of_device_id ufs_mtk_of_match[] = { 52 52 { .compatible = "mediatek,mt8183-ufshci" }, 53 + { .compatible = "mediatek,mt8195-ufshci" }, 53 54 {}, 54 55 }; 55 56 MODULE_DEVICE_TABLE(of, ufs_mtk_of_match); ··· 97 96 { 98 97 struct ufs_mtk_host *host = ufshcd_get_variant(hba); 99 98 100 - return !!(host->caps & UFS_MTK_CAP_BOOST_CRYPT_ENGINE); 99 + return host->caps & UFS_MTK_CAP_BOOST_CRYPT_ENGINE; 101 100 } 102 101 103 102 static bool ufs_mtk_is_va09_supported(struct ufs_hba *hba) 104 103 { 105 104 struct ufs_mtk_host *host = ufshcd_get_variant(hba); 106 105 107 - return !!(host->caps & UFS_MTK_CAP_VA09_PWR_CTRL); 106 + return host->caps & UFS_MTK_CAP_VA09_PWR_CTRL; 108 107 } 109 108 110 109 static bool ufs_mtk_is_broken_vcc(struct ufs_hba *hba) 111 110 { 112 111 struct ufs_mtk_host *host = ufshcd_get_variant(hba); 113 112 114 - return !!(host->caps & UFS_MTK_CAP_BROKEN_VCC); 113 + return host->caps & UFS_MTK_CAP_BROKEN_VCC; 115 114 } 116 115 117 116 static bool ufs_mtk_is_pmc_via_fastauto(struct ufs_hba *hba) 118 117 { 119 118 struct ufs_mtk_host *host = ufshcd_get_variant(hba); 120 119 121 - return !!(host->caps & UFS_MTK_CAP_PMC_VIA_FASTAUTO); 120 + return host->caps & UFS_MTK_CAP_PMC_VIA_FASTAUTO; 122 121 } 123 122 124 123 static bool ufs_mtk_is_tx_skew_fix(struct ufs_hba *hba) 125 124 { 126 125 struct ufs_mtk_host *host = ufshcd_get_variant(hba); 127 126 128 - return (host->caps & UFS_MTK_CAP_TX_SKEW_FIX); 127 + return host->caps & UFS_MTK_CAP_TX_SKEW_FIX; 129 128 } 130 129 131 130 static bool ufs_mtk_is_rtff_mtcmos(struct ufs_hba *hba) 132 131 { 133 132 struct ufs_mtk_host *host = ufshcd_get_variant(hba); 134 133 135 - return (host->caps & UFS_MTK_CAP_RTFF_MTCMOS); 134 + return host->caps & UFS_MTK_CAP_RTFF_MTCMOS; 136 135 } 137 136 138 137 static bool ufs_mtk_is_allow_vccqx_lpm(struct ufs_hba *hba) 139 138 { 140 139 struct ufs_mtk_host *host = ufshcd_get_variant(hba); 141 140 142 - return (host->caps & UFS_MTK_CAP_ALLOW_VCCQX_LPM); 141 + return host->caps & UFS_MTK_CAP_ALLOW_VCCQX_LPM; 142 + } 143 + 144 + static bool ufs_mtk_is_clk_scale_ready(struct ufs_hba *hba) 145 + { 146 + struct ufs_mtk_host *host = ufshcd_get_variant(hba); 147 + struct ufs_mtk_clk *mclk = &host->mclk; 148 + 149 + return mclk->ufs_sel_clki && 150 + mclk->ufs_sel_max_clki && 151 + mclk->ufs_sel_min_clki; 143 152 } 144 153 145 154 static void ufs_mtk_cfg_unipro_cg(struct ufs_hba *hba, bool enable) ··· 278 267 ufshcd_writel(hba, 279 268 ufshcd_readl(hba, REG_UFS_XOUFS_CTRL) | 0x80, 280 269 REG_UFS_XOUFS_CTRL); 270 + 271 + /* DDR_EN setting */ 272 + if (host->ip_ver >= IP_VER_MT6989) { 273 + ufshcd_rmwl(hba, UFS_MASK(0x7FFF, 8), 274 + 0x453000, REG_UFS_MMIO_OPT_CTRL_0); 275 + } 276 + 281 277 } 282 278 283 279 return 0; ··· 362 344 363 345 dev_err(hba->dev, "missing ack of refclk req, reg: 0x%x\n", value); 364 346 365 - ufs_mtk_ref_clk_notify(host->ref_clk_enabled, POST_CHANGE, res); 347 + /* 348 + * If clock on timeout, assume clock is off, notify tfa do clock 349 + * off setting.(keep DIFN disable, release resource) 350 + * If clock off timeout, assume clock will off finally, 351 + * set ref_clk_enabled directly.(keep DIFN disable, keep resource) 352 + */ 353 + if (on) 354 + ufs_mtk_ref_clk_notify(false, POST_CHANGE, res); 355 + else 356 + host->ref_clk_enabled = false; 366 357 367 358 return -ETIMEDOUT; 368 359 ··· 690 663 if (of_property_read_bool(np, "mediatek,ufs-rtff-mtcmos")) 691 664 host->caps |= UFS_MTK_CAP_RTFF_MTCMOS; 692 665 666 + if (of_property_read_bool(np, "mediatek,ufs-broken-rtc")) 667 + host->caps |= UFS_MTK_CAP_MCQ_BROKEN_RTC; 668 + 693 669 dev_info(hba->dev, "caps: 0x%x", host->caps); 694 670 } 695 671 ··· 809 779 return ret; 810 780 } 811 781 782 + static u32 ufs_mtk_mcq_get_irq(struct ufs_hba *hba, unsigned int cpu) 783 + { 784 + struct ufs_mtk_host *host = ufshcd_get_variant(hba); 785 + struct blk_mq_tag_set *tag_set = &hba->host->tag_set; 786 + struct blk_mq_queue_map *map = &tag_set->map[HCTX_TYPE_DEFAULT]; 787 + unsigned int nr = map->nr_queues; 788 + unsigned int q_index; 789 + 790 + q_index = map->mq_map[cpu]; 791 + if (q_index > nr) { 792 + dev_err(hba->dev, "hwq index %d exceed %d\n", 793 + q_index, nr); 794 + return MTK_MCQ_INVALID_IRQ; 795 + } 796 + 797 + return host->mcq_intr_info[q_index].irq; 798 + } 799 + 800 + static void ufs_mtk_mcq_set_irq_affinity(struct ufs_hba *hba, unsigned int cpu) 801 + { 802 + unsigned int irq, _cpu; 803 + int ret; 804 + 805 + irq = ufs_mtk_mcq_get_irq(hba, cpu); 806 + if (irq == MTK_MCQ_INVALID_IRQ) { 807 + dev_err(hba->dev, "invalid irq. unable to bind irq to cpu%d", cpu); 808 + return; 809 + } 810 + 811 + /* force migrate irq of cpu0 to cpu3 */ 812 + _cpu = (cpu == 0) ? 3 : cpu; 813 + ret = irq_set_affinity(irq, cpumask_of(_cpu)); 814 + if (ret) { 815 + dev_err(hba->dev, "set irq %d affinity to CPU %d failed\n", 816 + irq, _cpu); 817 + return; 818 + } 819 + dev_info(hba->dev, "set irq %d affinity to CPU: %d\n", irq, _cpu); 820 + } 821 + 822 + static bool ufs_mtk_is_legacy_chipset(struct ufs_hba *hba, u32 hw_ip_ver) 823 + { 824 + bool is_legacy = false; 825 + 826 + switch (hw_ip_ver) { 827 + case IP_LEGACY_VER_MT6893: 828 + case IP_LEGACY_VER_MT6781: 829 + /* can add other legacy chipset ID here accordingly */ 830 + is_legacy = true; 831 + break; 832 + default: 833 + break; 834 + } 835 + dev_info(hba->dev, "legacy IP version - 0x%x, is legacy : %d", hw_ip_ver, is_legacy); 836 + 837 + return is_legacy; 838 + } 839 + 840 + /* 841 + * HW version format has been changed from 01MMmmmm to 1MMMmmmm, since 842 + * project MT6878. In order to perform correct version comparison, 843 + * version number is changed by SW for the following projects. 844 + * IP_VER_MT6983 0x00360000 to 0x10360000 845 + * IP_VER_MT6897 0x01440000 to 0x10440000 846 + * IP_VER_MT6989 0x01450000 to 0x10450000 847 + * IP_VER_MT6991 0x01460000 to 0x10460000 848 + */ 849 + static void ufs_mtk_get_hw_ip_version(struct ufs_hba *hba) 850 + { 851 + struct ufs_mtk_host *host = ufshcd_get_variant(hba); 852 + u32 hw_ip_ver; 853 + 854 + hw_ip_ver = ufshcd_readl(hba, REG_UFS_MTK_IP_VER); 855 + 856 + if (((hw_ip_ver & (0xFF << 24)) == (0x1 << 24)) || 857 + ((hw_ip_ver & (0xFF << 24)) == 0)) { 858 + hw_ip_ver &= ~(0xFF << 24); 859 + hw_ip_ver |= (0x1 << 28); 860 + } 861 + 862 + host->ip_ver = hw_ip_ver; 863 + 864 + host->legacy_ip_ver = ufs_mtk_is_legacy_chipset(hba, hw_ip_ver); 865 + } 866 + 812 867 static void ufs_mtk_get_controller_version(struct ufs_hba *hba) 813 868 { 814 869 struct ufs_mtk_host *host = ufshcd_get_variant(hba); ··· 933 818 { 934 819 struct ufs_mtk_host *host = ufshcd_get_variant(hba); 935 820 struct list_head *head = &hba->clk_list_head; 936 - struct ufs_mtk_clk *mclk = &host->mclk; 937 821 struct ufs_clk_info *clki, *clki_tmp; 822 + struct device *dev = hba->dev; 823 + struct regulator *reg; 824 + u32 volt; 938 825 939 826 /* 940 827 * Find private clocks and store them in struct ufs_mtk_clk. ··· 954 837 host->mclk.ufs_sel_min_clki = clki; 955 838 clk_disable_unprepare(clki->clk); 956 839 list_del(&clki->list); 840 + } else if (!strcmp(clki->name, "ufs_fde")) { 841 + host->mclk.ufs_fde_clki = clki; 842 + } else if (!strcmp(clki->name, "ufs_fde_max_src")) { 843 + host->mclk.ufs_fde_max_clki = clki; 844 + clk_disable_unprepare(clki->clk); 845 + list_del(&clki->list); 846 + } else if (!strcmp(clki->name, "ufs_fde_min_src")) { 847 + host->mclk.ufs_fde_min_clki = clki; 848 + clk_disable_unprepare(clki->clk); 849 + list_del(&clki->list); 957 850 } 958 851 } 959 852 960 - if (!mclk->ufs_sel_clki || !mclk->ufs_sel_max_clki || 961 - !mclk->ufs_sel_min_clki) { 853 + list_for_each_entry(clki, head, list) { 854 + dev_info(hba->dev, "clk \"%s\" present", clki->name); 855 + } 856 + 857 + if (!ufs_mtk_is_clk_scale_ready(hba)) { 962 858 hba->caps &= ~UFSHCD_CAP_CLK_SCALING; 963 859 dev_info(hba->dev, 964 860 "%s: Clk-scaling not ready. Feature disabled.", 965 861 __func__); 862 + return; 863 + } 864 + 865 + /* 866 + * Default get vcore if dts have these settings. 867 + * No matter clock scaling support or not. (may disable by customer) 868 + */ 869 + reg = devm_regulator_get_optional(dev, "dvfsrc-vcore"); 870 + if (IS_ERR(reg)) { 871 + dev_info(dev, "failed to get dvfsrc-vcore: %ld", 872 + PTR_ERR(reg)); 873 + return; 874 + } 875 + 876 + if (of_property_read_u32(dev->of_node, "clk-scale-up-vcore-min", 877 + &volt)) { 878 + dev_info(dev, "failed to get clk-scale-up-vcore-min"); 879 + return; 880 + } 881 + 882 + host->mclk.reg_vcore = reg; 883 + host->mclk.vcore_volt = volt; 884 + 885 + /* If default boot is max gear, request vcore */ 886 + if (reg && volt && host->clk_scale_up) { 887 + if (regulator_set_voltage(reg, volt, INT_MAX)) { 888 + dev_info(hba->dev, 889 + "Failed to set vcore to %d\n", volt); 890 + } 966 891 } 967 892 } 968 893 ··· 1173 1014 1174 1015 /* Enable clk scaling*/ 1175 1016 hba->caps |= UFSHCD_CAP_CLK_SCALING; 1017 + host->clk_scale_up = true; /* default is max freq */ 1176 1018 1177 1019 /* Set runtime pm delay to replace default */ 1178 1020 shost->rpm_autosuspend_delay = MTK_RPM_AUTOSUSPEND_DELAY_MS; 1179 1021 1180 1022 hba->quirks |= UFSHCI_QUIRK_SKIP_MANUAL_WB_FLUSH_CTRL; 1023 + 1181 1024 hba->quirks |= UFSHCD_QUIRK_MCQ_BROKEN_INTR; 1182 - hba->quirks |= UFSHCD_QUIRK_MCQ_BROKEN_RTC; 1025 + if (host->caps & UFS_MTK_CAP_MCQ_BROKEN_RTC) 1026 + hba->quirks |= UFSHCD_QUIRK_MCQ_BROKEN_RTC; 1027 + 1183 1028 hba->vps->wb_flush_threshold = UFS_WB_BUF_REMAIN_PERCENT(80); 1184 1029 1185 1030 if (host->caps & UFS_MTK_CAP_DISABLE_AH8) ··· 1213 1050 1214 1051 ufs_mtk_setup_clocks(hba, true, POST_CHANGE); 1215 1052 1216 - host->ip_ver = ufshcd_readl(hba, REG_UFS_MTK_IP_VER); 1053 + ufs_mtk_get_hw_ip_version(hba); 1217 1054 1218 1055 goto out; 1219 1056 ··· 1668 1505 { 1669 1506 struct ufs_dev_info *dev_info = &hba->dev_info; 1670 1507 u16 mid = dev_info->wmanufacturerid; 1508 + unsigned int cpu; 1509 + 1510 + if (hba->mcq_enabled) { 1511 + /* Iterate all cpus to set affinity for mcq irqs */ 1512 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) 1513 + ufs_mtk_mcq_set_irq_affinity(hba, cpu); 1514 + } 1671 1515 1672 1516 if (mid == UFS_VENDOR_SAMSUNG) { 1673 1517 ufshcd_dme_set(hba, UIC_ARG_MIB(PA_TACTIVATE), 6); ··· 1768 1598 hba->vps->ondemand_data.downdifferential = 20; 1769 1599 } 1770 1600 1601 + static void _ufs_mtk_clk_scale(struct ufs_hba *hba, bool scale_up) 1602 + { 1603 + struct ufs_mtk_host *host = ufshcd_get_variant(hba); 1604 + struct ufs_mtk_clk *mclk = &host->mclk; 1605 + struct ufs_clk_info *clki = mclk->ufs_sel_clki; 1606 + struct ufs_clk_info *fde_clki = mclk->ufs_fde_clki; 1607 + struct regulator *reg; 1608 + int volt, ret = 0; 1609 + bool clk_bind_vcore = false; 1610 + bool clk_fde_scale = false; 1611 + 1612 + if (!hba->clk_scaling.is_initialized) 1613 + return; 1614 + 1615 + if (!clki || !fde_clki) 1616 + return; 1617 + 1618 + reg = host->mclk.reg_vcore; 1619 + volt = host->mclk.vcore_volt; 1620 + if (reg && volt != 0) 1621 + clk_bind_vcore = true; 1622 + 1623 + if (mclk->ufs_fde_max_clki && mclk->ufs_fde_min_clki) 1624 + clk_fde_scale = true; 1625 + 1626 + ret = clk_prepare_enable(clki->clk); 1627 + if (ret) { 1628 + dev_info(hba->dev, 1629 + "clk_prepare_enable() fail, ret: %d\n", ret); 1630 + return; 1631 + } 1632 + 1633 + if (clk_fde_scale) { 1634 + ret = clk_prepare_enable(fde_clki->clk); 1635 + if (ret) { 1636 + dev_info(hba->dev, 1637 + "fde clk_prepare_enable() fail, ret: %d\n", ret); 1638 + return; 1639 + } 1640 + } 1641 + 1642 + if (scale_up) { 1643 + if (clk_bind_vcore) { 1644 + ret = regulator_set_voltage(reg, volt, INT_MAX); 1645 + if (ret) { 1646 + dev_info(hba->dev, 1647 + "Failed to set vcore to %d\n", volt); 1648 + goto out; 1649 + } 1650 + } 1651 + 1652 + ret = clk_set_parent(clki->clk, mclk->ufs_sel_max_clki->clk); 1653 + if (ret) { 1654 + dev_info(hba->dev, "Failed to set clk mux, ret = %d\n", 1655 + ret); 1656 + } 1657 + 1658 + if (clk_fde_scale) { 1659 + ret = clk_set_parent(fde_clki->clk, 1660 + mclk->ufs_fde_max_clki->clk); 1661 + if (ret) { 1662 + dev_info(hba->dev, 1663 + "Failed to set fde clk mux, ret = %d\n", 1664 + ret); 1665 + } 1666 + } 1667 + } else { 1668 + if (clk_fde_scale) { 1669 + ret = clk_set_parent(fde_clki->clk, 1670 + mclk->ufs_fde_min_clki->clk); 1671 + if (ret) { 1672 + dev_info(hba->dev, 1673 + "Failed to set fde clk mux, ret = %d\n", 1674 + ret); 1675 + goto out; 1676 + } 1677 + } 1678 + 1679 + ret = clk_set_parent(clki->clk, mclk->ufs_sel_min_clki->clk); 1680 + if (ret) { 1681 + dev_info(hba->dev, "Failed to set clk mux, ret = %d\n", 1682 + ret); 1683 + goto out; 1684 + } 1685 + 1686 + if (clk_bind_vcore) { 1687 + ret = regulator_set_voltage(reg, 0, INT_MAX); 1688 + if (ret) { 1689 + dev_info(hba->dev, 1690 + "failed to set vcore to MIN\n"); 1691 + } 1692 + } 1693 + } 1694 + 1695 + out: 1696 + clk_disable_unprepare(clki->clk); 1697 + 1698 + if (clk_fde_scale) 1699 + clk_disable_unprepare(fde_clki->clk); 1700 + } 1701 + 1771 1702 /** 1772 1703 * ufs_mtk_clk_scale - Internal clk scaling operation 1773 1704 * ··· 1886 1615 struct ufs_mtk_host *host = ufshcd_get_variant(hba); 1887 1616 struct ufs_mtk_clk *mclk = &host->mclk; 1888 1617 struct ufs_clk_info *clki = mclk->ufs_sel_clki; 1889 - int ret = 0; 1890 1618 1891 - ret = clk_prepare_enable(clki->clk); 1892 - if (ret) { 1893 - dev_info(hba->dev, 1894 - "clk_prepare_enable() fail, ret: %d\n", ret); 1895 - return; 1896 - } 1619 + if (host->clk_scale_up == scale_up) 1620 + goto out; 1897 1621 1898 - if (scale_up) { 1899 - ret = clk_set_parent(clki->clk, mclk->ufs_sel_max_clki->clk); 1622 + if (scale_up) 1623 + _ufs_mtk_clk_scale(hba, true); 1624 + else 1625 + _ufs_mtk_clk_scale(hba, false); 1626 + 1627 + host->clk_scale_up = scale_up; 1628 + 1629 + /* Must always set before clk_set_rate() */ 1630 + if (scale_up) 1900 1631 clki->curr_freq = clki->max_freq; 1901 - } else { 1902 - ret = clk_set_parent(clki->clk, mclk->ufs_sel_min_clki->clk); 1632 + else 1903 1633 clki->curr_freq = clki->min_freq; 1904 - } 1905 - 1906 - if (ret) { 1907 - dev_info(hba->dev, 1908 - "Failed to set ufs_sel_clki, ret: %d\n", ret); 1909 - } 1910 - 1911 - clk_disable_unprepare(clki->clk); 1912 - 1634 + out: 1913 1635 trace_ufs_mtk_clk_scale(clki->name, scale_up, clk_get_rate(clki->clk)); 1914 1636 } 1915 1637
+32
drivers/ufs/host/ufs-mediatek.h
··· 133 133 UFS_MTK_CAP_DISABLE_MCQ = 1 << 8, 134 134 /* Control MTCMOS with RTFF */ 135 135 UFS_MTK_CAP_RTFF_MTCMOS = 1 << 9, 136 + 137 + UFS_MTK_CAP_MCQ_BROKEN_RTC = 1 << 10, 136 138 }; 137 139 138 140 struct ufs_mtk_crypt_cfg { ··· 149 147 struct ufs_clk_info *ufs_sel_clki; /* Mux */ 150 148 struct ufs_clk_info *ufs_sel_max_clki; /* Max src */ 151 149 struct ufs_clk_info *ufs_sel_min_clki; /* Min src */ 150 + struct ufs_clk_info *ufs_fde_clki; /* Mux */ 151 + struct ufs_clk_info *ufs_fde_max_clki; /* Max src */ 152 + struct ufs_clk_info *ufs_fde_min_clki; /* Min src */ 153 + struct regulator *reg_vcore; 154 + int vcore_volt; 152 155 }; 153 156 154 157 struct ufs_mtk_hw_ver { ··· 183 176 bool mphy_powered_on; 184 177 bool unipro_lpm; 185 178 bool ref_clk_enabled; 179 + bool clk_scale_up; 186 180 u16 ref_clk_ungating_wait_us; 187 181 u16 ref_clk_gating_wait_us; 188 182 u32 ip_ver; 183 + bool legacy_ip_ver; 189 184 190 185 bool mcq_set_intr; 191 186 bool is_mcq_intr_enabled; ··· 200 191 201 192 /* MTK RTT support number */ 202 193 #define MTK_MAX_NUM_RTT 2 194 + 195 + /* UFSHCI MTK ip version value */ 196 + enum { 197 + /* UFSHCI 3.1 */ 198 + IP_VER_MT6983 = 0x10360000, 199 + IP_VER_MT6878 = 0x10420200, 200 + 201 + /* UFSHCI 4.0 */ 202 + IP_VER_MT6897 = 0x10440000, 203 + IP_VER_MT6989 = 0x10450000, 204 + IP_VER_MT6899 = 0x10450100, 205 + IP_VER_MT6991_A0 = 0x10460000, 206 + IP_VER_MT6991_B0 = 0x10470000, 207 + IP_VER_MT6993 = 0x10480000, 208 + 209 + IP_VER_NONE = 0xFFFFFFFF 210 + }; 211 + 212 + enum ip_ver_legacy { 213 + IP_LEGACY_VER_MT6781 = 0x10380000, 214 + IP_LEGACY_VER_MT6879 = 0x10360000, 215 + IP_LEGACY_VER_MT6893 = 0x20160706 216 + }; 203 217 204 218 #endif /* !_UFS_MEDIATEK_H */
-8
drivers/ufs/host/ufs-qcom.c
··· 1898 1898 return 0; 1899 1899 } 1900 1900 1901 - #if IS_ENABLED(CONFIG_DEVFREQ_GOV_SIMPLE_ONDEMAND) 1902 1901 static void ufs_qcom_config_scaling_param(struct ufs_hba *hba, 1903 1902 struct devfreq_dev_profile *p, 1904 1903 struct devfreq_simple_ondemand_data *d) ··· 1909 1910 1910 1911 hba->clk_scaling.suspend_on_no_request = true; 1911 1912 } 1912 - #else 1913 - static void ufs_qcom_config_scaling_param(struct ufs_hba *hba, 1914 - struct devfreq_dev_profile *p, 1915 - struct devfreq_simple_ondemand_data *data) 1916 - { 1917 - } 1918 - #endif 1919 1913 1920 1914 /* Resources */ 1921 1915 static const struct ufshcd_res_info ufs_res_info[RES_MAX] = {
+9 -24
drivers/ufs/host/ufshcd-pci.c
··· 22 22 23 23 #define MAX_SUPP_MAC 64 24 24 25 - struct ufs_host { 26 - void (*late_init)(struct ufs_hba *hba); 27 - }; 28 - 29 25 enum intel_ufs_dsm_func_id { 30 26 INTEL_DSM_FNS = 0, 31 27 INTEL_DSM_RESET = 1, 32 28 }; 33 29 34 30 struct intel_host { 35 - struct ufs_host ufs_host; 36 31 u32 dsm_fns; 37 32 u32 active_ltr; 38 33 u32 idle_ltr; ··· 403 408 return ufs_intel_common_init(hba); 404 409 } 405 410 406 - static void ufs_intel_lkf_late_init(struct ufs_hba *hba) 411 + static int ufs_intel_lkf_init(struct ufs_hba *hba) 407 412 { 413 + int err; 414 + 415 + hba->nop_out_timeout = 200; 416 + hba->quirks |= UFSHCD_QUIRK_BROKEN_AUTO_HIBERN8; 417 + hba->caps |= UFSHCD_CAP_CRYPTO; 418 + err = ufs_intel_common_init(hba); 408 419 /* LKF always needs a full reset, so set PM accordingly */ 409 420 if (hba->caps & UFSHCD_CAP_DEEPSLEEP) { 410 421 hba->spm_lvl = UFS_PM_LVL_6; ··· 419 418 hba->spm_lvl = UFS_PM_LVL_5; 420 419 hba->rpm_lvl = UFS_PM_LVL_5; 421 420 } 422 - } 423 - 424 - static int ufs_intel_lkf_init(struct ufs_hba *hba) 425 - { 426 - struct ufs_host *ufs_host; 427 - int err; 428 - 429 - hba->nop_out_timeout = 200; 430 - hba->quirks |= UFSHCD_QUIRK_BROKEN_AUTO_HIBERN8; 431 - hba->caps |= UFSHCD_CAP_CRYPTO; 432 - err = ufs_intel_common_init(hba); 433 - ufs_host = ufshcd_get_variant(hba); 434 - ufs_host->late_init = ufs_intel_lkf_late_init; 435 421 return err; 436 422 } 437 423 ··· 432 444 433 445 static int ufs_intel_mtl_init(struct ufs_hba *hba) 434 446 { 447 + hba->rpm_lvl = UFS_PM_LVL_2; 448 + hba->spm_lvl = UFS_PM_LVL_2; 435 449 hba->caps |= UFSHCD_CAP_CRYPTO | UFSHCD_CAP_WB_EN; 436 450 return ufs_intel_common_init(hba); 437 451 } ··· 564 574 static int 565 575 ufshcd_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) 566 576 { 567 - struct ufs_host *ufs_host; 568 577 struct ufs_hba *hba; 569 578 void __iomem *mmio_base; 570 579 int err; ··· 595 606 dev_err(&pdev->dev, "Initialization failed\n"); 596 607 return err; 597 608 } 598 - 599 - ufs_host = ufshcd_get_variant(hba); 600 - if (ufs_host && ufs_host->late_init) 601 - ufs_host->late_init(hba); 602 609 603 610 pm_runtime_put_noidle(&pdev->dev); 604 611 pm_runtime_allow(&pdev->dev);
+13 -78
include/scsi/sas_ata.h
··· 15 15 16 16 #ifdef CONFIG_SCSI_SAS_ATA 17 17 18 - static inline int dev_is_sata(struct domain_device *dev) 18 + static inline bool dev_is_sata(struct domain_device *dev) 19 19 { 20 - return dev->dev_type == SAS_SATA_DEV || dev->dev_type == SAS_SATA_PM || 21 - dev->dev_type == SAS_SATA_PM_PORT || dev->dev_type == SAS_SATA_PENDING; 20 + switch (dev->dev_type) { 21 + case SAS_SATA_DEV: 22 + case SAS_SATA_PENDING: 23 + case SAS_SATA_PM: 24 + case SAS_SATA_PM_PORT: 25 + return true; 26 + default: 27 + return false; 28 + } 22 29 } 23 30 24 - int sas_get_ata_info(struct domain_device *dev, struct ex_phy *phy); 25 - int sas_ata_init(struct domain_device *dev); 26 - void sas_ata_task_abort(struct sas_task *task); 27 - void sas_ata_strategy_handler(struct Scsi_Host *shost); 28 - void sas_ata_eh(struct Scsi_Host *shost, struct list_head *work_q); 29 31 void sas_ata_schedule_reset(struct domain_device *dev); 30 - void sas_ata_wait_eh(struct domain_device *dev); 31 - void sas_probe_sata(struct asd_sas_port *port); 32 - void sas_suspend_sata(struct asd_sas_port *port); 33 - void sas_resume_sata(struct asd_sas_port *port); 34 - void sas_ata_end_eh(struct ata_port *ap); 35 32 void sas_ata_device_link_abort(struct domain_device *dev, bool force_reset); 36 - int sas_execute_ata_cmd(struct domain_device *device, u8 *fis, 37 - int force_phy_id); 33 + int sas_execute_ata_cmd(struct domain_device *device, u8 *fis, int force_phy_id); 38 34 int smp_ata_check_ready_type(struct ata_link *link); 39 - int sas_discover_sata(struct domain_device *dev); 40 - int sas_ata_add_dev(struct domain_device *parent, struct ex_phy *phy, 41 - struct domain_device *child, int phy_id); 42 35 43 36 extern const struct attribute_group sas_ata_sdev_attr_group; 44 37 45 38 #else 46 39 47 - static inline void sas_ata_disabled_notice(void) 40 + static inline bool dev_is_sata(struct domain_device *dev) 48 41 { 49 - pr_notice_once("ATA device seen but CONFIG_SCSI_SAS_ATA=N\n"); 50 - } 51 - 52 - static inline int dev_is_sata(struct domain_device *dev) 53 - { 54 - return 0; 55 - } 56 - static inline int sas_ata_init(struct domain_device *dev) 57 - { 58 - return 0; 59 - } 60 - static inline void sas_ata_task_abort(struct sas_task *task) 61 - { 62 - } 63 - 64 - static inline void sas_ata_strategy_handler(struct Scsi_Host *shost) 65 - { 66 - } 67 - 68 - static inline void sas_ata_eh(struct Scsi_Host *shost, struct list_head *work_q) 69 - { 42 + return false; 70 43 } 71 44 72 45 static inline void sas_ata_schedule_reset(struct domain_device *dev) 73 - { 74 - } 75 - 76 - static inline void sas_ata_wait_eh(struct domain_device *dev) 77 - { 78 - } 79 - 80 - static inline void sas_probe_sata(struct asd_sas_port *port) 81 - { 82 - } 83 - 84 - static inline void sas_suspend_sata(struct asd_sas_port *port) 85 - { 86 - } 87 - 88 - static inline void sas_resume_sata(struct asd_sas_port *port) 89 - { 90 - } 91 - 92 - static inline int sas_get_ata_info(struct domain_device *dev, struct ex_phy *phy) 93 - { 94 - return 0; 95 - } 96 - 97 - static inline void sas_ata_end_eh(struct ata_port *ap) 98 46 { 99 47 } 100 48 ··· 60 112 static inline int smp_ata_check_ready_type(struct ata_link *link) 61 113 { 62 114 return 0; 63 - } 64 - 65 - static inline int sas_discover_sata(struct domain_device *dev) 66 - { 67 - sas_ata_disabled_notice(); 68 - return -ENXIO; 69 - } 70 - 71 - static inline int sas_ata_add_dev(struct domain_device *parent, struct ex_phy *phy, 72 - struct domain_device *child, int phy_id) 73 - { 74 - sas_ata_disabled_notice(); 75 - return -ENODEV; 76 115 } 77 116 78 117 #define sas_ata_sdev_attr_group ((struct attribute_group) {})