Received: by 10.223.176.46 with SMTP id f43csp1301417wra; Fri, 19 Jan 2018 09:33:03 -0800 (PST) X-Google-Smtp-Source: ACJfBovnpmiWGVy7EMv9B+RXhrwydYIlrQMM7yzRicpHVGNvlLr85aT3fTfuiCmKx9OB+mUTKSjF X-Received: by 10.99.6.72 with SMTP id 69mr31775876pgg.50.1516383183663; Fri, 19 Jan 2018 09:33:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516383183; cv=none; d=google.com; s=arc-20160816; b=fRTOhhbe1fZr+m4LQBI1DXRwhiAP5DMbcjVrd9uyUeNiKiTTtsS9OGqR8UqNgaSrzB MOcysyiRsdcfbazNyzheNKNWjk+KfQSIv7ML2JMmpVopry607HGjEUizmP8PdOU2KcnK i4s+1fdtLqgpFLLsTgdnOE0vvjJawrD3MMyR+LJg+I7ToMjyh6MnDkTSNDATZ/uZwXui ilPHSOqmLuIheRZZ6Z/7sf01DnYK0QFYVEsQKWmeruA0b+6DVwxcKpnu+sXJEnFth7WW 61gJsIRXN+jZf6dDpquVa1MOGVUcW854nJapduk75rNvDqrU1c9JEPR/QqFBEAFcOri0 QkgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=ZW9hxmzbMLQGB9T7ZDZHGIhcCJ0dIY/KUxxAhj7BrMI=; b=hcIRzH9FrLd+dE7Tsd3Sa2PiQlSKigcsw1cf4HcRSI/ZjrRL0hxPfWNDvAmGRJ8+3c wJMaBsFgjwFa6XegGTgDthju2RP6XJt/+VLkjYEKfUrsi0zctt4Re67AivKTZOaq3yhp 9LNTvAAg8+hMx41jRd9GAqoEOxf53OCezgp02kxgZMuuMOD6hlTh9OgLgI7H25nA+9YT N0pcL5ULd0t8iTWa5VOoxSscTfiuUcAc5G+9/+gOH9QoykuNtRnNcy3sjwq5Uy9R+RWD bqSTDGQtLT2ILexeam42vKBTesW8XfWdLj3hPRTBOCZtsrLzftVkl+j+mQ6wSGZgBOJq FAqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=eguk8yPo; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a8-v6si975468plz.102.2018.01.19.09.32.49; Fri, 19 Jan 2018 09:33:03 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=eguk8yPo; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756068AbeASRbB (ORCPT + 99 others); Fri, 19 Jan 2018 12:31:01 -0500 Received: from mail-lf0-f68.google.com ([209.85.215.68]:42708 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755932AbeASRa4 (ORCPT ); Fri, 19 Jan 2018 12:30:56 -0500 Received: by mail-lf0-f68.google.com with SMTP id q17so2981837lfa.9 for ; Fri, 19 Jan 2018 09:30:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=ZW9hxmzbMLQGB9T7ZDZHGIhcCJ0dIY/KUxxAhj7BrMI=; b=eguk8yPo7eZpCV8DLaCKyI6/XnEEo5y+8/L/+v7xNhZvVmvHXk4E7S1V2WpL4HLMuI R0wHUBXHVkPLI07l2ozTiDIFIQMtmQ4rMn49Os2Rn+iO2lA1vkxhXsMBHy6oS58QSias 4/colb5Y4X8NOgcxSkHiMy6kX75rBNJUZjuNBA8yi9TI8vsccvxweiwYJnR6yNiysh6z 9laeY2BCEX0lGylPHL7Tj3Qu7HX6c2W16rtzWjshrXUNP10sp++EPh0jqmFUZ7xdV05d XnmWpD2VQC6RzDjZ8tyhwqLUP41ugLe4jKFs+ciAg84HNk8j4FKNIdStQXu+D81xSaGT Gslg== 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; bh=ZW9hxmzbMLQGB9T7ZDZHGIhcCJ0dIY/KUxxAhj7BrMI=; b=mhXMbV4QUhJ8acj/mWr/ZvFsOFIiSHa18ox3hjYk1p45GKJD5btCgv18T6Q528KYtm tgEem3WgdiggotpK9cGzsFaTp9vkRP2pmHJ9XLy8S8xWe5O3EkLK4t2ZqvG5e8jJ5yhy axCjPGsT7zfjKetV1YPp9JFFIiLBORLcFWlUn9HEDYKB/1Sjg53pbkrvpNNGS4SH8y5X oAr74Yu4/FciUaJ+A3EE5pqmEGTpv2uW5N4ei9y5QzrksRCM0kLbLcbbTckGN1gIDIJ3 XxXN4hDF6CLGWImoZreHjKdf3tlQFaUMfXJB3OV76UJts2EAAA9EreuApFhYlj/KAiPQ 9SmQ== X-Gm-Message-State: AKwxytd2m992IWEeoOl/junZeA432S6au4Ioov+LqxuLw386CyUH/4iD 3l5nfuzHj06wGAU4E3Kbbjg= X-Received: by 10.46.53.18 with SMTP id z18mr11817164ljz.4.1516383055198; Fri, 19 Jan 2018 09:30:55 -0800 (PST) Received: from linux.local ([95.79.164.146]) by smtp.gmail.com with ESMTPSA id n86sm381194lja.59.2018.01.19.09.30.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 19 Jan 2018 09:30:54 -0800 (PST) From: Serge Semin To: jdmason@kudzu.us, dave.jiang@intel.com, Allen.Hubbe@gmail.com Cc: gary.hook@amd.com, arnd@arndb.de, Sergey.Semin@t-platforms.ru, linux-ntb@googlegroups.com, linux-kernel@vger.kernel.org, Serge Semin Subject: [PATCH] NTB: ntb_perf: fix cast to restricted __le32 Date: Fri, 19 Jan 2018 20:30:44 +0300 Message-Id: <20180119173044.8013-1-fancer.lancer@gmail.com> X-Mailer: git-send-email 2.12.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Sparse is whining about the u32 and __le32 mixed usage in the driver. drivers/ntb/test/ntb_perf.c:288:21: warning: cast to restricted __le32 drivers/ntb/test/ntb_perf.c:295:37: warning: incorrect type in argument 4 (different base types) drivers/ntb/test/ntb_perf.c:295:37: expected unsigned int [unsigned] [usertype] val drivers/ntb/test/ntb_perf.c:295:37: got restricted __le32 [usertype] ... The NTB API can't be changed so ntb_spad_*() methods would return either pure __le32 or __be32, since the scratchpad data can have arbitrary endianness in general. In this case we need to forcibly cast all the u32 to be __le32 and vise-versa where it's supposed to be in accordance with the driver logic. Fixes: b83003b3fdc1 ("NTB: ntb_perf: Add full multi-port NTB API support") Signed-off-by: Serge Semin --- drivers/ntb/test/ntb_perf.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/drivers/ntb/test/ntb_perf.c b/drivers/ntb/test/ntb_perf.c index eaa252b71f82..5590aaf8e8a5 100644 --- a/drivers/ntb/test/ntb_perf.c +++ b/drivers/ntb/test/ntb_perf.c @@ -283,21 +283,21 @@ static int perf_spad_cmd_send(struct perf_peer *peer, enum perf_cmd cmd, sts = ntb_peer_spad_read(perf->ntb, peer->pidx, PERF_SPAD_CMD(perf->gidx)); - if (le32_to_cpu(sts) != PERF_CMD_INVAL) { + if (le32_to_cpu((__force __le32)sts) != PERF_CMD_INVAL) { usleep_range(MSG_UDELAY_LOW, MSG_UDELAY_HIGH); continue; } ntb_peer_spad_write(perf->ntb, peer->pidx, - PERF_SPAD_LDATA(perf->gidx), - cpu_to_le32(lower_32_bits(data))); + PERF_SPAD_LDATA(perf->gidx), + (__force u32)cpu_to_le32(lower_32_bits(data))); ntb_peer_spad_write(perf->ntb, peer->pidx, - PERF_SPAD_HDATA(perf->gidx), - cpu_to_le32(upper_32_bits(data))); + PERF_SPAD_HDATA(perf->gidx), + (__force u32)cpu_to_le32(upper_32_bits(data))); mmiowb(); ntb_peer_spad_write(perf->ntb, peer->pidx, PERF_SPAD_CMD(perf->gidx), - cpu_to_le32(cmd)); + (__force u32)cpu_to_le32(cmd)); mmiowb(); ntb_peer_db_set(perf->ntb, PERF_SPAD_NOTIFY(peer->gidx)); @@ -331,21 +331,21 @@ static int perf_spad_cmd_recv(struct perf_ctx *perf, int *pidx, continue; val = ntb_spad_read(perf->ntb, PERF_SPAD_CMD(peer->gidx)); - val = le32_to_cpu(val); + val = le32_to_cpu((__force __le32)val); if (val == PERF_CMD_INVAL) continue; *cmd = val; val = ntb_spad_read(perf->ntb, PERF_SPAD_LDATA(peer->gidx)); - *data = le32_to_cpu(val); + *data = le32_to_cpu((__force __le32)val); val = ntb_spad_read(perf->ntb, PERF_SPAD_HDATA(peer->gidx)); - *data |= (u64)le32_to_cpu(val) << 32; + *data |= (u64)le32_to_cpu((__force __le32)val) << 32; /* Next command can be retrieved from now */ ntb_spad_write(perf->ntb, PERF_SPAD_CMD(peer->gidx), - cpu_to_le32(PERF_CMD_INVAL)); + (__force u32)cpu_to_le32(PERF_CMD_INVAL)); dev_dbg(&perf->ntb->dev, "CMD recv: %d 0x%llx\n", *cmd, *data); @@ -381,7 +381,7 @@ static int perf_msg_cmd_send(struct perf_peer *peer, enum perf_cmd cmd, return ret; ntb_peer_msg_write(perf->ntb, peer->pidx, PERF_MSG_LDATA, - cpu_to_le32(lower_32_bits(data))); + (__force u32)cpu_to_le32(lower_32_bits(data))); if (ntb_msg_read_sts(perf->ntb) & outbits) { usleep_range(MSG_UDELAY_LOW, MSG_UDELAY_HIGH); @@ -389,12 +389,12 @@ static int perf_msg_cmd_send(struct perf_peer *peer, enum perf_cmd cmd, } ntb_peer_msg_write(perf->ntb, peer->pidx, PERF_MSG_HDATA, - cpu_to_le32(upper_32_bits(data))); + (__force u32)cpu_to_le32(upper_32_bits(data))); mmiowb(); /* This call shall trigger peer message event */ ntb_peer_msg_write(perf->ntb, peer->pidx, PERF_MSG_CMD, - cpu_to_le32(cmd)); + (__force u32)cpu_to_le32(cmd)); break; } @@ -414,13 +414,13 @@ static int perf_msg_cmd_recv(struct perf_ctx *perf, int *pidx, return -ENODATA; val = ntb_msg_read(perf->ntb, pidx, PERF_MSG_CMD); - *cmd = le32_to_cpu(val); + *cmd = le32_to_cpu((__force __le32)val); val = ntb_msg_read(perf->ntb, pidx, PERF_MSG_LDATA); - *data = le32_to_cpu(val); + *data = le32_to_cpu((__force __le32)val); val = ntb_msg_read(perf->ntb, pidx, PERF_MSG_HDATA); - *data |= (u64)le32_to_cpu(val) << 32; + *data |= (u64)le32_to_cpu((__force __le32)val) << 32; /* Next command can be retrieved from now */ ntb_msg_clear_sts(perf->ntb, inbits); -- 2.12.0