All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Sa, Nuno" <Nuno.Sa@analog.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: "linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"linux-rockchip@lists.infradead.org"
	<linux-rockchip@lists.infradead.org>,
	"linux-amlogic@lists.infradead.org"
	<linux-amlogic@lists.infradead.org>,
	"linux-imx@nxp.com" <linux-imx@nxp.com>,
	"linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>,
	Chunyan Zhang <zhang.lyra@gmail.com>,
	"Hennerich, Michael" <Michael.Hennerich@analog.com>,
	Martin Blumenstingl <martin.blumenstingl@googlemail.com>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	Cixi Geng <cixi.geng1@unisoc.com>,
	Kevin Hilman <khilman@baylibre.com>,
	Vladimir Zapolskiy <vz@mleia.com>,
	Pengutronix Kernel Team <kernel@pengutronix.de>,
	Alexandru Ardelean <aardelean@deviqon.com>,
	Fabio Estevam <festevam@gmail.com>,
	Andriy Tryshnivskyy <andriy.tryshnivskyy@opensynergy.com>,
	Haibo Chen <haibo.chen@nxp.com>, Shawn Guo <shawnguo@kernel.org>,
	Hans de Goede <hdegoede@redhat.com>,
	Miquel Raynal <miquel.raynal@bootlin.com>,
	Jerome Brunet <jbrunet@baylibre.com>,
	Heiko Stuebner <heiko@sntech.de>,
	Florian Boor <florian.boor@kernelconcepts.de>,
	"Regus, Ciprian" <Ciprian.Regus@analog.com>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Jonathan Cameron <jic23@kernel.org>,
	Neil Armstrong <narmstrong@baylibre.com>,
	Baolin Wang <baolin.wang@linux.alibaba.com>,
	Jyoti Bhayana <jbhayana@google.com>, Chen-Yu Tsai <wens@csie.org>,
	Orson Zhai <orsonzhai@gmail.com>
Subject: RE: [PATCH 03/15] iio: adc: axp288_adc: do not use internal iio_dev lock
Date: Tue, 20 Sep 2022 13:46:31 +0000	[thread overview]
Message-ID: <SJ0PR03MB6778EEF81693C026CE131B49994C9@SJ0PR03MB6778.namprd03.prod.outlook.com> (raw)
In-Reply-To: <CAHp75VfdUOTd9tRXdTVq_prNf_T2=iQ4tEjusHC=gXDZvb3Qeg@mail.gmail.com>



> -----Original Message-----
> From: Andy Shevchenko <andy.shevchenko@gmail.com>
> Sent: Tuesday, September 20, 2022 3:39 PM
> To: Sa, Nuno <Nuno.Sa@analog.com>
> Cc: linux-arm-kernel@lists.infradead.org; linux-rockchip@lists.infradead.org;
> linux-amlogic@lists.infradead.org; linux-imx@nxp.com; linux-
> iio@vger.kernel.org; Chunyan Zhang <zhang.lyra@gmail.com>; Hennerich,
> Michael <Michael.Hennerich@analog.com>; Martin Blumenstingl
> <martin.blumenstingl@googlemail.com>; Sascha Hauer
> <s.hauer@pengutronix.de>; Cixi Geng <cixi.geng1@unisoc.com>; Kevin
> Hilman <khilman@baylibre.com>; Vladimir Zapolskiy <vz@mleia.com>;
> Pengutronix Kernel Team <kernel@pengutronix.de>; Alexandru Ardelean
> <aardelean@deviqon.com>; Fabio Estevam <festevam@gmail.com>; Andriy
> Tryshnivskyy <andriy.tryshnivskyy@opensynergy.com>; Haibo Chen
> <haibo.chen@nxp.com>; Shawn Guo <shawnguo@kernel.org>; Hans de
> Goede <hdegoede@redhat.com>; Miquel Raynal
> <miquel.raynal@bootlin.com>; Jerome Brunet <jbrunet@baylibre.com>;
> Heiko Stuebner <heiko@sntech.de>; Florian Boor
> <florian.boor@kernelconcepts.de>; Regus, Ciprian
> <Ciprian.Regus@analog.com>; Lars-Peter Clausen <lars@metafoo.de>;
> Jonathan Cameron <jic23@kernel.org>; Neil Armstrong
> <narmstrong@baylibre.com>; Baolin Wang
> <baolin.wang@linux.alibaba.com>; Jyoti Bhayana <jbhayana@google.com>;
> Chen-Yu Tsai <wens@csie.org>; Orson Zhai <orsonzhai@gmail.com>
> Subject: Re: [PATCH 03/15] iio: adc: axp288_adc: do not use internal iio_dev
> lock
> 
> [External]
> 
> On Tue, Sep 20, 2022 at 4:37 PM Andy Shevchenko
> <andy.shevchenko@gmail.com> wrote:
> > On Tue, Sep 20, 2022 at 4:18 PM Sa, Nuno <Nuno.Sa@analog.com> wrote:
> > > > On Tue, Sep 20, 2022 at 2:28 PM Nuno Sá <nuno.sa@analog.com>
> wrote:
> 
> ...
> 
> > > > >         info = iio_priv(indio_dev);
> > > > > +       mutex_init(&info->lock);
> > > > >         info->irq = platform_get_irq(pdev, 0);
> > > > >         if (info->irq < 0)
> > > > >                 return info->irq;
> > > >
> > > > Consider initializing it as late as possible, like after IRQ retrieval
> > > > in this context (maybe even deeper, but no context available). Ditto
> > > > for the rest of the series.
> > >
> > > Any special reason for it (maybe related to lockdep :wondering: ) ? Just
> > > curious as I never noticed such a pattern when initializing mutexes.
> >
> > Yes. Micro-optimization based on the rule "don't create a resource in
> > case of known error".
> >
> > OTOH, you have to be sure that the mutex (and generally speaking a
> > locking) should be initialized early enough.
> 

Typically not really needed during probe...

> Note that "micro" in the above can be multiplied by 'k', where 'k' is
> the amount of deferred probes (probably not the case here, but again,
> "generally speaking").
> 

Well, I don't think 'mutex_init()' does that much that really matters in
these patches but ok, that rule is indeed a good practice that sometimes
makes a difference. And since I will definitely need a v2, I can make that
change. Where applicable, the best place is probably before registering the
IIO device...

- Nuno Sá
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic

WARNING: multiple messages have this Message-ID (diff)
From: "Sa, Nuno" <Nuno.Sa@analog.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: "linux-arm-kernel@lists.infradead.org" 
	<linux-arm-kernel@lists.infradead.org>,
	"linux-rockchip@lists.infradead.org" 
	<linux-rockchip@lists.infradead.org>,
	"linux-amlogic@lists.infradead.org" 
	<linux-amlogic@lists.infradead.org>,
	"linux-imx@nxp.com" <linux-imx@nxp.com>,
	"linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>,
	Chunyan Zhang <zhang.lyra@gmail.com>,
	"Hennerich, Michael" <Michael.Hennerich@analog.com>,
	Martin Blumenstingl <martin.blumenstingl@googlemail.com>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	Cixi Geng <cixi.geng1@unisoc.com>,
	Kevin Hilman <khilman@baylibre.com>,
	Vladimir Zapolskiy <vz@mleia.com>,
	Pengutronix Kernel Team <kernel@pengutronix.de>,
	Alexandru Ardelean <aardelean@deviqon.com>,
	Fabio Estevam <festevam@gmail.com>,
	Andriy Tryshnivskyy <andriy.tryshnivskyy@opensynergy.com>,
	Haibo Chen <haibo.chen@nxp.com>, Shawn Guo <shawnguo@kernel.org>,
	Hans de Goede <hdegoede@redhat.com>,
	Miquel Raynal <miquel.raynal@bootlin.com>,
	Jerome Brunet <jbrunet@baylibre.com>,
	Heiko Stuebner <heiko@sntech.de>,
	Florian Boor <florian.boor@kernelconcepts.de>,
	"Regus, Ciprian" <Ciprian.Regus@analog.com>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Jonathan Cameron <jic23@kernel.org>,
	Neil Armstrong <narmstrong@baylibre.com>,
	Baolin Wang <baolin.wang@linux.alibaba.com>,
	Jyoti Bhayana <jbhayana@google.com>, Chen-Yu Tsai <wens@csie.org>,
	Orson Zhai <orsonzhai@gmail.com>
Subject: RE: [PATCH 03/15] iio: adc: axp288_adc: do not use internal iio_dev lock
Date: Tue, 20 Sep 2022 13:46:31 +0000	[thread overview]
Message-ID: <SJ0PR03MB6778EEF81693C026CE131B49994C9@SJ0PR03MB6778.namprd03.prod.outlook.com> (raw)
In-Reply-To: <CAHp75VfdUOTd9tRXdTVq_prNf_T2=iQ4tEjusHC=gXDZvb3Qeg@mail.gmail.com>



> -----Original Message-----
> From: Andy Shevchenko <andy.shevchenko@gmail.com>
> Sent: Tuesday, September 20, 2022 3:39 PM
> To: Sa, Nuno <Nuno.Sa@analog.com>
> Cc: linux-arm-kernel@lists.infradead.org; linux-rockchip@lists.infradead.org;
> linux-amlogic@lists.infradead.org; linux-imx@nxp.com; linux-
> iio@vger.kernel.org; Chunyan Zhang <zhang.lyra@gmail.com>; Hennerich,
> Michael <Michael.Hennerich@analog.com>; Martin Blumenstingl
> <martin.blumenstingl@googlemail.com>; Sascha Hauer
> <s.hauer@pengutronix.de>; Cixi Geng <cixi.geng1@unisoc.com>; Kevin
> Hilman <khilman@baylibre.com>; Vladimir Zapolskiy <vz@mleia.com>;
> Pengutronix Kernel Team <kernel@pengutronix.de>; Alexandru Ardelean
> <aardelean@deviqon.com>; Fabio Estevam <festevam@gmail.com>; Andriy
> Tryshnivskyy <andriy.tryshnivskyy@opensynergy.com>; Haibo Chen
> <haibo.chen@nxp.com>; Shawn Guo <shawnguo@kernel.org>; Hans de
> Goede <hdegoede@redhat.com>; Miquel Raynal
> <miquel.raynal@bootlin.com>; Jerome Brunet <jbrunet@baylibre.com>;
> Heiko Stuebner <heiko@sntech.de>; Florian Boor
> <florian.boor@kernelconcepts.de>; Regus, Ciprian
> <Ciprian.Regus@analog.com>; Lars-Peter Clausen <lars@metafoo.de>;
> Jonathan Cameron <jic23@kernel.org>; Neil Armstrong
> <narmstrong@baylibre.com>; Baolin Wang
> <baolin.wang@linux.alibaba.com>; Jyoti Bhayana <jbhayana@google.com>;
> Chen-Yu Tsai <wens@csie.org>; Orson Zhai <orsonzhai@gmail.com>
> Subject: Re: [PATCH 03/15] iio: adc: axp288_adc: do not use internal iio_dev
> lock
> 
> [External]
> 
> On Tue, Sep 20, 2022 at 4:37 PM Andy Shevchenko
> <andy.shevchenko@gmail.com> wrote:
> > On Tue, Sep 20, 2022 at 4:18 PM Sa, Nuno <Nuno.Sa@analog.com> wrote:
> > > > On Tue, Sep 20, 2022 at 2:28 PM Nuno Sá <nuno.sa@analog.com>
> wrote:
> 
> ...
> 
> > > > >         info = iio_priv(indio_dev);
> > > > > +       mutex_init(&info->lock);
> > > > >         info->irq = platform_get_irq(pdev, 0);
> > > > >         if (info->irq < 0)
> > > > >                 return info->irq;
> > > >
> > > > Consider initializing it as late as possible, like after IRQ retrieval
> > > > in this context (maybe even deeper, but no context available). Ditto
> > > > for the rest of the series.
> > >
> > > Any special reason for it (maybe related to lockdep :wondering: ) ? Just
> > > curious as I never noticed such a pattern when initializing mutexes.
> >
> > Yes. Micro-optimization based on the rule "don't create a resource in
> > case of known error".
> >
> > OTOH, you have to be sure that the mutex (and generally speaking a
> > locking) should be initialized early enough.
> 

Typically not really needed during probe...

> Note that "micro" in the above can be multiplied by 'k', where 'k' is
> the amount of deferred probes (probably not the case here, but again,
> "generally speaking").
> 

Well, I don't think 'mutex_init()' does that much that really matters in
these patches but ok, that rule is indeed a good practice that sometimes
makes a difference. And since I will definitely need a v2, I can make that
change. Where applicable, the best place is probably before registering the
IIO device...

- Nuno Sá

WARNING: multiple messages have this Message-ID (diff)
From: "Sa, Nuno" <Nuno.Sa@analog.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: "linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"linux-rockchip@lists.infradead.org"
	<linux-rockchip@lists.infradead.org>,
	"linux-amlogic@lists.infradead.org"
	<linux-amlogic@lists.infradead.org>,
	"linux-imx@nxp.com" <linux-imx@nxp.com>,
	"linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>,
	Chunyan Zhang <zhang.lyra@gmail.com>,
	"Hennerich, Michael" <Michael.Hennerich@analog.com>,
	Martin Blumenstingl <martin.blumenstingl@googlemail.com>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	Cixi Geng <cixi.geng1@unisoc.com>,
	Kevin Hilman <khilman@baylibre.com>,
	Vladimir Zapolskiy <vz@mleia.com>,
	Pengutronix Kernel Team <kernel@pengutronix.de>,
	Alexandru Ardelean <aardelean@deviqon.com>,
	Fabio Estevam <festevam@gmail.com>,
	Andriy Tryshnivskyy <andriy.tryshnivskyy@opensynergy.com>,
	Haibo Chen <haibo.chen@nxp.com>, Shawn Guo <shawnguo@kernel.org>,
	Hans de Goede <hdegoede@redhat.com>,
	Miquel Raynal <miquel.raynal@bootlin.com>,
	Jerome Brunet <jbrunet@baylibre.com>,
	Heiko Stuebner <heiko@sntech.de>,
	Florian Boor <florian.boor@kernelconcepts.de>,
	"Regus, Ciprian" <Ciprian.Regus@analog.com>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Jonathan Cameron <jic23@kernel.org>,
	Neil Armstrong <narmstrong@baylibre.com>,
	Baolin Wang <baolin.wang@linux.alibaba.com>,
	Jyoti Bhayana <jbhayana@google.com>, Chen-Yu Tsai <wens@csie.org>,
	Orson Zhai <orsonzhai@gmail.com>
Subject: RE: [PATCH 03/15] iio: adc: axp288_adc: do not use internal iio_dev lock
Date: Tue, 20 Sep 2022 13:46:31 +0000	[thread overview]
Message-ID: <SJ0PR03MB6778EEF81693C026CE131B49994C9@SJ0PR03MB6778.namprd03.prod.outlook.com> (raw)
In-Reply-To: <CAHp75VfdUOTd9tRXdTVq_prNf_T2=iQ4tEjusHC=gXDZvb3Qeg@mail.gmail.com>



> -----Original Message-----
> From: Andy Shevchenko <andy.shevchenko@gmail.com>
> Sent: Tuesday, September 20, 2022 3:39 PM
> To: Sa, Nuno <Nuno.Sa@analog.com>
> Cc: linux-arm-kernel@lists.infradead.org; linux-rockchip@lists.infradead.org;
> linux-amlogic@lists.infradead.org; linux-imx@nxp.com; linux-
> iio@vger.kernel.org; Chunyan Zhang <zhang.lyra@gmail.com>; Hennerich,
> Michael <Michael.Hennerich@analog.com>; Martin Blumenstingl
> <martin.blumenstingl@googlemail.com>; Sascha Hauer
> <s.hauer@pengutronix.de>; Cixi Geng <cixi.geng1@unisoc.com>; Kevin
> Hilman <khilman@baylibre.com>; Vladimir Zapolskiy <vz@mleia.com>;
> Pengutronix Kernel Team <kernel@pengutronix.de>; Alexandru Ardelean
> <aardelean@deviqon.com>; Fabio Estevam <festevam@gmail.com>; Andriy
> Tryshnivskyy <andriy.tryshnivskyy@opensynergy.com>; Haibo Chen
> <haibo.chen@nxp.com>; Shawn Guo <shawnguo@kernel.org>; Hans de
> Goede <hdegoede@redhat.com>; Miquel Raynal
> <miquel.raynal@bootlin.com>; Jerome Brunet <jbrunet@baylibre.com>;
> Heiko Stuebner <heiko@sntech.de>; Florian Boor
> <florian.boor@kernelconcepts.de>; Regus, Ciprian
> <Ciprian.Regus@analog.com>; Lars-Peter Clausen <lars@metafoo.de>;
> Jonathan Cameron <jic23@kernel.org>; Neil Armstrong
> <narmstrong@baylibre.com>; Baolin Wang
> <baolin.wang@linux.alibaba.com>; Jyoti Bhayana <jbhayana@google.com>;
> Chen-Yu Tsai <wens@csie.org>; Orson Zhai <orsonzhai@gmail.com>
> Subject: Re: [PATCH 03/15] iio: adc: axp288_adc: do not use internal iio_dev
> lock
> 
> [External]
> 
> On Tue, Sep 20, 2022 at 4:37 PM Andy Shevchenko
> <andy.shevchenko@gmail.com> wrote:
> > On Tue, Sep 20, 2022 at 4:18 PM Sa, Nuno <Nuno.Sa@analog.com> wrote:
> > > > On Tue, Sep 20, 2022 at 2:28 PM Nuno Sá <nuno.sa@analog.com>
> wrote:
> 
> ...
> 
> > > > >         info = iio_priv(indio_dev);
> > > > > +       mutex_init(&info->lock);
> > > > >         info->irq = platform_get_irq(pdev, 0);
> > > > >         if (info->irq < 0)
> > > > >                 return info->irq;
> > > >
> > > > Consider initializing it as late as possible, like after IRQ retrieval
> > > > in this context (maybe even deeper, but no context available). Ditto
> > > > for the rest of the series.
> > >
> > > Any special reason for it (maybe related to lockdep :wondering: ) ? Just
> > > curious as I never noticed such a pattern when initializing mutexes.
> >
> > Yes. Micro-optimization based on the rule "don't create a resource in
> > case of known error".
> >
> > OTOH, you have to be sure that the mutex (and generally speaking a
> > locking) should be initialized early enough.
> 

Typically not really needed during probe...

> Note that "micro" in the above can be multiplied by 'k', where 'k' is
> the amount of deferred probes (probably not the case here, but again,
> "generally speaking").
> 

Well, I don't think 'mutex_init()' does that much that really matters in
these patches but ok, that rule is indeed a good practice that sometimes
makes a difference. And since I will definitely need a v2, I can make that
change. Where applicable, the best place is probably before registering the
IIO device...

- Nuno Sá
_______________________________________________
Linux-rockchip mailing list
Linux-rockchip@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip

WARNING: multiple messages have this Message-ID (diff)
From: "Sa, Nuno" <Nuno.Sa@analog.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: "linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"linux-rockchip@lists.infradead.org"
	<linux-rockchip@lists.infradead.org>,
	"linux-amlogic@lists.infradead.org"
	<linux-amlogic@lists.infradead.org>,
	"linux-imx@nxp.com" <linux-imx@nxp.com>,
	"linux-iio@vger.kernel.org" <linux-iio@vger.kernel.org>,
	Chunyan Zhang <zhang.lyra@gmail.com>,
	"Hennerich, Michael" <Michael.Hennerich@analog.com>,
	Martin Blumenstingl <martin.blumenstingl@googlemail.com>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	Cixi Geng <cixi.geng1@unisoc.com>,
	Kevin Hilman <khilman@baylibre.com>,
	Vladimir Zapolskiy <vz@mleia.com>,
	Pengutronix Kernel Team <kernel@pengutronix.de>,
	Alexandru Ardelean <aardelean@deviqon.com>,
	Fabio Estevam <festevam@gmail.com>,
	Andriy Tryshnivskyy <andriy.tryshnivskyy@opensynergy.com>,
	Haibo Chen <haibo.chen@nxp.com>, Shawn Guo <shawnguo@kernel.org>,
	Hans de Goede <hdegoede@redhat.com>,
	Miquel Raynal <miquel.raynal@bootlin.com>,
	Jerome Brunet <jbrunet@baylibre.com>,
	Heiko Stuebner <heiko@sntech.de>,
	Florian Boor <florian.boor@kernelconcepts.de>,
	"Regus, Ciprian" <Ciprian.Regus@analog.com>,
	Lars-Peter Clausen <lars@metafoo.de>,
	Jonathan Cameron <jic23@kernel.org>,
	Neil Armstrong <narmstrong@baylibre.com>,
	Baolin Wang <baolin.wang@linux.alibaba.com>,
	Jyoti Bhayana <jbhayana@google.com>, Chen-Yu Tsai <wens@csie.org>,
	Orson Zhai <orsonzhai@gmail.com>
Subject: RE: [PATCH 03/15] iio: adc: axp288_adc: do not use internal iio_dev lock
Date: Tue, 20 Sep 2022 13:46:31 +0000	[thread overview]
Message-ID: <SJ0PR03MB6778EEF81693C026CE131B49994C9@SJ0PR03MB6778.namprd03.prod.outlook.com> (raw)
In-Reply-To: <CAHp75VfdUOTd9tRXdTVq_prNf_T2=iQ4tEjusHC=gXDZvb3Qeg@mail.gmail.com>



> -----Original Message-----
> From: Andy Shevchenko <andy.shevchenko@gmail.com>
> Sent: Tuesday, September 20, 2022 3:39 PM
> To: Sa, Nuno <Nuno.Sa@analog.com>
> Cc: linux-arm-kernel@lists.infradead.org; linux-rockchip@lists.infradead.org;
> linux-amlogic@lists.infradead.org; linux-imx@nxp.com; linux-
> iio@vger.kernel.org; Chunyan Zhang <zhang.lyra@gmail.com>; Hennerich,
> Michael <Michael.Hennerich@analog.com>; Martin Blumenstingl
> <martin.blumenstingl@googlemail.com>; Sascha Hauer
> <s.hauer@pengutronix.de>; Cixi Geng <cixi.geng1@unisoc.com>; Kevin
> Hilman <khilman@baylibre.com>; Vladimir Zapolskiy <vz@mleia.com>;
> Pengutronix Kernel Team <kernel@pengutronix.de>; Alexandru Ardelean
> <aardelean@deviqon.com>; Fabio Estevam <festevam@gmail.com>; Andriy
> Tryshnivskyy <andriy.tryshnivskyy@opensynergy.com>; Haibo Chen
> <haibo.chen@nxp.com>; Shawn Guo <shawnguo@kernel.org>; Hans de
> Goede <hdegoede@redhat.com>; Miquel Raynal
> <miquel.raynal@bootlin.com>; Jerome Brunet <jbrunet@baylibre.com>;
> Heiko Stuebner <heiko@sntech.de>; Florian Boor
> <florian.boor@kernelconcepts.de>; Regus, Ciprian
> <Ciprian.Regus@analog.com>; Lars-Peter Clausen <lars@metafoo.de>;
> Jonathan Cameron <jic23@kernel.org>; Neil Armstrong
> <narmstrong@baylibre.com>; Baolin Wang
> <baolin.wang@linux.alibaba.com>; Jyoti Bhayana <jbhayana@google.com>;
> Chen-Yu Tsai <wens@csie.org>; Orson Zhai <orsonzhai@gmail.com>
> Subject: Re: [PATCH 03/15] iio: adc: axp288_adc: do not use internal iio_dev
> lock
> 
> [External]
> 
> On Tue, Sep 20, 2022 at 4:37 PM Andy Shevchenko
> <andy.shevchenko@gmail.com> wrote:
> > On Tue, Sep 20, 2022 at 4:18 PM Sa, Nuno <Nuno.Sa@analog.com> wrote:
> > > > On Tue, Sep 20, 2022 at 2:28 PM Nuno Sá <nuno.sa@analog.com>
> wrote:
> 
> ...
> 
> > > > >         info = iio_priv(indio_dev);
> > > > > +       mutex_init(&info->lock);
> > > > >         info->irq = platform_get_irq(pdev, 0);
> > > > >         if (info->irq < 0)
> > > > >                 return info->irq;
> > > >
> > > > Consider initializing it as late as possible, like after IRQ retrieval
> > > > in this context (maybe even deeper, but no context available). Ditto
> > > > for the rest of the series.
> > >
> > > Any special reason for it (maybe related to lockdep :wondering: ) ? Just
> > > curious as I never noticed such a pattern when initializing mutexes.
> >
> > Yes. Micro-optimization based on the rule "don't create a resource in
> > case of known error".
> >
> > OTOH, you have to be sure that the mutex (and generally speaking a
> > locking) should be initialized early enough.
> 

Typically not really needed during probe...

> Note that "micro" in the above can be multiplied by 'k', where 'k' is
> the amount of deferred probes (probably not the case here, but again,
> "generally speaking").
> 

Well, I don't think 'mutex_init()' does that much that really matters in
these patches but ok, that rule is indeed a good practice that sometimes
makes a difference. And since I will definitely need a v2, I can make that
change. Where applicable, the best place is probably before registering the
IIO device...

- Nuno Sá
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2022-09-20 13:47 UTC|newest]

Thread overview: 208+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-20 11:28 [PATCH 00/15] Make 'mlock' really private Nuno Sá
2022-09-20 11:28 ` Nuno Sá
2022-09-20 11:28 ` Nuno Sá
2022-09-20 11:28 ` Nuno Sá
2022-09-20 11:28 ` [PATCH 01/15] iio: adc: ad_sigma_delta: do not use internal iio_dev lock Nuno Sá
2022-09-20 11:28   ` Nuno Sá
2022-09-20 11:28   ` Nuno Sá
2022-09-20 11:28   ` Nuno Sá
2022-09-20 11:54   ` Miquel Raynal
2022-09-20 11:54     ` Miquel Raynal
2022-09-20 11:54     ` Miquel Raynal
2022-09-20 11:54     ` Miquel Raynal
2022-09-24 14:22     ` Jonathan Cameron
2022-09-24 14:22       ` Jonathan Cameron
2022-09-24 14:22       ` Jonathan Cameron
2022-09-24 14:22       ` Jonathan Cameron
2022-09-20 11:28 ` [PATCH 02/15] iio: adc: ad799x: " Nuno Sá
2022-09-20 11:28   ` Nuno Sá
2022-09-20 11:28   ` Nuno Sá
2022-09-20 11:28   ` Nuno Sá
2022-09-24 14:45   ` Jonathan Cameron
2022-09-24 14:45     ` Jonathan Cameron
2022-09-24 14:45     ` Jonathan Cameron
2022-09-24 14:45     ` Jonathan Cameron
2022-09-26 11:22     ` Nuno Sá
2022-09-26 11:22       ` Nuno Sá
2022-09-26 11:22       ` Nuno Sá
2022-09-26 11:22       ` Nuno Sá
2022-09-20 11:28 ` [PATCH 03/15] iio: adc: axp288_adc: " Nuno Sá
2022-09-20 11:28   ` Nuno Sá
2022-09-20 11:28   ` Nuno Sá
2022-09-20 11:28   ` Nuno Sá
2022-09-20 13:13   ` Andy Shevchenko
2022-09-20 13:13     ` Andy Shevchenko
2022-09-20 13:13     ` Andy Shevchenko
2022-09-20 13:13     ` Andy Shevchenko
2022-09-20 13:18     ` Sa, Nuno
2022-09-20 13:18       ` Sa, Nuno
2022-09-20 13:18       ` Sa, Nuno
2022-09-20 13:18       ` Sa, Nuno
2022-09-20 13:37       ` Andy Shevchenko
2022-09-20 13:37         ` Andy Shevchenko
2022-09-20 13:37         ` Andy Shevchenko
2022-09-20 13:37         ` Andy Shevchenko
2022-09-20 13:39         ` Andy Shevchenko
2022-09-20 13:39           ` Andy Shevchenko
2022-09-20 13:39           ` Andy Shevchenko
2022-09-20 13:39           ` Andy Shevchenko
2022-09-20 13:46           ` Sa, Nuno [this message]
2022-09-20 13:46             ` Sa, Nuno
2022-09-20 13:46             ` Sa, Nuno
2022-09-20 13:46             ` Sa, Nuno
2022-09-20 15:12             ` Andy Shevchenko
2022-09-20 15:12               ` Andy Shevchenko
2022-09-20 15:12               ` Andy Shevchenko
2022-09-20 15:12               ` Andy Shevchenko
2022-09-21  9:07               ` Nuno Sá
2022-09-21  9:07                 ` Nuno Sá
2022-09-21  9:07                 ` Nuno Sá
2022-09-21  9:07                 ` Nuno Sá
2022-09-24 15:23                 ` Jonathan Cameron
2022-09-24 15:23                   ` Jonathan Cameron
2022-09-24 15:23                   ` Jonathan Cameron
2022-09-24 15:23                   ` Jonathan Cameron
2022-09-24 15:24   ` Jonathan Cameron
2022-09-24 15:24     ` Jonathan Cameron
2022-09-24 15:24     ` Jonathan Cameron
2022-09-24 15:24     ` Jonathan Cameron
2022-09-20 11:28 ` [PATCH 04/15] iio: adc: imx7d_adc: " Nuno Sá
2022-09-20 11:28   ` Nuno Sá
2022-09-20 11:28   ` Nuno Sá
2022-09-20 11:28   ` Nuno Sá
2022-09-24 15:26   ` Jonathan Cameron
2022-09-24 15:26     ` Jonathan Cameron
2022-09-24 15:26     ` Jonathan Cameron
2022-09-24 15:26     ` Jonathan Cameron
2022-09-20 11:28 ` [PATCH 05/15] iio: adc: lpc32xx_adc: " Nuno Sá
2022-09-20 11:28   ` Nuno Sá
2022-09-20 11:28   ` Nuno Sá
2022-09-20 11:28   ` Nuno Sá
2022-09-24 15:27   ` Jonathan Cameron
2022-09-24 15:27     ` Jonathan Cameron
2022-09-24 15:27     ` Jonathan Cameron
2022-09-24 15:27     ` Jonathan Cameron
2022-09-20 11:28 ` [PATCH 06/15] iio: adc: ltc2947-core: " Nuno Sá
2022-09-20 11:28   ` Nuno Sá
2022-09-20 11:28   ` Nuno Sá
2022-09-20 11:28   ` Nuno Sá
2022-09-20 11:28 ` [PATCH 07/15] iio: adc: meson_saradc: " Nuno Sá
2022-09-20 11:28   ` Nuno Sá
2022-09-20 11:28   ` Nuno Sá
2022-09-20 11:28   ` Nuno Sá
2022-09-25 20:38   ` Martin Blumenstingl
2022-09-25 20:38     ` Martin Blumenstingl
2022-09-25 20:38     ` Martin Blumenstingl
2022-09-25 20:38     ` Martin Blumenstingl
2022-09-20 11:28 ` [PATCH 08/15] iio: adc: rockchip_saradc: " Nuno Sá
2022-09-20 11:28   ` Nuno Sá
2022-09-20 11:28   ` Nuno Sá
2022-09-20 11:28   ` Nuno Sá
2022-09-20 11:28 ` [PATCH 09/15] iio: adc: sc27xx_adc: " Nuno Sá
2022-09-20 11:28   ` Nuno Sá
2022-09-20 11:28   ` Nuno Sá
2022-09-20 11:28   ` Nuno Sá
2022-09-20 11:28 ` [PATCH 10/15] iio: adc: vf610_adc: " Nuno Sá
2022-09-20 11:28   ` Nuno Sá
2022-09-20 11:28   ` Nuno Sá
2022-09-20 11:28   ` Nuno Sá
2022-09-24 15:37   ` Jonathan Cameron
2022-09-24 15:37     ` Jonathan Cameron
2022-09-24 15:37     ` Jonathan Cameron
2022-09-24 15:37     ` Jonathan Cameron
2022-09-20 11:28 ` [PATCH 11/15] iio: common: scmi_iio: " Nuno Sá
2022-09-20 11:28   ` Nuno Sá
2022-09-20 11:28   ` Nuno Sá
2022-09-20 11:28   ` Nuno Sá
2022-09-24 15:42   ` Jonathan Cameron
2022-09-24 15:42     ` Jonathan Cameron
2022-09-24 15:42     ` Jonathan Cameron
2022-09-24 15:42     ` Jonathan Cameron
2022-09-20 11:28 ` [PATCH 12/15] iio: fyro: itg3200_core: " Nuno Sá
2022-09-20 11:28   ` Nuno Sá
2022-09-20 11:28   ` Nuno Sá
2022-09-20 11:28   ` Nuno Sá
2022-09-24 15:43   ` Jonathan Cameron
2022-09-24 15:43     ` Jonathan Cameron
2022-09-24 15:43     ` Jonathan Cameron
2022-09-24 15:43     ` Jonathan Cameron
2022-09-24 15:46   ` Jonathan Cameron
2022-09-24 15:46     ` Jonathan Cameron
2022-09-24 15:46     ` Jonathan Cameron
2022-09-24 15:46     ` Jonathan Cameron
2022-09-20 11:28 ` [PATCH 13/15] iio: health: max30100: " Nuno Sá
2022-09-20 11:28   ` Nuno Sá
2022-09-20 11:28   ` Nuno Sá
2022-09-20 11:28   ` Nuno Sá
2022-09-20 12:23   ` Miquel Raynal
2022-09-20 12:23     ` Miquel Raynal
2022-09-20 12:23     ` Miquel Raynal
2022-09-20 12:23     ` Miquel Raynal
2022-09-20 12:44     ` Sa, Nuno
2022-09-20 12:44       ` Sa, Nuno
2022-09-20 12:44       ` Sa, Nuno
2022-09-20 12:44       ` Sa, Nuno
2022-09-20 12:55       ` Miquel Raynal
2022-09-20 12:55         ` Miquel Raynal
2022-09-20 12:55         ` Miquel Raynal
2022-09-20 12:55         ` Miquel Raynal
2022-09-20 13:15         ` Sa, Nuno
2022-09-20 13:15           ` Sa, Nuno
2022-09-20 13:15           ` Sa, Nuno
2022-09-20 13:15           ` Sa, Nuno
2022-09-20 13:53           ` Miquel Raynal
2022-09-20 13:53             ` Miquel Raynal
2022-09-20 13:53             ` Miquel Raynal
2022-09-20 13:53             ` Miquel Raynal
2022-09-20 14:56             ` Nuno Sá
2022-09-20 14:56               ` Nuno Sá
2022-09-20 14:56               ` Nuno Sá
2022-09-20 14:56               ` Nuno Sá
2022-09-20 15:10               ` Miquel Raynal
2022-09-20 15:10                 ` Miquel Raynal
2022-09-20 15:10                 ` Miquel Raynal
2022-09-20 15:10                 ` Miquel Raynal
2022-09-24 15:53                 ` Jonathan Cameron
2022-09-24 15:53                   ` Jonathan Cameron
2022-09-24 15:53                   ` Jonathan Cameron
2022-09-24 15:53                   ` Jonathan Cameron
2022-09-26 10:06                   ` Nuno Sá
2022-09-26 10:06                     ` Nuno Sá
2022-09-26 10:06                     ` Nuno Sá
2022-09-26 10:06                     ` Nuno Sá
2022-10-02 11:03                     ` Jonathan Cameron
2022-10-02 11:03                       ` Jonathan Cameron
2022-10-02 11:03                       ` Jonathan Cameron
2022-10-02 11:03                       ` Jonathan Cameron
2022-10-04  7:57                       ` Nuno Sá
2022-10-04  7:57                         ` Nuno Sá
2022-10-04  7:57                         ` Nuno Sá
2022-10-04  7:57                         ` Nuno Sá
2022-09-20 11:28 ` [PATCH 14/15] iio: health: max30102: " Nuno Sá
2022-09-20 11:28   ` Nuno Sá
2022-09-20 11:28   ` Nuno Sá
2022-09-20 11:28   ` Nuno Sá
2022-09-24 15:54   ` Jonathan Cameron
2022-09-24 15:54     ` Jonathan Cameron
2022-09-24 15:54     ` Jonathan Cameron
2022-09-24 15:54     ` Jonathan Cameron
2022-09-30 10:04     ` Nuno Sá
2022-09-30 10:04       ` Nuno Sá
2022-09-30 10:04       ` Nuno Sá
2022-09-30 10:04       ` Nuno Sá
2022-10-02 11:08       ` Jonathan Cameron
2022-10-02 11:08         ` Jonathan Cameron
2022-10-02 11:08         ` Jonathan Cameron
2022-10-02 11:08         ` Jonathan Cameron
2022-10-04  7:53         ` Nuno Sá
2022-10-04  7:53           ` Nuno Sá
2022-10-04  7:53           ` Nuno Sá
2022-10-04  7:53           ` Nuno Sá
2022-09-20 11:28 ` [PATCH 15/15] iio: core: move 'mlock' to 'struct iio_dev_opaque' Nuno Sá
2022-09-20 11:28   ` Nuno Sá
2022-09-20 11:28   ` Nuno Sá
2022-09-20 11:28   ` Nuno Sá
2022-09-24 15:56   ` Jonathan Cameron
2022-09-24 15:56     ` Jonathan Cameron
2022-09-24 15:56     ` Jonathan Cameron
2022-09-24 15:56     ` Jonathan Cameron

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=SJ0PR03MB6778EEF81693C026CE131B49994C9@SJ0PR03MB6778.namprd03.prod.outlook.com \
    --to=nuno.sa@analog.com \
    --cc=Ciprian.Regus@analog.com \
    --cc=Michael.Hennerich@analog.com \
    --cc=aardelean@deviqon.com \
    --cc=andriy.tryshnivskyy@opensynergy.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=cixi.geng1@unisoc.com \
    --cc=festevam@gmail.com \
    --cc=florian.boor@kernelconcepts.de \
    --cc=haibo.chen@nxp.com \
    --cc=hdegoede@redhat.com \
    --cc=heiko@sntech.de \
    --cc=jbhayana@google.com \
    --cc=jbrunet@baylibre.com \
    --cc=jic23@kernel.org \
    --cc=kernel@pengutronix.de \
    --cc=khilman@baylibre.com \
    --cc=lars@metafoo.de \
    --cc=linux-amlogic@lists.infradead.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-imx@nxp.com \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=martin.blumenstingl@googlemail.com \
    --cc=miquel.raynal@bootlin.com \
    --cc=narmstrong@baylibre.com \
    --cc=orsonzhai@gmail.com \
    --cc=s.hauer@pengutronix.de \
    --cc=shawnguo@kernel.org \
    --cc=vz@mleia.com \
    --cc=wens@csie.org \
    --cc=zhang.lyra@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.