Skip to content

Commit 30be844

Browse files
committed
Merge tag 'qcom-drivers-for-5.13-2' of git://git.kernel.org/pub/scm/linux/kernel/git/qcom/linux into arm/drivers
More Qualcomm driver updates for 5.13 This improves the Qualcomm SCM driver logic related to detecting the calling convention, in particular on SC7180, and fixes a few small issues in the same. It introduces additonal sanity checks of the size of loaded segments in the MDT loader and adds a missing error in the return path of pdr_register_listener(). It makes it possible to specify the OEM specific firmware path in the wcn36xx control (and WiFi) driver. Lastly it adds a missing path specifier in the MAINTAINERS' entry and fixes a bunch of kerneldoc issues in various drivers. * tag 'qcom-drivers-for-5.13-2' of git://git.kernel.org/pub/scm/linux/kernel/git/qcom/linux: soc: qcom: mdt_loader: Detect truncated read of segments soc: qcom: mdt_loader: Validate that p_filesz < p_memsz soc: qcom: pdr: Fix error return code in pdr_register_listener firmware: qcom_scm: Fix kernel-doc function names to match firmware: qcom_scm: Suppress sysfs bind attributes firmware: qcom_scm: Workaround lack of "is available" call on SC7180 firmware: qcom_scm: Reduce locking section for __get_convention() firmware: qcom_scm: Make __qcom_scm_is_call_available() return bool soc: qcom: wcnss_ctrl: Allow reading firmware-name from DT soc: qcom: wcnss_ctrl: Introduce local variable "dev" dt-bindings: soc: qcom: wcnss: Add firmware-name property soc: qcom: address kernel-doc warnings MAINTAINERS: add another entry for ARM/QUALCOMM SUPPORT Link: https://lore.kernel.org/r/20210409162001.775851-1-bjorn.andersson@linaro.org Signed-off-by: Arnd Bergmann <arnd@arndb.de>
2 parents 3684100 + 0648c55 commit 30be844

13 files changed

Lines changed: 107 additions & 61 deletions

File tree

‎Documentation/devicetree/bindings/soc/qcom/qcom,wcnss.txt‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ block and a BT, WiFi and FM radio block, all using SMD as command channels.
2424
"qcom,riva",
2525
"qcom,pronto"
2626

27+
- firmware-name:
28+
Usage: optional
29+
Value type: <string>
30+
Definition: specifies the relative firmware image path for the WLAN NV
31+
blob. Defaults to "wlan/prima/WCNSS_qcom_wlan_nv.bin" if
32+
not specified.
33+
2734
= SUBNODES
2835
The subnodes of the wcnss node are optional and describe the individual blocks in
2936
the WCNSS.

‎MAINTAINERS‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2296,6 +2296,7 @@ F: drivers/tty/serial/msm_serial.c
22962296
F: drivers/usb/dwc3/dwc3-qcom.c
22972297
F: include/dt-bindings/*/qcom*
22982298
F: include/linux/*/qcom*
2299+
F: include/linux/soc/qcom/
22992300

23002301
ARM/RADISYS ENP2611 MACHINE SUPPORT
23012302
M: Lennert Buytenhek <kernel@wantstofly.org>

‎drivers/firmware/qcom_scm-legacy.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ static void __scm_legacy_do(const struct arm_smccc_args *smc,
118118
}
119119

120120
/**
121-
* qcom_scm_call() - Sends a command to the SCM and waits for the command to
121+
* scm_legacy_call() - Sends a command to the SCM and waits for the command to
122122
* finish processing.
123123
*
124124
* A note on cache maintenance:
@@ -209,7 +209,7 @@ int scm_legacy_call(struct device *dev, const struct qcom_scm_desc *desc,
209209
(n & 0xf))
210210

211211
/**
212-
* qcom_scm_call_atomic() - Send an atomic SCM command with up to 5 arguments
212+
* scm_legacy_call_atomic() - Send an atomic SCM command with up to 5 arguments
213213
* and 3 return values
214214
* @desc: SCM call descriptor containing arguments
215215
* @res: SCM call return values

‎drivers/firmware/qcom_scm-smc.c‎

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,10 @@ static void __scm_smc_do(const struct arm_smccc_args *smc,
7777
} while (res->a0 == QCOM_SCM_V2_EBUSY);
7878
}
7979

80-
int scm_smc_call(struct device *dev, const struct qcom_scm_desc *desc,
81-
struct qcom_scm_res *res, bool atomic)
80+
81+
int __scm_smc_call(struct device *dev, const struct qcom_scm_desc *desc,
82+
enum qcom_scm_convention qcom_convention,
83+
struct qcom_scm_res *res, bool atomic)
8284
{
8385
int arglen = desc->arginfo & 0xf;
8486
int i;
@@ -87,9 +89,8 @@ int scm_smc_call(struct device *dev, const struct qcom_scm_desc *desc,
8789
size_t alloc_len;
8890
gfp_t flag = atomic ? GFP_ATOMIC : GFP_KERNEL;
8991
u32 smccc_call_type = atomic ? ARM_SMCCC_FAST_CALL : ARM_SMCCC_STD_CALL;
90-
u32 qcom_smccc_convention =
91-
(qcom_scm_convention == SMC_CONVENTION_ARM_32) ?
92-
ARM_SMCCC_SMC_32 : ARM_SMCCC_SMC_64;
92+
u32 qcom_smccc_convention = (qcom_convention == SMC_CONVENTION_ARM_32) ?
93+
ARM_SMCCC_SMC_32 : ARM_SMCCC_SMC_64;
9394
struct arm_smccc_res smc_res;
9495
struct arm_smccc_args smc = {0};
9596

@@ -148,4 +149,5 @@ int scm_smc_call(struct device *dev, const struct qcom_scm_desc *desc,
148149
}
149150

150151
return (long)smc_res.a0 ? qcom_scm_remap_error(smc_res.a0) : 0;
152+
151153
}

‎drivers/firmware/qcom_scm.c‎

Lines changed: 50 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,10 @@ static void qcom_scm_clk_disable(void)
113113
clk_disable_unprepare(__scm->bus_clk);
114114
}
115115

116-
static int __qcom_scm_is_call_available(struct device *dev, u32 svc_id,
117-
u32 cmd_id);
116+
enum qcom_scm_convention qcom_scm_convention = SMC_CONVENTION_UNKNOWN;
117+
static DEFINE_SPINLOCK(scm_query_lock);
118118

119-
enum qcom_scm_convention qcom_scm_convention;
120-
static bool has_queried __read_mostly;
121-
static DEFINE_SPINLOCK(query_lock);
122-
123-
static void __query_convention(void)
119+
static enum qcom_scm_convention __get_convention(void)
124120
{
125121
unsigned long flags;
126122
struct qcom_scm_desc desc = {
@@ -133,36 +129,50 @@ static void __query_convention(void)
133129
.owner = ARM_SMCCC_OWNER_SIP,
134130
};
135131
struct qcom_scm_res res;
132+
enum qcom_scm_convention probed_convention;
136133
int ret;
134+
bool forced = false;
137135

138-
spin_lock_irqsave(&query_lock, flags);
139-
if (has_queried)
140-
goto out;
136+
if (likely(qcom_scm_convention != SMC_CONVENTION_UNKNOWN))
137+
return qcom_scm_convention;
141138

142-
qcom_scm_convention = SMC_CONVENTION_ARM_64;
143-
// Device isn't required as there is only one argument - no device
144-
// needed to dma_map_single to secure world
145-
ret = scm_smc_call(NULL, &desc, &res, true);
139+
/*
140+
* Device isn't required as there is only one argument - no device
141+
* needed to dma_map_single to secure world
142+
*/
143+
probed_convention = SMC_CONVENTION_ARM_64;
144+
ret = __scm_smc_call(NULL, &desc, probed_convention, &res, true);
146145
if (!ret && res.result[0] == 1)
147-
goto out;
146+
goto found;
147+
148+
/*
149+
* Some SC7180 firmwares didn't implement the
150+
* QCOM_SCM_INFO_IS_CALL_AVAIL call, so we fallback to forcing ARM_64
151+
* calling conventions on these firmwares. Luckily we don't make any
152+
* early calls into the firmware on these SoCs so the device pointer
153+
* will be valid here to check if the compatible matches.
154+
*/
155+
if (of_device_is_compatible(__scm ? __scm->dev->of_node : NULL, "qcom,scm-sc7180")) {
156+
forced = true;
157+
goto found;
158+
}
148159

149-
qcom_scm_convention = SMC_CONVENTION_ARM_32;
150-
ret = scm_smc_call(NULL, &desc, &res, true);
160+
probed_convention = SMC_CONVENTION_ARM_32;
161+
ret = __scm_smc_call(NULL, &desc, probed_convention, &res, true);
151162
if (!ret && res.result[0] == 1)
152-
goto out;
153-
154-
qcom_scm_convention = SMC_CONVENTION_LEGACY;
155-
out:
156-
has_queried = true;
157-
spin_unlock_irqrestore(&query_lock, flags);
158-
pr_info("qcom_scm: convention: %s\n",
159-
qcom_scm_convention_names[qcom_scm_convention]);
160-
}
163+
goto found;
164+
165+
probed_convention = SMC_CONVENTION_LEGACY;
166+
found:
167+
spin_lock_irqsave(&scm_query_lock, flags);
168+
if (probed_convention != qcom_scm_convention) {
169+
qcom_scm_convention = probed_convention;
170+
pr_info("qcom_scm: convention: %s%s\n",
171+
qcom_scm_convention_names[qcom_scm_convention],
172+
forced ? " (forced)" : "");
173+
}
174+
spin_unlock_irqrestore(&scm_query_lock, flags);
161175

162-
static inline enum qcom_scm_convention __get_convention(void)
163-
{
164-
if (unlikely(!has_queried))
165-
__query_convention();
166176
return qcom_scm_convention;
167177
}
168178

@@ -219,8 +229,8 @@ static int qcom_scm_call_atomic(struct device *dev,
219229
}
220230
}
221231

222-
static int __qcom_scm_is_call_available(struct device *dev, u32 svc_id,
223-
u32 cmd_id)
232+
static bool __qcom_scm_is_call_available(struct device *dev, u32 svc_id,
233+
u32 cmd_id)
224234
{
225235
int ret;
226236
struct qcom_scm_desc desc = {
@@ -247,7 +257,7 @@ static int __qcom_scm_is_call_available(struct device *dev, u32 svc_id,
247257

248258
ret = qcom_scm_call(dev, &desc, &res);
249259

250-
return ret ? : res.result[0];
260+
return ret ? false : !!res.result[0];
251261
}
252262

253263
/**
@@ -585,9 +595,8 @@ bool qcom_scm_pas_supported(u32 peripheral)
585595
};
586596
struct qcom_scm_res res;
587597

588-
ret = __qcom_scm_is_call_available(__scm->dev, QCOM_SCM_SVC_PIL,
589-
QCOM_SCM_PIL_PAS_IS_SUPPORTED);
590-
if (ret <= 0)
598+
if (!__qcom_scm_is_call_available(__scm->dev, QCOM_SCM_SVC_PIL,
599+
QCOM_SCM_PIL_PAS_IS_SUPPORTED))
591600
return false;
592601

593602
ret = qcom_scm_call(__scm->dev, &desc, &res);
@@ -1060,17 +1069,18 @@ EXPORT_SYMBOL(qcom_scm_ice_set_key);
10601069
*/
10611070
bool qcom_scm_hdcp_available(void)
10621071
{
1072+
bool avail;
10631073
int ret = qcom_scm_clk_enable();
10641074

10651075
if (ret)
10661076
return ret;
10671077

1068-
ret = __qcom_scm_is_call_available(__scm->dev, QCOM_SCM_SVC_HDCP,
1078+
avail = __qcom_scm_is_call_available(__scm->dev, QCOM_SCM_SVC_HDCP,
10691079
QCOM_SCM_HDCP_INVOKE);
10701080

10711081
qcom_scm_clk_disable();
10721082

1073-
return ret > 0;
1083+
return avail;
10741084
}
10751085
EXPORT_SYMBOL(qcom_scm_hdcp_available);
10761086

@@ -1242,7 +1252,7 @@ static int qcom_scm_probe(struct platform_device *pdev)
12421252
__scm = scm;
12431253
__scm->dev = &pdev->dev;
12441254

1245-
__query_convention();
1255+
__get_convention();
12461256

12471257
/*
12481258
* If requested enable "download mode", from this point on warmboot
@@ -1291,6 +1301,7 @@ static struct platform_driver qcom_scm_driver = {
12911301
.driver = {
12921302
.name = "qcom_scm",
12931303
.of_match_table = qcom_scm_dt_match,
1304+
.suppress_bind_attrs = true,
12941305
},
12951306
.probe = qcom_scm_probe,
12961307
.shutdown = qcom_scm_shutdown,

‎drivers/firmware/qcom_scm.h‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,11 @@ struct qcom_scm_res {
6161
};
6262

6363
#define SCM_SMC_FNID(s, c) ((((s) & 0xFF) << 8) | ((c) & 0xFF))
64-
extern int scm_smc_call(struct device *dev, const struct qcom_scm_desc *desc,
65-
struct qcom_scm_res *res, bool atomic);
64+
extern int __scm_smc_call(struct device *dev, const struct qcom_scm_desc *desc,
65+
enum qcom_scm_convention qcom_convention,
66+
struct qcom_scm_res *res, bool atomic);
67+
#define scm_smc_call(dev, desc, res, atomic) \
68+
__scm_smc_call((dev), (desc), qcom_scm_convention, (res), (atomic))
6669

6770
#define SCM_LEGACY_FNID(s, c) (((s) << 10) | ((c) & 0x3ff))
6871
extern int scm_legacy_call_atomic(struct device *dev,

‎drivers/soc/qcom/mdt_loader.c‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,14 @@ static int __qcom_mdt_load(struct device *dev, const struct firmware *fw,
230230
break;
231231
}
232232

233+
if (phdr->p_filesz > phdr->p_memsz) {
234+
dev_err(dev,
235+
"refusing to load segment %d with p_filesz > p_memsz\n",
236+
i);
237+
ret = -EINVAL;
238+
break;
239+
}
240+
233241
ptr = mem_region + offset;
234242

235243
if (phdr->p_filesz && phdr->p_offset < fw->size) {
@@ -253,6 +261,15 @@ static int __qcom_mdt_load(struct device *dev, const struct firmware *fw,
253261
break;
254262
}
255263

264+
if (seg_fw->size != phdr->p_filesz) {
265+
dev_err(dev,
266+
"failed to load segment %d from truncated file %s\n",
267+
i, fw_name);
268+
release_firmware(seg_fw);
269+
ret = -EINVAL;
270+
break;
271+
}
272+
256273
release_firmware(seg_fw);
257274
}
258275

‎drivers/soc/qcom/pdr_interface.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ static int pdr_register_listener(struct pdr_handle *pdr,
153153
if (resp.resp.result != QMI_RESULT_SUCCESS_V01) {
154154
pr_err("PDR: %s register listener failed: 0x%x\n",
155155
pds->service_path, resp.resp.error);
156-
return ret;
156+
return -EREMOTEIO;
157157
}
158158

159159
pds->state = resp.curr_state;

‎drivers/soc/qcom/wcnss_ctrl.c‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,8 @@ static int wcnss_download_nv(struct wcnss_ctrl *wcnss, bool *expect_cbc)
199199
{
200200
struct wcnss_download_nv_req *req;
201201
const struct firmware *fw;
202+
struct device *dev = wcnss->dev;
203+
const char *nvbin = NVBIN_FILE;
202204
const void *data;
203205
ssize_t left;
204206
int ret;
@@ -207,10 +209,13 @@ static int wcnss_download_nv(struct wcnss_ctrl *wcnss, bool *expect_cbc)
207209
if (!req)
208210
return -ENOMEM;
209211

210-
ret = request_firmware(&fw, NVBIN_FILE, wcnss->dev);
212+
ret = of_property_read_string(dev->of_node, "firmware-name", &nvbin);
213+
if (ret < 0 && ret != -EINVAL)
214+
goto free_req;
215+
216+
ret = request_firmware(&fw, nvbin, dev);
211217
if (ret < 0) {
212-
dev_err(wcnss->dev, "Failed to load nv file %s: %d\n",
213-
NVBIN_FILE, ret);
218+
dev_err(dev, "Failed to load nv file %s: %d\n", nvbin, ret);
214219
goto free_req;
215220
}
216221

@@ -235,7 +240,7 @@ static int wcnss_download_nv(struct wcnss_ctrl *wcnss, bool *expect_cbc)
235240

236241
ret = rpmsg_send(wcnss->channel, req, req->hdr.len);
237242
if (ret < 0) {
238-
dev_err(wcnss->dev, "failed to send smd packet\n");
243+
dev_err(dev, "failed to send smd packet\n");
239244
goto release_fw;
240245
}
241246

@@ -248,7 +253,7 @@ static int wcnss_download_nv(struct wcnss_ctrl *wcnss, bool *expect_cbc)
248253

249254
ret = wait_for_completion_timeout(&wcnss->ack, WCNSS_REQUEST_TIMEOUT);
250255
if (!ret) {
251-
dev_err(wcnss->dev, "timeout waiting for nv upload ack\n");
256+
dev_err(dev, "timeout waiting for nv upload ack\n");
252257
ret = -ETIMEDOUT;
253258
} else {
254259
*expect_cbc = wcnss->ack_status == WCNSS_ACK_COLD_BOOTING;

‎include/linux/soc/qcom/apr.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ void apr_driver_unregister(struct apr_driver *drv);
113113

114114
/**
115115
* module_apr_driver() - Helper macro for registering a aprbus driver
116-
* @__aprbus_driver: aprbus_driver struct
116+
* @__apr_driver: apr_driver struct
117117
*
118118
* Helper macro for aprbus drivers which do not do anything special in
119119
* module init/exit. This eliminates a lot of boilerplate. Each module

0 commit comments

Comments
 (0)