Skip to content

Commit 3d497bf

Browse files
committed
Merge tag 'qcom-drivers-for-6.19' of https://git.kernel.org/pub/scm/linux/kernel/git/qcom/linux into soc/drivers
Qualcomm driver updates for v6.19 Support for hardware-keymanager v1 support for wrapped keys is introduce in the ICE driver. Support for the new Kaanapali mobile platform is added to last-level cache controller, pd-mapper, and UBWC drivers. UBWC driver gains support for the Monaco and Glymur platforms. The PMIC GLINK driver is extended to handle the differences found in targets where the related firmware runs on the SoCCP. Support for running on targets without initialized SMEM is provided, by reworking the SMEM driver to differentiate between "not yet probed" and "probed but there was no SMEM". An unwanted WARN_ON() that triggered if clients asked for a SMEM item beyond the currently running system's limit, was removed, to allow new use cases to gracefully fail on old targets. The Qualcomm socinfo driver is extended with support for version 20 through 23 and support for providing version information about more than 32 remote processors. Identifiers for QCS6490 and SM8850 are also added. Additionally, a number of smaller bug fixes and cleanups in PBS, OCMEM, GSBI, TZMEM, and MDT-loader are included. * tag 'qcom-drivers-for-6.19' of https://git.kernel.org/pub/scm/linux/kernel/git/qcom/linux: (31 commits) soc: qcom: mdt_loader: rename 'firmware' parameter of qcom_mdt_load() soc: qcom: mdt_loader: merge __qcom_mdt_load() and qcom_mdt_load_no_init() soc: qcom: socinfo: Add reserve field to support future extension soc: qcom: socinfo: Add support for new fields in revision 20 dt-bindings: firmware: qcom,scm: Document SCM on Kaanapali SOC soc: qcom: socinfo: add support to extract more than 32 image versions soc: qcom: smem: drop the WARN_ON() on SMEM item validation soc: qcom: ubwc: Add config for Kaanapali soc: qcom: socinfo: Add SoC ID for QCS6490 dt-bindings: arm: qcom,ids: Add SoC ID for QCS6490 soc: qcom: ice: Add HWKM v1 support for wrapped keys soc: qcom: smem: better track SMEM uninitialized state err.h: add INIT_ERR_PTR() macro soc: qcom: smem: fix hwspinlock resource leak in probe error paths dt-bindings: soc: qcom,aoss-qmp: Document the Glymur AOSS side channel dt-bindings: soc: qcom,aoss-qmp: Document the Kaanapali AOSS channel soc: qcom: ubwc: Add QCS8300 UBWC cfg dt-bindings: firmware: qcom,scm: Document Glymur scm soc: qcom: socinfo: Add SM8850 SoC ID dt-bindings: arm: qcom,ids: Add SoC ID for SM8850 ... Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2 parents a677d87 + 186b8f8 commit 3d497bf

20 files changed

Lines changed: 645 additions & 95 deletions

File tree

Documentation/devicetree/bindings/cache/qcom,llcc.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ properties:
2121
compatible:
2222
enum:
2323
- qcom,ipq5424-llcc
24+
- qcom,kaanapali-llcc
2425
- qcom,qcs615-llcc
2526
- qcom,qcs8300-llcc
2627
- qcom,qdu1000-llcc
@@ -272,6 +273,7 @@ allOf:
272273
compatible:
273274
contains:
274275
enum:
276+
- qcom,kaanapali-llcc
275277
- qcom,sm8450-llcc
276278
- qcom,sm8550-llcc
277279
- qcom,sm8650-llcc

Documentation/devicetree/bindings/firmware/qcom,scm.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ properties:
2323
- enum:
2424
- qcom,scm-apq8064
2525
- qcom,scm-apq8084
26+
- qcom,scm-glymur
2627
- qcom,scm-ipq4019
2728
- qcom,scm-ipq5018
2829
- qcom,scm-ipq5332
@@ -31,6 +32,7 @@ properties:
3132
- qcom,scm-ipq806x
3233
- qcom,scm-ipq8074
3334
- qcom,scm-ipq9574
35+
- qcom,scm-kaanapali
3436
- qcom,scm-mdm9607
3537
- qcom,scm-milos
3638
- qcom,scm-msm8226
@@ -202,6 +204,7 @@ allOf:
202204
compatible:
203205
contains:
204206
enum:
207+
- qcom,scm-kaanapali
205208
- qcom,scm-milos
206209
- qcom,scm-sm8450
207210
- qcom,scm-sm8550

Documentation/devicetree/bindings/soc/qcom/qcom,aoss-qmp.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ properties:
2525
compatible:
2626
items:
2727
- enum:
28+
- qcom,glymur-aoss-qmp
29+
- qcom,kaanapali-aoss-qmp
2830
- qcom,milos-aoss-qmp
2931
- qcom,qcs615-aoss-qmp
3032
- qcom,qcs8300-aoss-qmp

drivers/soc/qcom/ice.c

Lines changed: 58 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,18 @@
2222
#include <soc/qcom/ice.h>
2323

2424
#define AES_256_XTS_KEY_SIZE 64 /* for raw keys only */
25-
#define QCOM_ICE_HWKM_WRAPPED_KEY_SIZE 100 /* assuming HWKM v2 */
25+
26+
#define QCOM_ICE_HWKM_V1 1 /* HWKM version 1 */
27+
#define QCOM_ICE_HWKM_V2 2 /* HWKM version 2 */
28+
29+
#define QCOM_ICE_HWKM_MAX_WRAPPED_KEY_SIZE 100 /* Maximum HWKM wrapped key size */
30+
31+
/*
32+
* Wrapped key size depends upon HWKM version:
33+
* HWKM version 1 supports 68 bytes
34+
* HWKM version 2 supports 100 bytes
35+
*/
36+
#define QCOM_ICE_HWKM_WRAPPED_KEY_SIZE(v) ((v) == QCOM_ICE_HWKM_V1 ? 68 : 100)
2637

2738
/* QCOM ICE registers */
2839

@@ -62,13 +73,15 @@ union crypto_cfg {
6273

6374
#define QCOM_ICE_REG_HWKM_TZ_KM_CTL (HWKM_OFFSET + 0x1000)
6475
#define QCOM_ICE_HWKM_DISABLE_CRC_CHECKS_VAL (BIT(1) | BIT(2))
76+
/* In HWKM v1 the ICE legacy mode is controlled from HWKM register space */
77+
#define QCOM_ICE_HWKM_ICE_LEGACY_MODE_ENABLED BIT(5)
6578

6679
#define QCOM_ICE_REG_HWKM_TZ_KM_STATUS (HWKM_OFFSET + 0x1004)
6780
#define QCOM_ICE_HWKM_KT_CLEAR_DONE BIT(0)
6881
#define QCOM_ICE_HWKM_BOOT_CMD_LIST0_DONE BIT(1)
6982
#define QCOM_ICE_HWKM_BOOT_CMD_LIST1_DONE BIT(2)
70-
#define QCOM_ICE_HWKM_CRYPTO_BIST_DONE_V2 BIT(7)
71-
#define QCOM_ICE_HWKM_BIST_DONE_V2 BIT(9)
83+
#define QCOM_ICE_HWKM_CRYPTO_BIST_DONE(v) (((v) == QCOM_ICE_HWKM_V1) ? BIT(14) : BIT(7))
84+
#define QCOM_ICE_HWKM_BIST_DONE(v) (((v) == QCOM_ICE_HWKM_V1) ? BIT(16) : BIT(9))
7285

7386
#define QCOM_ICE_REG_HWKM_BANK0_BANKN_IRQ_STATUS (HWKM_OFFSET + 0x2008)
7487
#define QCOM_ICE_HWKM_RSP_FIFO_CLEAR_VAL BIT(3)
@@ -97,6 +110,7 @@ struct qcom_ice {
97110
struct clk *core_clk;
98111
bool use_hwkm;
99112
bool hwkm_init_complete;
113+
u8 hwkm_version;
100114
};
101115

102116
static bool qcom_ice_check_supported(struct qcom_ice *ice)
@@ -114,9 +128,24 @@ static bool qcom_ice_check_supported(struct qcom_ice *ice)
114128
return false;
115129
}
116130

131+
/* HWKM version v2 is present from ICE 3.2.1 onwards while version v1
132+
* is present only in ICE 3.2.0. Earlier ICE version don't have HWKM.
133+
*/
134+
if (major > 3 ||
135+
(major == 3 && (minor >= 3 || (minor == 2 && step >= 1))))
136+
ice->hwkm_version = QCOM_ICE_HWKM_V2;
137+
else if ((major == 3) && (minor == 2))
138+
ice->hwkm_version = QCOM_ICE_HWKM_V1;
139+
else
140+
ice->hwkm_version = 0;
141+
117142
dev_info(dev, "Found QC Inline Crypto Engine (ICE) v%d.%d.%d\n",
118143
major, minor, step);
119144

145+
if (ice->hwkm_version)
146+
dev_info(dev, "QC Hardware Key Manager (HWKM) version v%d\n",
147+
ice->hwkm_version);
148+
120149
/* If fuses are blown, ICE might not work in the standard way. */
121150
regval = qcom_ice_readl(ice, QCOM_ICE_REG_FUSE_SETTING);
122151
if (regval & (QCOM_ICE_FUSE_SETTING_MASK |
@@ -131,19 +160,18 @@ static bool qcom_ice_check_supported(struct qcom_ice *ice)
131160
* v3.2.1 and later have HWKM v2. ICE v3.2.0 has HWKM v1. Earlier ICE
132161
* versions don't have HWKM at all. However, for HWKM to be fully
133162
* usable by Linux, the TrustZone software also needs to support certain
134-
* SCM calls including the ones to generate and prepare keys. That
135-
* effectively makes the earliest supported SoC be SM8650, which has
136-
* HWKM v2. Therefore, this driver doesn't include support for HWKM v1,
137-
* and it checks for the SCM call support before it decides to use HWKM.
163+
* SCM calls including the ones to generate and prepare keys. Support
164+
* for these SCM calls is present for SoCs with HWKM v2 and is being
165+
* added for SoCs with HWKM v1 as well but not every SoC with HWKM v1
166+
* currently supports this. So, this driver checks for the SCM call
167+
* support before it decides to use HWKM.
138168
*
139169
* Also, since HWKM and legacy mode are mutually exclusive, and
140170
* ICE-capable storage driver(s) need to know early on whether to
141171
* advertise support for raw keys or wrapped keys, HWKM cannot be used
142172
* unconditionally. A module parameter is used to opt into using it.
143173
*/
144-
if ((major >= 4 ||
145-
(major == 3 && (minor >= 3 || (minor == 2 && step >= 1)))) &&
146-
qcom_scm_has_wrapped_key_support()) {
174+
if (ice->hwkm_version && qcom_scm_has_wrapped_key_support()) {
147175
if (qcom_ice_use_wrapped_keys) {
148176
dev_info(dev, "Using HWKM. Supporting wrapped keys only.\n");
149177
ice->use_hwkm = true;
@@ -212,8 +240,8 @@ static int qcom_ice_wait_bist_status(struct qcom_ice *ice)
212240
(QCOM_ICE_HWKM_KT_CLEAR_DONE |
213241
QCOM_ICE_HWKM_BOOT_CMD_LIST0_DONE |
214242
QCOM_ICE_HWKM_BOOT_CMD_LIST1_DONE |
215-
QCOM_ICE_HWKM_CRYPTO_BIST_DONE_V2 |
216-
QCOM_ICE_HWKM_BIST_DONE_V2)) {
243+
QCOM_ICE_HWKM_CRYPTO_BIST_DONE(ice->hwkm_version) |
244+
QCOM_ICE_HWKM_BIST_DONE(ice->hwkm_version))) {
217245
dev_err(ice->dev, "HWKM self-test error!\n");
218246
/*
219247
* Too late to revoke use_hwkm here, as it was already
@@ -230,17 +258,23 @@ static void qcom_ice_hwkm_init(struct qcom_ice *ice)
230258
if (!ice->use_hwkm)
231259
return;
232260

233-
BUILD_BUG_ON(QCOM_ICE_HWKM_WRAPPED_KEY_SIZE >
261+
BUILD_BUG_ON(QCOM_ICE_HWKM_MAX_WRAPPED_KEY_SIZE >
234262
BLK_CRYPTO_MAX_HW_WRAPPED_KEY_SIZE);
235263
/*
236264
* When ICE is in HWKM mode, it only supports wrapped keys.
237265
* When ICE is in legacy mode, it only supports raw keys.
238266
*
239267
* Put ICE in HWKM mode. ICE defaults to legacy mode.
240268
*/
241-
regval = qcom_ice_readl(ice, QCOM_ICE_REG_CONTROL);
242-
regval &= ~QCOM_ICE_LEGACY_MODE_ENABLED;
243-
qcom_ice_writel(ice, regval, QCOM_ICE_REG_CONTROL);
269+
if (ice->hwkm_version == QCOM_ICE_HWKM_V2) {
270+
regval = qcom_ice_readl(ice, QCOM_ICE_REG_CONTROL);
271+
regval &= ~QCOM_ICE_LEGACY_MODE_ENABLED;
272+
qcom_ice_writel(ice, regval, QCOM_ICE_REG_CONTROL);
273+
} else if (ice->hwkm_version == QCOM_ICE_HWKM_V1) {
274+
regval = qcom_ice_readl(ice, QCOM_ICE_REG_HWKM_TZ_KM_CTL);
275+
regval &= ~QCOM_ICE_HWKM_ICE_LEGACY_MODE_ENABLED;
276+
qcom_ice_writel(ice, regval, QCOM_ICE_REG_HWKM_TZ_KM_CTL);
277+
}
244278

245279
/* Disable CRC checks. This HWKM feature is not used. */
246280
qcom_ice_writel(ice, QCOM_ICE_HWKM_DISABLE_CRC_CHECKS_VAL,
@@ -298,7 +332,7 @@ EXPORT_SYMBOL_GPL(qcom_ice_suspend);
298332

299333
static unsigned int translate_hwkm_slot(struct qcom_ice *ice, unsigned int slot)
300334
{
301-
return slot * 2;
335+
return ice->hwkm_version == QCOM_ICE_HWKM_V1 ? slot : slot * 2;
302336
}
303337

304338
static int qcom_ice_program_wrapped_key(struct qcom_ice *ice, unsigned int slot,
@@ -451,11 +485,12 @@ int qcom_ice_generate_key(struct qcom_ice *ice,
451485
{
452486
int err;
453487

454-
err = qcom_scm_generate_ice_key(lt_key, QCOM_ICE_HWKM_WRAPPED_KEY_SIZE);
488+
err = qcom_scm_generate_ice_key(lt_key,
489+
QCOM_ICE_HWKM_WRAPPED_KEY_SIZE(ice->hwkm_version));
455490
if (err)
456491
return err;
457492

458-
return QCOM_ICE_HWKM_WRAPPED_KEY_SIZE;
493+
return QCOM_ICE_HWKM_WRAPPED_KEY_SIZE(ice->hwkm_version);
459494
}
460495
EXPORT_SYMBOL_GPL(qcom_ice_generate_key);
461496

@@ -478,13 +513,13 @@ int qcom_ice_prepare_key(struct qcom_ice *ice,
478513
int err;
479514

480515
err = qcom_scm_prepare_ice_key(lt_key, lt_key_size,
481-
eph_key, QCOM_ICE_HWKM_WRAPPED_KEY_SIZE);
516+
eph_key, QCOM_ICE_HWKM_WRAPPED_KEY_SIZE(ice->hwkm_version));
482517
if (err == -EIO || err == -EINVAL)
483518
err = -EBADMSG; /* probably invalid key */
484519
if (err)
485520
return err;
486521

487-
return QCOM_ICE_HWKM_WRAPPED_KEY_SIZE;
522+
return QCOM_ICE_HWKM_WRAPPED_KEY_SIZE(ice->hwkm_version);
488523
}
489524
EXPORT_SYMBOL_GPL(qcom_ice_prepare_key);
490525

@@ -506,11 +541,11 @@ int qcom_ice_import_key(struct qcom_ice *ice,
506541
int err;
507542

508543
err = qcom_scm_import_ice_key(raw_key, raw_key_size,
509-
lt_key, QCOM_ICE_HWKM_WRAPPED_KEY_SIZE);
544+
lt_key, QCOM_ICE_HWKM_WRAPPED_KEY_SIZE(ice->hwkm_version));
510545
if (err)
511546
return err;
512547

513-
return QCOM_ICE_HWKM_WRAPPED_KEY_SIZE;
548+
return QCOM_ICE_HWKM_WRAPPED_KEY_SIZE(ice->hwkm_version);
514549
}
515550
EXPORT_SYMBOL_GPL(qcom_ice_import_key);
516551

0 commit comments

Comments
 (0)