Merge "usb: host: xhci: Remove helper API retuning dcba dma address"
This commit is contained in:
commit
63dbbf58d1
6 changed files with 26 additions and 87 deletions
|
@ -2241,17 +2241,6 @@ usb_hcd_get_sec_event_ring_dma_addr(struct usb_device *udev,
|
|||
return hcd->driver->get_sec_event_ring_dma_addr(hcd, intr_num);
|
||||
}
|
||||
|
||||
dma_addr_t
|
||||
usb_hcd_get_dcba_dma_addr(struct usb_device *udev)
|
||||
{
|
||||
struct usb_hcd *hcd = bus_to_hcd(udev->bus);
|
||||
|
||||
if (!HCD_RH_RUNNING(hcd))
|
||||
return 0;
|
||||
|
||||
return hcd->driver->get_dcba_dma_addr(hcd, udev);
|
||||
}
|
||||
|
||||
dma_addr_t
|
||||
usb_hcd_get_xfer_ring_dma_addr(struct usb_device *udev,
|
||||
struct usb_host_endpoint *ep)
|
||||
|
|
|
@ -697,16 +697,6 @@ usb_get_sec_event_ring_dma_addr(struct usb_device *dev,
|
|||
}
|
||||
EXPORT_SYMBOL(usb_get_sec_event_ring_dma_addr);
|
||||
|
||||
dma_addr_t
|
||||
usb_get_dcba_dma_addr(struct usb_device *dev)
|
||||
{
|
||||
if (dev->state == USB_STATE_NOTATTACHED)
|
||||
return 0;
|
||||
|
||||
return usb_hcd_get_dcba_dma_addr(dev);
|
||||
}
|
||||
EXPORT_SYMBOL(usb_get_dcba_dma_addr);
|
||||
|
||||
dma_addr_t usb_get_xfer_ring_dma_addr(struct usb_device *dev,
|
||||
struct usb_host_endpoint *ep)
|
||||
{
|
||||
|
|
|
@ -4995,17 +4995,6 @@ dma_addr_t xhci_get_sec_event_ring_dma_addr(struct usb_hcd *hcd,
|
|||
return 0;
|
||||
}
|
||||
|
||||
dma_addr_t xhci_get_dcba_dma_addr(struct usb_hcd *hcd,
|
||||
struct usb_device *udev)
|
||||
{
|
||||
struct xhci_hcd *xhci = hcd_to_xhci(hcd);
|
||||
|
||||
if (!(xhci->xhc_state & XHCI_STATE_HALTED) && xhci->dcbaa)
|
||||
return xhci->dcbaa->dev_context_ptrs[udev->slot_id];
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
dma_addr_t xhci_get_xfer_ring_dma_addr(struct usb_hcd *hcd,
|
||||
struct usb_device *udev, struct usb_host_endpoint *ep)
|
||||
{
|
||||
|
@ -5101,7 +5090,6 @@ static const struct hc_driver xhci_hc_driver = {
|
|||
.sec_event_ring_cleanup = xhci_sec_event_ring_cleanup,
|
||||
.get_sec_event_ring_dma_addr = xhci_get_sec_event_ring_dma_addr,
|
||||
.get_xfer_ring_dma_addr = xhci_get_xfer_ring_dma_addr,
|
||||
.get_dcba_dma_addr = xhci_get_dcba_dma_addr,
|
||||
.get_core_id = xhci_get_core_id,
|
||||
};
|
||||
|
||||
|
|
|
@ -752,7 +752,6 @@ extern int usb_sec_event_ring_cleanup(struct usb_device *dev,
|
|||
extern dma_addr_t
|
||||
usb_get_sec_event_ring_dma_addr(struct usb_device *dev,
|
||||
unsigned intr_num);
|
||||
extern dma_addr_t usb_get_dcba_dma_addr(struct usb_device *dev);
|
||||
extern dma_addr_t usb_get_xfer_ring_dma_addr(struct usb_device *dev,
|
||||
struct usb_host_endpoint *ep);
|
||||
extern int usb_get_controller_id(struct usb_device *dev);
|
||||
|
|
|
@ -403,8 +403,6 @@ struct hc_driver {
|
|||
unsigned intr_num);
|
||||
dma_addr_t (*get_xfer_ring_dma_addr)(struct usb_hcd *hcd,
|
||||
struct usb_device *udev, struct usb_host_endpoint *ep);
|
||||
dma_addr_t (*get_dcba_dma_addr)(struct usb_hcd *hcd,
|
||||
struct usb_device *udev);
|
||||
int (*get_core_id)(struct usb_hcd *hcd);
|
||||
};
|
||||
|
||||
|
@ -451,7 +449,6 @@ extern int usb_hcd_sec_event_ring_cleanup(struct usb_device *udev,
|
|||
extern dma_addr_t
|
||||
usb_hcd_get_sec_event_ring_dma_addr(struct usb_device *udev,
|
||||
unsigned intr_num);
|
||||
extern dma_addr_t usb_hcd_get_dcba_dma_addr(struct usb_device *udev);
|
||||
extern dma_addr_t
|
||||
usb_hcd_get_xfer_ring_dma_addr(struct usb_device *udev,
|
||||
struct usb_host_endpoint *ep);
|
||||
|
|
|
@ -46,8 +46,7 @@
|
|||
/* event ring iova base address */
|
||||
#define IOVA_BASE 0x1000
|
||||
|
||||
#define IOVA_DCBA_BASE 0x2000
|
||||
#define IOVA_XFER_RING_BASE (IOVA_DCBA_BASE + PAGE_SIZE * (SNDRV_CARDS + 1))
|
||||
#define IOVA_XFER_RING_BASE (IOVA_BASE + PAGE_SIZE * (SNDRV_CARDS + 1))
|
||||
#define IOVA_XFER_BUF_BASE (IOVA_XFER_RING_BASE + PAGE_SIZE * SNDRV_CARDS * 32)
|
||||
#define IOVA_XFER_RING_MAX (IOVA_XFER_BUF_BASE - PAGE_SIZE)
|
||||
#define IOVA_XFER_BUF_MAX (0xfffff000 - PAGE_SIZE)
|
||||
|
@ -84,8 +83,6 @@ struct uaudio_dev {
|
|||
unsigned int card_num;
|
||||
atomic_t in_use;
|
||||
struct kref kref;
|
||||
unsigned long dcba_iova;
|
||||
size_t dcba_size;
|
||||
wait_queue_head_t disconnect_wq;
|
||||
|
||||
/* interface specific */
|
||||
|
@ -102,9 +99,6 @@ struct uaudio_qmi_dev {
|
|||
struct iommu_domain *domain;
|
||||
|
||||
/* list to keep track of available iova */
|
||||
struct list_head dcba_list;
|
||||
size_t dcba_iova_size;
|
||||
unsigned long curr_dcba_iova;
|
||||
struct list_head xfer_ring_list;
|
||||
size_t xfer_ring_iova_size;
|
||||
unsigned long curr_xfer_ring_iova;
|
||||
|
@ -151,7 +145,6 @@ static struct msg_desc uaudio_stream_ind_desc = {
|
|||
|
||||
enum mem_type {
|
||||
MEM_EVENT_RING,
|
||||
MEM_DCBA,
|
||||
MEM_XFER_RING,
|
||||
MEM_XFER_BUF,
|
||||
};
|
||||
|
@ -177,6 +170,24 @@ enum usb_qmi_audio_format {
|
|||
USB_QMI_PCM_FORMAT_U32_BE,
|
||||
};
|
||||
|
||||
static enum usb_audio_device_speed_enum_v01
|
||||
get_speed_info(enum usb_device_speed udev_speed)
|
||||
{
|
||||
switch (udev_speed) {
|
||||
case USB_SPEED_LOW:
|
||||
return USB_AUDIO_DEVICE_SPEED_LOW_V01;
|
||||
case USB_SPEED_FULL:
|
||||
return USB_AUDIO_DEVICE_SPEED_FULL_V01;
|
||||
case USB_SPEED_HIGH:
|
||||
return USB_AUDIO_DEVICE_SPEED_HIGH_V01;
|
||||
case USB_SPEED_SUPER:
|
||||
return USB_AUDIO_DEVICE_SPEED_SUPER_V01;
|
||||
default:
|
||||
pr_err("%s: udev speed %d\n", __func__, udev_speed);
|
||||
return USB_AUDIO_DEVICE_SPEED_INVALID_V01;
|
||||
}
|
||||
}
|
||||
|
||||
static unsigned long uaudio_get_iova(unsigned long *curr_iova,
|
||||
size_t *curr_iova_size, struct list_head *head, size_t size)
|
||||
{
|
||||
|
@ -276,10 +287,6 @@ static unsigned long uaudio_iommu_map(enum mem_type mtype, phys_addr_t pa,
|
|||
if (uaudio_qdev->er_phys_addr == pa)
|
||||
map = false;
|
||||
break;
|
||||
case MEM_DCBA:
|
||||
va = uaudio_get_iova(&uaudio_qdev->curr_dcba_iova,
|
||||
&uaudio_qdev->dcba_iova_size, &uaudio_qdev->dcba_list, size);
|
||||
break;
|
||||
case MEM_XFER_RING:
|
||||
va = uaudio_get_iova(&uaudio_qdev->curr_xfer_ring_iova,
|
||||
&uaudio_qdev->xfer_ring_iova_size, &uaudio_qdev->xfer_ring_list,
|
||||
|
@ -364,10 +371,7 @@ static void uaudio_iommu_unmap(enum mem_type mtype, unsigned long va,
|
|||
else
|
||||
unmap = false;
|
||||
break;
|
||||
case MEM_DCBA:
|
||||
uaudio_put_iova(va, size, &uaudio_qdev->dcba_list,
|
||||
&uaudio_qdev->dcba_iova_size);
|
||||
break;
|
||||
|
||||
case MEM_XFER_RING:
|
||||
uaudio_put_iova(va, size, &uaudio_qdev->xfer_ring_list,
|
||||
&uaudio_qdev->xfer_ring_iova_size);
|
||||
|
@ -409,8 +413,7 @@ static int prepare_qmi_response(struct snd_usb_substream *subs,
|
|||
void *hdr_ptr;
|
||||
u8 *xfer_buf;
|
||||
u32 len, mult, remainder, xfer_buf_len;
|
||||
unsigned long va, tr_data_va = 0, tr_sync_va = 0, dcba_va = 0,
|
||||
xfer_buf_va = 0;
|
||||
unsigned long va, tr_data_va = 0, tr_sync_va = 0, xfer_buf_va = 0;
|
||||
phys_addr_t xhci_pa, xfer_buf_pa;
|
||||
|
||||
iface = usb_ifnum_to_if(subs->dev, subs->interface);
|
||||
|
@ -589,33 +592,17 @@ skip_sync_ep:
|
|||
resp->xhci_mem_info.evt_ring.size = PAGE_SIZE;
|
||||
uaudio_qdev->er_phys_addr = xhci_pa;
|
||||
|
||||
/* dcba */
|
||||
xhci_pa = usb_get_dcba_dma_addr(subs->dev);
|
||||
if (!xhci_pa) {
|
||||
pr_err("%s:failed to get dcba dma address\n", __func__);
|
||||
resp->speed_info = get_speed_info(subs->dev->speed);
|
||||
if (resp->speed_info == USB_AUDIO_DEVICE_SPEED_INVALID_V01)
|
||||
goto unmap_er;
|
||||
}
|
||||
|
||||
if (!uadev[card_num].dcba_iova) { /* mappped per usb device */
|
||||
va = uaudio_iommu_map(MEM_DCBA, xhci_pa, PAGE_SIZE);
|
||||
if (!va)
|
||||
goto unmap_er;
|
||||
|
||||
uadev[card_num].dcba_iova = va;
|
||||
uadev[card_num].dcba_size = PAGE_SIZE;
|
||||
}
|
||||
|
||||
dcba_va = uadev[card_num].dcba_iova;
|
||||
resp->xhci_mem_info.dcba.va = PREPEND_SID_TO_IOVA(dcba_va,
|
||||
uaudio_qdev->sid);
|
||||
resp->xhci_mem_info.dcba.pa = xhci_pa;
|
||||
resp->xhci_mem_info.dcba.size = PAGE_SIZE;
|
||||
resp->speed_info_valid = 1;
|
||||
|
||||
/* data transfer ring */
|
||||
xhci_pa = resp->xhci_mem_info.tr_data.pa;
|
||||
va = uaudio_iommu_map(MEM_XFER_RING, xhci_pa, PAGE_SIZE);
|
||||
if (!va)
|
||||
goto unmap_dcba;
|
||||
goto unmap_er;
|
||||
|
||||
tr_data_va = va;
|
||||
resp->xhci_mem_info.tr_data.va = PREPEND_SID_TO_IOVA(va,
|
||||
|
@ -715,8 +702,6 @@ unmap_sync:
|
|||
uaudio_iommu_unmap(MEM_XFER_RING, tr_sync_va, PAGE_SIZE);
|
||||
unmap_data:
|
||||
uaudio_iommu_unmap(MEM_XFER_RING, tr_data_va, PAGE_SIZE);
|
||||
unmap_dcba:
|
||||
uaudio_iommu_unmap(MEM_DCBA, dcba_va, PAGE_SIZE);
|
||||
unmap_er:
|
||||
uaudio_iommu_unmap(MEM_EVENT_RING, IOVA_BASE, PAGE_SIZE);
|
||||
err:
|
||||
|
@ -762,11 +747,6 @@ static void uaudio_dev_cleanup(struct uaudio_dev *dev)
|
|||
dev->info[if_idx].intf_num, dev->card_num);
|
||||
}
|
||||
|
||||
/* iommu_unmap dcba iova for a usb device */
|
||||
uaudio_iommu_unmap(MEM_DCBA, dev->dcba_iova, dev->dcba_size);
|
||||
|
||||
dev->dcba_iova = 0;
|
||||
dev->dcba_size = 0;
|
||||
dev->num_intf = 0;
|
||||
|
||||
/* free interface info */
|
||||
|
@ -1236,11 +1216,7 @@ static int uaudio_qmi_plat_probe(struct platform_device *pdev)
|
|||
goto free_domain;
|
||||
}
|
||||
|
||||
/* initialize dcba, xfer ring and xfer buf iova list */
|
||||
INIT_LIST_HEAD(&uaudio_qdev->dcba_list);
|
||||
uaudio_qdev->curr_dcba_iova = IOVA_DCBA_BASE;
|
||||
uaudio_qdev->dcba_iova_size = SNDRV_CARDS * PAGE_SIZE;
|
||||
|
||||
/* initialize xfer ring and xfer buf iova list */
|
||||
INIT_LIST_HEAD(&uaudio_qdev->xfer_ring_list);
|
||||
uaudio_qdev->curr_xfer_ring_iova = IOVA_XFER_RING_BASE;
|
||||
uaudio_qdev->xfer_ring_iova_size =
|
||||
|
|
Loading…
Add table
Reference in a new issue