* [PATCH] firmware: tegra: stop using seq_get_buf
@ 2021-08-10 15:54 Christoph Hellwig
2021-08-12 14:05 ` Thierry Reding
0 siblings, 1 reply; 2+ messages in thread
From: Christoph Hellwig @ 2021-08-10 15:54 UTC (permalink / raw)
To: thierry.reding, jonathanh; +Cc: linux-tegra, linux-kernel
Opencode a copy of mrq_debug_read in bpmp_debug_show so that it
can use seq_write directly instead of poking holes into the seq_file
abstractions using seq_get_buf.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
drivers/firmware/tegra/bpmp-debugfs.c | 58 ++++++++++++++++++++++-----
1 file changed, 47 insertions(+), 11 deletions(-)
diff --git a/drivers/firmware/tegra/bpmp-debugfs.c b/drivers/firmware/tegra/bpmp-debugfs.c
index 440d99c63638..3e9fa4b54358 100644
--- a/drivers/firmware/tegra/bpmp-debugfs.c
+++ b/drivers/firmware/tegra/bpmp-debugfs.c
@@ -296,25 +296,61 @@ static int bpmp_debug_show(struct seq_file *m, void *p)
struct file *file = m->private;
struct inode *inode = file_inode(file);
struct tegra_bpmp *bpmp = inode->i_private;
- char *databuf = NULL;
char fnamebuf[256];
const char *filename;
- uint32_t nbytes = 0;
- size_t len;
- int err;
-
- len = seq_get_buf(m, &databuf);
- if (!databuf)
- return -ENOMEM;
+ struct mrq_debug_request req = {
+ .cmd = cpu_to_le32(CMD_DEBUG_READ),
+ };
+ struct mrq_debug_response resp;
+ struct tegra_bpmp_message msg = {
+ .mrq = MRQ_DEBUG,
+ .tx = {
+ .data = &req,
+ .size = sizeof(req),
+ },
+ .rx = {
+ .data = &resp,
+ .size = sizeof(resp),
+ },
+ };
+ uint32_t fd = 0, len = 0;
+ int remaining, err;
filename = get_filename(bpmp, file, fnamebuf, sizeof(fnamebuf));
if (!filename)
return -ENOENT;
- err = mrq_debug_read(bpmp, filename, databuf, len, &nbytes);
- if (!err)
- seq_commit(m, nbytes);
+ mutex_lock(&bpmp_debug_lock);
+ err = mrq_debug_open(bpmp, filename, &fd, &len, 0);
+ if (err)
+ goto out;
+
+ req.frd.fd = fd;
+ remaining = len;
+
+ while (remaining > 0) {
+ err = tegra_bpmp_transfer(bpmp, &msg);
+ if (err < 0) {
+ goto close;
+ } else if (msg.rx.ret < 0) {
+ err = -EINVAL;
+ goto close;
+ }
+ if (resp.frd.readlen > remaining) {
+ pr_err("%s: read data length invalid\n", __func__);
+ err = -EINVAL;
+ goto close;
+ }
+
+ seq_write(m, resp.frd.data, resp.frd.readlen);
+ remaining -= resp.frd.readlen;
+ }
+
+close:
+ err = mrq_debug_close(bpmp, fd);
+out:
+ mutex_unlock(&bpmp_debug_lock);
return err;
}
--
2.30.2
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] firmware: tegra: stop using seq_get_buf
2021-08-10 15:54 [PATCH] firmware: tegra: stop using seq_get_buf Christoph Hellwig
@ 2021-08-12 14:05 ` Thierry Reding
0 siblings, 0 replies; 2+ messages in thread
From: Thierry Reding @ 2021-08-12 14:05 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: jonathanh, linux-tegra, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 462 bytes --]
On Tue, Aug 10, 2021 at 05:54:39PM +0200, Christoph Hellwig wrote:
> Opencode a copy of mrq_debug_read in bpmp_debug_show so that it
> can use seq_write directly instead of poking holes into the seq_file
> abstractions using seq_get_buf.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> drivers/firmware/tegra/bpmp-debugfs.c | 58 ++++++++++++++++++++++-----
> 1 file changed, 47 insertions(+), 11 deletions(-)
Applied, thanks.
Thierry
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-08-12 14:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-10 15:54 [PATCH] firmware: tegra: stop using seq_get_buf Christoph Hellwig
2021-08-12 14:05 ` Thierry Reding
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®