diff mbox

libibverbs: add ARM64 memory barrier macros

Message ID 20160520163207.B99DCE0B9D@smtp.ogc.us (mailing list archive)
State Superseded
Headers show

Commit Message

Steve Wise May 18, 2016, 9:16 p.m. UTC
The default generic barriers are not correct for ARM64. This results in
data corruption.  The correct macros are lifted from the linux kernel.

Signed-off-by: Steve Wise <swise@opengridcomputing.com>
---

Changes since RFC:

no change to the patch - just productive discussion about these barrier
implementations.  I propose we proceed to add this patch since it resolves
a data corruption bug.
---
 include/infiniband/arch.h |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

Comments

Woodruff, Robert J May 20, 2016, 4:39 p.m. UTC | #1
>The default generic barriers are not correct for ARM64. This results in data corruption.  The correct macros are lifted from the linux kernel.

Does this mean that the code you want to add to libibverbs will be tainted with GPL since they come from the Linux kernel.
I know that there are a lot of people that will not use a GPL library, since it could taint their applications with GPL if they 
link to that library. I thought that is why LGPL was invented to prevent such tainting. 
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Steve Wise May 20, 2016, 6:37 p.m. UTC | #2
> >The default generic barriers are not correct for ARM64. This results in data
> corruption.  The correct macros are lifted from the linux kernel.
> 
> Does this mean that the code you want to add to libibverbs will be tainted
with GPL
> since they come from the Linux kernel.

I guess so.

> I know that there are a lot of people that will not use a GPL library, since
it could
> taint their applications with GPL if they
> link to that library. I thought that is why LGPL was invented to prevent such
tainting.

I could utilize the code from FreeBSD.  Does that allow me to submit this to
libibverbs under the dual GPL/BSD license?

/*
 * Options for DMB and DSB:
 *      oshld   Outer Shareable, load
 *      oshst   Outer Shareable, store
 *      osh     Outer Shareable, all
 *      nshld   Non-shareable, load
 *      nshst   Non-shareable, store
 *      nsh     Non-shareable, all
 *      ishld   Inner Shareable, load
 *      ishst   Inner Shareable, store
 *      ish     Inner Shareable, all
 *      ld      Full system, load
 *      st      Full system, store
 *      sy      Full system, all
 */
#define dsb(opt)        __asm __volatile("dsb " __STRING(opt) : : : "memory")
#define dmb(opt)        __asm __volatile("dmb " __STRING(opt) : : : "memory")

#define mb()    dmb(sy) /* Full system memory barrier all */
#define wmb()   dmb(st) /* Full system memory barrier store */
#define rmb()   dmb(ld) /* Full system memory barrier load */



--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Steve Wise May 20, 2016, 6:46 p.m. UTC | #3
> > Does this mean that the code you want to add to libibverbs will be tainted
> with GPL
> > since they come from the Linux kernel.
> 
> I guess so.
> 
> > I know that there are a lot of people that will not use a GPL library, since
> it could
> > taint their applications with GPL if they
> > link to that library. I thought that is why LGPL was invented to prevent
such
> tainting.
> 
> I could utilize the code from FreeBSD.  Does that allow me to submit this to
> libibverbs under the dual GPL/BSD license?
> 

I think I can just re-implement these services myself based published works
describing the memory barrier assembly for ARM (like the document Jason
referenced earlier).  That will avoid any tainting.

Doug: Will that work?





--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Doug Ledford May 20, 2016, 8:17 p.m. UTC | #4
On 05/20/2016 02:46 PM, Steve Wise wrote:
>>> Does this mean that the code you want to add to libibverbs will be tainted
>> with GPL
>>> since they come from the Linux kernel.
>>
>> I guess so.
>>
>>> I know that there are a lot of people that will not use a GPL library, since
>> it could
>>> taint their applications with GPL if they
>>> link to that library. I thought that is why LGPL was invented to prevent
> such
>> tainting.
>>
>> I could utilize the code from FreeBSD.  Does that allow me to submit this to
>> libibverbs under the dual GPL/BSD license?
>>
> 
> I think I can just re-implement these services myself based published works
> describing the memory barrier assembly for ARM (like the document Jason
> referenced earlier).  That will avoid any tainting.
> 
> Doug: Will that work?

Either way works actually.  IANAL, but I've been told this multiple
times and will relay my possibly flawed memory of the legal issue.  The
original patch, even though lifted from the linux kernel, is likely to
fall under the scope of "operationally defined" code.  In other words,
the specific patch you wrote and the thing it implemented is so rigidly
defined by what it does, that there really is little to no room for any
different expression of the code.  When there is no room for different
expressions, the code is not copyrightable.
Steve Wise May 20, 2016, 8:20 p.m. UTC | #5
> >> I could utilize the code from FreeBSD.  Does that allow me to submit this
to
> >> libibverbs under the dual GPL/BSD license?
> >>
> >
> > I think I can just re-implement these services myself based published works
> > describing the memory barrier assembly for ARM (like the document Jason
> > referenced earlier).  That will avoid any tainting.
> >
> > Doug: Will that work?
> 
> Either way works actually.  IANAL, but I've been told this multiple
> times and will relay my possibly flawed memory of the legal issue.  The
> original patch, even though lifted from the linux kernel, is likely to
> fall under the scope of "operationally defined" code.  In other words,
> the specific patch you wrote and the thing it implemented is so rigidly
> defined by what it does, that there really is little to no room for any
> different expression of the code.  When there is no room for different
> expressions, the code is not copyrightable.
> 

That makes too much sense... ;)


--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/include/infiniband/arch.h b/include/infiniband/arch.h
index bc1738a..71f02f8 100644
--- a/include/infiniband/arch.h
+++ b/include/infiniband/arch.h
@@ -122,6 +122,15 @@  static inline uint64_t ntohll(uint64_t x) { return x; }
 #define wmb()	mb()					/* for s390x */
 #define wc_wmb() wmb()					/* for s390x */
 
+#elif defined(__aarch64__)
+
+#define dsb(opt)	asm volatile("dsb " #opt : : : "memory")
+
+#define mb()	dsb(sy)
+#define rmb()	dsb(ld)
+#define wmb()	dsb(st)
+#define wc_wmb() wmb()
+
 #else
 
 #warning No architecture specific defines found.  Using generic implementation.