From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6C83EC4338F for ; Tue, 10 Aug 2021 04:36:07 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BF71C6023B for ; Tue, 10 Aug 2021 04:36:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org BF71C6023B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=gibson.dropbear.id.au Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=nongnu.org Received: from localhost ([::1]:53374 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mDJUj-00038P-N8 for qemu-devel@archiver.kernel.org; Tue, 10 Aug 2021 00:36:05 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:52974) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mDJDx-0008PZ-Ng; Tue, 10 Aug 2021 00:18:45 -0400 Received: from bilbo.ozlabs.org ([2401:3900:2:1::2]:51079 helo=ozlabs.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mDJDv-0002V7-Fr; Tue, 10 Aug 2021 00:18:45 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 4GkKST3SLbz9tD5; Tue, 10 Aug 2021 14:18:17 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gibson.dropbear.id.au; s=201602; t=1628569097; bh=3sCV0/Y+Py0MdUnGy3t5OyBHOjuM8AbJAudnz9yUv70=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ovpaF+PvRrBqj6fazbi1l1W7BAftu8eIM5Sf6sT+VY/AY8q/XM5gISl3VYlH4UUvD dDTxHpC3II7ou9K4Y6Eo/msSjey9m/iTe1dQ1iTmu1Q2QC2OD9Ud/qsmoDW1FAEbG+ 1ZBeNjxdHNMpzWzmGBpYTI3ub3UJIcIiq4ktdCjM= Date: Tue, 10 Aug 2021 14:09:07 +1000 From: David Gibson To: Daniel Henrique Barboza Subject: Re: [PATCH 14/19] target/ppc/pmu_book3s_helper.c: add generic timeout helpers Message-ID: References: <20210809131057.1694145-1-danielhb413@gmail.com> <20210809131057.1694145-15-danielhb413@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="k1tvgk9oMICkl7vX" Content-Disposition: inline In-Reply-To: <20210809131057.1694145-15-danielhb413@gmail.com> Received-SPF: pass client-ip=2401:3900:2:1::2; envelope-from=dgibson@ozlabs.org; helo=ozlabs.org X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.248, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: gustavo.romero@linaro.org, clg@kaod.org, qemu-ppc@nongnu.org, qemu-devel@nongnu.org, groug@kaod.org Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" --k1tvgk9oMICkl7vX Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Aug 09, 2021 at 10:10:52AM -0300, Daniel Henrique Barboza wrote: > Before adding counter negative condition support for the other 5 > counters, create generic helpers that retrieves the elapsed timeout to > counter negative based on the event being sampled. >=20 > Signed-off-by: Daniel Henrique Barboza > --- > target/ppc/pmu_book3s_helper.c | 41 +++++++++++++++++++++++++++++----- > 1 file changed, 35 insertions(+), 6 deletions(-) >=20 > diff --git a/target/ppc/pmu_book3s_helper.c b/target/ppc/pmu_book3s_helpe= r.c > index e7af273cb6..7126e9b3d5 100644 > --- a/target/ppc/pmu_book3s_helper.c > +++ b/target/ppc/pmu_book3s_helper.c > @@ -111,23 +111,52 @@ static void update_PMCs(CPUPPCState *env, uint64_t = icount_delta) > update_PMC_PM_CYC(env, SPR_POWER_PMC6, icount_delta); > } > =20 > +static int64_t get_INST_CMPL_timeout(CPUPPCState *env, int sprn) > +{ > + int64_t remaining_insns; > + > + if (env->spr[sprn] =3D=3D 0) { Why do you need to special case the PMC being 0? > + return icount_to_ns(COUNTER_NEGATIVE_VAL); > + } > + > + if (env->spr[sprn] >=3D COUNTER_NEGATIVE_VAL) { > + return 0; > + } > + > + remaining_insns =3D COUNTER_NEGATIVE_VAL - env->spr[sprn]; > + return icount_to_ns(remaining_insns); > +} > + > +static int64_t get_CYC_timeout(CPUPPCState *env, int sprn) > +{ > + int64_t remaining_cyc; > + > + if (env->spr[sprn] =3D=3D 0) { > + return icount_to_ns(COUNTER_NEGATIVE_VAL); Why is icount involved in the CYC timeout logic? AFAICT it wasn't before this change. > + } > + > + if (env->spr[sprn] >=3D COUNTER_NEGATIVE_VAL) { > + return 0; > + } > + > + remaining_cyc =3D COUNTER_NEGATIVE_VAL - env->spr[sprn]; > + return muldiv64(remaining_cyc, NANOSECONDS_PER_SECOND, PPC_CPU_FREQ); > +} > + > static void set_PMU_excp_timer(CPUPPCState *env) > { > - uint64_t timeout, now, remaining_val; > + uint64_t timeout, now; > =20 > if (!(env->spr[SPR_POWER_MMCR0] & MMCR0_PMC1CE)) { > return; > } > =20 > - remaining_val =3D COUNTER_NEGATIVE_VAL - env->spr[SPR_POWER_PMC1]; > - > switch (get_PMC_event(env, SPR_POWER_PMC1)) { > case 0x2: > - timeout =3D icount_to_ns(remaining_val); > + timeout =3D get_INST_CMPL_timeout(env, SPR_POWER_PMC1); > break; > case 0x1e: > - timeout =3D muldiv64(remaining_val, NANOSECONDS_PER_SECOND, > - PPC_CPU_FREQ); > + timeout =3D get_CYC_timeout(env, SPR_POWER_PMC1); > break; > default: > return; --=20 David Gibson | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_ | _way_ _around_! http://www.ozlabs.org/~dgibson --k1tvgk9oMICkl7vX Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEdfRlhq5hpmzETofcbDjKyiDZs5IFAmER++MACgkQbDjKyiDZ s5KhSQ//fwITcaoSZbhxWOMXOuF7XInXu/uECd4YI81vx0qyYflxUj6MAVgofN6c iVcFwWmUYlQeoh30txaPanx6uJJ1PgLmKiFeaRtNy5LBCmU2RIgGqT/eH/VG7INU 49GzL1SuPY5rlGrQGTKKwm/NX/k/Y/liaAn94HwbI4CV1GwzcbZ9iuwcSecfpW9U o+4sxhoguZkMV35AYsUfsXk9Y3HJaMTrBaPWOm2N/mh85imrsA8JVSg+bC1R0ZF7 DbDMy2RmtHgWzOQqhImObLn3cpZ459NvvBQlXCPphco8HNe/PJ4e4fcT5vyRxyVm Nd8Ma6UZPbUpA3Dc2kqWk6Zkycir6byzzwKdAjemeIV0Npq8cCMmjAyZCWVPbjZ2 RJ+BF4LDstCppf+oMMQ6C7bw5VIWLQiZpuBjsO3tlyP4tASMJtnvEmVSLubmNbGI 0R0DmtEW9bhH3RgdbzYuu5Nr45nz4dr3EedbGZSPs838uaYVyQTepiuDbWGU1aDw aj1QsW/U6TpJfyFFKQw2BkfKnpzs8CjFiQ08sUvPIx1DBSQICJw78OC2fUj8Mm5B T1iLv3KQwvWjN8qvPWVasNJxrmpZ9X7eprdyKxjxi6U+GSJcunnFpD06NNUdpxUE KaxHSMSfKIUKAi0liou8KWHDIwyWZCbECBLfWcSW3nJxocX0qF8= =LwXd -----END PGP SIGNATURE----- --k1tvgk9oMICkl7vX--