From: Nikita Shubin <nikita.shubin@maquefel.me>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: "Atish Patra" <atishp@atishpatra.org>,
"Will Deacon" <will@kernel.org>,
"Sunil V L" <sunilvl@ventanamicro.com>,
"João Mário Domingos" <joao.mario@tecnico.ulisboa.pt>,
linux@yadro.com, "Nikita Shubin" <n.shubin@yadro.com>,
"Paul Walmsley" <paul.walmsley@sifive.com>,
"Palmer Dabbelt" <palmer@dabbelt.com>,
"Albert Ou" <aou@eecs.berkeley.edu>,
"Anup Patel" <anup@brainfault.org>,
"Mark Rutland" <mark.rutland@arm.com>,
linux-riscv <linux-riscv@lists.infradead.org>,
"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>,
"Linux ARM" <linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH v4 1/1] RISC-V: Create unique identification for SoC PMU
Date: Mon, 20 Jun 2022 17:44:02 +0300 [thread overview]
Message-ID: <20220620174402.1fb82fa4@redslave.neermore.group> (raw)
In-Reply-To: <CAMuHMdUoa9H3Nw7ctAbueeVOdJEo_D25niS7E07HWwV2H4Z9Qg@mail.gmail.com>
Hello Geert!
On Mon, 20 Jun 2022 09:50:14 +0200
Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> Hi Nikita,
>
> On Sun, Jun 19, 2022 at 1:11 PM Nikita Shubin
> <nikita.shubin@maquefel.me> wrote:
> > From: Nikita Shubin <n.shubin@yadro.com>
> >
> > Provide RISC-V SBI PMU id to distinguish different cores or SoCs via
> > "devices/platform/riscv-pmu/id" sysfs entry.
> >
> > The identification is generated as string of marchid, mimpid,
> > mvendorid in hex format separated by coma - "0x70032,0x70032,0x0".
> >
> > The CSRs are detailed in the RISC-V privileged spec [1].
> > [1] https://github.com/riscv/riscv-isa-manual
> >
> > Inspired-by: João Mário Domingos <joao.mario@tecnico.ulisboa.pt>
> > Signed-off-by: Nikita Shubin <n.shubin@yadro.com>
>
> Thanks for your patch!
>
> > --- a/arch/riscv/kernel/sbi.c
> > +++ b/arch/riscv/kernel/sbi.c
>
> > --- a/drivers/perf/riscv_pmu_sbi.c
> > +++ b/drivers/perf/riscv_pmu_sbi.c
> > @@ -693,6 +693,28 @@ static int pmu_sbi_setup_irqs(struct riscv_pmu
> > *pmu, struct platform_device *pde return 0;
> > }
> >
> > +static ssize_t id_show(struct device *dev,
> > + struct device_attribute *attr, char
> > *buf) +{
> > + int len;
> > + struct riscv_pmu *pmu = container_of(dev_get_drvdata(dev),
> > struct riscv_pmu, pmu); +
> > + len = sprintf(buf, "%s\n", pmu->pmuid);
> > + if (len <= 0)
> > + dev_err(dev, "invalid sprintf len: %d\n", len);
>
> How can this fail?
>
> Please use sysfs_emit() instead of sprintf(), and drop the error
> message.
Indeed, thank you for your comments.
Also i missed some explicit free:
> > +out_free_pmuid:
> > + kfree(pmu->pmuid);
This is not needed.
>
> > +
> > + return len;
> > +}
>
> Gr{oetje,eeting}s,
>
> Geert
>
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 --
> geert@linux-m68k.org
>
> In personal conversations with technical people, I call myself a
> hacker. But when I'm talking to journalists I just say "programmer"
> or something like that. -- Linus Torvalds
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2022-06-20 14:45 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-19 11:11 [PATCH v4 0/1] RISC-V: Create unique identification for SoC PMU Nikita Shubin
2022-06-19 11:11 ` [PATCH v4 1/1] " Nikita Shubin
2022-06-20 7:50 ` Geert Uytterhoeven
2022-06-20 14:44 ` Nikita Shubin [this message]
2022-06-20 12:00 ` Anup Patel
2022-06-20 14:40 ` Nikita Shubin
2022-06-20 19:40 ` Atish Patra
2022-06-21 7:41 ` Nikita Shubin
2022-06-21 7:51 ` Anup Patel
2022-06-21 7:59 ` Nikita Shubin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220620174402.1fb82fa4@redslave.neermore.group \
--to=nikita.shubin@maquefel.me \
--cc=anup@brainfault.org \
--cc=aou@eecs.berkeley.edu \
--cc=atishp@atishpatra.org \
--cc=geert@linux-m68k.org \
--cc=joao.mario@tecnico.ulisboa.pt \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=linux@yadro.com \
--cc=mark.rutland@arm.com \
--cc=n.shubin@yadro.com \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=sunilvl@ventanamicro.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox