Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp345360lqt; Thu, 6 Jun 2024 05:37:28 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWovbLlGLsUjQhfXWnZDOKsWVBWr4IcNT9HT2KnNJ3keT0XXS02+Zl6e66dmzB+rZ4fBoJinPse4UFPEjmCeotwIAhIcJ2uAwo0U0R+/Q== X-Google-Smtp-Source: AGHT+IEWsOqy7GP78JtKsNmjsvhSm8PPoY4fCF3ShHRepSimjKqgwUINoJkwcPyfX66d6hYRiMwt X-Received: by 2002:ac8:7d86:0:b0:43a:cbe9:2e32 with SMTP id d75a77b69052e-4402b66b214mr69604941cf.55.1717677447967; Thu, 06 Jun 2024 05:37:27 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717677447; cv=pass; d=google.com; s=arc-20160816; b=FojJDJ/IofET+SYd2nf9nAGsusX2jjiJRaSkHZn+GLrRv7wWRna/s2vNqqq7SdThpi ZIAE7g2pURYCkvYYHkBHx0y9PZdw69XTYvCTAI8pJP8n74LP/ysH6dKHErjJV7+WzAgV yF0ApK4SLluPjKQga5S62KHIvbCKiq8d2dOQ5xFTZQTOA5o5evUzWpZM858mmreYhhPZ CFiHNlCanwTAN4wH0hZEeSxsFlG9vtLb2Sq+caUes112wObdOtMGEiCqbT7T/i/bIHgc Hrpemz/CZ0vG+XeJgC+l92Ss+B/Bm3pEg2y2xZjYjJzWIkWLtdjJClmfld9k8+STgVEm J6bw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=N14xrse9hCUV/WALkqCWEOIxh9s6q281kaKSwcNGfu4=; fh=8BT74fsbp0XmH7IIgZ0DK4VOaTf919FiYR7F5ZR4Odg=; b=ynjsalygX9xgxDh8GKtwcBCn0QTF85hUzlkl2EQ3HNH6T8BNfSkI4AxI3X7pBErBRz viZGcLArZD7CXiZOGJj+hNcX1oraiB0eowp03yu1AIpC0aymj4kchOQTKFBlQQ+UnHrY +Q8fnKWtWF2kY/QyWo3Lw/jU/6K7th/4wh9bZLxmfKp4sSqGGe0LtzLxr7kj/KXpplZl MxOKr/CYZ+p73xraTDHwEj0EeU1vQ/LN2G1d1zpo0eq+CJnQOuYKP0fclJN168FYs8Af c0BbA9pu55kaZpPfcdZN9bx0YGlEpIlMZVEp/15dwEAkNuWREVi8SzJsR2zlj6SxChb4 BX8g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=fail header.i=@kernel.org header.s=k20201202 header.b=gQccY+ew; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-crypto+bounces-4788-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-crypto+bounces-4788-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id d75a77b69052e-44038a6934asi15895071cf.54.2024.06.06.05.37.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jun 2024 05:37:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto+bounces-4788-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=fail header.i=@kernel.org header.s=k20201202 header.b=gQccY+ew; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-crypto+bounces-4788-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-crypto+bounces-4788-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id A743D1C23460 for ; Thu, 6 Jun 2024 12:37:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3AF5F195981; Thu, 6 Jun 2024 12:37:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="gQccY+ew" X-Original-To: linux-crypto@vger.kernel.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.subspace.kernel.org (Postfix) with ESMTPS id EF3E7194AE3 for ; Thu, 6 Jun 2024 12:37:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717677439; cv=none; b=bYvyaY+DZ3uUHq+xuyyjDiESKT3cEV1j2ojDuGhMvAbT96sXJEN1UgRGXH99v16yBFKfCpErIH/oX7wuQKlm2TRqnOZVgqPHe1AV3QQeBuwLx9yhUJ/RqivVbZjs8EnTlxUEMmXHuz5umPKnlA2xMWK2dzgpuhRTegXef7wtSVg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717677439; c=relaxed/simple; bh=HbWT6OYIoSMUdqEwFQCigxt9BAs94whDX4VRszXZAK4=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=k1M+GE9qkcxDBQ+nXQwdpSKRBf35vI9d63g/WrfQbOaXuSXrAISdUUcpo40sNSlLFj8lA20UM3dCISd5U6d9aaYs7mUzH/ZBRJWQvk/7kiilRQCr30vnZcu3orVZdlh8J9hiFY+5EYPxbxuQ5+5xUuHsv7csQDai3vmGpbMY9kU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=gQccY+ew; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 023C2C4AF08; Thu, 6 Jun 2024 12:37:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717677438; bh=HbWT6OYIoSMUdqEwFQCigxt9BAs94whDX4VRszXZAK4=; h=Date:From:To:List-Id:Cc:Subject:In-Reply-To:References:From; b=gQccY+ewYZ9OHq/FOFWHIatCTpmuuNfakUNTLpbzz1a1XQ6WAS3HMlq4NK3goUqLG /EqwCMEDm8PanYBKvvdYg+14/Hnkh1BI4ahyRvNnk6kJBsa/4c3Sdm90R3JSVcBPTf MsO0Ifak7hYWZ43G0XgdvRWoJHNAj0GWdh2BUxpV9S9hlU6idtZ2354u4lN2ZY5cEm +Lw4kl2KV1HpkJ5iynjEuG3M/oN4l/aRa0XK/NJPPJi6IaqRDuhDZXS3jP8bvdsiKa xe/21JIyoonhpVBTuoXFV/FqnwxmZroxe1KV7eV1hZ6Rb6GGO8Jz+GM+xnmjEouPmF bdxIr+3TDj93g== Date: Thu, 6 Jun 2024 14:37:12 +0200 From: Marek =?UTF-8?B?QmVow7pu?= To: Andy Shevchenko Cc: Bartosz Golaszewski , Gregory CLEMENT , Arnd Bergmann , soc@kernel.org, arm@kernel.org, Hans de Goede , Ilpo =?UTF-8?B?SsOkcnZpbmVu?= , Olivia Mackall , Herbert Xu , Greg Kroah-Hartman , linux-crypto@vger.kernel.org Subject: Re: [PATCH v11 6/8] platform: cznic: turris-omnia-mcu: Add support for MCU provided TRNG Message-ID: <20240606143712.6b834d7c@dellmb> In-Reply-To: References: <20240605161851.13911-1-kabel@kernel.org> <20240605161851.13911-7-kabel@kernel.org> <20240606105308.3e02cf1e@dellmb> X-Mailer: Claws Mail 4.2.0 (GTK 3.24.41; x86_64-pc-linux-gnu) 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=UTF-8 Content-Transfer-Encoding: quoted-printable On Thu, 6 Jun 2024 13:11:09 +0300 Andy Shevchenko wrote: > On Thu, Jun 06, 2024 at 10:53:08AM +0200, Marek Beh=C3=BAn wrote: > > On Wed, 5 Jun 2024 22:00:20 +0300 > > Andy Shevchenko wrote: > > =20 > > > > + irq_idx =3D omnia_int_to_gpio_idx[__bf_shf(OMNIA_INT_TRNG)]; > > > > + irq =3D gpiod_to_irq(gpiochip_get_desc(&mcu->gc, irq_idx)); > > > > + if (irq < 0) > > > > + return dev_err_probe(dev, irq, "Cannot get TRNG IRQ= \n"); =20 > > >=20 > > > Okay, it's a bit more complicated than that. The gpiochip_get_desc() > > > shouldn't be used. Bart, what can you suggest to do here? Opencoding > > > it doesn't sound to me a (fully) correct approach in a long term. =20 > >=20 > > Note that I can't use gpiochip_request_own_desc(), nor any other > > function that calls gpio_request_commit() (like gpiod_get()), because > > that checks for gpiochip_line_is_valid(), and this returns false for > > the TRNG line, cause that line is not a GPIO line, but interrupt only > > line. > >=20 > > That is why I used > > irq =3D irq_create_mapping(dev, mcu->gc.irq.domain, irq_idx); > > until v7, with no reference to gpio descriptors, since this line is not > > a GPIO line. > >=20 > > We have discussed this back in April, in the thread > > https://lore.kernel.org/soc/20240418121116.22184-8-kabel@kernel.org/ > > where we concluded that > > irq =3D gpiod_to_irq(gpiochip_get_desc(gc, irq_idx)); > > is better... =20 >=20 > That's fine to not use other APIs, the problem here is with reference cou= nting > on the GPIO device. The API you could use is gpio_device_get_desc(). But = you > need to have a GPIO device pointer somewhere in your driver being availab= le. Rewriting to gpio_device_get_desc() is simple, since gpiochip_get_desc(gc, hwnum) is equivalent to gpio_device_get_desc(gc->gpiodev, hwnum) Obviously neither of these take care of reference counting. But what reference counting are you talking about? Is it the try_module_get(desc->gdev->owner) in gpiod_request()? Or are we talking only about the FLAG_REQUESTED flag on the descriptor flags? (This one should not be needed since the GPIO line cannot be requested, becuase it is not a valid GPIO line.) Since the line is not a valid GPIO line, I thought that we don't need to refcount in GPIO code. gpiod_to_irq() will call the gpiochip's .to_irq() method, which will call gpiochip_to_irq(), which will call irq_create_mapping() gpiod_to_irq() gpiochip_to_irq() irq_create_mapping() Then on gpiochip removal, the gpiochip_irqchip_remove() manually disposes all IRQ mappings with irq_dispose_mapping(). Marek