Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 31 May 2012 17:07:42 -0600
From:      Zbigniew Bodek <zbb@semihalf.com>
To:        Marcel Moolenaar <marcel@xcllnt.net>
Cc:        powerpc@freebsd.org, =?UTF-8?Q?Piotr_Zi=C4=99cik?= <kosmo@semihalf.com>
Subject:   Re: RFC: OpenPIC IPI patch
Message-ID:  <fcdca283083e354eb4d9733a572a1041@smtp.semihalf.com>
In-Reply-To: <251AF144-587C-4854-88B2-0CD7D26E1DF1@xcllnt.net>
References:  <0362C399-CB54-451E-A879-E836EF13CE72@semihalf.com> <251AF144-587C-4854-88B2-0CD7D26E1DF1@xcllnt.net>

next in thread | previous in thread | raw e-mail | index | archive | help
--=_3b7ad5037c6a1e9c6e236a745119b2c2
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset="UTF-8"

On Wed, 30 May 2012 13:36:46 -0700, Marcel Moolenaar <marcel@xcllnt.net>
wrote:
> On May 30, 2012, at 1:13 PM, Rafal Jaworowski wrote:
> 
>> Can you please have a look at this patch and let us know about any
>> comments / objections? We identified a problem with IPI on the recent
FSL
>> eOpenPIC, description in the patch:
>> 
>> http://people.freebsd.org/~raj/patches/powerpc/openpic.diff
> 
> Looks good. Please consider adding some checks to openpic_ipi() where
> we peek into the cpuset_t type and access the "bits". An assert would
> be nice if the set contains cpus number 32 or up. This to make it
> painfully obvious that it's time to extend openpic_ipi() to handle more
> than 32 CPUs if and when the need arises.
> 
> FYI,

Indeed, there should be a sanity check in here.
I suggest the following assert:

diff --git a/sys/powerpc/powerpc/openpic.c b/sys/powerpc/powerpc/openpic.c
index 95af605..45858b6 100644
--- a/sys/powerpc/powerpc/openpic.c
+++ b/sys/powerpc/powerpc/openpic.c
@@ -29,6 +29,7 @@
#include <sys/systm.h>
#include <sys/bus.h>
#include <sys/conf.h>
+#include <sys/cpuset.h>
#include <sys/kernel.h>
#include <sys/proc.h>
#include <sys/rman.h>
@@ -344,8 +345,14 @@ void
openpic_ipi(device_t dev, cpuset_t cpumask)
{
	struct openpic_softc *sc;
+	cpuset_t ns_cpus;	/* Mask of not supported CPUs */
+
+	CPU_FILL(&ns_cpus);
+	ns_cpus.__bits[0] = 0;

	KASSERT(dev == root_pic, ("Cannot send IPIs from non-root OpenPIC"));
+	KASSERT(CPU_OVERLAP(&ns_cpus,  &cpumask) == 0,
+	    ("Cannot send an IPI to a CPU which number exceeds #31"));

	sc = device_get_softc(dev);
	sched_pin();

The patch is also available in the email's attachment.
Please send any comments and/or objections.

Best regards
Zbyszek Bodek

--=_3b7ad5037c6a1e9c6e236a745119b2c2
Content-Transfer-Encoding: base64
Content-Type: text/x-patch; charset="UTF-8";
 name="ipi_assert.patch"; 
Content-Disposition: attachment;
 filename="ipi_assert.patch"; 

ZGlmZiAtLWdpdCBhL3N5cy9wb3dlcnBjL3Bvd2VycGMvb3BlbnBpYy5jIGIvc3lzL3Bvd2VycGMv
cG93ZXJwYy9vcGVucGljLmMKaW5kZXggOTVhZjYwNS4uNDU4NThiNiAxMDA2NDQKLS0tIGEvc3lz
L3Bvd2VycGMvcG93ZXJwYy9vcGVucGljLmMKKysrIGIvc3lzL3Bvd2VycGMvcG93ZXJwYy9vcGVu
cGljLmMKQEAgLTI5LDYgKzI5LDcgQEAKICNpbmNsdWRlIDxzeXMvc3lzdG0uaD4KICNpbmNsdWRl
IDxzeXMvYnVzLmg+CiAjaW5jbHVkZSA8c3lzL2NvbmYuaD4KKyNpbmNsdWRlIDxzeXMvY3B1c2V0
Lmg+CiAjaW5jbHVkZSA8c3lzL2tlcm5lbC5oPgogI2luY2x1ZGUgPHN5cy9wcm9jLmg+CiAjaW5j
bHVkZSA8c3lzL3JtYW4uaD4KQEAgLTM0NCw4ICszNDUsMTQgQEAgdm9pZAogb3BlbnBpY19pcGko
ZGV2aWNlX3QgZGV2LCBjcHVzZXRfdCBjcHVtYXNrKQogewogCXN0cnVjdCBvcGVucGljX3NvZnRj
ICpzYzsKKwljcHVzZXRfdCBuc19jcHVzOwkvKiBNYXNrIG9mIG5vdCBzdXBwb3J0ZWQgQ1BVcyAq
LworCisJQ1BVX0ZJTEwoJm5zX2NwdXMpOworCW5zX2NwdXMuX19iaXRzWzBdID0gMDsKIAogCUtB
U1NFUlQoZGV2ID09IHJvb3RfcGljLCAoIkNhbm5vdCBzZW5kIElQSXMgZnJvbSBub24tcm9vdCBP
cGVuUElDIikpOworCUtBU1NFUlQoQ1BVX09WRVJMQVAoJm5zX2NwdXMsICAmY3B1bWFzaykgPT0g
MCwKKwkgICAgKCJDYW5ub3Qgc2VuZCBhbiBJUEkgdG8gYSBDUFUgd2hpY2ggbnVtYmVyIGV4Y2Vl
ZHMgIzMxIikpOwogCiAJc2MgPSBkZXZpY2VfZ2V0X3NvZnRjKGRldik7CiAJc2NoZWRfcGluKCk7
Cg==
--=_3b7ad5037c6a1e9c6e236a745119b2c2--




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?fcdca283083e354eb4d9733a572a1041>