Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp183130pxa; Tue, 18 Aug 2020 20:42:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzOk+aFtqvYBCwWuOf4GPHHqbeiiRQ5SkbF8qGyuomLRVKHncd+3PUJhc8xYGThBcDReNg6 X-Received: by 2002:a17:906:fc26:: with SMTP id ov38mr22180295ejb.99.1597808526959; Tue, 18 Aug 2020 20:42:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597808526; cv=none; d=google.com; s=arc-20160816; b=XlXKbHLpYALXR6WxCLj2u1vWQBEpCGoZr257pRFnIjq8Zhw9XqjL9z1D9W7tpqscOk sbY0K3CA7fn+zBm67kpdYKaUu30AzAjF+zenYjuaaGAJH0La6Rh7nhvbFGxITD+Eswh1 PoONNoaA6KKdBft4puFtJTuMFcsmN7A4ke+D22EvU3X8KtwEQXEzfD9YAkqD+14O4S2u /RtCmDgNjx+AZCWUwYAH2dUYgZCZMSfY8W+VnsHoCcDjZcqOlm3eFu8BerIurovPKUIc /Nw8cDYLuk1CGF/kGcgW9ApzamYzmel+4feRGfr8AqhhvOfsqxzFDixSEPyAzNWUbXjq dlfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=ZuU80Z7VtjiOx9KYQrgsSGrMxc3EizeZUZWTydpUAn4=; b=LeVbHATOr6iR9wj9GAJ+tS+7Kh4KsvPl7smsuMgf1duoUsxbhEOB3JSBDC7QlkAbko t7agFLZYJJitgKngemhz8Jq1i5i+tVBTCiSWlAhhPsy1qdh3OJAQ2IAdEpuSMJWJuKOJ qna6iS5WvYFD5cGGNnZbAuJU7yqbmNkk8My1GP20bDipWGQiX/gKF+DMJxJJlQZDFHQ8 fyPU0b/EObjEnOyl1u+0u/s9LdYOz8NXI2UYVzdhuNrznHavmArdV+Nidnm1jmyZU/YF 1MaWlKD8hdzSGlBtLBMEFRM7Cmqg0H7zeu24M7PnhjKsI2MKS4DvI1CflYdSJpOJAD8R KISA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=bVFkn7Jp; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d30si20027110edn.97.2020.08.18.20.41.43; Tue, 18 Aug 2020 20:42:06 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=bVFkn7Jp; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727864AbgHSDFz (ORCPT + 99 others); Tue, 18 Aug 2020 23:05:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57424 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726605AbgHSDFy (ORCPT ); Tue, 18 Aug 2020 23:05:54 -0400 Received: from mail-qk1-x741.google.com (mail-qk1-x741.google.com [IPv6:2607:f8b0:4864:20::741]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE79DC061389; Tue, 18 Aug 2020 20:05:53 -0700 (PDT) Received: by mail-qk1-x741.google.com with SMTP id 77so20400651qkm.5; Tue, 18 Aug 2020 20:05:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ZuU80Z7VtjiOx9KYQrgsSGrMxc3EizeZUZWTydpUAn4=; b=bVFkn7Jpptl33UIirsnQkeycmvNl+gvNzoYFkghC8+6LGL5udoY37qDPQN2nCnq1Q8 T58YXrbN4JyvG+RZkoxxlSeoX2I/CI19QvzMqFadCN7TYhE1y1N+nbG/bGDZ4vP/Kr6q E2Ow4NFC9C923Y1Qai+wqjaZ5/kB5iFLLMgeXX6Z2MvyC4l/XVLo71WW2Od7wscGRqNP jHq+bVWN5DXVgb+L0bk/aUCIoOM9k09jd8sLwDunWR1LD5d+i6BgZDUG158hj+Y4e8ZQ PCnOeM7iPGTvFRvi3sZmvKShkK7JyBe2rnJdRHK4kkVA7pdCWJSQ0Ug5s9lpQu+CxzpA nZNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=ZuU80Z7VtjiOx9KYQrgsSGrMxc3EizeZUZWTydpUAn4=; b=MkX5yD9TaqIF4cdx4VbxfpnIpkPvBbXbigSuo4dW3hlarSk75Ouv5cpTPAfIaml1D6 7J1hFTjzVLX8V9oum+FOh2AETZ9XHwyGdEsJ3jcwFvtfgHFN5y3rBnkfcF8v4du3nlHi VfY1WtYu8fFWgxugpghHnC3RY+Sq+BZOjUgNemfZR+oeuLg7XL9/5DgLdsJ/weUn4d6e +lNgiiXLjDoG0F9JBza6SPMHKkNECxsecI6AjfMdiFZztiZiO9iupO8rAiYEkUid+I9k aAe3w1XLdK+AMOBB1pVxxDH/4mZUW6U+FcrQbExm5OZ/GTpuAql6BXhvho99Yg8Qjl3l J6Ng== X-Gm-Message-State: AOAM531vczUeqEQYR5feT7Y8CCY0j79SSqKq4Q0jMq+8XS6Mu4eYusQu 4+ODvU1updFrcabXRUXKBAk= X-Received: by 2002:a05:620a:63a:: with SMTP id 26mr20332775qkv.490.1597806353035; Tue, 18 Aug 2020 20:05:53 -0700 (PDT) Received: from atris.xiphos.ca (198-48-202-89.cpe.pppoe.ca. [198.48.202.89]) by smtp.gmail.com with ESMTPSA id m30sm27724520qtm.46.2020.08.18.20.05.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 Aug 2020 20:05:52 -0700 (PDT) From: Liam Beguin To: liambeguin@gmail.com, ysato@users.sourceforge.jp, dalias@libc.org Cc: linux-sh@vger.kernel.org, linux-kernel@vger.kernel.org, kernel test robot Subject: [PATCH 1/1] sh: add support for cmpxchg on u8 and u16 pointers Date: Tue, 18 Aug 2020 23:05:11 -0400 Message-Id: <20200819030511.1114-1-liambeguin@gmail.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Do these function need to be impletmented in each header simulataneously? Thanks, Liam 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; -- 2.27.0