From owner-freebsd-xen@FreeBSD.ORG Tue Jan 14 15:30:36 2014 Return-Path: Delivered-To: freebsd-xen@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 38A2044B for ; Tue, 14 Jan 2014 15:30:36 +0000 (UTC) Received: from mail-ve0-f169.google.com (mail-ve0-f169.google.com [209.85.128.169]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id E8F9A1147 for ; Tue, 14 Jan 2014 15:30:35 +0000 (UTC) Received: by mail-ve0-f169.google.com with SMTP id oz11so1306400veb.28 for ; Tue, 14 Jan 2014 07:30:29 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=Dkffv3Bdg/bcXtmbh00LB6dpAG6Zssbgh76zRz3crPU=; b=CNCtWUbLBpdlpCHnci6kmumHM93BpRtPqJtGHdmB7n8FJJX+ktbEfIFCtkG+OI6c0Q 7byF9O6PNifsDRk6d8uNSyz80OwdWzceQvIbMd9dGif7X676F3aEoxiprQcCrO6N10Ia dfsuY79mtj/bkD8vN/J6IFl43vfSQutyDmLpkDmAmsXWBklsfwmwogJjO2DF+hNIwxG5 bWSpsbYW8r2TztNyr5C+RrRRdsGhcLIrrKl5OSNP6RD8CX7PrhQ2mqmiC6BDQOksfYvR OXbeVAFmQIkUgSRpOQp4iBsCUZg2jNzGZfTsRA/0gqjDRA+8LVoWDcT2GrtmOxRM6Y1Y ASjw== X-Gm-Message-State: ALoCoQmCLa0VofZ1q6nuZf6KsfGy6CkuPrWjQ9G4M8cUdZXzxO3MEAtwJ7nCuUsGrqFI5b3J/5lv MIME-Version: 1.0 X-Received: by 10.221.37.1 with SMTP id tc1mr1052759vcb.32.1389713428998; Tue, 14 Jan 2014 07:30:28 -0800 (PST) Received: by 10.58.132.205 with HTTP; Tue, 14 Jan 2014 07:30:28 -0800 (PST) In-Reply-To: <1389711582-66908-6-git-send-email-roger.pau@citrix.com> References: <1389711582-66908-1-git-send-email-roger.pau@citrix.com> <1389711582-66908-6-git-send-email-roger.pau@citrix.com> Date: Tue, 14 Jan 2014 08:30:28 -0700 Message-ID: Subject: Re: [PATCH v10 05/20] xen: rework xen timer so it can be used early in boot process From: Will Andrews To: Roger Pau Monne Content-Type: text/plain; charset=UTF-8 Cc: freebsd-xen@freebsd.org X-BeenThere: freebsd-xen@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: Discussion of the freebsd port to xen - implementation and usage List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 14 Jan 2014 15:30:36 -0000 Looks good to me. It appears to go with your PATCH v10 06/20, and your commit log should note the dependency directly. Thanks! --Will. On Tue, Jan 14, 2014 at 7:59 AM, Roger Pau Monne wrote: > This should not introduce any functional change, and makes the > functions suitable to be called before we have actually mapped the > vcpu_info struct on a per-cpu basis. > --- > sys/dev/xen/timer/timer.c | 29 ++++++++++++++++++++--------- > 1 files changed, 20 insertions(+), 9 deletions(-) > > diff --git a/sys/dev/xen/timer/timer.c b/sys/dev/xen/timer/timer.c > index 354085b..b2f6bcd 100644 > --- a/sys/dev/xen/timer/timer.c > +++ b/sys/dev/xen/timer/timer.c > @@ -230,22 +230,22 @@ xen_fetch_vcpu_tinfo(struct vcpu_time_info *dst, struct vcpu_time_info *src) > /** > * \brief Get the current time, in nanoseconds, since the hypervisor booted. > * > + * \param vcpu vcpu_info structure to fetch the time from. > + * > * \note This function returns the current CPU's idea of this value, unless > * it happens to be less than another CPU's previously determined value. > */ > static uint64_t > -xen_fetch_vcpu_time(void) > +xen_fetch_vcpu_time(struct vcpu_info *vcpu) > { > struct vcpu_time_info dst; > struct vcpu_time_info *src; > uint32_t pre_version; > uint64_t now; > volatile uint64_t last; > - struct vcpu_info *vcpu = DPCPU_GET(vcpu_info); > > src = &vcpu->time; > > - critical_enter(); > do { > pre_version = xen_fetch_vcpu_tinfo(&dst, src); > barrier(); > @@ -266,16 +266,19 @@ xen_fetch_vcpu_time(void) > } > } while (!atomic_cmpset_64(&xen_timer_last_time, last, now)); > > - critical_exit(); > - > return (now); > } > > static uint32_t > xentimer_get_timecount(struct timecounter *tc) > { > + uint32_t xen_time; > > - return ((uint32_t)xen_fetch_vcpu_time() & UINT_MAX); > + critical_enter(); > + xen_time = (uint32_t)xen_fetch_vcpu_time(DPCPU_GET(vcpu_info)) & UINT_MAX; > + critical_exit(); > + > + return (xen_time); > } > > /** > @@ -305,7 +308,12 @@ xen_fetch_wallclock(struct timespec *ts) > static void > xen_fetch_uptime(struct timespec *ts) > { > - uint64_t uptime = xen_fetch_vcpu_time(); > + uint64_t uptime; > + > + critical_enter(); > + uptime = xen_fetch_vcpu_time(DPCPU_GET(vcpu_info)); > + critical_exit(); > + > ts->tv_sec = uptime / NSEC_IN_SEC; > ts->tv_nsec = uptime % NSEC_IN_SEC; > } > @@ -354,7 +362,7 @@ xentimer_intr(void *arg) > struct xentimer_softc *sc = (struct xentimer_softc *)arg; > struct xentimer_pcpu_data *pcpu = DPCPU_PTR(xentimer_pcpu); > > - pcpu->last_processed = xen_fetch_vcpu_time(); > + pcpu->last_processed = xen_fetch_vcpu_time(DPCPU_GET(vcpu_info)); > if (pcpu->timer != 0 && sc->et.et_active) > sc->et.et_event_cb(&sc->et, sc->et.et_arg); > > @@ -415,7 +423,10 @@ xentimer_et_start(struct eventtimer *et, > do { > if (++i == 60) > panic("can't schedule timer"); > - next_time = xen_fetch_vcpu_time() + first_in_ns; > + critical_enter(); > + next_time = xen_fetch_vcpu_time(DPCPU_GET(vcpu_info)) + > + first_in_ns; > + critical_exit(); > error = xentimer_vcpu_start_timer(cpu, next_time); > } while (error == -ETIME); > > -- > 1.7.7.5 (Apple Git-26) > > _______________________________________________ > freebsd-current@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-current > To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org"