From: Jesse Barnes <jbarnes@virtuousgeek.org> To: Andy Isaacson <adi@hexapodia.org> Cc: Andrew Morton <akpm@linux-foundation.org>, linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org, Matthew Garrett <mjg59@srcf.ucam.org> Subject: Re: [PATCH 2/2] x86 platform driver: intelligent power sharing driver Date: Sat, 15 May 2010 09:29:08 -0700 [thread overview] Message-ID: <20100515092908.02cc71ba@blake> (raw) In-Reply-To: <20100515085456.GB7125@hexapodia.org> On Sat, 15 May 2010 01:54:56 -0700 Andy Isaacson <adi@hexapodia.org> wrote: > On Mon, May 10, 2010 at 10:00:46PM -0400, Andrew Morton wrote: > > > + int i; > > > + u16 avg; > > > + > > > + for (i = 0; i < IPS_SAMPLE_COUNT; i++) > > > + total += (u64)(array[i] * 100); > > > > Actually, that does work. Somehow the compiler will promote > > array[i] to u64 _before_ doing the multiplication. I think. > > Still, it looks like a deliberate attempt to trick the compiler > > into doing a multiplicative overflow ;) > > It seems to promote to int, probably due to the implicit type of > "100". Aind since array is u16, * 100 can't overflow int. So yes, > it's safe, but it does catch the eye as potentially unsafe. Newest version uses do_div, I think I got it right there. > > > > + cur_seqno = (thm_readl(THM_ITV) & > > > ITV_ME_SEQNO_MASK) >> > > > + ITV_ME_SEQNO_SHIFT; > > > + if (cur_seqno == last_seqno && > > > + time_after(jiffies, seqno_timestamp + HZ)) { > > > + dev_warn(&ips->dev->dev, "ME failed to > > > update for more than 1s, likely hung\n"); > > > + } else { > > > + seqno_timestamp = get_jiffies_64(); > > > + last_seqno = cur_seqno; > > > + } > > > + > > > + last_msecs = jiffies_to_msecs(jiffies); > > Once it triggers, this will print the "likely hung" message every > second until the end of time, won't it? The ME should eventually reset itself, but in the interim we can't trust its data. So I should add some better handling for that case (e.g. disable turbo); however this was more of a debug feature for early MEs, I don't think it'll happen on production hardware. Jesse
WARNING: multiple messages have this Message-ID (diff)
From: Jesse Barnes <jbarnes@virtuousgeek.org> To: Andy Isaacson <adi@hexapodia.org> Cc: Andrew Morton <akpm@linux-foundation.org>, intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] x86 platform driver: intelligent power sharing driver Date: Sat, 15 May 2010 09:29:08 -0700 [thread overview] Message-ID: <20100515092908.02cc71ba@blake> (raw) In-Reply-To: <20100515085456.GB7125@hexapodia.org> On Sat, 15 May 2010 01:54:56 -0700 Andy Isaacson <adi@hexapodia.org> wrote: > On Mon, May 10, 2010 at 10:00:46PM -0400, Andrew Morton wrote: > > > + int i; > > > + u16 avg; > > > + > > > + for (i = 0; i < IPS_SAMPLE_COUNT; i++) > > > + total += (u64)(array[i] * 100); > > > > Actually, that does work. Somehow the compiler will promote > > array[i] to u64 _before_ doing the multiplication. I think. > > Still, it looks like a deliberate attempt to trick the compiler > > into doing a multiplicative overflow ;) > > It seems to promote to int, probably due to the implicit type of > "100". Aind since array is u16, * 100 can't overflow int. So yes, > it's safe, but it does catch the eye as potentially unsafe. Newest version uses do_div, I think I got it right there. > > > > + cur_seqno = (thm_readl(THM_ITV) & > > > ITV_ME_SEQNO_MASK) >> > > > + ITV_ME_SEQNO_SHIFT; > > > + if (cur_seqno == last_seqno && > > > + time_after(jiffies, seqno_timestamp + HZ)) { > > > + dev_warn(&ips->dev->dev, "ME failed to > > > update for more than 1s, likely hung\n"); > > > + } else { > > > + seqno_timestamp = get_jiffies_64(); > > > + last_seqno = cur_seqno; > > > + } > > > + > > > + last_msecs = jiffies_to_msecs(jiffies); > > Once it triggers, this will print the "likely hung" message every > second until the end of time, won't it? The ME should eventually reset itself, but in the interim we can't trust its data. So I should add some better handling for that case (e.g. disable turbo); however this was more of a debug feature for early MEs, I don't think it'll happen on production hardware. Jesse
next prev parent reply other threads:[~2010-05-15 16:29 UTC|newest] Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top 2010-05-10 21:25 Intelligent power sharing driver Jesse Barnes 2010-05-10 21:26 ` [PATCH 1/2] timer: add on-stack deferrable timer interfaces Jesse Barnes 2010-05-10 21:26 ` [PATCH 2/2] x86 platform driver: intelligent power sharing driver Jesse Barnes 2010-05-11 2:00 ` Andrew Morton 2010-05-11 2:00 ` Andrew Morton 2010-05-11 14:59 ` Jesse Barnes 2010-05-11 18:18 ` Jesse Barnes 2010-05-11 18:18 ` Jesse Barnes 2010-05-11 15:38 ` Andrew Morton 2010-05-11 15:38 ` Andrew Morton 2010-05-11 18:59 ` Jesse Barnes 2010-05-14 22:41 ` Jesse Barnes 2010-05-15 8:54 ` Andy Isaacson 2010-05-15 16:29 ` Jesse Barnes [this message] 2010-05-15 16:29 ` Jesse Barnes -- strict thread matches above, loose matches on Subject: below -- 2010-03-26 23:29 [RFC] Intelligent " Jesse Barnes 2010-03-26 23:29 ` [PATCH 2/2] x86 platform driver: intelligent " Jesse Barnes 2010-04-13 19:24 ` Pavel Machek 2010-04-13 19:40 ` Jesse Barnes 2010-04-13 19:40 ` Jesse Barnes
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=20100515092908.02cc71ba@blake \ --to=jbarnes@virtuousgeek.org \ --cc=adi@hexapodia.org \ --cc=akpm@linux-foundation.org \ --cc=intel-gfx@lists.freedesktop.org \ --cc=linux-kernel@vger.kernel.org \ --cc=mjg59@srcf.ucam.org \ /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: linkBe 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.