From nobody Fri Dec 19 13:47:44 2025 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 31572126C15 for ; Tue, 3 Sep 2024 21:22:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725398572; cv=none; b=uqujJuEGjhcxLFNWykB7XzDOx7ayY0iqrc5PspF5zfqlEZ3K8h4NDsWz4yD01nb45yshISjHw4OU9NW8G7owBO7qExTtCfwaqLxrG4T3BBaMkao/1JfdF7vgIKxMNJYNFoH8SS60knDAhjVlTg29nS7oY1PEC9OI4Ln4EBbABYE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725398572; c=relaxed/simple; bh=XeVESrItEVM4R9ipyaNeknfhuHOQ4dILrBWsO0yCW3s=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-type; b=pGKL2DPk5zWttPgpFF6kgBZMLqEmaOx8LWvX7qDx6Ee6OleLsN2aRuODodUdawVcsr/kZnzIMMh6WTvIRzUuq18gg162+pFbKeenz8As1HsTq/BuSbtlYjlGiKkwwidL8HlMY9U8tvdoZmBYF6MSQEq1ZRagpSNF5UXQ8ahdrTo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=L7N5XGLk; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="L7N5XGLk" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1725398569; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5OaxE+qf4J1jZnk8c8Xd2x+KJy3fbwff+kIsNtq2Opo=; b=L7N5XGLkRKQtN+OxAUFbXBeEomevjrLg7DLibICXjbY3GkdmpuerHOrtSUsDRK+wBvoloW KzS6821jewIb5nnM0/G4M6Jj4DcSE3kRmVygwNs7oha6JhMY2HlytCJQmx8MhihwmXUseV giS6f0352pMCu8ahXd3GdyWZ+m66hYE= Received: from mail-oa1-f70.google.com (mail-oa1-f70.google.com [209.85.160.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-177-_5o5EzA8MgWOpbYPIfQEMA-1; Tue, 03 Sep 2024 17:22:47 -0400 X-MC-Unique: _5o5EzA8MgWOpbYPIfQEMA-1 Received: by mail-oa1-f70.google.com with SMTP id 586e51a60fabf-27823557164so782100fac.2 for ; Tue, 03 Sep 2024 14:22:47 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725398566; x=1726003366; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5OaxE+qf4J1jZnk8c8Xd2x+KJy3fbwff+kIsNtq2Opo=; b=kX42yBhWqVH8D3mgKu2YfXaxWcI5infs0EpbOZNQMPAJhTF0IBNo2FTDD/YdL0pjys 3sMJr0kxas3/TDfkcunTWRNtpLSy7mtX1WyVC/1aC1zHpaK2E4/HRfD3W6rC2BFqc85D jhTh1SHvqeiCjPXmQbKNOTJwP69+c4RJMk+Vs1T8Gw+OwZd8QYJiS85BsH0bxhK/AKn+ XHTqzHWHIVW/jYBVDrHF+wJOT1HbKJrMaL6S9C8+O+CbudA39zak+lxM6A+DZlcq/ZdF YKJeB3Z3xVo7J/mFVTfrHlraQuwWOIsaDSEaUePiuq7Jk7Xio3fZ4paPDFE4b7U8O7cL WmtQ== X-Forwarded-Encrypted: i=1; AJvYcCXJPmGFx4MGluCIVZVH6mt+C82wY03Tp2NG+Z4l87dy+Tb8i6CQpTi0tnVJWxb31444CtnaWxz74GRm/TE=@vger.kernel.org X-Gm-Message-State: AOJu0YwVlCFeiCfgwud1McMhPtoh6PySeIY6rGBrPG5fwqHfUpfE320F v3zdSELhOSN+63yVyIcyX1MjDJ/Zidunj/jBe/EB30FK/hN66pUrSgWodutzdlmQB48bZoNv7uX nK1tb/X6GeEJHjSXHVA1OGibD7ZUk7IOR0YcQSBqhAu0qNJRuHh6GA42cdT7rpw== X-Received: by 2002:a05:6870:331e:b0:25e:7a1:ea8f with SMTP id 586e51a60fabf-277d06c897amr10603215fac.47.1725398566443; Tue, 03 Sep 2024 14:22:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG5djy4RfXuBi03LceJtw15luMRH4Faxo5Y9BNdPLILRJ8AbHm4nzFztUWK6JYZrH61sMi09w== X-Received: by 2002:a05:6870:331e:b0:25e:7a1:ea8f with SMTP id 586e51a60fabf-277d06c897amr10603204fac.47.1725398566139; Tue, 03 Sep 2024 14:22:46 -0700 (PDT) Received: from x1.redhat.com (c-98-219-206-88.hsd1.pa.comcast.net. [98.219.206.88]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7a806bfb8c9sm564737185a.25.2024.09.03.14.22.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2024 14:22:44 -0700 (PDT) From: Brian Masney To: herbert@gondor.apana.org.au Cc: davem@davemloft.net, quic_omprsing@quicinc.com, neil.armstrong@linaro.org, quic_bjorande@quicinc.com, linux-arm-msm@vger.kernel.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, ernesto.mnd.fernandez@gmail.com, quic_jhugo@quicinc.com Subject: [PATCH v2 1/2] crypto: qcom-rng: fix support for ACPI-based systems Date: Tue, 3 Sep 2024 17:22:19 -0400 Message-ID: <20240903212230.707376-2-bmasney@redhat.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240903212230.707376-1-bmasney@redhat.com> References: <20240903212230.707376-1-bmasney@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The qcom-rng driver supports both ACPI and device tree based systems. ACPI support was broken when the hw_random interface support was added. Let's go ahead and fix this by adding a check for has_acpi_companion(). This fix was boot tested on a Qualcomm Amberwing server. Fixes: f29cd5bb64c2 ("crypto: qcom-rng - Add hw_random interface support") Reported-by: Ernesto A. Fern\ufffd\ufffdndez Closes: https://lore.kernel.org/linux-arm-msm/20240828184019.GA21181@eaf/ Cc: stable@vger.kernel.org Signed-off-by: Brian Masney --- Note: I looked at updating the struct qcom_rng_acpi_match to have driver_data point to &qcom_prng_ee_of_data, however that won't work since struct acpi_device_id has a driver_data member of type kernel_ulong_t. struct of_device_id has the data member set to type const void *. As I get available time, I'll look to see if it's possible to migrate struct acpi_device_id.driver_data from a kernel_ulong_t to a const void * to match what's done in struct of_device_id. That will allow removing the has_acpi_companion() check in the future. I suspect that change is not going to be trivial though. drivers/crypto/qcom-rng.c | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/drivers/crypto/qcom-rng.c b/drivers/crypto/qcom-rng.c index c670d7d0c11e..7ba978f0ce8b 100644 --- a/drivers/crypto/qcom-rng.c +++ b/drivers/crypto/qcom-rng.c @@ -176,6 +176,21 @@ static struct rng_alg qcom_rng_alg =3D { } }; =20 +static struct qcom_rng_of_data qcom_prng_of_data =3D { + .skip_init =3D false, + .hwrng_support =3D false, +}; + +static struct qcom_rng_of_data qcom_prng_ee_of_data =3D { + .skip_init =3D true, + .hwrng_support =3D false, +}; + +static struct qcom_rng_of_data qcom_trng_of_data =3D { + .skip_init =3D true, + .hwrng_support =3D true, +}; + static int qcom_rng_probe(struct platform_device *pdev) { struct qcom_rng *rng; @@ -196,7 +211,10 @@ static int qcom_rng_probe(struct platform_device *pdev) if (IS_ERR(rng->clk)) return PTR_ERR(rng->clk); =20 - rng->of_data =3D (struct qcom_rng_of_data *)of_device_get_match_data(&pde= v->dev); + if (has_acpi_companion(&pdev->dev)) + rng->of_data =3D &qcom_prng_ee_of_data; + else + rng->of_data =3D (struct qcom_rng_of_data *)of_device_get_match_data(&pd= ev->dev); =20 qcom_rng_dev =3D rng; ret =3D crypto_register_rng(&qcom_rng_alg); @@ -231,21 +249,6 @@ static void qcom_rng_remove(struct platform_device *pd= ev) qcom_rng_dev =3D NULL; } =20 -static struct qcom_rng_of_data qcom_prng_of_data =3D { - .skip_init =3D false, - .hwrng_support =3D false, -}; - -static struct qcom_rng_of_data qcom_prng_ee_of_data =3D { - .skip_init =3D true, - .hwrng_support =3D false, -}; - -static struct qcom_rng_of_data qcom_trng_of_data =3D { - .skip_init =3D true, - .hwrng_support =3D true, -}; - static const struct acpi_device_id __maybe_unused qcom_rng_acpi_match[] = =3D { { .id =3D "QCOM8160", .driver_data =3D 1 }, {} --=20 2.46.0 From nobody Fri Dec 19 13:47:44 2025 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 47E9E1922CD for ; Tue, 3 Sep 2024 21:22:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725398573; cv=none; b=LY5W/iBR7KQhLNacppOtNxuxLSJ+z9WS3DnzM0J98X8zpby7v+aCyOYs2qx5cz/UnYQeWqWy5VuSW4ZW4CHDyE4iwNHxV7y6XSwEC/PCK/bZw8cASPrD+hZu9mH1U6iHCpyRrXJlw/We0C0iL0L0YVblfxeItgceNWeuqgnT6vk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725398573; c=relaxed/simple; bh=8P1Jum47rGgM7FDX62HMOHw91bamdwad0+5M/vSm+X0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-type; b=pj1DZ8tubQzZP2m80Hobf2YRQNQ7fhwYPPoqvFo8DcRgoIpwhu/0sYxoMBTiyoKDZz8U7HImzWk+eUa9uFIufgBR2m6j3tm5PfVQNWmVDvi2E+ug+5gKTPm/ZTLXr6vW9o6TuZkBGaT2ME6MVIACdq4NlZnuJIDWbp6QaB097AE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=U640d6iX; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="U640d6iX" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1725398571; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=x8BQfqOVIo0s9x5Bh8x8Xi9+zxZ5VGhm3NLe1eX0SoQ=; b=U640d6iXbRZbI42cUA81k+AhotHl6t835KYw8r2TuY8aQKYFrN3u3dkwEYkhdisZOVJdGb O86/ING9HdXSDaepBrYNlRFwCsRZw4rtlCSDCdgsTsDlurZchU7tMBH46SShFx6AGaNKAE FnMcl0u//dYOdIGv8VLMl+eNPj4RXyw= Received: from mail-oa1-f71.google.com (mail-oa1-f71.google.com [209.85.160.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-647-MDlf4KM0OSq4jBFGxn3Ykw-1; Tue, 03 Sep 2024 17:22:50 -0400 X-MC-Unique: MDlf4KM0OSq4jBFGxn3Ykw-1 Received: by mail-oa1-f71.google.com with SMTP id 586e51a60fabf-277f1e27d63so3955071fac.0 for ; Tue, 03 Sep 2024 14:22:50 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725398569; x=1726003369; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=x8BQfqOVIo0s9x5Bh8x8Xi9+zxZ5VGhm3NLe1eX0SoQ=; b=kdU2Y03pfUIHLEdXx4G3wz41p2UpKgonKHDUU0IGAeRdZKrH/8yJOLDojx0Y7u5UK7 8jTEOXDNdYvehCclBZZoWexCwdJAV9Hy2G4uoV9SyksFh/iZP6GkQXmQBreBKd8Bs+Bs goWfnQo6M0RwwPhdLhnZqJfVQvK2iuMfeOKdXo3rn1a1ywuMK/UNQ4ccuckZ/r9aQlXf KVMJ8+a7W6kUCQwcStmO9AoNd7YUUvNpV4imSEDmcOjTHyiG+EPSeiRdoU3xPjB4kHH1 Qwdae6l76ecZZ8xUwCvhUdl/URSHw6zCcHIn/rD0NoVT9+8kzFyj0EJBQ2nehzYeqWW1 cq3A== X-Forwarded-Encrypted: i=1; AJvYcCUdsKQSTbCyyClyaBugGSPz2rk3abzYfv4I+yMYedhQqeXoLgOhLRtbSYxkBRPh6swn2uBjdG6sW55QX+s=@vger.kernel.org X-Gm-Message-State: AOJu0YzVuNvzKz2MWJWz66TFlHfcGl2ihilOdK3OOdCQnxxctW54zNJ+ l5LjrLN4RZeS37XCPg868Okf7OznciQTIGPej4sRcp8iIMy7bGDhRpz75NT9TCNBZXYc7ekUgpZ CDLoR8bAaIdD18CJM15mqKwr/P/scHA3wYJucXgWnaOC4rMGVz/o1pgjJsY01uA== X-Received: by 2002:a05:6870:ab13:b0:261:648:ddc5 with SMTP id 586e51a60fabf-277d0440313mr13448329fac.22.1725398569453; Tue, 03 Sep 2024 14:22:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGkeRLWZ/sDG45fCql0Gm6F6kVH9oaiaaJPzDMm1J3AN0Z6MSDkiIcKaR6kgJxb0RqGP1wSkQ== X-Received: by 2002:a05:6870:ab13:b0:261:648:ddc5 with SMTP id 586e51a60fabf-277d0440313mr13448302fac.22.1725398569071; Tue, 03 Sep 2024 14:22:49 -0700 (PDT) Received: from x1.redhat.com (c-98-219-206-88.hsd1.pa.comcast.net. [98.219.206.88]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7a806bfb8c9sm564737185a.25.2024.09.03.14.22.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Sep 2024 14:22:47 -0700 (PDT) From: Brian Masney To: herbert@gondor.apana.org.au Cc: davem@davemloft.net, quic_omprsing@quicinc.com, neil.armstrong@linaro.org, quic_bjorande@quicinc.com, linux-arm-msm@vger.kernel.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, ernesto.mnd.fernandez@gmail.com, quic_jhugo@quicinc.com Subject: [PATCH v2 2/2] crypto: qcom-rng: rename *_of_data to *_match_data Date: Tue, 3 Sep 2024 17:22:20 -0400 Message-ID: <20240903212230.707376-3-bmasney@redhat.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240903212230.707376-1-bmasney@redhat.com> References: <20240903212230.707376-1-bmasney@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The qcom-rng driver supports both ACPI and device tree based systems. Let's rename all instances of *_of_data to *_match_data so that it's not implied that this driver only supports device tree. Signed-off-by: Brian Masney --- drivers/crypto/qcom-rng.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/drivers/crypto/qcom-rng.c b/drivers/crypto/qcom-rng.c index 7ba978f0ce8b..f630962469c8 100644 --- a/drivers/crypto/qcom-rng.c +++ b/drivers/crypto/qcom-rng.c @@ -36,14 +36,14 @@ struct qcom_rng { void __iomem *base; struct clk *clk; struct hwrng hwrng; - struct qcom_rng_of_data *of_data; + struct qcom_rng_match_data *match_data; }; =20 struct qcom_rng_ctx { struct qcom_rng *rng; }; =20 -struct qcom_rng_of_data { +struct qcom_rng_match_data { bool skip_init; bool hwrng_support; }; @@ -155,7 +155,7 @@ static int qcom_rng_init(struct crypto_tfm *tfm) =20 ctx->rng =3D qcom_rng_dev; =20 - if (!ctx->rng->of_data->skip_init) + if (!ctx->rng->match_data->skip_init) return qcom_rng_enable(ctx->rng); =20 return 0; @@ -176,17 +176,17 @@ static struct rng_alg qcom_rng_alg =3D { } }; =20 -static struct qcom_rng_of_data qcom_prng_of_data =3D { +static struct qcom_rng_match_data qcom_prng_match_data =3D { .skip_init =3D false, .hwrng_support =3D false, }; =20 -static struct qcom_rng_of_data qcom_prng_ee_of_data =3D { +static struct qcom_rng_match_data qcom_prng_ee_match_data =3D { .skip_init =3D true, .hwrng_support =3D false, }; =20 -static struct qcom_rng_of_data qcom_trng_of_data =3D { +static struct qcom_rng_match_data qcom_trng_match_data =3D { .skip_init =3D true, .hwrng_support =3D true, }; @@ -212,9 +212,10 @@ static int qcom_rng_probe(struct platform_device *pdev) return PTR_ERR(rng->clk); =20 if (has_acpi_companion(&pdev->dev)) - rng->of_data =3D &qcom_prng_ee_of_data; + rng->match_data =3D &qcom_prng_ee_match_data; else - rng->of_data =3D (struct qcom_rng_of_data *)of_device_get_match_data(&pd= ev->dev); + rng->match_data =3D + (struct qcom_rng_match_data *)of_device_get_match_data(&pdev->dev); =20 qcom_rng_dev =3D rng; ret =3D crypto_register_rng(&qcom_rng_alg); @@ -224,7 +225,7 @@ static int qcom_rng_probe(struct platform_device *pdev) return ret; } =20 - if (rng->of_data->hwrng_support) { + if (rng->match_data->hwrng_support) { rng->hwrng.name =3D "qcom_hwrng"; rng->hwrng.read =3D qcom_hwrng_read; rng->hwrng.quality =3D QCOM_TRNG_QUALITY; @@ -256,9 +257,9 @@ static const struct acpi_device_id __maybe_unused qcom_= rng_acpi_match[] =3D { MODULE_DEVICE_TABLE(acpi, qcom_rng_acpi_match); =20 static const struct of_device_id __maybe_unused qcom_rng_of_match[] =3D { - { .compatible =3D "qcom,prng", .data =3D &qcom_prng_of_data }, - { .compatible =3D "qcom,prng-ee", .data =3D &qcom_prng_ee_of_data }, - { .compatible =3D "qcom,trng", .data =3D &qcom_trng_of_data }, + { .compatible =3D "qcom,prng", .data =3D &qcom_prng_match_data }, + { .compatible =3D "qcom,prng-ee", .data =3D &qcom_prng_ee_match_data }, + { .compatible =3D "qcom,trng", .data =3D &qcom_trng_match_data }, {} }; MODULE_DEVICE_TABLE(of, qcom_rng_of_match); --=20 2.46.0