Skip to content

Commit 8745d0e

Browse files
committed
Merge tag 'tegra-for-5.15-firmware' of git://git.kernel.org/pub/scm/linux/kernel/git/tegra/linux into arm/drivers
firmware: tegra: Changes for v5.15-rc1 This contains a single fix to stop a slight abuse of the seq_buf API. * tag 'tegra-for-5.15-firmware' of git://git.kernel.org/pub/scm/linux/kernel/git/tegra/linux: firmware: tegra: Stop using seq_get_buf() Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnd Bergmann <[email protected]>
2 parents 1bb24be + dd00d75 commit 8745d0e

File tree

1 file changed

+47
-11
lines changed

1 file changed

+47
-11
lines changed

drivers/firmware/tegra/bpmp-debugfs.c

Lines changed: 47 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -296,25 +296,61 @@ static int bpmp_debug_show(struct seq_file *m, void *p)
296296
struct file *file = m->private;
297297
struct inode *inode = file_inode(file);
298298
struct tegra_bpmp *bpmp = inode->i_private;
299-
char *databuf = NULL;
300299
char fnamebuf[256];
301300
const char *filename;
302-
uint32_t nbytes = 0;
303-
size_t len;
304-
int err;
305-
306-
len = seq_get_buf(m, &databuf);
307-
if (!databuf)
308-
return -ENOMEM;
301+
struct mrq_debug_request req = {
302+
.cmd = cpu_to_le32(CMD_DEBUG_READ),
303+
};
304+
struct mrq_debug_response resp;
305+
struct tegra_bpmp_message msg = {
306+
.mrq = MRQ_DEBUG,
307+
.tx = {
308+
.data = &req,
309+
.size = sizeof(req),
310+
},
311+
.rx = {
312+
.data = &resp,
313+
.size = sizeof(resp),
314+
},
315+
};
316+
uint32_t fd = 0, len = 0;
317+
int remaining, err;
309318

310319
filename = get_filename(bpmp, file, fnamebuf, sizeof(fnamebuf));
311320
if (!filename)
312321
return -ENOENT;
313322

314-
err = mrq_debug_read(bpmp, filename, databuf, len, &nbytes);
315-
if (!err)
316-
seq_commit(m, nbytes);
323+
mutex_lock(&bpmp_debug_lock);
324+
err = mrq_debug_open(bpmp, filename, &fd, &len, 0);
325+
if (err)
326+
goto out;
327+
328+
req.frd.fd = fd;
329+
remaining = len;
330+
331+
while (remaining > 0) {
332+
err = tegra_bpmp_transfer(bpmp, &msg);
333+
if (err < 0) {
334+
goto close;
335+
} else if (msg.rx.ret < 0) {
336+
err = -EINVAL;
337+
goto close;
338+
}
317339

340+
if (resp.frd.readlen > remaining) {
341+
pr_err("%s: read data length invalid\n", __func__);
342+
err = -EINVAL;
343+
goto close;
344+
}
345+
346+
seq_write(m, resp.frd.data, resp.frd.readlen);
347+
remaining -= resp.frd.readlen;
348+
}
349+
350+
close:
351+
err = mrq_debug_close(bpmp, fd);
352+
out:
353+
mutex_unlock(&bpmp_debug_lock);
318354
return err;
319355
}
320356

0 commit comments

Comments
 (0)