| .. | .. |
|---|
| 1 | 1 | // SPDX-License-Identifier: GPL-2.0 |
|---|
| 2 | | -/** |
|---|
| 2 | +/* |
|---|
| 3 | 3 | * xhci-dbc.c - xHCI debug capability early driver |
|---|
| 4 | 4 | * |
|---|
| 5 | 5 | * Copyright (C) 2016 Intel Corporation |
|---|
| .. | .. |
|---|
| 12 | 12 | #include <linux/console.h> |
|---|
| 13 | 13 | #include <linux/pci_regs.h> |
|---|
| 14 | 14 | #include <linux/pci_ids.h> |
|---|
| 15 | | -#include <linux/bootmem.h> |
|---|
| 15 | +#include <linux/memblock.h> |
|---|
| 16 | 16 | #include <linux/io.h> |
|---|
| 17 | 17 | #include <asm/pci-direct.h> |
|---|
| 18 | 18 | #include <asm/fixmap.h> |
|---|
| 19 | 19 | #include <linux/bcd.h> |
|---|
| 20 | 20 | #include <linux/export.h> |
|---|
| 21 | | -#include <linux/version.h> |
|---|
| 22 | 21 | #include <linux/module.h> |
|---|
| 23 | 22 | #include <linux/delay.h> |
|---|
| 24 | 23 | #include <linux/kthread.h> |
|---|
| 24 | +#include <linux/usb/xhci-dbgp.h> |
|---|
| 25 | 25 | |
|---|
| 26 | 26 | #include "../host/xhci.h" |
|---|
| 27 | 27 | #include "xhci-dbc.h" |
|---|
| .. | .. |
|---|
| 94 | 94 | { |
|---|
| 95 | 95 | void *virt; |
|---|
| 96 | 96 | |
|---|
| 97 | | - virt = alloc_bootmem_pages_nopanic(PAGE_SIZE); |
|---|
| 97 | + virt = memblock_alloc(PAGE_SIZE, PAGE_SIZE); |
|---|
| 98 | 98 | if (!virt) |
|---|
| 99 | 99 | return NULL; |
|---|
| 100 | 100 | |
|---|
| .. | .. |
|---|
| 135 | 135 | { |
|---|
| 136 | 136 | u32 result; |
|---|
| 137 | 137 | |
|---|
| 138 | + /* Can not use readl_poll_timeout_atomic() for early boot things */ |
|---|
| 138 | 139 | do { |
|---|
| 139 | 140 | result = readl(ptr); |
|---|
| 140 | 141 | result &= mask; |
|---|
| .. | .. |
|---|
| 191 | 192 | if (!seg) |
|---|
| 192 | 193 | return; |
|---|
| 193 | 194 | |
|---|
| 194 | | - free_bootmem(seg->dma, PAGE_SIZE); |
|---|
| 195 | + memblock_free(seg->dma, PAGE_SIZE); |
|---|
| 195 | 196 | ring->segment = NULL; |
|---|
| 196 | 197 | } |
|---|
| 197 | 198 | |
|---|
| .. | .. |
|---|
| 533 | 534 | |
|---|
| 534 | 535 | xdbc_mem_init(); |
|---|
| 535 | 536 | |
|---|
| 536 | | - mmiowb(); |
|---|
| 537 | | - |
|---|
| 538 | 537 | ret = xdbc_start(); |
|---|
| 539 | 538 | if (ret < 0) |
|---|
| 540 | 539 | goto reset_out; |
|---|
| .. | .. |
|---|
| 586 | 585 | return ret; |
|---|
| 587 | 586 | |
|---|
| 588 | 587 | xdbc_mem_init(); |
|---|
| 589 | | - |
|---|
| 590 | | - mmiowb(); |
|---|
| 591 | 588 | |
|---|
| 592 | 589 | ret = xdbc_start(); |
|---|
| 593 | 590 | if (ret < 0) { |
|---|
| .. | .. |
|---|
| 675 | 672 | xdbc_free_ring(&xdbc.in_ring); |
|---|
| 676 | 673 | |
|---|
| 677 | 674 | if (xdbc.table_dma) |
|---|
| 678 | | - free_bootmem(xdbc.table_dma, PAGE_SIZE); |
|---|
| 675 | + memblock_free(xdbc.table_dma, PAGE_SIZE); |
|---|
| 679 | 676 | |
|---|
| 680 | 677 | if (xdbc.out_dma) |
|---|
| 681 | | - free_bootmem(xdbc.out_dma, PAGE_SIZE); |
|---|
| 678 | + memblock_free(xdbc.out_dma, PAGE_SIZE); |
|---|
| 682 | 679 | |
|---|
| 683 | 680 | xdbc.table_base = NULL; |
|---|
| 684 | 681 | xdbc.out_buf = NULL; |
|---|
| .. | .. |
|---|
| 717 | 714 | |
|---|
| 718 | 715 | static void xdbc_handle_tx_event(struct xdbc_trb *evt_trb) |
|---|
| 719 | 716 | { |
|---|
| 720 | | - size_t remain_length; |
|---|
| 721 | 717 | u32 comp_code; |
|---|
| 722 | 718 | int ep_id; |
|---|
| 723 | 719 | |
|---|
| 724 | 720 | comp_code = GET_COMP_CODE(le32_to_cpu(evt_trb->field[2])); |
|---|
| 725 | | - remain_length = EVENT_TRB_LEN(le32_to_cpu(evt_trb->field[2])); |
|---|
| 726 | 721 | ep_id = TRB_TO_EP_ID(le32_to_cpu(evt_trb->field[3])); |
|---|
| 727 | 722 | |
|---|
| 728 | 723 | switch (comp_code) { |
|---|
| 729 | 724 | case COMP_SUCCESS: |
|---|
| 730 | | - remain_length = 0; |
|---|
| 731 | 725 | case COMP_SHORT_PACKET: |
|---|
| 732 | 726 | break; |
|---|
| 733 | 727 | case COMP_TRB_ERROR: |
|---|
| .. | .. |
|---|
| 978 | 972 | goto free_and_quit; |
|---|
| 979 | 973 | } |
|---|
| 980 | 974 | |
|---|
| 981 | | - base = ioremap_nocache(xdbc.xhci_start, xdbc.xhci_length); |
|---|
| 975 | + base = ioremap(xdbc.xhci_start, xdbc.xhci_length); |
|---|
| 982 | 976 | if (!base) { |
|---|
| 983 | 977 | xdbc_trace("failed to remap the io address\n"); |
|---|
| 984 | 978 | ret = -ENOMEM; |
|---|
| .. | .. |
|---|
| 1000 | 994 | xdbc_free_ring(&xdbc.evt_ring); |
|---|
| 1001 | 995 | xdbc_free_ring(&xdbc.out_ring); |
|---|
| 1002 | 996 | xdbc_free_ring(&xdbc.in_ring); |
|---|
| 1003 | | - free_bootmem(xdbc.table_dma, PAGE_SIZE); |
|---|
| 1004 | | - free_bootmem(xdbc.out_dma, PAGE_SIZE); |
|---|
| 997 | + memblock_free(xdbc.table_dma, PAGE_SIZE); |
|---|
| 998 | + memblock_free(xdbc.out_dma, PAGE_SIZE); |
|---|
| 1005 | 999 | writel(0, &xdbc.xdbc_reg->control); |
|---|
| 1006 | 1000 | early_iounmap(xdbc.xhci_base, xdbc.xhci_length); |
|---|
| 1007 | 1001 | |
|---|