* [PATCH v1 1/2] iopoll: Introduce ioreadXX_poll_timeout() macros
@ 2023-03-30 14:14 Andy Shevchenko
2023-03-30 14:14 ` [PATCH v1 2/2] thunderbolt: Make use of ioread32_poll_timeout() Andy Shevchenko
2023-03-31 8:12 ` [PATCH v1 1/2] iopoll: Introduce ioreadXX_poll_timeout() macros Olliver Schinagl
0 siblings, 2 replies; 7+ messages in thread
From: Andy Shevchenko @ 2023-03-30 14:14 UTC (permalink / raw)
To: Mika Westerberg, Andy Shevchenko, Olliver Schinagl, linux-usb,
linux-kernel
Cc: Andreas Noever, Michael Jamet, Yehezkel Bernat
From: Olliver Schinagl <oliver@schinagl.nl>
There are users in the Linux kernel that would benefit from using
ioreadXX_poll_timeout() macros, such as ioread32_poll_timeout().
Introduce those macros.
Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
Co-developed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
include/linux/iopoll.h | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/include/linux/iopoll.h b/include/linux/iopoll.h
index 2c8860e406bd..30ba609175a7 100644
--- a/include/linux/iopoll.h
+++ b/include/linux/iopoll.h
@@ -140,6 +140,7 @@
#define readx_poll_timeout_atomic(op, addr, val, cond, delay_us, timeout_us) \
read_poll_timeout_atomic(op, val, cond, delay_us, timeout_us, false, addr)
+/* readX() */
#define readb_poll_timeout(addr, val, cond, delay_us, timeout_us) \
readx_poll_timeout(readb, addr, val, cond, delay_us, timeout_us)
@@ -164,6 +165,7 @@
#define readq_poll_timeout_atomic(addr, val, cond, delay_us, timeout_us) \
readx_poll_timeout_atomic(readq, addr, val, cond, delay_us, timeout_us)
+/* readX_relaxed() */
#define readb_relaxed_poll_timeout(addr, val, cond, delay_us, timeout_us) \
readx_poll_timeout(readb_relaxed, addr, val, cond, delay_us, timeout_us)
@@ -188,4 +190,29 @@
#define readq_relaxed_poll_timeout_atomic(addr, val, cond, delay_us, timeout_us) \
readx_poll_timeout_atomic(readq_relaxed, addr, val, cond, delay_us, timeout_us)
+/* ioreadXX() */
+#define ioread8_poll_timeout(addr, val, cond, delay_us, timeout_us) \
+ readx_poll_timeout(ioread8, addr, val, cond, delay_us, timeout_us)
+
+#define ioread8_poll_timeout_atomic(addr, val, cond, delay_us, timeout_us) \
+ readx_poll_timeout_atomic(ioread8, addr, val, cond, delay_us, timeout_us)
+
+#define ioread16_poll_timeout(addr, val, cond, delay_us, timeout_us) \
+ readx_poll_timeout(ioread16, addr, val, cond, delay_us, timeout_us)
+
+#define ioread16_poll_timeout_atomic(addr, val, cond, delay_us, timeout_us) \
+ readx_poll_timeout_atomic(ioread16, addr, val, cond, delay_us, timeout_us)
+
+#define ioread32_poll_timeout(addr, val, cond, delay_us, timeout_us) \
+ readx_poll_timeout(ioread32, addr, val, cond, delay_us, timeout_us)
+
+#define ioread32_poll_timeout_atomic(addr, val, cond, delay_us, timeout_us) \
+ readx_poll_timeout_atomic(ioread32, addr, val, cond, delay_us, timeout_us)
+
+#define ioread64_poll_timeout(addr, val, cond, delay_us, timeout_us) \
+ readx_poll_timeout(ioread64, addr, val, cond, delay_us, timeout_us)
+
+#define ioread64_poll_timeout_atomic(addr, val, cond, delay_us, timeout_us) \
+ readx_poll_timeout_atomic(ioread64, addr, val, cond, delay_us, timeout_us)
+
#endif /* _LINUX_IOPOLL_H */
--
2.40.0.1.gaa8946217a0b
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v1 2/2] thunderbolt: Make use of ioread32_poll_timeout()
2023-03-30 14:14 [PATCH v1 1/2] iopoll: Introduce ioreadXX_poll_timeout() macros Andy Shevchenko
@ 2023-03-30 14:14 ` Andy Shevchenko
2023-03-31 8:12 ` [PATCH v1 1/2] iopoll: Introduce ioreadXX_poll_timeout() macros Olliver Schinagl
1 sibling, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2023-03-30 14:14 UTC (permalink / raw)
To: Mika Westerberg, Andy Shevchenko, Olliver Schinagl, linux-usb,
linux-kernel
Cc: Andreas Noever, Michael Jamet, Yehezkel Bernat
Instead of open coding the same routine switch the code to use
ioread32_poll_timeout().
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/thunderbolt/nhi.c | 20 ++++++++------------
1 file changed, 8 insertions(+), 12 deletions(-)
diff --git a/drivers/thunderbolt/nhi.c b/drivers/thunderbolt/nhi.c
index d76e923fbc6a..d0bf11b40131 100644
--- a/drivers/thunderbolt/nhi.c
+++ b/drivers/thunderbolt/nhi.c
@@ -16,8 +16,8 @@
#include <linux/dma-mapping.h>
#include <linux/interrupt.h>
#include <linux/iommu.h>
+#include <linux/iopoll.h>
#include <linux/module.h>
-#include <linux/delay.h>
#include <linux/property.h>
#include <linux/string_helpers.h>
@@ -40,7 +40,7 @@
#define MSIX_MIN_VECS 6
#define MSIX_MAX_VECS 16
-#define NHI_MAILBOX_TIMEOUT 500 /* ms */
+#define NHI_MAILBOX_TIMEOUT_US 500000
/* Host interface quirks */
#define QUIRK_AUTO_CLEAR_INT BIT(0)
@@ -830,8 +830,8 @@ EXPORT_SYMBOL_GPL(tb_ring_free);
*/
int nhi_mailbox_cmd(struct tb_nhi *nhi, enum nhi_mailbox_cmd cmd, u32 data)
{
- ktime_t timeout;
u32 val;
+ int ret;
iowrite32(data, nhi->iobase + REG_INMAIL_DATA);
@@ -840,16 +840,12 @@ int nhi_mailbox_cmd(struct tb_nhi *nhi, enum nhi_mailbox_cmd cmd, u32 data)
val |= REG_INMAIL_OP_REQUEST | cmd;
iowrite32(val, nhi->iobase + REG_INMAIL_CMD);
- timeout = ktime_add_ms(ktime_get(), NHI_MAILBOX_TIMEOUT);
- do {
- val = ioread32(nhi->iobase + REG_INMAIL_CMD);
- if (!(val & REG_INMAIL_OP_REQUEST))
- break;
- usleep_range(10, 20);
- } while (ktime_before(ktime_get(), timeout));
+ ret = ioread32_poll_timeout(nhi->iobase + REG_INMAIL_CMD,
+ val, !(val & REG_INMAIL_OP_REQUEST),
+ 40, NHI_MAILBOX_TIMEOUT_US);
+ if (ret)
+ return ret;
- if (val & REG_INMAIL_OP_REQUEST)
- return -ETIMEDOUT;
if (val & REG_INMAIL_ERROR)
return -EIO;
--
2.40.0.1.gaa8946217a0b
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v1 1/2] iopoll: Introduce ioreadXX_poll_timeout() macros
2023-03-30 14:14 [PATCH v1 1/2] iopoll: Introduce ioreadXX_poll_timeout() macros Andy Shevchenko
2023-03-30 14:14 ` [PATCH v1 2/2] thunderbolt: Make use of ioread32_poll_timeout() Andy Shevchenko
@ 2023-03-31 8:12 ` Olliver Schinagl
2023-04-05 8:58 ` Andy Shevchenko
1 sibling, 1 reply; 7+ messages in thread
From: Olliver Schinagl @ 2023-03-31 8:12 UTC (permalink / raw)
To: Andy Shevchenko, Mika Westerberg, linux-usb, linux-kernel
Cc: Andreas Noever, Michael Jamet, Yehezkel Bernat
Hey Andy,
On 30-03-2023 16:14, Andy Shevchenko wrote:
> From: Olliver Schinagl <oliver@schinagl.nl>
>
> There are users in the Linux kernel that would benefit from using
> ioreadXX_poll_timeout() macros, such as ioread32_poll_timeout().
> Introduce those macros.
>
> Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
> Co-developed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
> include/linux/iopoll.h | 27 +++++++++++++++++++++++++++
> 1 file changed, 27 insertions(+)
>
> diff --git a/include/linux/iopoll.h b/include/linux/iopoll.h
> index 2c8860e406bd..30ba609175a7 100644
> --- a/include/linux/iopoll.h
> +++ b/include/linux/iopoll.h
> @@ -140,6 +140,7 @@
> #define readx_poll_timeout_atomic(op, addr, val, cond, delay_us, timeout_us) \
> read_poll_timeout_atomic(op, val, cond, delay_us, timeout_us, false, addr)
>
> +/* readX() */
> #define readb_poll_timeout(addr, val, cond, delay_us, timeout_us) \
> readx_poll_timeout(readb, addr, val, cond, delay_us, timeout_us)
>
> <snip>
> #endif /* _LINUX_IOPOLL_H */
Thanks for re-posting this? (I don't recall If I actually posted the
first time around).
But I actually have a small addendum for this series, as it will break
`drivers/net/wwan/t7xx/t7xx_dpmaif.c` due to a redefinition (yeah I know).
So I have:
https://gitlab.com/olliver/linux/-/commit/c9e591f2dabb2dbaeceebee61fa70b70fdbffc2a
https://gitlab.com/olliver/linux/-/commit/41e0f8c08a1c55940813a240215910336ad7bec2
https://gitlab.com/olliver/linux/-/commit/f36562f09b0185d403415864ef7218b46a742cdc
https://gitlab.com/olliver/linux/-/commit/66237fd97bc42d272602b01dc0cca541c619b2be
Which actually replaces silly calls like readx_poll_timeout(ioread32, ... .
Do you want me to (re-?)post this as a series? I can put your
thunderbolt (and your changes here) and post as one big series (or you
can do the same obviously).
Olliver
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v1 1/2] iopoll: Introduce ioreadXX_poll_timeout() macros
2023-03-31 8:12 ` [PATCH v1 1/2] iopoll: Introduce ioreadXX_poll_timeout() macros Olliver Schinagl
@ 2023-04-05 8:58 ` Andy Shevchenko
2023-04-05 9:41 ` Mika Westerberg
0 siblings, 1 reply; 7+ messages in thread
From: Andy Shevchenko @ 2023-04-05 8:58 UTC (permalink / raw)
To: Olliver Schinagl
Cc: Mika Westerberg, linux-usb, linux-kernel, Andreas Noever,
Michael Jamet, Yehezkel Bernat
On Fri, Mar 31, 2023 at 10:12:31AM +0200, Olliver Schinagl wrote:
> On 30-03-2023 16:14, Andy Shevchenko wrote:
...
> But I actually have a small addendum for this series, as it will break
> `drivers/net/wwan/t7xx/t7xx_dpmaif.c` due to a redefinition (yeah I know).
>
> So I have:
> https://gitlab.com/olliver/linux/-/commit/c9e591f2dabb2dbaeceebee61fa70b70fdbffc2a
> https://gitlab.com/olliver/linux/-/commit/41e0f8c08a1c55940813a240215910336ad7bec2
> https://gitlab.com/olliver/linux/-/commit/f36562f09b0185d403415864ef7218b46a742cdc
> https://gitlab.com/olliver/linux/-/commit/66237fd97bc42d272602b01dc0cca541c619b2be
>
> Which actually replaces silly calls like readx_poll_timeout(ioread32, ... .
>
> Do you want me to (re-?)post this as a series? I can put your thunderbolt
> (and your changes here) and post as one big series (or you can do the same
> obviously).
I believe the best course of action is to collect this series and your fix
in your hands and send it as a material for Linux WWAN subsystem with Mika's
Ack (if he has no objections). That said, let's wait for Mika's answer
on this.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v1 1/2] iopoll: Introduce ioreadXX_poll_timeout() macros
2023-04-05 8:58 ` Andy Shevchenko
@ 2023-04-05 9:41 ` Mika Westerberg
2023-04-05 11:15 ` Andy Shevchenko
0 siblings, 1 reply; 7+ messages in thread
From: Mika Westerberg @ 2023-04-05 9:41 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Olliver Schinagl, linux-usb, linux-kernel, Andreas Noever,
Michael Jamet, Yehezkel Bernat
Hi,
On Wed, Apr 05, 2023 at 11:58:15AM +0300, Andy Shevchenko wrote:
> On Fri, Mar 31, 2023 at 10:12:31AM +0200, Olliver Schinagl wrote:
> > On 30-03-2023 16:14, Andy Shevchenko wrote:
>
> ...
>
> > But I actually have a small addendum for this series, as it will break
> > `drivers/net/wwan/t7xx/t7xx_dpmaif.c` due to a redefinition (yeah I know).
> >
> > So I have:
> > https://gitlab.com/olliver/linux/-/commit/c9e591f2dabb2dbaeceebee61fa70b70fdbffc2a
> > https://gitlab.com/olliver/linux/-/commit/41e0f8c08a1c55940813a240215910336ad7bec2
> > https://gitlab.com/olliver/linux/-/commit/f36562f09b0185d403415864ef7218b46a742cdc
> > https://gitlab.com/olliver/linux/-/commit/66237fd97bc42d272602b01dc0cca541c619b2be
> >
> > Which actually replaces silly calls like readx_poll_timeout(ioread32, ... .
> >
> > Do you want me to (re-?)post this as a series? I can put your thunderbolt
> > (and your changes here) and post as one big series (or you can do the same
> > obviously).
>
> I believe the best course of action is to collect this series and your fix
> in your hands and send it as a material for Linux WWAN subsystem with Mika's
> Ack (if he has no objections). That said, let's wait for Mika's answer
> on this.
No objections from my side.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v1 1/2] iopoll: Introduce ioreadXX_poll_timeout() macros
2023-04-05 9:41 ` Mika Westerberg
@ 2023-04-05 11:15 ` Andy Shevchenko
2023-04-05 11:18 ` Andy Shevchenko
0 siblings, 1 reply; 7+ messages in thread
From: Andy Shevchenko @ 2023-04-05 11:15 UTC (permalink / raw)
To: Mika Westerberg
Cc: Olliver Schinagl, linux-usb, linux-kernel, Andreas Noever,
Michael Jamet, Yehezkel Bernat
On Wed, Apr 05, 2023 at 12:41:47PM +0300, Mika Westerberg wrote:
> On Wed, Apr 05, 2023 at 11:58:15AM +0300, Andy Shevchenko wrote:
> > On Fri, Mar 31, 2023 at 10:12:31AM +0200, Olliver Schinagl wrote:
> > > On 30-03-2023 16:14, Andy Shevchenko wrote:
...
> > > But I actually have a small addendum for this series, as it will break
> > > `drivers/net/wwan/t7xx/t7xx_dpmaif.c` due to a redefinition (yeah I know).
> > >
> > > So I have:
> > > https://gitlab.com/olliver/linux/-/commit/c9e591f2dabb2dbaeceebee61fa70b70fdbffc2a
> > > https://gitlab.com/olliver/linux/-/commit/41e0f8c08a1c55940813a240215910336ad7bec2
> > > https://gitlab.com/olliver/linux/-/commit/f36562f09b0185d403415864ef7218b46a742cdc
> > > https://gitlab.com/olliver/linux/-/commit/66237fd97bc42d272602b01dc0cca541c619b2be
> > >
> > > Which actually replaces silly calls like readx_poll_timeout(ioread32, ... .
> > >
> > > Do you want me to (re-?)post this as a series? I can put your thunderbolt
> > > (and your changes here) and post as one big series (or you can do the same
> > > obviously).
> >
> > I believe the best course of action is to collect this series and your fix
> > in your hands and send it as a material for Linux WWAN subsystem with Mika's
> > Ack (if he has no objections). That said, let's wait for Mika's answer
> > on this.
>
> No objections from my side.
Thank you, Mika!
This implies that I stop issuing a new version and Olliver takes over.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v1 1/2] iopoll: Introduce ioreadXX_poll_timeout() macros
2023-04-05 11:15 ` Andy Shevchenko
@ 2023-04-05 11:18 ` Andy Shevchenko
0 siblings, 0 replies; 7+ messages in thread
From: Andy Shevchenko @ 2023-04-05 11:18 UTC (permalink / raw)
To: Mika Westerberg
Cc: Olliver Schinagl, linux-usb, linux-kernel, Andreas Noever,
Michael Jamet, Yehezkel Bernat
On Wed, Apr 05, 2023 at 02:15:42PM +0300, Andy Shevchenko wrote:
> On Wed, Apr 05, 2023 at 12:41:47PM +0300, Mika Westerberg wrote:
> > On Wed, Apr 05, 2023 at 11:58:15AM +0300, Andy Shevchenko wrote:
> > > On Fri, Mar 31, 2023 at 10:12:31AM +0200, Olliver Schinagl wrote:
> > > > On 30-03-2023 16:14, Andy Shevchenko wrote:
...
> > > > But I actually have a small addendum for this series, as it will break
> > > > `drivers/net/wwan/t7xx/t7xx_dpmaif.c` due to a redefinition (yeah I know).
> > > >
> > > > So I have:
> > > > https://gitlab.com/olliver/linux/-/commit/c9e591f2dabb2dbaeceebee61fa70b70fdbffc2a
> > > > https://gitlab.com/olliver/linux/-/commit/41e0f8c08a1c55940813a240215910336ad7bec2
> > > > https://gitlab.com/olliver/linux/-/commit/f36562f09b0185d403415864ef7218b46a742cdc
> > > > https://gitlab.com/olliver/linux/-/commit/66237fd97bc42d272602b01dc0cca541c619b2be
> > > >
> > > > Which actually replaces silly calls like readx_poll_timeout(ioread32, ... .
> > > >
> > > > Do you want me to (re-?)post this as a series? I can put your thunderbolt
> > > > (and your changes here) and post as one big series (or you can do the same
> > > > obviously).
> > >
> > > I believe the best course of action is to collect this series and your fix
> > > in your hands and send it as a material for Linux WWAN subsystem with Mika's
> > > Ack (if he has no objections). That said, let's wait for Mika's answer
> > > on this.
> >
> > No objections from my side.
>
> Thank you, Mika!
>
> This implies that I stop issuing a new version and Olliver takes over.
Olliver, just note that I reduced a lot your initial patch in a sense to add
only what is close to the existing users, i.e. ioreadXX() and their atomic
versions (no be(), no _rep() variants). If you are objecting that, you need
to have yet another patch(es) to prove that there are users.
Also note, that I reordered macro appearance to be consistent with existing
schema.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2023-04-05 11:18 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-30 14:14 [PATCH v1 1/2] iopoll: Introduce ioreadXX_poll_timeout() macros Andy Shevchenko
2023-03-30 14:14 ` [PATCH v1 2/2] thunderbolt: Make use of ioread32_poll_timeout() Andy Shevchenko
2023-03-31 8:12 ` [PATCH v1 1/2] iopoll: Introduce ioreadXX_poll_timeout() macros Olliver Schinagl
2023-04-05 8:58 ` Andy Shevchenko
2023-04-05 9:41 ` Mika Westerberg
2023-04-05 11:15 ` Andy Shevchenko
2023-04-05 11:18 ` Andy Shevchenko
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).