.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * Huawei HiNIC PCI Express Linux driver |
---|
3 | 4 | * Copyright(c) 2017 Huawei Technologies Co., Ltd |
---|
4 | | - * |
---|
5 | | - * This program is free software; you can redistribute it and/or modify it |
---|
6 | | - * under the terms and conditions of the GNU General Public License, |
---|
7 | | - * version 2, as published by the Free Software Foundation. |
---|
8 | | - * |
---|
9 | | - * This program is distributed in the hope it will be useful, but WITHOUT |
---|
10 | | - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
---|
11 | | - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
---|
12 | | - * for more details. |
---|
13 | | - * |
---|
14 | 5 | */ |
---|
15 | 6 | |
---|
16 | 7 | #include <linux/kernel.h> |
---|
.. | .. |
---|
121 | 112 | return HINIC_API_CMD_STATUS_GET(val, CONS_IDX); |
---|
122 | 113 | } |
---|
123 | 114 | |
---|
| 115 | +static void dump_api_chain_reg(struct hinic_api_cmd_chain *chain) |
---|
| 116 | +{ |
---|
| 117 | + u32 addr, val; |
---|
| 118 | + |
---|
| 119 | + addr = HINIC_CSR_API_CMD_STATUS_ADDR(chain->chain_type); |
---|
| 120 | + val = hinic_hwif_read_reg(chain->hwif, addr); |
---|
| 121 | + |
---|
| 122 | + dev_err(&chain->hwif->pdev->dev, "Chain type: 0x%x, cpld error: 0x%x, check error: 0x%x, current fsm: 0x%x\n", |
---|
| 123 | + chain->chain_type, HINIC_API_CMD_STATUS_GET(val, CPLD_ERR), |
---|
| 124 | + HINIC_API_CMD_STATUS_GET(val, CHKSUM_ERR), |
---|
| 125 | + HINIC_API_CMD_STATUS_GET(val, FSM)); |
---|
| 126 | + |
---|
| 127 | + dev_err(&chain->hwif->pdev->dev, "Chain hw current ci: 0x%x\n", |
---|
| 128 | + HINIC_API_CMD_STATUS_GET(val, CONS_IDX)); |
---|
| 129 | + |
---|
| 130 | + addr = HINIC_CSR_API_CMD_CHAIN_PI_ADDR(chain->chain_type); |
---|
| 131 | + val = hinic_hwif_read_reg(chain->hwif, addr); |
---|
| 132 | + dev_err(&chain->hwif->pdev->dev, "Chain hw current pi: 0x%x\n", val); |
---|
| 133 | +} |
---|
| 134 | + |
---|
124 | 135 | /** |
---|
125 | 136 | * chain_busy - check if the chain is still processing last requests |
---|
126 | 137 | * @chain: chain to check |
---|
.. | .. |
---|
140 | 151 | |
---|
141 | 152 | /* check for a space for a new command */ |
---|
142 | 153 | if (chain->cons_idx == MASKED_IDX(chain, prod_idx + 1)) { |
---|
143 | | - dev_err(&pdev->dev, "API CMD chain %d is busy\n", |
---|
144 | | - chain->chain_type); |
---|
| 154 | + dev_err(&pdev->dev, "API CMD chain %d is busy, cons_idx: %d, prod_idx: %d\n", |
---|
| 155 | + chain->chain_type, chain->cons_idx, |
---|
| 156 | + chain->prod_idx); |
---|
| 157 | + dump_api_chain_reg(chain); |
---|
145 | 158 | return -EBUSY; |
---|
146 | 159 | } |
---|
147 | 160 | break; |
---|
.. | .. |
---|
341 | 354 | err = wait_for_status_poll(chain); |
---|
342 | 355 | if (err) { |
---|
343 | 356 | dev_err(&pdev->dev, "API CMD Poll status timeout\n"); |
---|
| 357 | + dump_api_chain_reg(chain); |
---|
344 | 358 | break; |
---|
345 | 359 | } |
---|
346 | 360 | break; |
---|
.. | .. |
---|
359 | 373 | * @chain: chain for the command |
---|
360 | 374 | * @dest: destination node on the card that will receive the command |
---|
361 | 375 | * @cmd: command data |
---|
362 | | - * @size: the command size |
---|
| 376 | + * @cmd_size: the command size |
---|
363 | 377 | * |
---|
364 | 378 | * Return 0 - Success, negative - Failure |
---|
365 | 379 | **/ |
---|
.. | .. |
---|
613 | 627 | u8 *cmd_vaddr; |
---|
614 | 628 | int err = 0; |
---|
615 | 629 | |
---|
616 | | - cmd_vaddr = dma_zalloc_coherent(&pdev->dev, API_CMD_BUF_SIZE, |
---|
617 | | - &cmd_paddr, GFP_KERNEL); |
---|
| 630 | + cmd_vaddr = dma_alloc_coherent(&pdev->dev, API_CMD_BUF_SIZE, |
---|
| 631 | + &cmd_paddr, GFP_KERNEL); |
---|
618 | 632 | if (!cmd_vaddr) { |
---|
619 | 633 | dev_err(&pdev->dev, "Failed to allocate API CMD DMA memory\n"); |
---|
620 | 634 | return -ENOMEM; |
---|
.. | .. |
---|
663 | 677 | dma_addr_t node_paddr; |
---|
664 | 678 | int err; |
---|
665 | 679 | |
---|
666 | | - node = dma_zalloc_coherent(&pdev->dev, chain->cell_size, |
---|
667 | | - &node_paddr, GFP_KERNEL); |
---|
| 680 | + node = dma_alloc_coherent(&pdev->dev, chain->cell_size, &node_paddr, |
---|
| 681 | + GFP_KERNEL); |
---|
668 | 682 | if (!node) { |
---|
669 | 683 | dev_err(&pdev->dev, "Failed to allocate dma API CMD cell\n"); |
---|
670 | 684 | return -ENOMEM; |
---|
.. | .. |
---|
804 | 818 | { |
---|
805 | 819 | struct hinic_hwif *hwif = attr->hwif; |
---|
806 | 820 | struct pci_dev *pdev = hwif->pdev; |
---|
807 | | - size_t cell_ctxt_size; |
---|
808 | 821 | |
---|
809 | 822 | chain->hwif = hwif; |
---|
810 | 823 | chain->chain_type = attr->chain_type; |
---|
.. | .. |
---|
816 | 829 | |
---|
817 | 830 | sema_init(&chain->sem, 1); |
---|
818 | 831 | |
---|
819 | | - cell_ctxt_size = chain->num_cells * sizeof(*chain->cell_ctxt); |
---|
820 | | - chain->cell_ctxt = devm_kzalloc(&pdev->dev, cell_ctxt_size, GFP_KERNEL); |
---|
| 832 | + chain->cell_ctxt = devm_kcalloc(&pdev->dev, chain->num_cells, |
---|
| 833 | + sizeof(*chain->cell_ctxt), GFP_KERNEL); |
---|
821 | 834 | if (!chain->cell_ctxt) |
---|
822 | 835 | return -ENOMEM; |
---|
823 | 836 | |
---|
824 | | - chain->wb_status = dma_zalloc_coherent(&pdev->dev, |
---|
825 | | - sizeof(*chain->wb_status), |
---|
826 | | - &chain->wb_status_paddr, |
---|
827 | | - GFP_KERNEL); |
---|
| 837 | + chain->wb_status = dma_alloc_coherent(&pdev->dev, |
---|
| 838 | + sizeof(*chain->wb_status), |
---|
| 839 | + &chain->wb_status_paddr, |
---|
| 840 | + GFP_KERNEL); |
---|
828 | 841 | if (!chain->wb_status) { |
---|
829 | 842 | dev_err(&pdev->dev, "Failed to allocate DMA wb status\n"); |
---|
830 | 843 | return -ENOMEM; |
---|