Re: [PATCH v2 02/11] soc/fsl/qbman: Use shared-dma-pool for QMan private memory allocations

From: Scott Wood
Date: Sun Apr 23 2017 - 21:45:32 EST


On Wed, 2017-04-19 at 16:48 -0400, Roy Pledge wrote:
> @@ -727,10 +730,81 @@ static int fsl_qman_probe(struct platform_device
> *pdev)
> Â qm_channel_caam = QMAN_CHANNEL_CAAM_REV3;
> Â }
> Â
> - ret = zero_priv_mem(dev, node, fqd_a, fqd_sz);
> - WARN_ON(ret);
> - if (ret)
> - return -ENODEV;
> + if (fqd_a) {
> +#ifdef CONFIG_PPC
> + /*
> + Â* For PPC backward DT compatibility
> + Â* FQD memory MUST be zero'd by software
> + Â*/
> + zero_priv_mem(fqd_a, fqd_sz);
> +#endif

Should probably warn if you get here on non-PPC rather than silently accepting
it.

> + } else {
> + /*
> + Â* Order of memory regions is assumed as FQD followed by
> PFDR
> + Â* in order to ensure allocations from the correct regions
> the
> + Â* driver initializes then allocates each piece in order
> + Â*/

This should be explicitly specified in the binding rather than here.



> + ret = of_reserved_mem_device_init_by_idx(dev, dev->of_node,
> 0);
> + if (ret) {
> + dev_err(dev, "of_reserved_mem_device_init_by_idx(0)
> failed 0x%x\n",
> + ret);
> + return -ENODEV;
> + }
> + mem_node = of_parse_phandle(dev->of_node, "memory-region",
> 0);
> + if (mem_node) {
> + ret = of_property_read_u64(mem_node, "size",
> &size);
> + if (ret) {
> + dev_err(dev, "FQD: of_address_to_resource
> fails 0x%x\n",
> + ret);
> + return -ENODEV;
> + }
> + fqd_sz = size;
> + } else {
> + dev_err(dev, "No memory-region found for FQD\n");
> + return -ENODEV;
> + }
> + if (!dma_zalloc_coherent(dev, fqd_sz, &fqd_a, 0)) {
> + dev_err(dev, "Alloc FQD memory failed\n");
> + return -ENODEV;
> + }
> +
> + /*
> + Â* Disassociate the FQD reseverd memory area from the
> device
> + Â* because a device can only have one DMA memory area. This
> + Â* should be fine since the memory is allocated and
> initialized
> + Â* and only ever accessed by the QMan device from now on
> + Â*/
> + of_reserved_mem_device_release(dev);

s/reseverd/reserved/


> + }
> + dev_info(dev, "Allocated FQD 0x%llx 0x%zx\n", fqd_a, fqd_sz);

dev_dbg()?

-Scott