[PATCH 4/6] crypto: add i.MX6 CAAM support

Steffen Trumtrar s.trumtrar at pengutronix.de
Fri Oct 23 02:55:03 PDT 2015


Hi!

On Wed, Oct 14, 2015 at 04:16:30PM +0200, Lucas Stach wrote:
> Am Mittwoch, den 14.10.2015, 15:39 +0200 schrieb Steffen Trumtrar:
> > Add the i.MX6 crypto core CAAM.
> > 
> > The core itself works with jobrings in which descriptors can be
> > queued/dequeued for processing.
> > 
> > Signed-off-by: Steffen Trumtrar <s.trumtrar at pengutronix.de>
> > ---
> >  
> [...]
> 
> > +/*
> > + * Init JobR independent of platform property detection
> > + */
> > +static int caam_jr_init(struct device_d *dev)
> > +{
> > +	struct caam_drv_private_jr *jrp;
> > +	int i, error;
> > +
> > +	jrp = dev->priv;
> > +
> > +	error = caam_reset_hw_jr(dev);
> > +	if (error)
> > +		return -EINVAL;
> > +
> > +	error = -ENOMEM;
> > +	jrp->inpring = dma_alloc_coherent(sizeof(*jrp->inpring) * JOBR_DEPTH,
> > +					  DMA_ADDRESS_BROKEN);
> > +	if (!jrp->inpring)
> > +		return error;
> > +
> > +	jrp->outring = dma_alloc_coherent(sizeof(*jrp->outring) *
> > +					  JOBR_DEPTH, DMA_ADDRESS_BROKEN);
> > +	if (!jrp->outring)
> > +		goto out_free_inpring;
> 
> No new code with DMA_ADDRESS_BROKEN please.
> 
> > +
> > +	jrp->entinfo = xzalloc(sizeof(*jrp->entinfo) * JOBR_DEPTH);
> > +	if (!jrp->entinfo)
> > +		goto out_free_outring;
> > +
> > +	for (i = 0; i < JOBR_DEPTH; i++)
> > +		jrp->entinfo[i].desc_addr_dma = !0;
> > +
> > +	/* Setup rings */
> > +	jrp->inp_ring_write_index = 0;
> > +	jrp->out_ring_read_index = 0;
> > +	jrp->head = 0;
> > +	jrp->tail = 0;
> > +
> > +	wr_reg64(&jrp->rregs->inpring_base, (dma_addr_t) jrp->inpring);
> > +	wr_reg64(&jrp->rregs->outring_base, (dma_addr_t) jrp->outring);
> 
> This should use the real DMA address, provided by dma_alloc_coherent
> above. Hint: it also gets rid of the cast. ;)
> 
> > +	wr_reg32(&jrp->rregs->inpring_size, JOBR_DEPTH);
> > +	wr_reg32(&jrp->rregs->outring_size, JOBR_DEPTH);
> > +
> > +	jrp->ringsize = JOBR_DEPTH;
> > +
> > +	return 0;
> > +
> > +out_free_outring:
> > +	dma_free_coherent(jrp->outring, 0, sizeof(struct jr_outentry) * JOBR_DEPTH);
> > +out_free_inpring:
> > +	dma_free_coherent(jrp->inpring, 0, sizeof(dma_addr_t) * JOBR_DEPTH);
> > +	dev_err(dev, "can't allocate job rings for %d\n", jrp->ridx);
> > +	return error;
> > +}
> > +
> [...]
> 

You are right (obviously). I will change that.

Thanks,
Steffen

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |



More information about the barebox mailing list