* [PATCH mmc-next v3 1/2] dt-bindings: mmc: add alias example @ 2020-08-25 13:44 Matthias Schiffer 2020-08-25 13:44 ` [PATCH mmc-next v3 2/2] mmc: allow setting slot index via device tree alias Matthias Schiffer 2020-08-28 22:24 ` [PATCH mmc-next v3 1/2] dt-bindings: mmc: add alias example Rob Herring 0 siblings, 2 replies; 5+ messages in thread From: Matthias Schiffer @ 2020-08-25 13:44 UTC (permalink / raw) To: Ulf Hansson, Rob Herring Cc: Sascha Hauer, linux-mmc, devicetree, linux-kernel, Matthias Schiffer As for I2C and SPI, it now is possible to reserve a fixed index for mmc/mmcblk devices. Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com> --- v3: new patch Documentation/devicetree/bindings/mmc/mmc-controller.yaml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Documentation/devicetree/bindings/mmc/mmc-controller.yaml b/Documentation/devicetree/bindings/mmc/mmc-controller.yaml index b96da0c7f819..22ed4a36c65d 100644 --- a/Documentation/devicetree/bindings/mmc/mmc-controller.yaml +++ b/Documentation/devicetree/bindings/mmc/mmc-controller.yaml @@ -367,6 +367,14 @@ examples: }; - | + /* + * Optionally define an alias to reserve a fixed index for the + * mmc and mmcblk devices + */ + aliases { + mmc0 = &mmc3; + }; + mmc3: mmc@1c12000 { #address-cells = <1>; #size-cells = <0>; -- 2.17.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH mmc-next v3 2/2] mmc: allow setting slot index via device tree alias 2020-08-25 13:44 [PATCH mmc-next v3 1/2] dt-bindings: mmc: add alias example Matthias Schiffer @ 2020-08-25 13:44 ` Matthias Schiffer 2020-08-28 22:24 ` [PATCH mmc-next v3 1/2] dt-bindings: mmc: add alias example Rob Herring 1 sibling, 0 replies; 5+ messages in thread From: Matthias Schiffer @ 2020-08-25 13:44 UTC (permalink / raw) To: Ulf Hansson, Rob Herring Cc: Sascha Hauer, linux-mmc, devicetree, linux-kernel, Matthias Schiffer As with GPIO, UART and others, allow specifying the device index via the aliases node in the device tree. On embedded devices, there is often a combination of removable (e.g. SD card) and non-removable MMC devices (e.g. eMMC). Therefore the index might change depending on * host of removable device * removable card present or not This makes it difficult to hardcode the root device, if it is on the non-removable device. E.g. if SD card is present eMMC will be mmcblk1, if SD card is not present at boot, eMMC will be mmcblk0. Alternative solutions like PARTUUIDs do not cover the case where multiple mmcblk devices contain the same image. This is a common issue on devices that can boot both from eMMC (for regular boot) and SD cards (as a temporary boot medium for development). When a firmware image is installed to eMMC after a test boot via SD card, there will be no reliable way to refer to a specific device using (PART)UUIDs oder LABELs. The demand for this feature has led to multiple attempts to implement it, dating back at least to 2012 (see https://www.spinics.net/lists/linux-mmc/msg26586.html for a previous discussion from 2014). All indices defined in the aliases node will be reserved for use by the respective MMC device, moving the indices of devices that don't have an alias up into the non-reserved range. If the aliases node is not found, the driver will act as before. This is a rebased and slightly cleaned up version of https://www.spinics.net/lists/linux-mmc/msg26588.html . Based-on-patch-by: Sascha Hauer <s.hauer@pengutronix.de> Link: https://lkml.org/lkml/2020/8/5/194 Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com> --- v3: - remove unneeded mmcblock changes - remove most helper functions to simplify code - extended commit message v2: - fix missing symbols for modular mmcblock drivers/mmc/core/host.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c index c8fae6611b73..96b2ca1f1b06 100644 --- a/drivers/mmc/core/host.c +++ b/drivers/mmc/core/host.c @@ -376,6 +376,20 @@ int mmc_of_parse_voltage(struct device_node *np, u32 *mask) } EXPORT_SYMBOL(mmc_of_parse_voltage); +/** + * mmc_first_nonreserved_index() - get the first index that is not reserved + */ +static int mmc_first_nonreserved_index(void) +{ + int max; + + max = of_alias_get_highest_id("mmc"); + if (max < 0) + return 0; + + return max + 1; +} + /** * mmc_alloc_host - initialise the per-host structure. * @extra: sizeof private data structure @@ -387,6 +401,7 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev) { int err; struct mmc_host *host; + int alias_id, min_idx, max_idx; host = kzalloc(sizeof(struct mmc_host) + extra, GFP_KERNEL); if (!host) @@ -395,7 +410,16 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev) /* scanning will be enabled when we're ready */ host->rescan_disable = 1; - err = ida_simple_get(&mmc_host_ida, 0, 0, GFP_KERNEL); + alias_id = of_alias_get_id(dev->of_node, "mmc"); + if (alias_id >= 0) { + min_idx = alias_id; + max_idx = alias_id + 1; + } else { + min_idx = mmc_first_nonreserved_index(); + max_idx = 0; + } + + err = ida_simple_get(&mmc_host_ida, min_idx, max_idx, GFP_KERNEL); if (err < 0) { kfree(host); return NULL; -- 2.17.1 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH mmc-next v3 1/2] dt-bindings: mmc: add alias example 2020-08-25 13:44 [PATCH mmc-next v3 1/2] dt-bindings: mmc: add alias example Matthias Schiffer 2020-08-25 13:44 ` [PATCH mmc-next v3 2/2] mmc: allow setting slot index via device tree alias Matthias Schiffer @ 2020-08-28 22:24 ` Rob Herring 2020-08-31 7:58 ` Matthias Schiffer 1 sibling, 1 reply; 5+ messages in thread From: Rob Herring @ 2020-08-28 22:24 UTC (permalink / raw) To: Matthias Schiffer Cc: Ulf Hansson, Sascha Hauer, linux-mmc, devicetree, linux-kernel On Tue, Aug 25, 2020 at 03:44:40PM +0200, Matthias Schiffer wrote: > As for I2C and SPI, it now is possible to reserve a fixed index for > mmc/mmcblk devices. > > Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com> > --- > > v3: new patch > > Documentation/devicetree/bindings/mmc/mmc-controller.yaml | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/Documentation/devicetree/bindings/mmc/mmc-controller.yaml b/Documentation/devicetree/bindings/mmc/mmc-controller.yaml > index b96da0c7f819..22ed4a36c65d 100644 > --- a/Documentation/devicetree/bindings/mmc/mmc-controller.yaml > +++ b/Documentation/devicetree/bindings/mmc/mmc-controller.yaml > @@ -367,6 +367,14 @@ examples: > }; > > - | > + /* > + * Optionally define an alias to reserve a fixed index for the > + * mmc and mmcblk devices > + */ > + aliases { > + mmc0 = &mmc3; > + }; This will break if we improve schemas because this node is actually /example-1/aliases. So please drop. If you want, I'd really like to have a defined set (i.e. a schema) of alias names. This would require deleting a bunch on some platforms that just made up a bunch of them. > + > mmc3: mmc@1c12000 { > #address-cells = <1>; > #size-cells = <0>; > -- > 2.17.1 > ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH mmc-next v3 1/2] dt-bindings: mmc: add alias example 2020-08-28 22:24 ` [PATCH mmc-next v3 1/2] dt-bindings: mmc: add alias example Rob Herring @ 2020-08-31 7:58 ` Matthias Schiffer 2020-08-31 9:16 ` Ulf Hansson 0 siblings, 1 reply; 5+ messages in thread From: Matthias Schiffer @ 2020-08-31 7:58 UTC (permalink / raw) To: Rob Herring Cc: Ulf Hansson, Sascha Hauer, linux-mmc, devicetree, linux-kernel On Fri, 2020-08-28 at 16:24 -0600, Rob Herring wrote: > On Tue, Aug 25, 2020 at 03:44:40PM +0200, Matthias Schiffer wrote: > > As for I2C and SPI, it now is possible to reserve a fixed index for > > mmc/mmcblk devices. > > > > Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com > > > > > --- > > > > v3: new patch > > > > Documentation/devicetree/bindings/mmc/mmc-controller.yaml | 8 > > ++++++++ > > 1 file changed, 8 insertions(+) > > > > diff --git a/Documentation/devicetree/bindings/mmc/mmc- > > controller.yaml b/Documentation/devicetree/bindings/mmc/mmc- > > controller.yaml > > index b96da0c7f819..22ed4a36c65d 100644 > > --- a/Documentation/devicetree/bindings/mmc/mmc-controller.yaml > > +++ b/Documentation/devicetree/bindings/mmc/mmc-controller.yaml > > @@ -367,6 +367,14 @@ examples: > > }; > > > > - | > > + /* > > + * Optionally define an alias to reserve a fixed index for the > > + * mmc and mmcblk devices > > + */ > > + aliases { > > + mmc0 = &mmc3; > > + }; > > This will break if we improve schemas because this node is actually > /example-1/aliases. > > So please drop. If you want, I'd really like to have a defined set > (i.e. > a schema) of alias names. This would require deleting a bunch on > some > platforms that just made up a bunch of them. Ulf suggested that I add some kind of documentation about the new mmc alias support to the binding docs. As long as we don't have a proper schema for aliases, should I just add an explanation to the toplevel description of Documentation/devicetree/bindings/mmc/mmc-controller.yaml, or maybe a comment? > > > + > > mmc3: mmc@1c12000 { > > #address-cells = <1>; > > #size-cells = <0>; > > -- > > 2.17.1 > > ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH mmc-next v3 1/2] dt-bindings: mmc: add alias example 2020-08-31 7:58 ` Matthias Schiffer @ 2020-08-31 9:16 ` Ulf Hansson 0 siblings, 0 replies; 5+ messages in thread From: Ulf Hansson @ 2020-08-31 9:16 UTC (permalink / raw) To: Matthias Schiffer Cc: Rob Herring, Sascha Hauer, linux-mmc, DTML, Linux Kernel Mailing List On Mon, 31 Aug 2020 at 09:58, Matthias Schiffer <matthias.schiffer@ew.tq-group.com> wrote: > > On Fri, 2020-08-28 at 16:24 -0600, Rob Herring wrote: > > On Tue, Aug 25, 2020 at 03:44:40PM +0200, Matthias Schiffer wrote: > > > As for I2C and SPI, it now is possible to reserve a fixed index for > > > mmc/mmcblk devices. > > > > > > Signed-off-by: Matthias Schiffer <matthias.schiffer@ew.tq-group.com > > > > > > > --- > > > > > > v3: new patch > > > > > > Documentation/devicetree/bindings/mmc/mmc-controller.yaml | 8 > > > ++++++++ > > > 1 file changed, 8 insertions(+) > > > > > > diff --git a/Documentation/devicetree/bindings/mmc/mmc- > > > controller.yaml b/Documentation/devicetree/bindings/mmc/mmc- > > > controller.yaml > > > index b96da0c7f819..22ed4a36c65d 100644 > > > --- a/Documentation/devicetree/bindings/mmc/mmc-controller.yaml > > > +++ b/Documentation/devicetree/bindings/mmc/mmc-controller.yaml > > > @@ -367,6 +367,14 @@ examples: > > > }; > > > > > > - | > > > + /* > > > + * Optionally define an alias to reserve a fixed index for the > > > + * mmc and mmcblk devices > > > + */ > > > + aliases { > > > + mmc0 = &mmc3; > > > + }; > > > > This will break if we improve schemas because this node is actually > > /example-1/aliases. > > > > So please drop. If you want, I'd really like to have a defined set > > (i.e. > > a schema) of alias names. This would require deleting a bunch on > > some > > platforms that just made up a bunch of them. > > Ulf suggested that I add some kind of documentation about the new mmc > alias support to the binding docs. > > As long as we don't have a proper schema for aliases, should I just add > an explanation to the toplevel description of > Documentation/devicetree/bindings/mmc/mmc-controller.yaml, or maybe a > comment? I would prefer to add an explanation in the toplevel description, although I have no strong opinion. This is similar to what we already do for serial devices, see Documentation/devicetree/bindings/serial/serial.yaml. > > > > > > > + > > > mmc3: mmc@1c12000 { > > > #address-cells = <1>; > > > #size-cells = <0>; > > > -- > > > 2.17.1 > > > > Kind regards Uffe ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-08-31 9:17 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2020-08-25 13:44 [PATCH mmc-next v3 1/2] dt-bindings: mmc: add alias example Matthias Schiffer 2020-08-25 13:44 ` [PATCH mmc-next v3 2/2] mmc: allow setting slot index via device tree alias Matthias Schiffer 2020-08-28 22:24 ` [PATCH mmc-next v3 1/2] dt-bindings: mmc: add alias example Rob Herring 2020-08-31 7:58 ` Matthias Schiffer 2020-08-31 9:16 ` Ulf Hansson
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).