Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp322210pxa; Wed, 19 Aug 2020 02:12:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwJr8knmjqFg2HZVr1sqWLevEhMbYkaeWE0hwYDY81u7l8zPln9mAFILeNz1w2IQZkouQtG X-Received: by 2002:a05:6402:a59:: with SMTP id bt25mr24173622edb.71.1597828363952; Wed, 19 Aug 2020 02:12:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597828363; cv=none; d=google.com; s=arc-20160816; b=p/TpDZtnTmScmqbkbYew1DrQapKfPSvaFqCF62L5iCRHJ8FU/Px3M76WmNL0To8tPt 1/rWUlvsueLltXUe+Ha4F5w/eFYmHJwUSFjEnRTGki4Po7B/kw2nxjBYRPgVw5YNW6X2 32BDkgWsZLdxbUsPkiJ7/a/JBIwkEt/+ff6mCsAUhF/0LXtVkUck2FQ1yGVbeLDbFecn SC39dwk4FxhiOoX9bSoD0auh5U7+xvTHYBmYPP3RIyc10L8LG5noRaM8whcIU/WCdqZE byTtA1Rik01K8KpBASEMnPtDk/Q5UhQU7vGa+3WwWrtvJrxXTNOLCu2t1xJ7l/aFa0jE UcVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=FVTm4vOQa6whaO6/eSa1Eurslvl1A1eOKwJkxD7vXBA=; b=BIpTAeghchRL8iz/Q94voTmb6Yat1nHQhPMJUCm1vvpH1hpRtGBkHTKarrFqGkAMhj geRe0wsYnU8w7zpxxnJocBayhD65ida4L35XnU2CdbAbjTYQ5tkirFnuBXyYlquYr9J9 1yCQ1qk/bCbihnoCT63D6O45GmgPqSV+RuL/dfXDhzAaK1VIZ6nL7M7XnB39Qzhs+PlI BZjmjzUUYYck1XGZLf84pwKmI7Pi5Cz0tkwLUa35Y25edyxPPW1wz5KS9lmWXLQ63TOW P7sVDsqBx+UL5svvGJUbbmINqo6LvZuubZonrShE+KwA6JhNR2HPLIu3pqoyryGA+fXA i/bw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q18si15289260ejz.135.2020.08.19.02.12.20; Wed, 19 Aug 2020 02:12:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726919AbgHSJKA (ORCPT + 99 others); Wed, 19 Aug 2020 05:10:00 -0400 Received: from mail-oi1-f196.google.com ([209.85.167.196]:37021 "EHLO mail-oi1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726110AbgHSJJ7 (ORCPT ); Wed, 19 Aug 2020 05:09:59 -0400 Received: by mail-oi1-f196.google.com with SMTP id e6so20419563oii.4; Wed, 19 Aug 2020 02:09:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=FVTm4vOQa6whaO6/eSa1Eurslvl1A1eOKwJkxD7vXBA=; b=bbOe2pfhAYKaIEx1TZ5StoSvQNy1SJL9xlBYmHXMYE1n8+VbdVy0CaEepnhY9CthV4 bc/3rEMYRT0IYtKhaFG/nUcpqX2DGPbYGiTdHVWtcIYzjzbMSKrPHDOvC1xPv5+RR3FD 0H3jxyYh9IXOgRkil3+8VZAHlBy2/i5hS0dH2w909ukU270oj/ufuM+a5MEymgBXhL+J m/hWTgy671BpRi/g9fzyrYefmWrM8PV1ns9dpKA9UKT6gjXMSVQaVvxDKx67LaRz7g+t jYugkALnwDkhHgQ6Ld/YkUc0Y5204x4iGrVTco0JK0aO2h5HUBVsUOco8duKubgvcPU9 vjHA== X-Gm-Message-State: AOAM533kgYZZOD9XPeRK79uaw/xd7miqSJlMC+7QzJzIQfGjB1IRDNZW 5aBTdQXGv/eacKOznRRpvtpuxgHbnT9hPNiiALU= X-Received: by 2002:aca:4b54:: with SMTP id y81mr2633865oia.54.1597828198046; Wed, 19 Aug 2020 02:09:58 -0700 (PDT) MIME-Version: 1.0 References: <20200819030511.1114-1-liambeguin@gmail.com> In-Reply-To: <20200819030511.1114-1-liambeguin@gmail.com> From: Geert Uytterhoeven Date: Wed, 19 Aug 2020 11:09:46 +0200 Message-ID: Subject: Re: [PATCH 1/1] sh: add support for cmpxchg on u8 and u16 pointers To: Liam Beguin Cc: Yoshinori Sato , Rich Felker , Linux-sh list , Linux Kernel Mailing List , kernel test robot Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Liam, On Wed, Aug 19, 2020 at 5:07 AM Liam Beguin wrote: > The kernel test bot reported[1] that using set_mask_bits on a u8 causes > the following issue on SuperH: > > >> ERROR: modpost: "__cmpxchg_called_with_bad_pointer" [drivers/phy/ti/phy-tusb1210.ko] undefined! > > Add support for cmpxchg on u8 and u16 pointers. > > [1] https://lore.kernel.org/patchwork/patch/1288894/#1485536 > > Reported-by: kernel test robot > Signed-off-by: Liam Beguin > --- > > Hi, > > This was reported by the kernel test bot on an architecture I can't > really test on. I was only able to make sure the build succeeds, but > nothing more. > This patch is based on the __cmpxchg_u32 impletmentation and seems > incomplete based on the different cmpxchg headers I can find. Indeed. This version is suitable for non-SMP machines only. BTW, it looks like this version can be replaced by the one in asm-generic? > > Do these function need to be impletmented in each header > simulataneously? Yes, we need them for all variants. > arch/sh/include/asm/cmpxchg-irq.h | 27 +++++++++++++++++++++++++++ > arch/sh/include/asm/cmpxchg.h | 5 +++-- > 2 files changed, 30 insertions(+), 2 deletions(-) > > diff --git a/arch/sh/include/asm/cmpxchg-irq.h b/arch/sh/include/asm/cmpxchg-irq.h > index 07d3e7f08389..918c4153a930 100644 > --- a/arch/sh/include/asm/cmpxchg-irq.h > +++ b/arch/sh/include/asm/cmpxchg-irq.h > @@ -51,4 +51,31 @@ static inline unsigned long __cmpxchg_u32(volatile int *m, unsigned long old, > return retval; > } > > +static inline unsigned long __cmpxchg_u16(volatile u16 *m, unsigned long old, > + unsigned long new) > +{ > + u16 retval; > + unsigned long flags; > + > + local_irq_save(flags); > + retval = *m; > + if (retval == old) > + *m = new; > + local_irq_restore(flags); > + return (unsigned long)retval; > +} > + > +static inline unsigned long __cmpxchg_u8(volatile u8 *m, unsigned long old, > + unsigned long new) > +{ > + u8 retval; > + unsigned long flags; > + > + local_irq_save(flags); > + retval = *m; > + if (retval == old) > + *m = new; > + local_irq_restore(flags); > + return (unsigned long)retval; > +} > #endif /* __ASM_SH_CMPXCHG_IRQ_H */ > diff --git a/arch/sh/include/asm/cmpxchg.h b/arch/sh/include/asm/cmpxchg.h > index e9501d85c278..7d65d0fd1665 100644 > --- a/arch/sh/include/asm/cmpxchg.h > +++ b/arch/sh/include/asm/cmpxchg.h > @@ -56,8 +56,9 @@ static inline unsigned long __cmpxchg(volatile void * ptr, unsigned long old, > unsigned long new, int size) > { > switch (size) { > - case 4: > - return __cmpxchg_u32(ptr, old, new); > + case 4: return __cmpxchg_u32((int *)ptr, old, new); > + case 2: return __cmpxchg_u16((u16 *)ptr, old, new); > + case 1: return __cmpxchg_u8((u8 *)ptr, old, new); > } > __cmpxchg_called_with_bad_pointer(); > return old; Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds