All of lore.kernel.org
 help / color / mirror / Atom feed
From: Laurent Vivier <lvivier@redhat.com>
To: rutu.shah.26@gmail.com, qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, kvm@vger.kernel.org, mst@redhat.com,
	jasowang@redhat.com, lcapitulino@redhat.com, kraxel@redhat.com,
	qemu-block@nongnu.org, borntraeger@de.ibm.com,
	samuel.thibault@ens-lyon.org, balrogg@gmail.com,
	alistair.francis@xilinx.com, qemu-arm@nongnu.org,
	stefanha@redhat.com, pbonzini@redhat.com,
	cornelia.huck@de.ibm.com, jsnow@redhat.com, rth@twiddle.net,
	kwolf@redhat.com, crosthwaite.peter@gmail.com, armbru@redhat.com,
	blauwirbel@gmail.co, qemu-ppc@nongnu.org, imammedo@redhat.com
Subject: Re: [Qemu-ppc] [PATCH] Replacing (and removing) get_ticks_per_sec() function with NANOSECONDS_PER_SECOND Signed-off-by: Rutuja Shah <rutu.shah.26@gmail.com>
Date: Tue, 15 Mar 2016 11:08:08 +0100	[thread overview]
Message-ID: <56E7DF08.2050400@redhat.com> (raw)
In-Reply-To: <1457638209-14218-1-git-send-email-rutu.shah.26@gmail.com>



On 10/03/2016 20:30, rutu.shah.26@gmail.com wrote:
> From: Rutuja Shah <rutu.shah.26@gmail.com>
> 
> ---
>  audio/audio.c             |  2 +-
>  audio/noaudio.c           |  4 ++--
>  audio/spiceaudio.c        |  2 +-
>  audio/wavaudio.c          |  2 +-
>  backends/baum.c           |  2 +-
>  block/qed.c               |  2 +-
>  cpus.c                    |  6 +++---
>  hw/acpi/core.c            |  4 ++--
>  hw/arm/omap1.c            | 14 +++++++-------
>  hw/arm/spitz.c            |  2 +-
>  hw/arm/stellaris.c        |  2 +-
>  hw/arm/strongarm.c        |  2 +-
>  hw/audio/adlib.c          |  2 +-
>  hw/audio/sb16.c           |  4 ++--
>  hw/block/fdc.c            |  2 +-
>  hw/block/pflash_cfi02.c   |  4 ++--
>  hw/bt/hci-csr.c           |  4 ++--
>  hw/char/cadence_uart.c    |  4 ++--
>  hw/char/serial.c          |  6 +++---
>  hw/display/vga.c          |  6 +++---
>  hw/dma/rc4030.c           |  2 +-
>  hw/ide/core.c             |  2 +-
>  hw/input/hid.c            |  2 +-
>  hw/input/tsc2005.c        |  2 +-
>  hw/input/tsc210x.c        |  2 +-
>  hw/intc/i8259.c           |  2 +-
>  hw/misc/arm_sysctl.c      |  2 +-
>  hw/misc/macio/cuda.c      | 16 ++++++++--------
>  hw/misc/macio/macio.c     |  2 +-
>  hw/net/dp8393x.c          |  2 +-
>  hw/ppc/ppc.c              | 18 +++++++++---------
>  hw/ppc/ppc405_uc.c        |  4 ++--
>  hw/ppc/ppc_booke.c        |  2 +-
>  hw/sd/sdhci-internal.h    |  2 +-
>  hw/sparc64/sun4u.c        |  4 ++--
>  hw/timer/i8254.c          |  4 ++--
>  hw/timer/i8254_common.c   |  6 +++---
>  hw/timer/mc146818rtc.c    |  6 +++---
>  hw/timer/omap_gptimer.c   |  2 +-
>  hw/timer/omap_synctimer.c |  2 +-
>  hw/timer/pl031.c          | 10 +++++-----
>  hw/timer/pxa2xx_timer.c   | 14 +++++++-------
>  hw/usb/hcd-ehci.c         |  4 ++--
>  hw/usb/hcd-musb.c         |  2 +-
>  hw/usb/hcd-ohci.c         | 10 +++++-----
>  hw/usb/hcd-uhci.c         |  6 +++---
>  hw/usb/tusb6010.c         |  4 ++--
>  hw/watchdog/wdt_diag288.c |  2 +-
>  hw/watchdog/wdt_ib700.c   |  2 +-
>  include/hw/acpi/acpi.h    |  2 +-
>  include/qemu/timer.h      |  9 ++-------
>  monitor.c                 |  4 ++--
>  target-ppc/kvm.c          |  4 ++--
>  53 files changed, 114 insertions(+), 119 deletions(-)
> 
> diff --git a/audio/audio.c b/audio/audio.c
> index e841532..8c2c495 100644
> --- a/audio/audio.c
> +++ b/audio/audio.c
> @@ -1870,7 +1870,7 @@ static void audio_init (void)
>          conf.period.ticks = 1;
>      } else {
>          conf.period.ticks =
> -            muldiv64 (1, get_ticks_per_sec (), conf.period.hertz);
> +            muldiv64 (1, NANOSECONDS_PER_SECOND, conf.period.hertz);

This can be replaced by:

	conf.period.ticks = NANOSECONDS_PER_SECOND / conf.period.hertz;

>      }
>  
>      e = qemu_add_vm_change_state_handler (audio_vm_change_state_handler, s);
...
> diff --git a/hw/usb/hcd-musb.c b/hw/usb/hcd-musb.c
> index cd23197..27d9d0b 100644
> --- a/hw/usb/hcd-musb.c
> +++ b/hw/usb/hcd-musb.c
> @@ -564,7 +564,7 @@ static void musb_schedule_cb(USBPort *port, USBPacket *packey)
>          ep->intv_timer[dir] = timer_new_ns(QEMU_CLOCK_VIRTUAL, musb_cb_tick, ep);
>  
>      timer_mod(ep->intv_timer[dir], qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) +
> -                   muldiv64(timeout, get_ticks_per_sec(), 8000));
> +                   muldiv64(timeout, NANOSECONDS_PER_SECOND, 8000));

Can be replaced by: "timeout * 125000"

(I don't think the value of  NANOSECONDS_PER_SECOND will change in the
future ;) ).

>  }
>  
>  static int musb_timeout(int ttype, int speed, int val)
> diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c
> index 17ed461..a9bf805 100644
> --- a/hw/usb/hcd-ohci.c
> +++ b/hw/usb/hcd-ohci.c
> @@ -1849,12 +1849,12 @@ static void usb_ohci_init(OHCIState *ohci, DeviceState *dev,
>  
>      if (usb_frame_time == 0) {
>  #ifdef OHCI_TIME_WARP
> -        usb_frame_time = get_ticks_per_sec();
> -        usb_bit_time = muldiv64(1, get_ticks_per_sec(), USB_HZ/1000);
> +        usb_frame_time = NANOSECONDS_PER_SECOND;
> +        usb_bit_time = muldiv64(1, NANOSECONDS_PER_SECOND, USB_HZ/1000);

Can be replaced by:

    usb_bit_time = NANOSECONDS_PER_SECOND / (USB_HZ / 1000);

>  #else
> -        usb_frame_time = muldiv64(1, get_ticks_per_sec(), 1000);
> -        if (get_ticks_per_sec() >= USB_HZ) {
> -            usb_bit_time = muldiv64(1, get_ticks_per_sec(), USB_HZ);
> +        usb_frame_time = muldiv64(1, NANOSECONDS_PER_SECOND, 1000);

    usb_frame_time = NANOSECONDS_PER_SECOND / 1000;

> +        if (NANOSECONDS_PER_SECOND >= USB_HZ) {
> +            usb_bit_time = muldiv64(1, NANOSECONDS_PER_SECOND, USB_HZ);

    usb_bit_time = NANOSECONDS_PER_SECOND / USB_HZ;

>          } else {
>              usb_bit_time = 1;
>          }
...

WARNING: multiple messages have this Message-ID (diff)
From: Laurent Vivier <lvivier@redhat.com>
To: rutu.shah.26@gmail.com, qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, kvm@vger.kernel.org, mst@redhat.com,
	jasowang@redhat.com, lcapitulino@redhat.com, kraxel@redhat.com,
	qemu-block@nongnu.org, armbru@redhat.com, borntraeger@de.ibm.com,
	samuel.thibault@ens-lyon.org, alistair.francis@xilinx.com,
	qemu-arm@nongnu.org, stefanha@redhat.com, imammedo@redhat.com,
	cornelia.huck@de.ibm.com, jsnow@redhat.com, rth@twiddle.net,
	kwolf@redhat.com, crosthwaite.peter@gmail.com,
	blauwirbel@gmail.co, qemu-ppc@nongnu.org, pbonzini@redhat.com
Subject: Re: [Qemu-devel] [Qemu-ppc] [PATCH] Replacing (and removing) get_ticks_per_sec() function with NANOSECONDS_PER_SECOND Signed-off-by: Rutuja Shah <rutu.shah.26@gmail.com>
Date: Tue, 15 Mar 2016 11:08:08 +0100	[thread overview]
Message-ID: <56E7DF08.2050400@redhat.com> (raw)
In-Reply-To: <1457638209-14218-1-git-send-email-rutu.shah.26@gmail.com>



On 10/03/2016 20:30, rutu.shah.26@gmail.com wrote:
> From: Rutuja Shah <rutu.shah.26@gmail.com>
> 
> ---
>  audio/audio.c             |  2 +-
>  audio/noaudio.c           |  4 ++--
>  audio/spiceaudio.c        |  2 +-
>  audio/wavaudio.c          |  2 +-
>  backends/baum.c           |  2 +-
>  block/qed.c               |  2 +-
>  cpus.c                    |  6 +++---
>  hw/acpi/core.c            |  4 ++--
>  hw/arm/omap1.c            | 14 +++++++-------
>  hw/arm/spitz.c            |  2 +-
>  hw/arm/stellaris.c        |  2 +-
>  hw/arm/strongarm.c        |  2 +-
>  hw/audio/adlib.c          |  2 +-
>  hw/audio/sb16.c           |  4 ++--
>  hw/block/fdc.c            |  2 +-
>  hw/block/pflash_cfi02.c   |  4 ++--
>  hw/bt/hci-csr.c           |  4 ++--
>  hw/char/cadence_uart.c    |  4 ++--
>  hw/char/serial.c          |  6 +++---
>  hw/display/vga.c          |  6 +++---
>  hw/dma/rc4030.c           |  2 +-
>  hw/ide/core.c             |  2 +-
>  hw/input/hid.c            |  2 +-
>  hw/input/tsc2005.c        |  2 +-
>  hw/input/tsc210x.c        |  2 +-
>  hw/intc/i8259.c           |  2 +-
>  hw/misc/arm_sysctl.c      |  2 +-
>  hw/misc/macio/cuda.c      | 16 ++++++++--------
>  hw/misc/macio/macio.c     |  2 +-
>  hw/net/dp8393x.c          |  2 +-
>  hw/ppc/ppc.c              | 18 +++++++++---------
>  hw/ppc/ppc405_uc.c        |  4 ++--
>  hw/ppc/ppc_booke.c        |  2 +-
>  hw/sd/sdhci-internal.h    |  2 +-
>  hw/sparc64/sun4u.c        |  4 ++--
>  hw/timer/i8254.c          |  4 ++--
>  hw/timer/i8254_common.c   |  6 +++---
>  hw/timer/mc146818rtc.c    |  6 +++---
>  hw/timer/omap_gptimer.c   |  2 +-
>  hw/timer/omap_synctimer.c |  2 +-
>  hw/timer/pl031.c          | 10 +++++-----
>  hw/timer/pxa2xx_timer.c   | 14 +++++++-------
>  hw/usb/hcd-ehci.c         |  4 ++--
>  hw/usb/hcd-musb.c         |  2 +-
>  hw/usb/hcd-ohci.c         | 10 +++++-----
>  hw/usb/hcd-uhci.c         |  6 +++---
>  hw/usb/tusb6010.c         |  4 ++--
>  hw/watchdog/wdt_diag288.c |  2 +-
>  hw/watchdog/wdt_ib700.c   |  2 +-
>  include/hw/acpi/acpi.h    |  2 +-
>  include/qemu/timer.h      |  9 ++-------
>  monitor.c                 |  4 ++--
>  target-ppc/kvm.c          |  4 ++--
>  53 files changed, 114 insertions(+), 119 deletions(-)
> 
> diff --git a/audio/audio.c b/audio/audio.c
> index e841532..8c2c495 100644
> --- a/audio/audio.c
> +++ b/audio/audio.c
> @@ -1870,7 +1870,7 @@ static void audio_init (void)
>          conf.period.ticks = 1;
>      } else {
>          conf.period.ticks =
> -            muldiv64 (1, get_ticks_per_sec (), conf.period.hertz);
> +            muldiv64 (1, NANOSECONDS_PER_SECOND, conf.period.hertz);

This can be replaced by:

	conf.period.ticks = NANOSECONDS_PER_SECOND / conf.period.hertz;

>      }
>  
>      e = qemu_add_vm_change_state_handler (audio_vm_change_state_handler, s);
...
> diff --git a/hw/usb/hcd-musb.c b/hw/usb/hcd-musb.c
> index cd23197..27d9d0b 100644
> --- a/hw/usb/hcd-musb.c
> +++ b/hw/usb/hcd-musb.c
> @@ -564,7 +564,7 @@ static void musb_schedule_cb(USBPort *port, USBPacket *packey)
>          ep->intv_timer[dir] = timer_new_ns(QEMU_CLOCK_VIRTUAL, musb_cb_tick, ep);
>  
>      timer_mod(ep->intv_timer[dir], qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) +
> -                   muldiv64(timeout, get_ticks_per_sec(), 8000));
> +                   muldiv64(timeout, NANOSECONDS_PER_SECOND, 8000));

Can be replaced by: "timeout * 125000"

(I don't think the value of  NANOSECONDS_PER_SECOND will change in the
future ;) ).

>  }
>  
>  static int musb_timeout(int ttype, int speed, int val)
> diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c
> index 17ed461..a9bf805 100644
> --- a/hw/usb/hcd-ohci.c
> +++ b/hw/usb/hcd-ohci.c
> @@ -1849,12 +1849,12 @@ static void usb_ohci_init(OHCIState *ohci, DeviceState *dev,
>  
>      if (usb_frame_time == 0) {
>  #ifdef OHCI_TIME_WARP
> -        usb_frame_time = get_ticks_per_sec();
> -        usb_bit_time = muldiv64(1, get_ticks_per_sec(), USB_HZ/1000);
> +        usb_frame_time = NANOSECONDS_PER_SECOND;
> +        usb_bit_time = muldiv64(1, NANOSECONDS_PER_SECOND, USB_HZ/1000);

Can be replaced by:

    usb_bit_time = NANOSECONDS_PER_SECOND / (USB_HZ / 1000);

>  #else
> -        usb_frame_time = muldiv64(1, get_ticks_per_sec(), 1000);
> -        if (get_ticks_per_sec() >= USB_HZ) {
> -            usb_bit_time = muldiv64(1, get_ticks_per_sec(), USB_HZ);
> +        usb_frame_time = muldiv64(1, NANOSECONDS_PER_SECOND, 1000);

    usb_frame_time = NANOSECONDS_PER_SECOND / 1000;

> +        if (NANOSECONDS_PER_SECOND >= USB_HZ) {
> +            usb_bit_time = muldiv64(1, NANOSECONDS_PER_SECOND, USB_HZ);

    usb_bit_time = NANOSECONDS_PER_SECOND / USB_HZ;

>          } else {
>              usb_bit_time = 1;
>          }
...

  parent reply	other threads:[~2016-03-15 10:08 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-10 19:30 [PATCH] Replacing (and removing) get_ticks_per_sec() function with NANOSECONDS_PER_SECOND Signed-off-by: Rutuja Shah <rutu.shah.26@gmail.com> rutu.shah.26
2016-03-10 19:30 ` [Qemu-devel] " rutu.shah.26
2016-03-10 21:10 ` [Qemu-arm] " Eric Blake
2016-03-10 21:10   ` Eric Blake
2016-03-10 21:10   ` Eric Blake
2016-03-11  6:57   ` rutuja shah
2016-03-11  6:57     ` rutuja shah
2016-03-11  6:57     ` rutuja shah
2016-03-11 11:01 ` Stefan Hajnoczi
2016-03-11 11:01   ` [Qemu-devel] " Stefan Hajnoczi
2016-03-11 11:01   ` Stefan Hajnoczi
2016-03-11 11:44 ` Christian Borntraeger
2016-03-11 11:44   ` [Qemu-devel] " Christian Borntraeger
2016-03-11 11:44   ` Christian Borntraeger
2016-03-11 12:07   ` Paolo Bonzini
2016-03-11 12:07     ` [Qemu-devel] " Paolo Bonzini
2016-03-11 12:12     ` [Qemu-arm] " Christian Borntraeger
2016-03-11 12:12       ` [Qemu-devel] " Christian Borntraeger
2016-03-11 12:12       ` Christian Borntraeger
2016-03-11 12:26       ` Paolo Bonzini
2016-03-11 12:26         ` [Qemu-devel] " Paolo Bonzini
2016-03-11 13:22         ` Christian Borntraeger
2016-03-11 13:22           ` [Qemu-devel] " Christian Borntraeger
2016-03-11 13:22           ` Christian Borntraeger
2016-03-12 16:20 ` [Qemu-arm] " rutuja shah
2016-03-12 16:20   ` [Qemu-devel] " rutuja shah
2016-03-12 16:20   ` rutuja shah
2016-03-15 10:08 ` Laurent Vivier [this message]
2016-03-15 10:08   ` [Qemu-devel] [Qemu-ppc] " Laurent Vivier

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=56E7DF08.2050400@redhat.com \
    --to=lvivier@redhat.com \
    --cc=alistair.francis@xilinx.com \
    --cc=armbru@redhat.com \
    --cc=balrogg@gmail.com \
    --cc=blauwirbel@gmail.co \
    --cc=borntraeger@de.ibm.com \
    --cc=cornelia.huck@de.ibm.com \
    --cc=crosthwaite.peter@gmail.com \
    --cc=imammedo@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=kwolf@redhat.com \
    --cc=lcapitulino@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=rth@twiddle.net \
    --cc=rutu.shah.26@gmail.com \
    --cc=samuel.thibault@ens-lyon.org \
    --cc=stefanha@redhat.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.