File tree Expand file tree Collapse file tree 1 file changed +35
-3
lines changed Expand file tree Collapse file tree 1 file changed +35
-3
lines changed Original file line number Diff line number Diff line change @@ -365,16 +365,48 @@ static __always_inline void __cmpwait(volatile void *ptr,
365
365
{
366
366
unsigned long tmp ;
367
367
368
+ u32 * __ptr32b ;
369
+ ulong __s , __val , __mask ;
370
+
368
371
asm goto(ALTERNATIVE ("j %l[no_zawrs]" , "nop" ,
369
372
0 , RISCV_ISA_EXT_ZAWRS , 1 )
370
373
: : : : no_zawrs );
371
374
372
375
switch (size ) {
373
376
case 1 :
374
- fallthrough ;
377
+ __ptr32b = (u32 * )((ulong )(ptr ) & ~0x3 );
378
+ __s = ((ulong )(ptr ) & 0x3 ) * BITS_PER_BYTE ;
379
+ __val = val << __s ;
380
+ __mask = 0xff << __s ;
381
+
382
+ asm volatile (
383
+ " lr.w %0, %1\n"
384
+ " and %0, %0, %3\n"
385
+ " xor %0, %0, %2\n"
386
+ " bnez %0, 1f\n"
387
+ ZAWRS_WRS_NTO "\n"
388
+ "1:"
389
+ : "=&r" (tmp ), "+A" (* (__ptr32b ))
390
+ : "r" (__val ), "r" (__mask )
391
+ : "memory" );
392
+ break ;
375
393
case 2 :
376
- /* RISC-V doesn't have lr instructions on byte and half-word. */
377
- goto no_zawrs ;
394
+ __ptr32b = (u32 * )((ulong )(ptr ) & ~0x3 );
395
+ __s = ((ulong )(ptr ) & 0x2 ) * BITS_PER_BYTE ;
396
+ __val = val << __s ;
397
+ __mask = 0xffff << __s ;
398
+
399
+ asm volatile (
400
+ " lr.w %0, %1\n"
401
+ " and %0, %0, %3\n"
402
+ " xor %0, %0, %2\n"
403
+ " bnez %0, 1f\n"
404
+ ZAWRS_WRS_NTO "\n"
405
+ "1:"
406
+ : "=&r" (tmp ), "+A" (* (__ptr32b ))
407
+ : "r" (__val ), "r" (__mask )
408
+ : "memory" );
409
+ break ;
378
410
case 4 :
379
411
asm volatile (
380
412
" lr.w %0, %1\n"
You can’t perform that action at this time.
0 commit comments