Hi Roland, Applied with several adjustments, see below. On Thu, Nov 29, 2018 at 02:42:07PM +0100, Roland Hieber wrote: > +/* > + * construct_rng_self_test_jobdesc() - Implement destination address in RNG self test descriptors > + * Returns zero on success, and negative on error. > + */ > +static void construct_rng_self_test_jobdesc(u32 *desc, const u32 *rng_st_dsc, u8 *res_addr, int desc_size) > +{ > + int result_addr_idx = desc_size - 5; > + int i; > + > + for (i = 0; i < desc_size; i++) { > + desc[i] = rng_st_dsc[i]; > + } > + > + /* Replace destination address in the descriptor */ > + desc[result_addr_idx] = (u32)res_addr; > + > + pr_vdebug("RNG SELF TEST DESCRIPTOR:\n"); > + for (i = 0; i < desc_size; i++) { > + pr_vdebug("0x%08X\n", desc[i]); > + } Dropped these for now. Should be a memory_display with suitable message priority one we have it. > +int caam_rng_self_test(struct device_d *dev, const u8 caam_era, const u8 rngvid, const u8 rngrev) > +{ > + int ret, i, desc_size = 0, result_size = 0, job_err = 0; > + const u32 *rng_st_dsc; > + const u8 *exp_result; > + u32 *desc; > + u8 *result; > + > + pr_debug("got CAAM ERA %d, RNG Version ID %d, RNG revision %d\n", caam_era, rngvid, rngrev); > + > + if (caam_era < 8 && rngvid == 4 && rngrev < 3) { > + // older affected i.MX chipsets have CAAM < 8 and have RNG4 < 4.3 No C++ comments please. > + rng_st_dsc = rng_dsc1; > + desc_size = ARRAY_SIZE(rng_dsc1); > + exp_result = rng_result1; > + result_size = ARRAY_SIZE(rng_result1); > + } else if (caam_era >= 8 || (rngvid >= 4 && rngrev >= 3)) { > + // newer affected chipsets have CAAM >= 8 or RNG4 >= 4.3 > + rng_st_dsc = rng_dsc2; > + desc_size = ARRAY_SIZE(rng_dsc2); > + exp_result = rng_result2; > + result_size = ARRAY_SIZE(rng_result2); > + } else { > + pr_err("Error: Invalid CAAM ERA (%d) or RNG Version ID (%d) or RNG revision (%d)\n", > + caam_era, rngvid, rngrev); > + return -EINVAL; > + } > + > + result = dma_alloc(sizeof(*result) * result_size); > + if (!result) { > + return -ENOMEM; > + } > + > + desc = dma_alloc(sizeof(*desc) * desc_size); > + if (!desc) { > + return -ENOMEM; > + } Loosing memory here. > + > + construct_rng_self_test_jobdesc(desc, rng_st_dsc, result, desc_size); > + > + dma_sync_single_for_device((unsigned long)desc, > + desc_size * sizeof(*desc), DMA_TO_DEVICE); > + dma_sync_single_for_device((unsigned long)result, > + result_size * sizeof(*result), DMA_FROM_DEVICE); > + > + /* wait for job completion */ > + ret = caam_jr_enqueue(dev, desc, rng_self_test_done, &job_err); > + if (ret) { > + pr_err("Error while running RNG self-test descriptor: %d %s\n", > + ret, strerror(ret)); > + goto err; > + } > + if (job_err) { > + pr_err("Job Error:\n"); > + caam_jr_strstatus(dev, job_err); > + goto err; ret will be 0 here, not what we want. Sascha -- 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 | _______________________________________________ barebox mailing list barebox@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/barebox