| .. | .. |
|---|
| 266 | 266 | int i; |
|---|
| 267 | 267 | void *next_uncached; |
|---|
| 268 | 268 | struct esas2r_request *first_request, *last_request; |
|---|
| 269 | + bool dma64 = false; |
|---|
| 269 | 270 | |
|---|
| 270 | 271 | if (index >= MAX_ADAPTERS) { |
|---|
| 271 | 272 | esas2r_log(ESAS2R_LOG_CRIT, |
|---|
| .. | .. |
|---|
| 286 | 287 | a->pcid = pcid; |
|---|
| 287 | 288 | a->host = host; |
|---|
| 288 | 289 | |
|---|
| 289 | | - if (sizeof(dma_addr_t) > 4) { |
|---|
| 290 | | - const uint64_t required_mask = dma_get_required_mask |
|---|
| 291 | | - (&pcid->dev); |
|---|
| 292 | | - if (required_mask > DMA_BIT_MASK(32) |
|---|
| 293 | | - && !pci_set_dma_mask(pcid, DMA_BIT_MASK(64)) |
|---|
| 294 | | - && !pci_set_consistent_dma_mask(pcid, |
|---|
| 295 | | - DMA_BIT_MASK(64))) { |
|---|
| 296 | | - esas2r_log_dev(ESAS2R_LOG_INFO, |
|---|
| 297 | | - &(a->pcid->dev), |
|---|
| 298 | | - "64-bit PCI addressing enabled\n"); |
|---|
| 299 | | - } else if (!pci_set_dma_mask(pcid, DMA_BIT_MASK(32)) |
|---|
| 300 | | - && !pci_set_consistent_dma_mask(pcid, |
|---|
| 301 | | - DMA_BIT_MASK(32))) { |
|---|
| 302 | | - esas2r_log_dev(ESAS2R_LOG_INFO, |
|---|
| 303 | | - &(a->pcid->dev), |
|---|
| 304 | | - "32-bit PCI addressing enabled\n"); |
|---|
| 305 | | - } else { |
|---|
| 306 | | - esas2r_log(ESAS2R_LOG_CRIT, |
|---|
| 307 | | - "failed to set DMA mask"); |
|---|
| 308 | | - esas2r_kill_adapter(index); |
|---|
| 309 | | - return 0; |
|---|
| 310 | | - } |
|---|
| 311 | | - } else { |
|---|
| 312 | | - if (!pci_set_dma_mask(pcid, DMA_BIT_MASK(32)) |
|---|
| 313 | | - && !pci_set_consistent_dma_mask(pcid, |
|---|
| 314 | | - DMA_BIT_MASK(32))) { |
|---|
| 315 | | - esas2r_log_dev(ESAS2R_LOG_INFO, |
|---|
| 316 | | - &(a->pcid->dev), |
|---|
| 317 | | - "32-bit PCI addressing enabled\n"); |
|---|
| 318 | | - } else { |
|---|
| 319 | | - esas2r_log(ESAS2R_LOG_CRIT, |
|---|
| 320 | | - "failed to set DMA mask"); |
|---|
| 321 | | - esas2r_kill_adapter(index); |
|---|
| 322 | | - return 0; |
|---|
| 323 | | - } |
|---|
| 290 | + if (sizeof(dma_addr_t) > 4 && |
|---|
| 291 | + dma_get_required_mask(&pcid->dev) > DMA_BIT_MASK(32) && |
|---|
| 292 | + !dma_set_mask_and_coherent(&pcid->dev, DMA_BIT_MASK(64))) |
|---|
| 293 | + dma64 = true; |
|---|
| 294 | + |
|---|
| 295 | + if (!dma64 && dma_set_mask_and_coherent(&pcid->dev, DMA_BIT_MASK(32))) { |
|---|
| 296 | + esas2r_log(ESAS2R_LOG_CRIT, "failed to set DMA mask"); |
|---|
| 297 | + esas2r_kill_adapter(index); |
|---|
| 298 | + return 0; |
|---|
| 324 | 299 | } |
|---|
| 300 | + |
|---|
| 301 | + esas2r_log_dev(ESAS2R_LOG_INFO, &pcid->dev, |
|---|
| 302 | + "%s-bit PCI addressing enabled\n", dma64 ? "64" : "32"); |
|---|
| 303 | + |
|---|
| 325 | 304 | esas2r_adapters[index] = a; |
|---|
| 326 | 305 | sprintf(a->name, ESAS2R_DRVR_NAME "_%02d", index); |
|---|
| 327 | 306 | esas2r_debug("new adapter %p, name %s", a, a->name); |
|---|
| .. | .. |
|---|
| 783 | 762 | |
|---|
| 784 | 763 | static void esas2r_init_pci_cfg_space(struct esas2r_adapter *a) |
|---|
| 785 | 764 | { |
|---|
| 786 | | - int pcie_cap_reg; |
|---|
| 787 | | - |
|---|
| 788 | | - pcie_cap_reg = pci_find_capability(a->pcid, PCI_CAP_ID_EXP); |
|---|
| 789 | | - if (pcie_cap_reg) { |
|---|
| 765 | + if (pci_is_pcie(a->pcid)) { |
|---|
| 790 | 766 | u16 devcontrol; |
|---|
| 791 | 767 | |
|---|
| 792 | | - pci_read_config_word(a->pcid, pcie_cap_reg + PCI_EXP_DEVCTL, |
|---|
| 793 | | - &devcontrol); |
|---|
| 768 | + pcie_capability_read_word(a->pcid, PCI_EXP_DEVCTL, &devcontrol); |
|---|
| 794 | 769 | |
|---|
| 795 | 770 | if ((devcontrol & PCI_EXP_DEVCTL_READRQ) > |
|---|
| 796 | 771 | PCI_EXP_DEVCTL_READRQ_512B) { |
|---|
| .. | .. |
|---|
| 799 | 774 | |
|---|
| 800 | 775 | devcontrol &= ~PCI_EXP_DEVCTL_READRQ; |
|---|
| 801 | 776 | devcontrol |= PCI_EXP_DEVCTL_READRQ_512B; |
|---|
| 802 | | - pci_write_config_word(a->pcid, |
|---|
| 803 | | - pcie_cap_reg + PCI_EXP_DEVCTL, |
|---|
| 804 | | - devcontrol); |
|---|
| 777 | + pcie_capability_write_word(a->pcid, PCI_EXP_DEVCTL, |
|---|
| 778 | + devcontrol); |
|---|
| 805 | 779 | } |
|---|
| 806 | 780 | } |
|---|
| 807 | 781 | } |
|---|
| .. | .. |
|---|
| 1262 | 1236 | a->init_msg = ESAS2R_INIT_MSG_GET_INIT; |
|---|
| 1263 | 1237 | break; |
|---|
| 1264 | 1238 | } |
|---|
| 1239 | + fallthrough; |
|---|
| 1265 | 1240 | |
|---|
| 1266 | 1241 | case ESAS2R_INIT_MSG_GET_INIT: |
|---|
| 1267 | 1242 | if (msg == ESAS2R_INIT_MSG_GET_INIT) { |
|---|
| .. | .. |
|---|
| 1275 | 1250 | esas2r_hdebug("FAILED"); |
|---|
| 1276 | 1251 | } |
|---|
| 1277 | 1252 | } |
|---|
| 1278 | | - /* fall through */ |
|---|
| 1253 | + fallthrough; |
|---|
| 1279 | 1254 | |
|---|
| 1280 | 1255 | default: |
|---|
| 1281 | 1256 | rq->req_stat = RS_SUCCESS; |
|---|