mhi: core: Enable MHI for 64bit. Necessary Changes

Change-Id: I9ac7df3a6ecffaf78e23232ead005fba9eadc9c1

Signed-off-by: Andrei Danaila <adanaila@codeaurora.org>
This commit is contained in:
Andrei Danaila 2015-04-22 15:21:24 -07:00 committed by David Keitel
parent 9d5bf6cc71
commit 5c37a03e64
8 changed files with 32 additions and 40 deletions

View file

@ -22,7 +22,7 @@
#include <linux/spinlock.h>
#include <linux/sched.h>
#include <linux/cdev.h>
#include <mach/msm_pcie.h>
#include <linux/msm_pcie.h>
#include <linux/sched.h>
extern struct mhi_pcie_devices mhi_devices;

View file

@ -50,7 +50,7 @@ static ssize_t bhi_write(struct file *file,
wait_event_interruptible(*mhi_dev_ctxt->mhi_ev_wq.bhi_event,
mhi_dev_ctxt->mhi_state == MHI_STATE_BHI);
mhi_log(MHI_MSG_INFO, "Entered. User Image size 0x%x\n", count);
mhi_log(MHI_MSG_INFO, "Entered. User Image size 0x%zx\n", count);
bhi_ctxt->unaligned_image_loc = kmalloc(count + (align_len - 1),
GFP_KERNEL);
@ -185,7 +185,7 @@ int bhi_probe(struct mhi_pcie_dev_info *mhi_pcie_device)
mhi_log(MHI_MSG_CRITICAL,
"Failed to instantiate class %d\n",
ret_val);
r = (int)bhi_ctxt->bhi_class;
r = PTR_RET(bhi_ctxt->bhi_class);
goto err_class_create;
}
cdev_init(&bhi_ctxt->cdev, &bhi_fops);
@ -197,7 +197,7 @@ int bhi_probe(struct mhi_pcie_dev_info *mhi_pcie_device)
if (IS_ERR(bhi_ctxt->dev)) {
mhi_log(MHI_MSG_CRITICAL,
"Failed to add bhi cdev\n");
r = (int)bhi_ctxt->dev;
r = PTR_RET(bhi_ctxt->dev);
goto err_dev_create;
}
return 0;

View file

@ -19,6 +19,7 @@
#include <linux/delay.h>
#include <linux/debugfs.h>
#include <linux/pm_runtime.h>
#include <linux/interrupt.h>
#define CREATE_TRACE_POINTS
#include "mhi_trace.h"

View file

@ -215,8 +215,7 @@ static enum MHI_STATUS mhi_init_device_ctrl(struct mhi_device_ctxt
/* Calculate the size of the control segment needed */
ctrl_seg_size += align_len - (ctrl_seg_size % align_len);
ret_val = mhi_mallocmemregion(mhi_dev_ctxt->mhi_ctrl_seg_info,
ret_val = mhi_mallocmemregion(mhi_dev_ctxt, mhi_dev_ctxt->mhi_ctrl_seg_info,
ctrl_seg_size);
if (MHI_STATUS_SUCCESS != ret_val)
return MHI_STATUS_ERROR;
@ -309,12 +308,12 @@ static enum MHI_STATUS mhi_spawn_threads(struct mhi_device_ctxt *mhi_dev_ctxt)
mhi_dev_ctxt->event_thread_handle = kthread_run(parse_event_thread,
mhi_dev_ctxt,
"mhi_ev_thrd");
if (-ENOMEM == (int)mhi_dev_ctxt->event_thread_handle)
if (IS_ERR(mhi_dev_ctxt->event_thread_handle))
return MHI_STATUS_ERROR;
mhi_dev_ctxt->st_thread_handle = kthread_run(mhi_state_change_thread,
mhi_dev_ctxt,
"mhi_st_thrd");
if (-ENOMEM == (int)mhi_dev_ctxt->event_thread_handle)
if (IS_ERR(mhi_dev_ctxt->event_thread_handle))
return MHI_STATUS_ERROR;
return MHI_STATUS_SUCCESS;
}
@ -334,6 +333,7 @@ enum MHI_STATUS mhi_init_device_ctxt(struct mhi_pcie_dev_info *dev_info,
struct mhi_device_ctxt *mhi_dev_ctxt)
{
int r = 0;
if (NULL == dev_info || NULL == mhi_dev_ctxt)
return MHI_STATUS_ERROR;
mhi_log(MHI_MSG_VERBOSE, "mhi_init_device_ctxt>Init MHI dev ctxt\n");

View file

@ -84,10 +84,6 @@ int mhi_init_pcie_device(struct mhi_pcie_dev_info *mhi_pcie_dev)
ioremap_nocache(pci_resource_start(pcie_device, 0),
pci_resource_len(pcie_device, 0));
if (!mhi_pcie_dev->core.bar0_base) {
mhi_log(MHI_MSG_ERROR,
"Failed to map bar 0 addr 0x%x len 0x%x.\n",
pci_resource_start(pcie_device, 0),
pci_resource_len(pcie_device, 0));
goto mhi_device_list_error;
}
@ -97,10 +93,6 @@ int mhi_init_pcie_device(struct mhi_pcie_dev_info *mhi_pcie_dev)
ioremap_nocache(pci_resource_start(pcie_device, 2),
pci_resource_len(pcie_device, 2));
if (!mhi_pcie_dev->core.bar2_base) {
mhi_log(MHI_MSG_ERROR,
"Failed to map bar 2 addr 0x%x len 0x%x.\n",
pci_resource_start(pcie_device, 2),
pci_resource_len(pcie_device, 2));
goto io_map_err;
}
@ -149,7 +141,7 @@ static void mhi_move_interrupts(struct mhi_device_ctxt *mhi_dev_ctxt, u32 cpu)
int mhi_cpu_notifier_cb(struct notifier_block *nfb, unsigned long action,
void *hcpu)
{
u32 cpu = (u32)hcpu;
uintptr_t cpu = (uintptr_t)hcpu;
struct mhi_device_ctxt *mhi_dev_ctxt = container_of(nfb,
struct mhi_device_ctxt,
mhi_cpu_notifier);
@ -596,7 +588,7 @@ enum MHI_STATUS mhi_queue_xfer(struct mhi_client_handle *client_handle,
wmb();
mhi_log(MHI_MSG_VERBOSE,
"Channel %d Has buf size of %d and buf addr %lx, flags 0x%x\n",
"Channel %d Has buf size of %zd and buf addr %lx, flags 0x%x\n",
chan, buf_len, (uintptr_t)buf, mhi_flags);
/* Add the TRB to the correct transfer ring */

View file

@ -266,7 +266,8 @@ inline u64 mhi_get_memregion_len(struct mhi_meminfo *meminfo)
return meminfo->size;
}
enum MHI_STATUS mhi_mallocmemregion(struct mhi_meminfo *meminfo, size_t size)
enum MHI_STATUS mhi_mallocmemregion(struct mhi_device_ctxt *mhi_dev_ctxt,
struct mhi_meminfo *meminfo, size_t size)
{
meminfo->va_unaligned = (uintptr_t)dma_alloc_coherent(
meminfo->dev,

View file

@ -58,7 +58,8 @@ struct mhi_meminfo {
uintptr_t size;
};
enum MHI_STATUS mhi_mallocmemregion(struct mhi_meminfo *meminfo, size_t size);
enum MHI_STATUS mhi_mallocmemregion(struct mhi_device_ctxt *mhi_dev_ctxt,
struct mhi_meminfo *meminfo, size_t size);
uintptr_t mhi_get_phy_addr(struct mhi_meminfo *meminfo);
void *mhi_get_virt_addr(struct mhi_meminfo *meminfo);

View file

@ -268,8 +268,8 @@ static enum MHI_STATUS mhi_init_inbound(struct uci_client *client_handle,
i, chan_attributes->nr_trbs);
for (i = 0; i < chan_attributes->nr_trbs; ++i) {
data_loc = kmalloc(buf_size, GFP_KERNEL);
uci_log(UCI_DBG_INFO, "Allocated buffer %p size %d\n",
data_loc, buf_size);
uci_log(UCI_DBG_INFO, "Allocated buffer %p size %zd\n",
data_loc, buf_size);
if (data_loc == NULL)
return -ENOMEM;
dma_addr = dma_map_single(NULL, data_loc,
@ -329,7 +329,7 @@ static int mhi_uci_send_packet(struct mhi_client_handle **client_handle,
data_loc = kmalloc(data_to_insert_now, GFP_KERNEL);
if (NULL == data_loc) {
uci_log(UCI_DBG_ERROR,
"Failed to allocate memory 0x%x\n",
"Failed to allocate memory 0x%zx\n",
data_to_insert_now);
return -ENOMEM;
}
@ -670,8 +670,7 @@ static int mhi_uci_client_release(struct inode *mhi_inode,
uci_handle->in_buf_list[i],
buf_size,
DMA_FROM_DEVICE);
kfree(dma_to_virt(NULL,
uci_handle->in_buf_list[i]));
kfree((void *)uci_handle->in_buf_list[i]);
}
kfree(uci_handle->in_buf_list);
atomic_set(&uci_handle->avail_pkts, 0);
@ -721,14 +720,13 @@ static ssize_t mhi_uci_client_read(struct file *file, char __user *buf,
}
phy_buf = result.payload_buf;
if (phy_buf != 0)
uci_handle->pkt_loc = dma_to_virt(NULL,
phy_buf);
uci_handle->pkt_loc = (void *)phy_buf;
else
uci_handle->pkt_loc = 0;
uci_handle->pkt_size = result.bytes_xferd;
*bytes_pending = uci_handle->pkt_size;
uci_log(UCI_DBG_VERBOSE,
"Got pkt of size 0x%x at addr 0x%lx, chan %d\n",
"Got pkt of size 0x%zx at addr 0x%lx, chan %d\n",
uci_handle->pkt_size, (uintptr_t)phy_buf, chan);
dma_unmap_single(NULL, (dma_addr_t)phy_buf,
buf_size,
@ -798,7 +796,7 @@ static ssize_t mhi_uci_client_read(struct file *file, char __user *buf,
bytes_copied = *bytes_pending;
*bytes_pending = 0;
uci_log(UCI_DBG_VERBOSE,
"Copied 0x%x of 0x%x, chan %d\n",
"Copied 0x%zx of 0x%x, chan %d\n",
bytes_copied, (u32)*bytes_pending, chan);
} else {
addr_offset = uci_handle->pkt_size - *bytes_pending;
@ -812,7 +810,7 @@ static ssize_t mhi_uci_client_read(struct file *file, char __user *buf,
bytes_copied = uspace_buf_size;
*bytes_pending -= uspace_buf_size;
uci_log(UCI_DBG_VERBOSE,
"Copied 0x%x of 0x%x,chan %d\n",
"Copied 0x%zx of 0x%x,chan %d\n",
bytes_copied,
(u32)*bytes_pending,
chan);
@ -841,7 +839,7 @@ static ssize_t mhi_uci_client_read(struct file *file, char __user *buf,
uci_handle->pkt_loc = 0;
}
uci_log(UCI_DBG_VERBOSE,
"Returning 0x%x bytes, 0x%x bytes left\n",
"Returning 0x%zx bytes, 0x%x bytes left\n",
bytes_copied, (u32)*bytes_pending);
mutex_unlock(mutex);
return bytes_copied;
@ -979,13 +977,13 @@ static void process_rs232_state(struct mhi_result *result)
}
if (result->bytes_xferd != sizeof(struct rs232_ctrl_msg)) {
uci_log(UCI_DBG_ERROR,
"Buffer is of wrong size is: 0x%x: expected 0x%x\n",
"Buffer is of wrong size is: 0x%x: expected 0x%zx\n",
result->bytes_xferd, sizeof(struct rs232_ctrl_msg));
goto error_size;
}
dma_unmap_single(NULL, result->payload_buf,
result->bytes_xferd, DMA_FROM_DEVICE);
rs232_pkt = dma_to_virt(NULL, result->payload_buf);
rs232_pkt = (void *)result->payload_buf;
MHI_GET_CTRL_DEST_ID(CTRL_DEST_ID, rs232_pkt, chan);
client = &uci_ctxt.client_handles[chan / 2];
@ -1040,8 +1038,7 @@ static void parse_outbound_ack(struct uci_client *uci_handle,
result->payload_buf,
result->bytes_xferd,
DMA_TO_DEVICE);
kfree(dma_to_virt(NULL,
result->payload_buf));
kfree((void *) result->payload_buf);
uci_log(UCI_DBG_VERBOSE,
"Received ack on chan %d, pending acks: 0x%x\n",
uci_handle->out_chan,
@ -1053,7 +1050,7 @@ static void parse_outbound_ack(struct uci_client *uci_handle,
static void uci_xfer_cb(struct mhi_cb_info *cb_info)
{
u32 chan_nr;
int chan_nr;
struct uci_client *uci_handle = NULL;
u32 client_index;
struct mhi_result *result;
@ -1061,7 +1058,7 @@ static void uci_xfer_cb(struct mhi_cb_info *cb_info)
if (!cb_info)
uci_log(UCI_DBG_CRITICAL, "Bad CB info from MHI.\n");
if (cb_info->result) {
chan_nr = (u32)cb_info->result->user_data;
chan_nr = (uintptr_t)cb_info->result->user_data;
client_index = CHAN_TO_CLIENT(chan_nr);
uci_handle =
&uci_ctxt.client_handles[client_index];
@ -1082,7 +1079,7 @@ static void uci_xfer_cb(struct mhi_cb_info *cb_info)
return;
}
result = cb_info->result;
chan_nr = (u32)result->user_data;
chan_nr = (uintptr_t)result->user_data;
client_index = chan_nr / 2;
uci_handle =
&uci_ctxt.client_handles[client_index];
@ -1118,7 +1115,7 @@ static int mhi_register_client(struct uci_client *mhi_client, int index)
mhi_client->out_chan,
0,
&uci_ctxt.client_info,
(void *)(mhi_client->out_chan));
(void *)(uintptr_t)(mhi_client->out_chan));
if (MHI_STATUS_SUCCESS != ret_val)
uci_log(UCI_DBG_ERROR,
"Failed to init outbound chan 0x%x, ret 0x%x\n",
@ -1129,7 +1126,7 @@ static int mhi_register_client(struct uci_client *mhi_client, int index)
mhi_client->in_chan,
0,
&uci_ctxt.client_info,
(void *)(mhi_client->in_chan));
(void *)(uintptr_t)(mhi_client->in_chan));
if (MHI_STATUS_SUCCESS != ret_val)
uci_log(UCI_DBG_ERROR,
"Failed to init inbound chan 0x%x, ret 0x%x\n",