linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kirill Kapranov <kirill.kapranov@compulab.co.il>
To: Mark Brown <broonie@kernel.org>
Cc: Geert Uytterhoeven <geert+renesas@glider.be>,
	linux-spi@vger.kernel.org, linux-renesas-soc@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH -next] spi: Fix double IDR allocation with DT aliases
Date: Sat, 25 Aug 2018 20:54:53 +0300	[thread overview]
Message-ID: <a1bba27e-a287-c162-a238-eeae1e84d63c@compulab.co.il> (raw)
In-Reply-To: <20180823102121.GC5207@sirena.org.uk>

> For DT systems the dynamically allocated IDs start at the maximum
> positive ID and work down so in practice it is vanishingly unlikely that
> there will be a collision as idiomatic static DT IDs would be low
> integers.

Yes, this algorithm seems really bullet-proof. However, it isn't 
actually used now. The ID allocation algorithm using  atomic_dec_return 
call had been introduced 2006-01-08 as [1]. It was being used in the 
mainline kernel (with some improvements) up to 2017-08-16, when it has 
been replaced with the newer algorithm using Linux idr, accordingly [2].

Since idr_alloc call works incrementally, the situation of a 'fixed' ID 
squatting by a driver with 'dynamic ID' seems more than possible.
Therefore it would be justified to use a hardcoded constant 
SPI_DYN_FIRST_BUS_NUM (that was introduced in [2] and eliminated in 
[3]), but with a sufficiently greater value of the constant.

[1] 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?h=v4.18&id=8ae12a0d85987dc138f8c944cb78a92bf466cea0 

[2] 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?h=v4.18&id=9b61e302210eba55768962f2f11e96bb508c2408
[3] 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?h=v4.18&id=42bdd7061a6e24d7b21d3d21973615fecef544ef


  reply	other threads:[~2018-08-25 17:55 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-21  9:53 [PATCH -next] spi: Fix double IDR allocation with DT aliases Geert Uytterhoeven
2018-08-21 13:40 ` Greg KH
2018-08-21 17:42   ` Geert Uytterhoeven
2018-08-22 17:51 ` Kirill Kapranov
2018-08-23 10:21   ` Mark Brown
2018-08-25 17:54     ` Kirill Kapranov [this message]
2018-08-26 13:24       ` Mark Brown
2018-08-28 19:47         ` Kirill kapranov
2018-08-27 14:13 ` Fabio Estevam
2018-08-28 20:58 ` Applied "spi: Fix double IDR allocation with DT aliases" to the spi tree 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=a1bba27e-a287-c162-a238-eeae1e84d63c@compulab.co.il \
    --to=kirill.kapranov@compulab.co.il \
    --cc=broonie@kernel.org \
    --cc=geert+renesas@glider.be \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=linux-spi@vger.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;
as well as URLs for NNTP newsgroup(s).