From: Lucas Stach <l.stach@pengutronix.de>
To: Arnd Bergmann <arnd@arndb.de>, Mark Brown <broonie@kernel.org>
Cc: Naresh Kamboju <naresh.kamboju@linaro.org>,
Geert Uytterhoeven <geert+renesas@glider.be>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] spi: fix bogus SPI bus number
Date: Tue, 17 Oct 2017 14:20:34 +0200 [thread overview]
Message-ID: <1508242834.2146.16.camel@pengutronix.de> (raw)
In-Reply-To: <20171017104519.878892-1-arnd@arndb.de>
Am Dienstag, den 17.10.2017, 12:44 +0200 schrieb Arnd Bergmann:
> lkft found a boot time regression on the Hikey board that has no
> aliases entry for spi buses. of_alias_get_highest_id() here
> returns -ENODEV, which is then used as the initial number for the
> IDR allocation, and that in turn triggers a WARN_ON:
>
> WARNING: CPU: 3 PID: 53 at include/linux/idr.h:113
> spi_register_controller+0x890/0x940
>
> This reworks the algorithm to turn any negative number into zero
> again, restoring the original behavior for the Hikey case.
>
> Fixes: 9ce70d49fa80 ("spi: fix IDR collision on systems with both
> fixed and dynamic SPI bus numbers")
> Reported-by: Naresh Kamboju <naresh.kamboju@linaro.org>
> Link: https://lkft.validation.linaro.org/scheduler/job/48009#L3147
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> Not tested yet, please review carefully
I've already sent a v2 of the borked patch, which Mark apparently
applied to his fix/idr branch.
Regards,
Lucas
> ---
> drivers/spi/spi.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
> index 0483410e7cb3..4b6985ec962c 100644
> --- a/drivers/spi/spi.c
> +++ b/drivers/spi/spi.c
> @@ -2116,9 +2116,11 @@ int spi_register_controller(struct
> spi_controller *ctlr)
> }
> if (ctlr->bus_num < 0) {
> mutex_lock(&board_lock);
> + id = of_alias_get_highest_id("spi");
> + if (id < 0)
> + id = -1;
> id = idr_alloc(&spi_master_idr, ctlr,
> - of_alias_get_highest_id("spi") + 1,
> - 0, GFP_KERNEL);
> + id + 1, 0, GFP_KERNEL);
> mutex_unlock(&board_lock);
> if (WARN(id < 0, "couldn't get idr"))
> return id;
next prev parent reply other threads:[~2017-10-17 12:20 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-17 10:44 Arnd Bergmann
2017-10-17 12:20 ` Lucas Stach [this message]
2017-10-17 12:25 ` 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=1508242834.2146.16.camel@pengutronix.de \
--to=l.stach@pengutronix.de \
--cc=andriy.shevchenko@linux.intel.com \
--cc=arnd@arndb.de \
--cc=broonie@kernel.org \
--cc=geert+renesas@glider.be \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=naresh.kamboju@linaro.org \
--cc=rafael.j.wysocki@intel.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
all inboxes | Powered by JetHome®