From: Pratyush Yadav <p.yadav@ti.com>
To: Arnd Bergmann <arnd@kernel.org>
Cc: Heiko Stuebner <heiko@sntech.de>, Arnd Bergmann <arnd@arndb.de>,
Alexander Kochetkov <al.kochet@gmail.com>,
Nick Desaulniers <ndesaulniers@google.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
linux-spi <linux-spi@vger.kernel.org>,
Nathan Chancellor <nathan@kernel.org>,
"open list:ARM/Rockchip SoC support"
<linux-rockchip@lists.infradead.org>,
Mark Brown <broonie@kernel.org>, Jon Lin <jon.lin@rock-chips.com>,
clang-built-linux <clang-built-linux@googlegroups.com>,
Vincent Pelletier <plr.vincent@gmail.com>,
Johan Jonker <jbx6244@gmail.com>,
Chris Ruehl <chris.ruehl@gtsys.com.hk>,
Linux ARM <linux-arm-kernel@lists.infradead.org>,
Emil Renner Berthing <kernel@esmil.dk>
Subject: Re: [PATCH] spi: rockchip: avoid objtool warning
Date: Fri, 26 Feb 2021 16:34:53 +0530 [thread overview]
Message-ID: <20210226110451.ijpllyczuquerfsr@ti.com> (raw)
In-Reply-To: <CAK8P3a3ep7DFnMYnA7q5b-P8X7nd3TAz=t82011j8=koK3T08A@mail.gmail.com>
On 26/02/21 10:49AM, Arnd Bergmann wrote:
> On Fri, Feb 26, 2021 at 9:16 AM 'Pratyush Yadav' via Clang Built Linux
> <clang-built-linux@googlegroups.com> wrote:
> >
> > Hi,
> >
> > On 25/02/21 01:55PM, Arnd Bergmann wrote:
> > > From: Arnd Bergmann <arnd@arndb.de>
> > >
> > > Building this file with clang leads to a an unreachable code path
> > > causing a warning from objtool:
> > >
> > > drivers/spi/spi-rockchip.o: warning: objtool: rockchip_spi_transfer_one()+0x2e0: sibling call from callable instruction with modified stack frame
> > >
> > > Use BUG() instead of unreachable() to avoid the undefined behavior
> > > if it does happen.
> > >
> > > Fixes: 65498c6ae241 ("spi: rockchip: support 4bit words")
> > > Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> > > ---
> > > drivers/spi/spi-rockchip.c | 2 +-
> > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/spi/spi-rockchip.c b/drivers/spi/spi-rockchip.c
> > > index 936ef54e0903..972beac1169a 100644
> > > --- a/drivers/spi/spi-rockchip.c
> > > +++ b/drivers/spi/spi-rockchip.c
> > > @@ -521,7 +521,7 @@ static void rockchip_spi_config(struct rockchip_spi *rs,
> > > * ctlr->bits_per_word_mask, so this shouldn't
> > > * happen
> > > */
> > > - unreachable();
> > > + BUG();
> >
> > checkpatch says:
> >
> > Avoid crashing the kernel - try using WARN_ON & recovery code rather
> > than BUG() or BUG_ON()
> >
> > Which makes sense to me. This is not something bad enough to justify
> > crashing the kernel.
>
> I thought about rewriting it more thoroughly when I wrote the patch, but
> couldn't come up with a good alternative, so I did the simplest change
> in this direction, replacing the silent crash with a loud one.
>
> Should we just dev_warn() and return instead, hoping that it won't do
> more harm?
Hmm... I'm not very familiar with this device or driver so take what I
say with a grain of salt. On the surface level it looks like it might
end up doing something wrong or unexpected.
Returning an error code from this function (along with the dev_warn() or
WARN_ON()) is the most sensible thing to do IMO. If the SPI layer sends
an invalid value then the driver should be well within its rights to
refuse the transaction. The function is currently void but making it
return int seems fairly straightforward.
>
> The backtrace from WARN_ON() probably doesn't help here.
>
> Arnd
--
Regards,
Pratyush Yadav
Texas Instruments Inc.
_______________________________________________
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:[~2021-02-26 11:06 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-25 12:55 [PATCH] spi: rockchip: avoid objtool warning Arnd Bergmann
2021-02-25 14:09 ` Emil Renner Berthing
2021-02-25 21:16 ` Nick Desaulniers
2021-02-25 21:19 ` Heiko Stübner
2021-02-26 8:15 ` Pratyush Yadav
2021-02-26 9:49 ` Arnd Bergmann
2021-02-26 11:04 ` Pratyush Yadav [this message]
2021-02-26 11:15 ` Arnd Bergmann
2021-03-01 23:37 ` Mark Brown
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=20210226110451.ijpllyczuquerfsr@ti.com \
--to=p.yadav@ti.com \
--cc=al.kochet@gmail.com \
--cc=arnd@arndb.de \
--cc=arnd@kernel.org \
--cc=broonie@kernel.org \
--cc=chris.ruehl@gtsys.com.hk \
--cc=clang-built-linux@googlegroups.com \
--cc=heiko@sntech.de \
--cc=jbx6244@gmail.com \
--cc=jon.lin@rock-chips.com \
--cc=kernel@esmil.dk \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=linux-spi@vger.kernel.org \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=plr.vincent@gmail.com \
/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