From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 78312C4345F for ; Wed, 24 Apr 2024 18:33:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) id 5EA7FC3277B; Wed, 24 Apr 2024 18:33:52 +0000 (UTC) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.kernel.org (Postfix) with ESMTPS id 6830BC2BD10; Wed, 24 Apr 2024 18:33:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 smtp.kernel.org 6830BC2BD10 Authentication-Results: smtp.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.kernel.org; spf=fail smtp.mailfrom=kernel.org X-CSE-ConnectionGUID: nD91NUo5QiWCHwjB+oEJbg== X-CSE-MsgGUID: Oty92MNDSw+lObt9QsH8oQ== X-IronPort-AV: E=McAfee;i="6600,9927,11054"; a="32126204" X-IronPort-AV: E=Sophos;i="6.07,226,1708416000"; d="scan'208";a="32126204" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Apr 2024 11:33:51 -0700 X-CSE-ConnectionGUID: tyxhSyVeQVe56rlsmUI8Qw== X-CSE-MsgGUID: ANZZIUuBQgGxZ19tESR6/Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,226,1708416000"; d="scan'208";a="24874373" Received: from smile.fi.intel.com ([10.237.72.54]) by fmviesa010.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 24 Apr 2024 11:33:48 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.97) (envelope-from ) id 1rzhRA-00000000kY5-3iAc; Wed, 24 Apr 2024 21:33:44 +0300 Date: Wed, 24 Apr 2024 21:33:44 +0300 From: Andy Shevchenko To: Marek =?iso-8859-1?Q?Beh=FAn?= List-Id: Cc: Gregory CLEMENT , Arnd Bergmann , soc@kernel.org, arm@kernel.org, Hans de Goede , Ilpo =?iso-8859-1?Q?J=E4rvinen?= , Olivia Mackall , Herbert Xu , Greg Kroah-Hartman , linux-crypto@vger.kernel.org Subject: Re: [PATCH v7 6/9] platform: cznic: turris-omnia-mcu: Add support for MCU provided TRNG Message-ID: References: <20240424173809.7214-1-kabel@kernel.org> <20240424173809.7214-7-kabel@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20240424173809.7214-7-kabel@kernel.org> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo On Wed, Apr 24, 2024 at 07:38:05PM +0200, Marek Behún wrote: > Add support for true random number generator provided by the MCU. > New Omnia boards come without the Atmel SHA204-A chip. Instead the > crypto functionality is provided by new microcontroller, which has > a TRNG peripheral. ... > +static void omnia_irq_mapping_drop(void *res) > +{ > + irq_dispose_mapping((unsigned int)(unsigned long)res); > +} Leftover? > +int omnia_mcu_register_trng(struct omnia_mcu *mcu) > +{ > + struct device *dev = &mcu->client->dev; > + u8 irq_idx, dummy; > + int irq, err; > + > + if (!(mcu->features & FEAT_TRNG)) > + return 0; > + > + irq_idx = omnia_int_to_gpio_idx[__bf_shf(INT_TRNG)]; > + irq = gpiod_to_irq(gpiochip_get_desc(&mcu->gc, irq_idx)); > + if (irq < 0) > + return dev_err_probe(dev, irq, "Cannot get TRNG IRQ\n"); > + err = devm_add_action_or_reset(dev, omnia_irq_mapping_drop, > + (void *)(unsigned long)irq); > + if (err) > + return err; Are you sure it's correct now? > + /* If someone else cleared the TRNG interrupt but did not read the > + * entropy, a new interrupt won't be generated, and entropy collection > + * will be stuck. Ensure an interrupt will be generated by executing > + * the collect entropy command (and discarding the result). > + */ > + err = omnia_cmd_read(mcu->client, CMD_TRNG_COLLECT_ENTROPY, &dummy, 1); > + if (err) > + return err; > + > + init_completion(&mcu->trng_completion); > + > + err = devm_request_threaded_irq(dev, irq, NULL, omnia_trng_irq_handler, > + IRQF_ONESHOT, "turris-omnia-mcu-trng", > + mcu); > + if (err) > + return dev_err_probe(dev, err, "Cannot request TRNG IRQ\n"); > + > + mcu->trng.name = "turris-omnia-mcu-trng"; > + mcu->trng.read = omnia_trng_read; > + mcu->trng.priv = (unsigned long)mcu; > + > + err = devm_hwrng_register(dev, &mcu->trng); > + if (err) > + return dev_err_probe(dev, err, "Cannot register TRNG\n"); > + > + return 0; > +} -- With Best Regards, Andy Shevchenko