| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * Copyright (C) 2005 - 2016 Broadcom |
|---|
| 3 | 4 | * All rights reserved. |
|---|
| 4 | | - * |
|---|
| 5 | | - * This program is free software; you can redistribute it and/or |
|---|
| 6 | | - * modify it under the terms of the GNU General Public License version 2 |
|---|
| 7 | | - * as published by the Free Software Foundation. The full GNU General |
|---|
| 8 | | - * Public License is included in this distribution in the file called COPYING. |
|---|
| 9 | 5 | * |
|---|
| 10 | 6 | * Contact Information: |
|---|
| 11 | 7 | * linux-drivers@emulex.com |
|---|
| .. | .. |
|---|
| 1808 | 1804 | total_size = buf_len; |
|---|
| 1809 | 1805 | |
|---|
| 1810 | 1806 | get_fat_cmd.size = sizeof(struct be_cmd_req_get_fat) + 60*1024; |
|---|
| 1811 | | - get_fat_cmd.va = dma_zalloc_coherent(&adapter->pdev->dev, |
|---|
| 1812 | | - get_fat_cmd.size, |
|---|
| 1813 | | - &get_fat_cmd.dma, GFP_ATOMIC); |
|---|
| 1807 | + get_fat_cmd.va = dma_alloc_coherent(&adapter->pdev->dev, |
|---|
| 1808 | + get_fat_cmd.size, |
|---|
| 1809 | + &get_fat_cmd.dma, GFP_ATOMIC); |
|---|
| 1814 | 1810 | if (!get_fat_cmd.va) |
|---|
| 1815 | 1811 | return -ENOMEM; |
|---|
| 1816 | 1812 | |
|---|
| .. | .. |
|---|
| 2291 | 2287 | |
|---|
| 2292 | 2288 | /* Uses sync mcc */ |
|---|
| 2293 | 2289 | int be_cmd_read_port_transceiver_data(struct be_adapter *adapter, |
|---|
| 2294 | | - u8 page_num, u8 *data) |
|---|
| 2290 | + u8 page_num, u32 off, u32 len, u8 *data) |
|---|
| 2295 | 2291 | { |
|---|
| 2296 | 2292 | struct be_dma_mem cmd; |
|---|
| 2297 | 2293 | struct be_mcc_wrb *wrb; |
|---|
| .. | .. |
|---|
| 2302 | 2298 | return -EINVAL; |
|---|
| 2303 | 2299 | |
|---|
| 2304 | 2300 | cmd.size = sizeof(struct be_cmd_resp_port_type); |
|---|
| 2305 | | - cmd.va = dma_zalloc_coherent(&adapter->pdev->dev, cmd.size, &cmd.dma, |
|---|
| 2306 | | - GFP_ATOMIC); |
|---|
| 2301 | + cmd.va = dma_alloc_coherent(&adapter->pdev->dev, cmd.size, &cmd.dma, |
|---|
| 2302 | + GFP_ATOMIC); |
|---|
| 2307 | 2303 | if (!cmd.va) { |
|---|
| 2308 | 2304 | dev_err(&adapter->pdev->dev, "Memory allocation failed\n"); |
|---|
| 2309 | 2305 | return -ENOMEM; |
|---|
| .. | .. |
|---|
| 2325 | 2321 | req->port = cpu_to_le32(adapter->hba_port_num); |
|---|
| 2326 | 2322 | req->page_num = cpu_to_le32(page_num); |
|---|
| 2327 | 2323 | status = be_mcc_notify_wait(adapter); |
|---|
| 2328 | | - if (!status) { |
|---|
| 2324 | + if (!status && len > 0) { |
|---|
| 2329 | 2325 | struct be_cmd_resp_port_type *resp = cmd.va; |
|---|
| 2330 | 2326 | |
|---|
| 2331 | | - memcpy(data, resp->page_data, PAGE_DATA_LEN); |
|---|
| 2327 | + memcpy(data, resp->page_data + off, len); |
|---|
| 2332 | 2328 | } |
|---|
| 2333 | 2329 | err: |
|---|
| 2334 | 2330 | mutex_unlock(&adapter->mcc_lock); |
|---|
| .. | .. |
|---|
| 2419 | 2415 | int status; |
|---|
| 2420 | 2416 | |
|---|
| 2421 | 2417 | status = be_cmd_read_port_transceiver_data(adapter, TR_PAGE_A0, |
|---|
| 2422 | | - page_data); |
|---|
| 2418 | + 0, PAGE_DATA_LEN, page_data); |
|---|
| 2423 | 2419 | if (!status) { |
|---|
| 2424 | 2420 | switch (adapter->phy.interface_type) { |
|---|
| 2425 | 2421 | case PHY_TYPE_QSFP: |
|---|
| .. | .. |
|---|
| 2444 | 2440 | int status; |
|---|
| 2445 | 2441 | |
|---|
| 2446 | 2442 | status = be_cmd_read_port_transceiver_data(adapter, TR_PAGE_A0, |
|---|
| 2447 | | - page_data); |
|---|
| 2443 | + 0, PAGE_DATA_LEN, page_data); |
|---|
| 2448 | 2444 | if (!status) { |
|---|
| 2449 | 2445 | strlcpy(adapter->phy.vendor_name, page_data + |
|---|
| 2450 | 2446 | SFP_VENDOR_NAME_OFFSET, SFP_VENDOR_NAME_LEN - 1); |
|---|
| .. | .. |
|---|
| 2762 | 2758 | bool crc_match; |
|---|
| 2763 | 2759 | const u8 *p; |
|---|
| 2764 | 2760 | |
|---|
| 2765 | | - struct flash_comp gen3_flash_types[] = { |
|---|
| 2761 | + static const struct flash_comp gen3_flash_types[] = { |
|---|
| 2766 | 2762 | { BE3_ISCSI_PRIMARY_IMAGE_START, OPTYPE_ISCSI_ACTIVE, |
|---|
| 2767 | 2763 | BE3_COMP_MAX_SIZE, IMAGE_FIRMWARE_ISCSI}, |
|---|
| 2768 | 2764 | { BE3_REDBOOT_START, OPTYPE_REDBOOT, |
|---|
| .. | .. |
|---|
| 2785 | 2781 | BE3_PHY_FW_COMP_MAX_SIZE, IMAGE_FIRMWARE_PHY} |
|---|
| 2786 | 2782 | }; |
|---|
| 2787 | 2783 | |
|---|
| 2788 | | - struct flash_comp gen2_flash_types[] = { |
|---|
| 2784 | + static const struct flash_comp gen2_flash_types[] = { |
|---|
| 2789 | 2785 | { BE2_ISCSI_PRIMARY_IMAGE_START, OPTYPE_ISCSI_ACTIVE, |
|---|
| 2790 | 2786 | BE2_COMP_MAX_SIZE, IMAGE_FIRMWARE_ISCSI}, |
|---|
| 2791 | 2787 | { BE2_REDBOOT_START, OPTYPE_REDBOOT, |
|---|
| .. | .. |
|---|
| 3066 | 3062 | |
|---|
| 3067 | 3063 | flash_cmd.size = sizeof(struct lancer_cmd_req_write_object) |
|---|
| 3068 | 3064 | + LANCER_FW_DOWNLOAD_CHUNK; |
|---|
| 3069 | | - flash_cmd.va = dma_zalloc_coherent(dev, flash_cmd.size, |
|---|
| 3070 | | - &flash_cmd.dma, GFP_KERNEL); |
|---|
| 3065 | + flash_cmd.va = dma_alloc_coherent(dev, flash_cmd.size, &flash_cmd.dma, |
|---|
| 3066 | + GFP_KERNEL); |
|---|
| 3071 | 3067 | if (!flash_cmd.va) |
|---|
| 3072 | 3068 | return -ENOMEM; |
|---|
| 3073 | 3069 | |
|---|
| .. | .. |
|---|
| 3184 | 3180 | } |
|---|
| 3185 | 3181 | |
|---|
| 3186 | 3182 | flash_cmd.size = sizeof(struct be_cmd_write_flashrom); |
|---|
| 3187 | | - flash_cmd.va = dma_zalloc_coherent(dev, flash_cmd.size, &flash_cmd.dma, |
|---|
| 3188 | | - GFP_KERNEL); |
|---|
| 3183 | + flash_cmd.va = dma_alloc_coherent(dev, flash_cmd.size, &flash_cmd.dma, |
|---|
| 3184 | + GFP_KERNEL); |
|---|
| 3189 | 3185 | if (!flash_cmd.va) |
|---|
| 3190 | 3186 | return -ENOMEM; |
|---|
| 3191 | 3187 | |
|---|
| .. | .. |
|---|
| 3435 | 3431 | goto err; |
|---|
| 3436 | 3432 | } |
|---|
| 3437 | 3433 | cmd.size = sizeof(struct be_cmd_req_get_phy_info); |
|---|
| 3438 | | - cmd.va = dma_zalloc_coherent(&adapter->pdev->dev, cmd.size, &cmd.dma, |
|---|
| 3439 | | - GFP_ATOMIC); |
|---|
| 3434 | + cmd.va = dma_alloc_coherent(&adapter->pdev->dev, cmd.size, &cmd.dma, |
|---|
| 3435 | + GFP_ATOMIC); |
|---|
| 3440 | 3436 | if (!cmd.va) { |
|---|
| 3441 | 3437 | dev_err(&adapter->pdev->dev, "Memory alloc failure\n"); |
|---|
| 3442 | 3438 | status = -ENOMEM; |
|---|
| .. | .. |
|---|
| 3522 | 3518 | |
|---|
| 3523 | 3519 | memset(&attribs_cmd, 0, sizeof(struct be_dma_mem)); |
|---|
| 3524 | 3520 | attribs_cmd.size = sizeof(struct be_cmd_resp_cntl_attribs); |
|---|
| 3525 | | - attribs_cmd.va = dma_zalloc_coherent(&adapter->pdev->dev, |
|---|
| 3526 | | - attribs_cmd.size, |
|---|
| 3527 | | - &attribs_cmd.dma, GFP_ATOMIC); |
|---|
| 3521 | + attribs_cmd.va = dma_alloc_coherent(&adapter->pdev->dev, |
|---|
| 3522 | + attribs_cmd.size, |
|---|
| 3523 | + &attribs_cmd.dma, GFP_ATOMIC); |
|---|
| 3528 | 3524 | if (!attribs_cmd.va) { |
|---|
| 3529 | 3525 | dev_err(&adapter->pdev->dev, "Memory allocation failure\n"); |
|---|
| 3530 | 3526 | status = -ENOMEM; |
|---|
| .. | .. |
|---|
| 3699 | 3695 | |
|---|
| 3700 | 3696 | memset(&get_mac_list_cmd, 0, sizeof(struct be_dma_mem)); |
|---|
| 3701 | 3697 | get_mac_list_cmd.size = sizeof(struct be_cmd_resp_get_mac_list); |
|---|
| 3702 | | - get_mac_list_cmd.va = dma_zalloc_coherent(&adapter->pdev->dev, |
|---|
| 3703 | | - get_mac_list_cmd.size, |
|---|
| 3704 | | - &get_mac_list_cmd.dma, |
|---|
| 3705 | | - GFP_ATOMIC); |
|---|
| 3698 | + get_mac_list_cmd.va = dma_alloc_coherent(&adapter->pdev->dev, |
|---|
| 3699 | + get_mac_list_cmd.size, |
|---|
| 3700 | + &get_mac_list_cmd.dma, |
|---|
| 3701 | + GFP_ATOMIC); |
|---|
| 3706 | 3702 | |
|---|
| 3707 | 3703 | if (!get_mac_list_cmd.va) { |
|---|
| 3708 | 3704 | dev_err(&adapter->pdev->dev, |
|---|
| .. | .. |
|---|
| 3829 | 3825 | |
|---|
| 3830 | 3826 | memset(&cmd, 0, sizeof(struct be_dma_mem)); |
|---|
| 3831 | 3827 | cmd.size = sizeof(struct be_cmd_req_set_mac_list); |
|---|
| 3832 | | - cmd.va = dma_zalloc_coherent(&adapter->pdev->dev, cmd.size, &cmd.dma, |
|---|
| 3833 | | - GFP_KERNEL); |
|---|
| 3828 | + cmd.va = dma_alloc_coherent(&adapter->pdev->dev, cmd.size, &cmd.dma, |
|---|
| 3829 | + GFP_KERNEL); |
|---|
| 3834 | 3830 | if (!cmd.va) |
|---|
| 3835 | 3831 | return -ENOMEM; |
|---|
| 3836 | 3832 | |
|---|
| .. | .. |
|---|
| 4035 | 4031 | |
|---|
| 4036 | 4032 | memset(&cmd, 0, sizeof(struct be_dma_mem)); |
|---|
| 4037 | 4033 | cmd.size = sizeof(struct be_cmd_resp_acpi_wol_magic_config_v1); |
|---|
| 4038 | | - cmd.va = dma_zalloc_coherent(&adapter->pdev->dev, cmd.size, &cmd.dma, |
|---|
| 4039 | | - GFP_ATOMIC); |
|---|
| 4034 | + cmd.va = dma_alloc_coherent(&adapter->pdev->dev, cmd.size, &cmd.dma, |
|---|
| 4035 | + GFP_ATOMIC); |
|---|
| 4040 | 4036 | if (!cmd.va) { |
|---|
| 4041 | 4037 | dev_err(&adapter->pdev->dev, "Memory allocation failure\n"); |
|---|
| 4042 | 4038 | status = -ENOMEM; |
|---|
| .. | .. |
|---|
| 4089 | 4085 | |
|---|
| 4090 | 4086 | memset(&extfat_cmd, 0, sizeof(struct be_dma_mem)); |
|---|
| 4091 | 4087 | extfat_cmd.size = sizeof(struct be_cmd_resp_get_ext_fat_caps); |
|---|
| 4092 | | - extfat_cmd.va = dma_zalloc_coherent(&adapter->pdev->dev, |
|---|
| 4093 | | - extfat_cmd.size, &extfat_cmd.dma, |
|---|
| 4094 | | - GFP_ATOMIC); |
|---|
| 4088 | + extfat_cmd.va = dma_alloc_coherent(&adapter->pdev->dev, |
|---|
| 4089 | + extfat_cmd.size, &extfat_cmd.dma, |
|---|
| 4090 | + GFP_ATOMIC); |
|---|
| 4095 | 4091 | if (!extfat_cmd.va) |
|---|
| 4096 | 4092 | return -ENOMEM; |
|---|
| 4097 | 4093 | |
|---|
| .. | .. |
|---|
| 4127 | 4123 | |
|---|
| 4128 | 4124 | memset(&extfat_cmd, 0, sizeof(struct be_dma_mem)); |
|---|
| 4129 | 4125 | extfat_cmd.size = sizeof(struct be_cmd_resp_get_ext_fat_caps); |
|---|
| 4130 | | - extfat_cmd.va = dma_zalloc_coherent(&adapter->pdev->dev, |
|---|
| 4131 | | - extfat_cmd.size, &extfat_cmd.dma, |
|---|
| 4132 | | - GFP_ATOMIC); |
|---|
| 4126 | + extfat_cmd.va = dma_alloc_coherent(&adapter->pdev->dev, |
|---|
| 4127 | + extfat_cmd.size, &extfat_cmd.dma, |
|---|
| 4128 | + GFP_ATOMIC); |
|---|
| 4133 | 4129 | |
|---|
| 4134 | 4130 | if (!extfat_cmd.va) { |
|---|
| 4135 | 4131 | dev_err(&adapter->pdev->dev, "%s: Memory allocation failure\n", |
|---|
| .. | .. |
|---|
| 4354 | 4350 | |
|---|
| 4355 | 4351 | memset(&cmd, 0, sizeof(struct be_dma_mem)); |
|---|
| 4356 | 4352 | cmd.size = sizeof(struct be_cmd_resp_get_func_config); |
|---|
| 4357 | | - cmd.va = dma_zalloc_coherent(&adapter->pdev->dev, cmd.size, &cmd.dma, |
|---|
| 4358 | | - GFP_ATOMIC); |
|---|
| 4353 | + cmd.va = dma_alloc_coherent(&adapter->pdev->dev, cmd.size, &cmd.dma, |
|---|
| 4354 | + GFP_ATOMIC); |
|---|
| 4359 | 4355 | if (!cmd.va) { |
|---|
| 4360 | 4356 | dev_err(&adapter->pdev->dev, "Memory alloc failure\n"); |
|---|
| 4361 | 4357 | status = -ENOMEM; |
|---|
| .. | .. |
|---|
| 4452 | 4448 | |
|---|
| 4453 | 4449 | memset(&cmd, 0, sizeof(struct be_dma_mem)); |
|---|
| 4454 | 4450 | cmd.size = sizeof(struct be_cmd_resp_get_profile_config); |
|---|
| 4455 | | - cmd.va = dma_zalloc_coherent(&adapter->pdev->dev, cmd.size, &cmd.dma, |
|---|
| 4456 | | - GFP_ATOMIC); |
|---|
| 4451 | + cmd.va = dma_alloc_coherent(&adapter->pdev->dev, cmd.size, &cmd.dma, |
|---|
| 4452 | + GFP_ATOMIC); |
|---|
| 4457 | 4453 | if (!cmd.va) |
|---|
| 4458 | 4454 | return -ENOMEM; |
|---|
| 4459 | 4455 | |
|---|
| .. | .. |
|---|
| 4539 | 4535 | |
|---|
| 4540 | 4536 | memset(&cmd, 0, sizeof(struct be_dma_mem)); |
|---|
| 4541 | 4537 | cmd.size = sizeof(struct be_cmd_req_set_profile_config); |
|---|
| 4542 | | - cmd.va = dma_zalloc_coherent(&adapter->pdev->dev, cmd.size, &cmd.dma, |
|---|
| 4543 | | - GFP_ATOMIC); |
|---|
| 4538 | + cmd.va = dma_alloc_coherent(&adapter->pdev->dev, cmd.size, &cmd.dma, |
|---|
| 4539 | + GFP_ATOMIC); |
|---|
| 4544 | 4540 | if (!cmd.va) |
|---|
| 4545 | 4541 | return -ENOMEM; |
|---|
| 4546 | 4542 | |
|---|