Received: by 2002:a89:48b:0:b0:1f5:f2ab:c469 with SMTP id a11csp629627lqd; Wed, 24 Apr 2024 11:58:31 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWDVYW6ICUOLKwJVL4m3hw3Gmmyttqjv9ZdePj8+hK7lUTxOIbrjIoo05MVp8SdHgB6cRfUjkyXq+M3v3aTdIf9tIva6YLUWI63k/LQ2Q== X-Google-Smtp-Source: AGHT+IGYeTiqaaM8VI38UwqqqhTy7xn4UfxinTsUuRznT0FYOWYHJFjCw46FJ/RVcqMFAVMKJYCT X-Received: by 2002:a17:903:32ce:b0:1e4:24cc:e021 with SMTP id i14-20020a17090332ce00b001e424cce021mr3944571plr.50.1713985111313; Wed, 24 Apr 2024 11:58:31 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713985111; cv=pass; d=google.com; s=arc-20160816; b=Y9ZFEqFvQEfGncSB54O+KAHyM1aHQCUl1LayHI6gz3eLgmZRKmP6/a2iF/pypvNL+t zWclem1s0UBJ2GQWGnJ0gKyoVq0BZt2UAuPT2TcD2hkBHmsTBNSJg2U9TrIQqQyTp3yL /Q7j7s7SOWxYfBwMGRsB/Oo0dG0t7N2nHMm9DUZ5l/DQU/TF2D6kvzpLkHyE0YPjYCe7 EYUNYPEM61S7fJpbIAljbz7hd6Q1/2tQ0ZWIOqfXAKArV5NV6sRT3uXNOSqyE23g9DSo pKCQLATYcfF+i+N4oEQkRfuJqECeyzLL+VWF868xrkxEtwq/EGWKDrDoTl5PV+7fb0T+ Ekcw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=organization:in-reply-to:content-transfer-encoding :content-disposition:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:references:message-id:subject:cc:to:from:date; bh=cuWmk99aMAo62bO0YYSUryvDkEQZTrG4MipfGqiocyE=; fh=+xMXiYvvyxWnylPpvGJGHxO5AdE0tqn17q7/q2XRASo=; b=YXPgo6E47szHF+iD9Qg37mPq18as0YDdYE8Y4liw6+Q7Oqd3al1qT1Usy0ETJmGXpk t6hJ4s5cqlOTlOEzTQDqfIXbYWcJkDiH1JVbxbrDyp8YpkiuYcQTxHfDrHAE9R48R1K4 ehrrjC3mqrmChdyIHU8vnqQ0UqxfJz70g4LTIZob+CNGtxY+pUkcxGlyLFetRtjuiBFx S0KGCl8/EoRV6c9a7r7HPfIAmM82NrfOJY9I2wvp3+G/9iDdt7wKN/xl3g9+8VhmfNWr 0OSzdIgyntUn8N0BdkkMs8U6TtLSabHOXHlgGGdOecy/Y/B9WRjrIU7Ocm1UH6rtw1Ul HtCg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-crypto+bounces-3826-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-crypto+bounces-3826-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id s19-20020a170902a51300b001e85dc6b450si11069563plq.159.2024.04.24.11.58.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Apr 2024 11:58:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto+bounces-3826-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of linux-crypto+bounces-3826-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-crypto+bounces-3826-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 3D554B28165 for ; Wed, 24 Apr 2024 18:33:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9CAF81D53C; Wed, 24 Apr 2024 18:33:52 +0000 (UTC) X-Original-To: linux-crypto@vger.kernel.org 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.subspace.kernel.org (Postfix) with ESMTPS id 346561CF9A for ; Wed, 24 Apr 2024 18:33:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.9 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713983632; cv=none; b=f6Vl0ShRSl3dE6B5Kno4jBHbg/9Qa4bthJevwvUix2aO3DR03KlWLHMZN+EqkStPmUHk96D/g15nyOiQFC2QaCwY8i35cQ7hxCzqb8RSuJyjmkdLy7NKCRKRL9Fl90UVm9VO/IdHUIqctDSlM1At9UJEDlXc+8KJfnr3j7Vc+4s= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713983632; c=relaxed/simple; bh=lXPwk1l5R4TU4c5qE/qPwPMB0kYhCMN4XzpdXEceGtc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=S3b3dMdpPZ+84HCB33O7uJTxh56VJx2ITJtafmqkSQzec9yzD+bVAtJmwfi15NSZsDphBjY8d0DhpJz2L0IoJmT8Lvpjv9TsF585qm+c0WT57WAOUBbMnGJMlGpHHVrcK29zxa/e2CeJVUq0nU0t5A2azNJ91j2joC04YqhHisA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=fail smtp.mailfrom=kernel.org; arc=none smtp.client-ip=198.175.65.9 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=kernel.org X-CSE-ConnectionGUID: jWoQJ2OfQ2eB8rYjwpcHxw== X-CSE-MsgGUID: IgJDjMShTxqcRN9Hk3CqQg== X-IronPort-AV: E=McAfee;i="6600,9927,11054"; a="32126197" X-IronPort-AV: E=Sophos;i="6.07,226,1708416000"; d="scan'208";a="32126197" 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?= 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> Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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