本文整理汇总了C++中sg_dma_len函数的典型用法代码示例。如果您正苦于以下问题:C++ sg_dma_len函数的具体用法?C++ sg_dma_len怎么用?C++ sg_dma_len使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sg_dma_len函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: mv_cesa_req_dma_iter_next_transfer
bool mv_cesa_req_dma_iter_next_transfer(struct mv_cesa_dma_iter *iter,
struct mv_cesa_sg_dma_iter *sgiter,
unsigned int len)
{
if (!sgiter->sg)
return false;
sgiter->op_offset += len;
sgiter->offset += len;
if (sgiter->offset == sg_dma_len(sgiter->sg)) {
if (sg_is_last(sgiter->sg))
return false;
sgiter->offset = 0;
sgiter->sg = sg_next(sgiter->sg);
}
if (sgiter->op_offset == iter->op_len)
return false;
return true;
}
开发者ID:AK101111,项目名称:linux,代码行数:21,代码来源:tdma.c
示例2: viafb_dma_copy_out_sg
/*
* Do a scatter/gather DMA copy from FB memory. You must have done
* a successful call to viafb_request_dma() first.
*/
int viafb_dma_copy_out_sg(unsigned int offset, struct scatterlist *sg, int nsg)
{
struct viafb_vx855_dma_descr *descr;
void *descrpages;
dma_addr_t descr_handle;
unsigned long flags;
int i;
struct scatterlist *sgentry;
dma_addr_t nextdesc;
/*
* Get a place to put the descriptors.
*/
descrpages = dma_alloc_coherent(&global_dev.pdev->dev,
nsg*sizeof(struct viafb_vx855_dma_descr),
&descr_handle, GFP_KERNEL);
if (descrpages == NULL) {
dev_err(&global_dev.pdev->dev, "Unable to get descr page.\n");
return -ENOMEM;
}
mutex_lock(&viafb_dma_lock);
/*
* Fill them in.
*/
descr = descrpages;
nextdesc = descr_handle + sizeof(struct viafb_vx855_dma_descr);
for_each_sg(sg, sgentry, nsg, i) {
dma_addr_t paddr = sg_dma_address(sgentry);
descr->addr_low = paddr & 0xfffffff0;
descr->addr_high = ((u64) paddr >> 32) & 0x0fff;
descr->fb_offset = offset;
descr->seg_size = sg_dma_len(sgentry) >> 4;
descr->tile_mode = 0;
descr->next_desc_low = (nextdesc&0xfffffff0) | VIAFB_DMA_MAGIC;
descr->next_desc_high = ((u64) nextdesc >> 32) & 0x0fff;
descr->pad = 0xffffffff; /* VIA driver does this */
offset += sg_dma_len(sgentry);
nextdesc += sizeof(struct viafb_vx855_dma_descr);
descr++;
}
开发者ID:3sOx,项目名称:asuswrt-merlin,代码行数:44,代码来源:via-core.c
示例3: videobuf_dma_map
int videobuf_dma_map(struct videobuf_queue* q, struct videobuf_dmabuf *dma)
{
MAGIC_CHECK(dma->magic,MAGIC_DMABUF);
BUG_ON(0 == dma->nr_pages);
if (dma->pages) {
dma->sglist = videobuf_pages_to_sg(dma->pages, dma->nr_pages,
dma->offset);
}
if (dma->vmalloc) {
dma->sglist = videobuf_vmalloc_to_sg
(dma->vmalloc,dma->nr_pages);
}
if (dma->bus_addr) {
dma->sglist = kmalloc(sizeof(struct scatterlist), GFP_KERNEL);
if (NULL != dma->sglist) {
dma->sglen = 1;
sg_dma_address(&dma->sglist[0]) = dma->bus_addr & PAGE_MASK;
dma->sglist[0].offset = dma->bus_addr & ~PAGE_MASK;
sg_dma_len(&dma->sglist[0]) = dma->nr_pages * PAGE_SIZE;
}
}
if (NULL == dma->sglist) {
dprintk(1,"scatterlist is NULL\n");
return -ENOMEM;
}
if (!dma->bus_addr) {
dma->sglen = dma_map_sg(q->dev, dma->sglist,
dma->nr_pages, dma->direction);
if (0 == dma->sglen) {
printk(KERN_WARNING
"%s: videobuf_map_sg failed\n",__func__);
kfree(dma->sglist);
dma->sglist = NULL;
dma->sglen = 0;
return -EIO;
}
}
return 0;
}
开发者ID:johnny,项目名称:CobraDroidBeta,代码行数:40,代码来源:videobuf-dma-sg.c
示例4: dma_start
static int dma_start(struct rk_mmc *host)
{
int i, res, direction, sg_len;
enum rk29_dmasrc src;
struct mmc_data *data = host->data;
BUG_ON(!data);
host->dma_xfer_size = 0;
if (data->flags & MMC_DATA_READ){
direction = DMA_FROM_DEVICE;
src = RK29_DMASRC_HW;
}else{
direction = DMA_TO_DEVICE;
src = RK29_DMASRC_MEM;
}
sg_len = rk_mmc_pre_dma_transfer(host, host->data, 0);
if(sg_len < 0){
host->ops->stop(host);
return sg_len;
}
res = rk29_dma_devconfig(MMC_DMA_CHN, src, host->dma_addr);
if(unlikely(res < 0))
return res;
for(i = 0; i < sg_len; i++){
res = rk29_dma_enqueue(MMC_DMA_CHN, host,
sg_dma_address(&data->sg[i]),
sg_dma_len(&data->sg[i]));
if(unlikely(res < 0))
return res;
}
res = rk29_dma_ctrl(MMC_DMA_CHN, RK29_DMAOP_START);
if(unlikely(res < 0))
return res;
return res;
}
开发者ID:Dee-UK,项目名称:RK3188_KK_4.4.02_Beta,代码行数:40,代码来源:rkemmc.c
示例5: mmc_dma_rx_start
/* Supports scatter/gather */
static void mmc_dma_rx_start(struct mmci_host *host)
{
unsigned int len;
int i, dma_len;
struct scatterlist *sg;
struct mmc_request *mrq = host->mrq;
struct mmc_data *reqdata = mrq->data;
void *dmaaddr;
u32 dmalen, dmaxferlen;
sg = reqdata->sg;
len = reqdata->sg_len;
dma_len = dma_map_sg(
mmc_dev(host->mmc), reqdata->sg, reqdata->sg_len,
DMA_FROM_DEVICE);
if (dma_len == 0)
return;
/* Setup transfer */
for (i = 0; i < len; i++) {
dmalen = (u32) sg_dma_len(&sg[i]);
dmaaddr = (void *) sg_dma_address(&sg[i]);
/* Build a list with a max size if 15872 bytes per seg */
while (dmalen > 0) {
dmaxferlen = dmalen;
if (dmaxferlen > 15872)
dmaxferlen = 15872;
lpc178x_dma_queue_llist_entry(dmac_drvdat.lastch,
(void *) SD_FIFO((u32)host->base),
dmaaddr, dmaxferlen);
dmaaddr += dmaxferlen;
dmalen -= dmaxferlen;
}
}
}
开发者ID:KroMignon,项目名称:linux-emcraft,代码行数:40,代码来源:mmci.c
示例6: tegra_gem_prime_map_dma_buf
static struct sg_table *
tegra_gem_prime_map_dma_buf(struct dma_buf_attachment *attach,
enum dma_data_direction dir)
{
struct drm_gem_object *gem = attach->dmabuf->priv;
struct tegra_bo *bo = to_tegra_bo(gem);
struct sg_table *sgt;
sgt = kmalloc(sizeof(*sgt), GFP_KERNEL);
if (!sgt)
return NULL;
if (bo->pages) {
struct scatterlist *sg;
unsigned int i;
if (sg_alloc_table(sgt, bo->num_pages, GFP_KERNEL))
goto free;
for_each_sg(sgt->sgl, sg, bo->num_pages, i)
sg_set_page(sg, bo->pages[i], PAGE_SIZE, 0);
if (dma_map_sg(attach->dev, sgt->sgl, sgt->nents, dir) == 0)
goto free;
} else {
if (sg_alloc_table(sgt, 1, GFP_KERNEL))
goto free;
sg_dma_address(sgt->sgl) = bo->paddr;
sg_dma_len(sgt->sgl) = gem->size;
}
return sgt;
free:
sg_free_table(sgt);
kfree(sgt);
return NULL;
}
开发者ID:JaneDu,项目名称:ath,代码行数:39,代码来源:gem.c
示例7: tegra_gem_prime_map_dma_buf
static struct sg_table *
tegra_gem_prime_map_dma_buf(struct dma_buf_attachment *attach,
enum dma_data_direction dir)
{
struct drm_gem_object *gem = attach->dmabuf->priv;
struct tegra_bo *bo = to_tegra_bo(gem);
struct sg_table *sgt;
sgt = kmalloc(sizeof(*sgt), GFP_KERNEL);
if (!sgt)
return NULL;
if (sg_alloc_table(sgt, 1, GFP_KERNEL)) {
kfree(sgt);
return NULL;
}
sg_dma_address(sgt->sgl) = bo->paddr;
sg_dma_len(sgt->sgl) = gem->size;
return sgt;
}
开发者ID:mikuhatsune001,项目名称:linux2.6.32,代码行数:22,代码来源:gem.c
示例8: fill_xfer_opecodes
static unsigned int fill_xfer_opecodes(
struct opecode* op_ptr ,
struct scatterlist* sg_list ,
unsigned int sg_nums ,
bool xfer_first,
bool xfer_last ,
unsigned int xfer_mode
)
{
struct scatterlist* curr_sg;
int sg_index;
unsigned int op_count;
dma_addr_t dma_address;
unsigned int dma_length;
bool dma_last;
if (IS_ERR_OR_NULL(op_ptr) || IS_ERR_OR_NULL(sg_list) || (sg_nums < 1)) {
return 0;
}
op_count = 0;
for_each_sg(sg_list, curr_sg, sg_nums, sg_index) {
dma_address = sg_dma_address(curr_sg);
dma_length = sg_dma_len(curr_sg);
dma_last = (sg_index >= sg_nums-1) ? xfer_last : 0;
set_xfer_opecode(
op_ptr , /* struct opecode* op_ptr */
0 , /* bool fetch */
0 , /* bool done */
xfer_first , /* bool xfer_first */
dma_last , /* bool xfer_last */
dma_address, /* dma_addr_t addr */
dma_length , /* unsigned int size */
xfer_mode /* unsigned int mode */
);
op_count++;
op_ptr++;
xfer_first = 0;
}
开发者ID:ikwzm,项目名称:ZYBO_PUMP,代码行数:39,代码来源:pump_proc.c
示例9: samsung_dmadev_prepare
static int samsung_dmadev_prepare(unsigned ch,
struct samsung_dma_prep_info *info)
{
struct scatterlist sg;
struct dma_chan *chan = (struct dma_chan *)ch;
struct dma_async_tx_descriptor *desc;
switch (info->cap) {
case DMA_SLAVE:
sg_init_table(&sg, 1);
sg_dma_len(&sg) = info->len;
sg_set_page(&sg, pfn_to_page(PFN_DOWN(info->buf)),
info->len, offset_in_page(info->buf));
sg_dma_address(&sg) = info->buf;
desc = chan->device->device_prep_slave_sg(chan,
&sg, 1, info->direction, DMA_PREP_INTERRUPT);
break;
case DMA_CYCLIC:
desc = chan->device->device_prep_dma_cyclic(chan,
info->buf, info->len, info->period, info->direction);
break;
default:
dev_err(&chan->dev->device, "unsupported format\n");
return -EFAULT;
}
if (!desc) {
dev_err(&chan->dev->device, "cannot prepare cyclic dma\n");
return -EFAULT;
}
desc->callback = info->fp;
desc->callback_param = info->fp_param;
dmaengine_submit((struct dma_async_tx_descriptor *)desc);
return 0;
}
开发者ID:Apaisal,项目名称:linux,代码行数:39,代码来源:dma-ops.c
示例10: usdhi6_sg_unmap
/* Unmap the current page: common for multiple and single block IO */
static void usdhi6_sg_unmap(struct usdhi6_host *host, bool force)
{
struct mmc_data *data = host->mrq->data;
struct page *page = host->head_pg.page;
if (page) {
/* Previous block was cross-page boundary */
struct scatterlist *sg = data->sg_len > 1 ?
host->sg : data->sg;
size_t blk_head = host->head_len;
if (!data->error && data->flags & MMC_DATA_READ) {
memcpy(host->head_pg.mapped + PAGE_SIZE - blk_head,
host->bounce_buf, blk_head);
memcpy(host->pg.mapped, host->bounce_buf + blk_head,
data->blksz - blk_head);
}
flush_dcache_page(page);
kunmap(page);
host->head_pg.page = NULL;
if (!force && sg_dma_len(sg) + sg->offset >
(host->page_idx << PAGE_SHIFT) + data->blksz - blk_head)
/* More blocks in this SG, don't unmap the next page */
return;
}
page = host->pg.page;
if (!page)
return;
flush_dcache_page(page);
kunmap(page);
host->pg.page = NULL;
}
开发者ID:513855417,项目名称:linux,代码行数:39,代码来源:usdhi6rol0.c
示例11: camera_core_start_overlay
static void
camera_core_start_overlay(struct camera_device *cam)
{
int err;
unsigned long irqflags;
if (!cam->previewing)
return;
spin_lock_irqsave(&cam->overlay_lock, irqflags);
sg_dma_address(&cam->overlay_sglist) = cam->overlay_base_phys;
sg_dma_len(&cam->overlay_sglist)= cam->pix.sizeimage;
while (cam->overlay_cnt < 2) {
err = camera_core_sgdma_queue(cam, &cam->overlay_sglist, 1,
camera_core_overlay_callback, NULL);
if (err)
break;
++cam->overlay_cnt;
}
spin_unlock_irqrestore(&cam->overlay_lock, irqflags);
}
开发者ID:GodFox,项目名称:magx_kernel_xpixl,代码行数:23,代码来源:camera_core.c
示例12: hptiop_buildsgl
static int hptiop_buildsgl(struct scsi_cmnd *scp, struct hpt_iopsg *psg)
{
struct Scsi_Host *host = scp->device->host;
struct hptiop_hba *hba = (struct hptiop_hba *)host->hostdata;
struct scatterlist *sg;
int idx, nseg;
nseg = scsi_dma_map(scp);
BUG_ON(nseg < 0);
if (!nseg)
return 0;
HPT_SCP(scp)->sgcnt = nseg;
HPT_SCP(scp)->mapped = 1;
BUG_ON(HPT_SCP(scp)->sgcnt > hba->max_sg_descriptors);
scsi_for_each_sg(scp, sg, HPT_SCP(scp)->sgcnt, idx) {
psg[idx].pci_address = cpu_to_le64(sg_dma_address(sg));
psg[idx].size = cpu_to_le32(sg_dma_len(sg));
psg[idx].eot = (idx == HPT_SCP(scp)->sgcnt - 1) ?
cpu_to_le32(1) : 0;
}
开发者ID:cilynx,项目名称:dd-wrt,代码行数:23,代码来源:hptiop.c
示例13: vb2_dma_contig_map_dmabuf
static void vb2_dma_contig_map_dmabuf(void *mem_priv)
{
struct vb2_dc_buf *buf = mem_priv;
struct dma_buf *dmabuf;
struct sg_table *sg;
enum dma_data_direction dir;
if (!buf || !buf->db_attach)
return;
WARN_ON(buf->dma_addr);
dmabuf = buf->db_attach->dmabuf;
/* TODO need a way to know if we are camera or display, etc.. */
dir = DMA_BIDIRECTIONAL;
/* get the associated sg for this buffer */
sg = dma_buf_map_attachment(buf->db_attach, dir);
if (!sg)
return;
/*
* convert sglist to paddr:
* Assumption: for dma-contig, dmabuf would map to single entry
* Will print a warning if it has more than one.
*/
if (sg->nents > 1)
printk(KERN_WARNING
"dmabuf scatterlist has more than 1 entry\n");
buf->dma_addr = sg_dma_address(sg->sgl);
buf->size = sg_dma_len(sg->sgl);
/* save this sg in dmabuf for put_scatterlist */
dmabuf->priv = sg;
}
开发者ID:ARMP,项目名称:ARMP-i9300,代码行数:37,代码来源:videobuf2-dma-contig.c
示例14: kzalloc
static struct sg_table *omap_gem_map_dma_buf(
struct dma_buf_attachment *attachment,
enum dma_data_direction dir)
{
struct drm_gem_object *obj = attachment->dmabuf->priv;
struct sg_table *sg;
dma_addr_t dma_addr;
int ret;
sg = kzalloc(sizeof(*sg), GFP_KERNEL);
if (!sg)
return ERR_PTR(-ENOMEM);
/* camera, etc, need physically contiguous.. but we need a
* better way to know this..
*/
ret = omap_gem_pin(obj, &dma_addr);
if (ret)
goto out;
ret = sg_alloc_table(sg, 1, GFP_KERNEL);
if (ret)
goto out;
sg_init_table(sg->sgl, 1);
sg_dma_len(sg->sgl) = obj->size;
sg_set_page(sg->sgl, pfn_to_page(PFN_DOWN(dma_addr)), obj->size, 0);
sg_dma_address(sg->sgl) = dma_addr;
/* this must be after omap_gem_pin() to ensure we have pages attached */
omap_gem_dma_sync_buffer(obj, dir);
return sg;
out:
kfree(sg);
return ERR_PTR(ret);
}
开发者ID:SantoshShilimkar,项目名称:linux,代码行数:37,代码来源:omap_gem_dmabuf.c
示例15: omap2_mcspi_tx_dma
static void omap2_mcspi_tx_dma(struct spi_device *spi,
struct spi_transfer *xfer,
struct dma_slave_config cfg)
{
struct omap2_mcspi *mcspi;
struct omap2_mcspi_dma *mcspi_dma;
unsigned int count;
mcspi = spi_master_get_devdata(spi->master);
mcspi_dma = &mcspi->dma_channels[spi->chip_select];
count = xfer->len;
if (mcspi_dma->dma_tx) {
struct dma_async_tx_descriptor *tx;
struct scatterlist sg;
dmaengine_slave_config(mcspi_dma->dma_tx, &cfg);
sg_init_table(&sg, 1);
sg_dma_address(&sg) = xfer->tx_dma;
sg_dma_len(&sg) = xfer->len;
tx = dmaengine_prep_slave_sg(mcspi_dma->dma_tx, &sg, 1,
DMA_MEM_TO_DEV, DMA_PREP_INTERRUPT | DMA_CTRL_ACK);
if (tx) {
tx->callback = omap2_mcspi_tx_callback;
tx->callback_param = spi;
dmaengine_submit(tx);
} else {
/* FIXME: fall back to PIO? */
}
}
dma_async_issue_pending(mcspi_dma->dma_tx);
omap2_mcspi_set_dma_req(spi, 0, 1);
}
开发者ID:imcek,项目名称:BEAGLEBONE_BSP,代码行数:36,代码来源:spi-omap2-mcspi.c
示例16: ispmmu_vmap
dma_addr_t ispmmu_vmap(const struct scatterlist *sglist,
int sglen)
{
int err;
void *da;
struct sg_table *sgt;
unsigned int i;
struct scatterlist *sg, *src = (struct scatterlist *)sglist;
/*
* convert isp sglist to iommu sgt
* FIXME: should be fixed in the upper layer?
*/
sgt = kmalloc(sizeof(*sgt), GFP_KERNEL);
if (!sgt)
return -ENOMEM;
err = sg_alloc_table(sgt, sglen, GFP_KERNEL);
if (err)
goto err_sg_alloc;
for_each_sg(sgt->sgl, sg, sgt->nents, i)
sg_set_buf(sg, phys_to_virt(sg_dma_address(src + i)),
sg_dma_len(src + i));
da = (void *)iommu_vmap(isp_iommu, 0, sgt, IOMMU_FLAG);
if (IS_ERR(da))
goto err_vmap;
return (dma_addr_t)da;
err_vmap:
sg_free_table(sgt);
err_sg_alloc:
kfree(sgt);
return -ENOMEM;
}
开发者ID:macroliu,项目名称:I8320Kernel,代码行数:36,代码来源:ispmmu.c
示例17: iser_data_buf_aligned_len
/**
* iser_data_buf_aligned_len - Tries to determine the maximal correctly aligned
* for RDMA sub-list of a scatter-gather list of memory buffers, and returns
* the number of entries which are aligned correctly. Supports the case where
* consecutive SG elements are actually fragments of the same physcial page.
*/
static unsigned int iser_data_buf_aligned_len(struct iser_data_buf *data)
{
struct scatterlist *sg;
dma_addr_t end_addr, next_addr;
int i, cnt;
unsigned int ret_len = 0;
sg = (struct scatterlist *)data->buf;
for (cnt = 0, i = 0; i < data->dma_nents; i++, cnt++) {
/* iser_dbg("Checking sg iobuf [%d]: phys=0x%08lX "
"offset: %ld sz: %ld\n", i,
(unsigned long)page_to_phys(sg[i].page),
(unsigned long)sg[i].offset,
(unsigned long)sg[i].length); */
end_addr = sg_dma_address(&sg[i]) +
sg_dma_len(&sg[i]);
/* iser_dbg("Checking sg iobuf end address "
"0x%08lX\n", end_addr); */
if (i + 1 < data->dma_nents) {
next_addr = sg_dma_address(&sg[i+1]);
/* are i, i+1 fragments of the same page? */
if (end_addr == next_addr)
continue;
else if (!IS_4K_ALIGNED(end_addr)) {
ret_len = cnt + 1;
break;
}
}
}
if (i == data->dma_nents)
ret_len = cnt; /* loop ended */
iser_dbg("Found %d aligned entries out of %d in sg:0x%p\n",
ret_len, data->dma_nents, data);
return ret_len;
}
开发者ID:FatSunHYS,项目名称:OSCourseDesign,代码行数:42,代码来源:iser_memory.c
示例18: srp_indirect_data
static int srp_indirect_data(struct scsi_cmnd *sc, struct srp_cmd *cmd,
struct srp_indirect_buf *id,
enum dma_data_direction dir, srp_rdma_t rdma_io,
int dma_map, int ext_desc)
{
struct iu_entry *iue = NULL;
struct srp_direct_buf *md = NULL;
struct scatterlist dummy, *sg = NULL;
dma_addr_t token = 0;
int err = 0;
int nmd, nsg = 0, len;
if (dma_map || ext_desc) {
iue = (struct iu_entry *) sc->SCp.ptr;
sg = scsi_sglist(sc);
dprintk("%p %u %u %d %d\n",
iue, scsi_bufflen(sc), id->len,
cmd->data_in_desc_cnt, cmd->data_out_desc_cnt);
}
nmd = id->table_desc.len / sizeof(struct srp_direct_buf);
if ((dir == DMA_FROM_DEVICE && nmd == cmd->data_in_desc_cnt) ||
(dir == DMA_TO_DEVICE && nmd == cmd->data_out_desc_cnt)) {
md = &id->desc_list[0];
goto rdma;
}
if (ext_desc && dma_map) {
md = dma_alloc_coherent(iue->target->dev, id->table_desc.len,
&token, GFP_KERNEL);
if (!md) {
eprintk("Can't get dma memory %u\n", id->table_desc.len);
return -ENOMEM;
}
sg_init_one(&dummy, md, id->table_desc.len);
sg_dma_address(&dummy) = token;
sg_dma_len(&dummy) = id->table_desc.len;
err = rdma_io(sc, &dummy, 1, &id->table_desc, 1, DMA_TO_DEVICE,
id->table_desc.len);
if (err) {
eprintk("Error copying indirect table %d\n", err);
goto free_mem;
}
} else {
eprintk("This command uses external indirect buffer\n");
return -EINVAL;
}
rdma:
if (dma_map) {
nsg = dma_map_sg(iue->target->dev, sg, scsi_sg_count(sc),
DMA_BIDIRECTIONAL);
if (!nsg) {
eprintk("fail to map %p %d\n", iue, scsi_sg_count(sc));
err = -EIO;
goto free_mem;
}
len = min(scsi_bufflen(sc), id->len);
} else
len = id->len;
err = rdma_io(sc, sg, nsg, md, nmd, dir, len);
if (dma_map)
dma_unmap_sg(iue->target->dev, sg, nsg, DMA_BIDIRECTIONAL);
free_mem:
if (token && dma_map)
dma_free_coherent(iue->target->dev, id->table_desc.len, md, token);
return err;
}
开发者ID:KroMignon,项目名称:linux-emcraft,代码行数:75,代码来源:libsrp.c
示例19: ump_ion_import_wrapper
/*
* IOCTL operation; Import fd to UMP memory
*/
int ump_ion_import_wrapper(u32 __user * argument, struct ump_session_data * session_data)
{
_ump_uk_ion_import_s user_interaction;
ump_dd_handle *ump_handle;
ump_dd_physical_block * blocks;
unsigned long num_blocks;
struct ion_handle *ion_hnd;
struct scatterlist *sg;
struct scatterlist *sg_ion;
unsigned long i = 0;
ump_session_memory_list_element * session_memory_element = NULL;
if (ion_client_ump==NULL)
ion_client_ump = ion_client_create(ion_exynos, -1, "ump");
/* Sanity check input parameters */
if (NULL == argument || NULL == session_data)
{
MSG_ERR(("NULL parameter in ump_ioctl_allocate()\n"));
return -ENOTTY;
}
/* Copy the user space memory to kernel space (so we safely can read it) */
if (0 != copy_from_user(&user_interaction, argument, sizeof(user_interaction)))
{
MSG_ERR(("copy_from_user() in ump_ioctl_allocate()\n"));
return -EFAULT;
}
user_interaction.ctx = (void *) session_data;
/* translate fd to secure ID*/
ion_hnd = ion_import_fd(ion_client_ump, user_interaction.ion_fd);
sg_ion = ion_map_dma(ion_client_ump,ion_hnd);
blocks = (ump_dd_physical_block*)_mali_osk_malloc(sizeof(ump_dd_physical_block)*1024);
if (NULL == blocks) {
MSG_ERR(("Failed to allocate blocks in ump_ioctl_allocate()\n"));
return -ENOMEM;
}
sg = sg_ion;
do {
blocks[i].addr = sg_phys(sg);
blocks[i].size = sg_dma_len(sg);
i++;
if (i>=1024) {
_mali_osk_free(blocks);
MSG_ERR(("ion_import fail() in ump_ioctl_allocate()\n"));
return -EFAULT;
}
sg = sg_next(sg);
} while(sg);
num_blocks = i;
/* Initialize the session_memory_element, and add it to the session object */
session_memory_element = _mali_osk_calloc( 1, sizeof(ump_session_memory_list_element));
if (NULL == session_memory_element)
{
_mali_osk_free(blocks);
DBG_MSG(1, ("Failed to allocate ump_session_memory_list_element in ump_ioctl_allocate()\n"));
return -EFAULT;
}
ump_handle = ump_dd_handle_create_from_phys_blocks(blocks, num_blocks);
if (UMP_DD_HANDLE_INVALID == ump_handle)
{
_mali_osk_free(session_memory_element);
_mali_osk_free(blocks);
DBG_MSG(1, ("Failed to allocate ump_session_memory_list_element in ump_ioctl_allocate()\n"));
return -EFAULT;
}
session_memory_element->mem = (ump_dd_mem*)ump_handle;
_mali_osk_mutex_wait(session_data->lock);
_mali_osk_list_add(&(session_memory_element->list), &(session_data->list_head_session_memory_list));
_mali_osk_mutex_signal(session_data->lock);
ion_unmap_dma(ion_client_ump,ion_hnd);
ion_free(ion_client_ump, ion_hnd);
_mali_osk_free(blocks);
user_interaction.secure_id = ump_dd_secure_id_get(ump_handle);
user_interaction.size = ump_dd_size_get(ump_handle);
user_interaction.ctx = NULL;
if (0 != copy_to_user(argument, &user_interaction, sizeof(user_interaction)))
{
/* If the copy fails then we should release the memory. We can use the IOCTL release to accomplish this */
MSG_ERR(("copy_to_user() failed in ump_ioctl_allocate()\n"));
return -EFAULT;
}
//.........这里部分代码省略.........
开发者ID:caoxin1988,项目名称:linux-3.0.86,代码行数:101,代码来源:ump_ukk_ref_wrappers.c
示例20: mmc_omap_prepare_dma
/* Prepare to transfer the next segment of a scatterlist */
static void
mmc_omap_prepare_dma(struct mmc_omap_host *host, struct mmc_data *data)
{
int dma_ch = host->dma_ch;
unsigned long data_addr;
u16 buf, frame;
u32 count;
struct scatterlist *sg = &data->sg[host->sg_idx];
int src_port = 0;
int dst_port = 0;
int sync_dev = 0;
data_addr = host->phys_base + OMAP_MMC_REG_DATA;
frame = data->blksz;
count = sg_dma_len(sg);
if ((data->blocks == 1) && (count > data->blksz))
count = frame;
host->dma_len = count;
/* FIFO is 16x2 bytes on 15xx, and 32x2 bytes on 16xx and 24xx.
* Use 16 or 32 word frames when the blocksize is at least that large.
* Blocksize is usually 512 bytes; but not for some SD reads.
*/
if (cpu_is_omap15xx() && frame > 32)
frame = 32;
else if (frame > 64)
frame = 64;
count /= frame;
frame >>= 1;
if (!(data->flags & MMC_DATA_WRITE)) {
buf = 0x800f | ((frame - 1) << 8);
if (cpu_class_is_omap1()) {
src_port = OMAP_DMA_PORT_TIPB;
dst_port = OMAP_DMA_PORT_EMIFF;
}
if (cpu_is_omap24xx())
sync_dev = OMAP24XX_DMA_MMC1_RX;
omap_set_dma_src_params(dma_ch, src_port,
OMAP_DMA_AMODE_CONSTANT,
data_addr, 0, 0);
omap_set_dma_dest_params(dma_ch, dst_port,
OMAP_DMA_AMODE_POST_INC,
sg_dma_address(sg), 0, 0);
omap_set_dma_dest_data_pack(dma_ch, 1);
omap_set_dma_dest_burst_mode(dma_ch, OMAP_DMA_DATA_BURST_4);
} else {
buf = 0x0f80 | ((frame - 1) << 0);
if (cpu_class_is_omap1()) {
src_port = OMAP_DMA_PORT_EMIFF;
dst_port = OMAP_DMA_PORT_TIPB;
}
if (cpu_is_omap24xx())
sync_dev = OMAP24XX_DMA_MMC1_TX;
omap_set_dma_dest_params(dma_ch, dst_port,
OMAP_DMA_AMODE_CONSTANT,
data_addr, 0, 0);
omap_set_dma_src_params(dma_ch, src_port,
OMAP_DMA_AMODE_POST_INC,
sg_dma_address(sg), 0, 0);
omap_set_dma_src_data_pack(dma_ch, 1);
omap_set_dma_src_burst_mode(dma_ch, OMAP_DMA_DATA_BURST_4);
}
/* Max limit for DMA frame count is 0xffff */
BUG_ON(count > 0xffff);
OMAP_MMC_WRITE(host, BUF, buf);
omap_set_dma_transfer_params(dma_ch, OMAP_DMA_DATA_TYPE_S16,
frame, count, OMAP_DMA_SYNC_FRAME,
sync_dev, 0);
}
开发者ID:A2109devs,项目名称:lenovo_a2109a_kernel,代码行数:79,代码来源:omap.c
注:本文中的sg_dma_len函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论