[v3,3/3] serial: core: Update uart_poll_timeout() function to return unsigned long

Message ID 20231026135628.2800617-1-vamshigajjela@google.com
State New
Headers
Series None |

Commit Message

Vamshi Gajjela Oct. 26, 2023, 1:56 p.m. UTC
  From: VAMSHI GAJJELA <vamshigajjela@google.com>

The function uart_fifo_timeout() returns an unsigned long value, which
is the number of jiffies. Therefore, change the variable timeout in the
function uart_poll_timeout() from int to unsigned long.
Change the return type of the function uart_poll_timeout() from int to
unsigned long to be consistent with the type of timeout values.

Signed-off-by: VAMSHI GAJJELA <vamshigajjela@google.com>
---
v3:
- updated description
v2:
- unsigned long instead of unsigned int
- added () after function name in short log
- updated description

 include/linux/serial_core.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Comments

Greg KH Oct. 27, 2023, 6:43 a.m. UTC | #1
On Thu, Oct 26, 2023 at 07:26:28PM +0530, Vamshi Gajjela wrote:
> From: VAMSHI GAJJELA <vamshigajjela@google.com>

Please use lower case letters like I think you mean to?

Also, where are patches 1/3 and 2/3 of this series?  I can't do anything
without them as well.

> The function uart_fifo_timeout() returns an unsigned long value, which
> is the number of jiffies. Therefore, change the variable timeout in the
> function uart_poll_timeout() from int to unsigned long.
> Change the return type of the function uart_poll_timeout() from int to
> unsigned long to be consistent with the type of timeout values.
> 
> Signed-off-by: VAMSHI GAJJELA <vamshigajjela@google.com>
> ---
> v3:
> - updated description
> v2:
> - unsigned long instead of unsigned int
> - added () after function name in short log
> - updated description
> 
>  include/linux/serial_core.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
> index bb6f073bc159..6916a1d7e477 100644
> --- a/include/linux/serial_core.h
> +++ b/include/linux/serial_core.h
> @@ -773,9 +773,9 @@ static inline unsigned long uart_fifo_timeout(struct uart_port *port)
>  }
>  
>  /* Base timer interval for polling */
> -static inline int uart_poll_timeout(struct uart_port *port)
> +static inline unsigned long uart_poll_timeout(struct uart_port *port)
>  {
> -	int timeout = uart_fifo_timeout(port);
> +	unsigned long timeout = uart_fifo_timeout(port);
>  
>  	return timeout > 6 ? (timeout / 2 - 2) : 1;

So we are now doing 64bit math?  Did that just make things slower?

What bug is this actually fixing?  How have you tested this to verify it
works?

thanks,

greg k-h
  
Ilpo Järvinen Oct. 27, 2023, 8:19 a.m. UTC | #2
On Fri, 27 Oct 2023, Greg Kroah-Hartman wrote:

> On Thu, Oct 26, 2023 at 07:26:28PM +0530, Vamshi Gajjela wrote:
> > From: VAMSHI GAJJELA <vamshigajjela@google.com>
> 
> Please use lower case letters like I think you mean to?
> 
> Also, where are patches 1/3 and 2/3 of this series?  I can't do anything
> without them as well.
> 
> > The function uart_fifo_timeout() returns an unsigned long value, which
> > is the number of jiffies. Therefore, change the variable timeout in the
> > function uart_poll_timeout() from int to unsigned long.
> > Change the return type of the function uart_poll_timeout() from int to
> > unsigned long to be consistent with the type of timeout values.
> > 
> > Signed-off-by: VAMSHI GAJJELA <vamshigajjela@google.com>
> > ---
> > v3:
> > - updated description
> > v2:
> > - unsigned long instead of unsigned int
> > - added () after function name in short log
> > - updated description
> > 
> >  include/linux/serial_core.h | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
> > index bb6f073bc159..6916a1d7e477 100644
> > --- a/include/linux/serial_core.h
> > +++ b/include/linux/serial_core.h
> > @@ -773,9 +773,9 @@ static inline unsigned long uart_fifo_timeout(struct uart_port *port)
> >  }
> >  
> >  /* Base timer interval for polling */
> > -static inline int uart_poll_timeout(struct uart_port *port)
> > +static inline unsigned long uart_poll_timeout(struct uart_port *port)
> >  {
> > -	int timeout = uart_fifo_timeout(port);
> > +	unsigned long timeout = uart_fifo_timeout(port);
> >  
> >  	return timeout > 6 ? (timeout / 2 - 2) : 1;
> 
> So we are now doing 64bit math?  Did that just make things slower?

That divide with a constant 2 though so I'd expect compiler to turn it 
into a shift.

> What bug is this actually fixing?  How have you tested this to verify it
> works?

AFAIK this doesn't fix anything because emptying when measured in jiffies
isn't that big number. It's just about making the types more consistent.
  
Greg KH Oct. 27, 2023, 11:01 a.m. UTC | #3
On Fri, Oct 27, 2023 at 11:19:26AM +0300, Ilpo Järvinen wrote:
> On Fri, 27 Oct 2023, Greg Kroah-Hartman wrote:
> 
> > On Thu, Oct 26, 2023 at 07:26:28PM +0530, Vamshi Gajjela wrote:
> > > From: VAMSHI GAJJELA <vamshigajjela@google.com>
> > 
> > Please use lower case letters like I think you mean to?
> > 
> > Also, where are patches 1/3 and 2/3 of this series?  I can't do anything
> > without them as well.
> > 
> > > The function uart_fifo_timeout() returns an unsigned long value, which
> > > is the number of jiffies. Therefore, change the variable timeout in the
> > > function uart_poll_timeout() from int to unsigned long.
> > > Change the return type of the function uart_poll_timeout() from int to
> > > unsigned long to be consistent with the type of timeout values.
> > > 
> > > Signed-off-by: VAMSHI GAJJELA <vamshigajjela@google.com>
> > > ---
> > > v3:
> > > - updated description
> > > v2:
> > > - unsigned long instead of unsigned int
> > > - added () after function name in short log
> > > - updated description
> > > 
> > >  include/linux/serial_core.h | 4 ++--
> > >  1 file changed, 2 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
> > > index bb6f073bc159..6916a1d7e477 100644
> > > --- a/include/linux/serial_core.h
> > > +++ b/include/linux/serial_core.h
> > > @@ -773,9 +773,9 @@ static inline unsigned long uart_fifo_timeout(struct uart_port *port)
> > >  }
> > >  
> > >  /* Base timer interval for polling */
> > > -static inline int uart_poll_timeout(struct uart_port *port)
> > > +static inline unsigned long uart_poll_timeout(struct uart_port *port)
> > >  {
> > > -	int timeout = uart_fifo_timeout(port);
> > > +	unsigned long timeout = uart_fifo_timeout(port);
> > >  
> > >  	return timeout > 6 ? (timeout / 2 - 2) : 1;
> > 
> > So we are now doing 64bit math?  Did that just make things slower?
> 
> That divide with a constant 2 though so I'd expect compiler to turn it 
> into a shift.

Hopefully :)

> > What bug is this actually fixing?  How have you tested this to verify it
> > works?
> 
> AFAIK this doesn't fix anything because emptying when measured in jiffies
> isn't that big number. It's just about making the types more consistent.

Ah, ok, I'll wait for a proper version to be sent as I obviously can't
take it like-this.

thanks,

greg k-h
  
Vamshi Gajjela Oct. 27, 2023, 1:58 p.m. UTC | #4
On Fri, Oct 27, 2023 at 12:13 PM Greg Kroah-Hartman
<gregkh@linuxfoundation.org> wrote:
>
> On Thu, Oct 26, 2023 at 07:26:28PM +0530, Vamshi Gajjela wrote:
> > From: VAMSHI GAJJELA <vamshigajjela@google.com>
>
> Please use lower case letters like I think you mean to?
Sure, I will update.
>
> Also, where are patches 1/3 and 2/3 of this series?  I can't do anything
> without them as well.
1/3 is dropped:
https://lore.kernel.org/lkml/CAMTSyjqc118-by6LRHaSN7k8fOcR6K0kmYXdthPD7rqJuYOaVw@mail.gmail.com/
2/3 is a clean up:
https://lore.kernel.org/lkml/CAMTSyjpiz_LVtVAzaNpD-xThtp6sKNy-Uvkr+CaH9b10VRYD9A@mail.gmail.com/
for 2/3 waiting on response from Ilpo Järvinen

>
> > The function uart_fifo_timeout() returns an unsigned long value, which
> > is the number of jiffies. Therefore, change the variable timeout in the
> > function uart_poll_timeout() from int to unsigned long.
> > Change the return type of the function uart_poll_timeout() from int to
> > unsigned long to be consistent with the type of timeout values.
> >
> > Signed-off-by: VAMSHI GAJJELA <vamshigajjela@google.com>
> > ---
> > v3:
> > - updated description
> > v2:
> > - unsigned long instead of unsigned int
> > - added () after function name in short log
> > - updated description
> >
> >  include/linux/serial_core.h | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
> > index bb6f073bc159..6916a1d7e477 100644
> > --- a/include/linux/serial_core.h
> > +++ b/include/linux/serial_core.h
> > @@ -773,9 +773,9 @@ static inline unsigned long uart_fifo_timeout(struct uart_port *port)
> >  }
> >
> >  /* Base timer interval for polling */
> > -static inline int uart_poll_timeout(struct uart_port *port)
> > +static inline unsigned long uart_poll_timeout(struct uart_port *port)
> >  {
> > -     int timeout = uart_fifo_timeout(port);
> > +     unsigned long timeout = uart_fifo_timeout(port);
> >
> >       return timeout > 6 ? (timeout / 2 - 2) : 1;
>
> So we are now doing 64bit math?  Did that just make things slower?
>
> What bug is this actually fixing?  How have you tested this to verify it
> works?
>
> thanks,
>
> greg k-h
  
Ilpo Järvinen Oct. 27, 2023, 2:05 p.m. UTC | #5
On Fri, 27 Oct 2023, VAMSHI GAJJELA wrote:

> On Fri, Oct 27, 2023 at 12:13 PM Greg Kroah-Hartman
> <gregkh@linuxfoundation.org> wrote:
> >
> > On Thu, Oct 26, 2023 at 07:26:28PM +0530, Vamshi Gajjela wrote:
> > > From: VAMSHI GAJJELA <vamshigajjela@google.com>
> >
> > Please use lower case letters like I think you mean to?
> Sure, I will update.
> >
> > Also, where are patches 1/3 and 2/3 of this series?  I can't do anything
> > without them as well.
> 1/3 is dropped:
> https://lore.kernel.org/lkml/CAMTSyjqc118-by6LRHaSN7k8fOcR6K0kmYXdthPD7rqJuYOaVw@mail.gmail.com/
> 2/3 is a clean up:
> https://lore.kernel.org/lkml/CAMTSyjpiz_LVtVAzaNpD-xThtp6sKNy-Uvkr+CaH9b10VRYD9A@mail.gmail.com/
> for 2/3 waiting on response from Ilpo Järvinen

I didn't realize you were waiting for some input.

You can do that rename if you want. Now that I looked again that patch, I 
was considering that perhaps the local frame_time variable could also be 
dropped in that function.
  
Greg KH Oct. 27, 2023, 2:16 p.m. UTC | #6
On Fri, Oct 27, 2023 at 07:28:12PM +0530, VAMSHI GAJJELA wrote:
> On Fri, Oct 27, 2023 at 12:13 PM Greg Kroah-Hartman
> <gregkh@linuxfoundation.org> wrote:
> >
> > On Thu, Oct 26, 2023 at 07:26:28PM +0530, Vamshi Gajjela wrote:
> > > From: VAMSHI GAJJELA <vamshigajjela@google.com>
> >
> > Please use lower case letters like I think you mean to?
> Sure, I will update.
> >
> > Also, where are patches 1/3 and 2/3 of this series?  I can't do anything
> > without them as well.
> 1/3 is dropped:
> https://lore.kernel.org/lkml/CAMTSyjqc118-by6LRHaSN7k8fOcR6K0kmYXdthPD7rqJuYOaVw@mail.gmail.com/
> 2/3 is a clean up:
> https://lore.kernel.org/lkml/CAMTSyjpiz_LVtVAzaNpD-xThtp6sKNy-Uvkr+CaH9b10VRYD9A@mail.gmail.com/
> for 2/3 waiting on response from Ilpo Järvinen

But I see no threading of anything here, please submit things so that we
have a chance to know what is going on.  What would you do if you got a
patch that only said 3/3 to review?

thanks,

greg k-h
  

Patch

diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index bb6f073bc159..6916a1d7e477 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -773,9 +773,9 @@  static inline unsigned long uart_fifo_timeout(struct uart_port *port)
 }
 
 /* Base timer interval for polling */
-static inline int uart_poll_timeout(struct uart_port *port)
+static inline unsigned long uart_poll_timeout(struct uart_port *port)
 {
-	int timeout = uart_fifo_timeout(port);
+	unsigned long timeout = uart_fifo_timeout(port);
 
 	return timeout > 6 ? (timeout / 2 - 2) : 1;
 }