Received: by 10.223.176.46 with SMTP id f43csp1520598wra; Fri, 19 Jan 2018 12:43:31 -0800 (PST) X-Google-Smtp-Source: ACJfBosHTMpoBLw0+zsBXtksl3OdewwIyYdVG+YFut9U8nPojsManOiqr8qUUURFJqij2wDYiLF2 X-Received: by 10.98.223.29 with SMTP id u29mr43856353pfg.166.1516394611421; Fri, 19 Jan 2018 12:43:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516394611; cv=none; d=google.com; s=arc-20160816; b=Y4k16BffhxPyELgpI+5HAsy0/wSd6KZJio8WlUzFKzohGYYvb7A6F0WjTvxaz/gQce 8kdzOrTn6/iR1oPW++oky0u9eaEH6f3BtAGk/pda9IHq/HcJg+vI2371MjVKMRuPWRoy TVedMTVRdZcUQtuor9MixaJle+6cTWRYjYBwFsiY0A+elI6sve2h0GifuAH//VWd9/yt 0+ZGic85/YbpcW5oLXIEiuHFzKgbeVZjJSDbblVoNy8EvmkbOsUTsu34JMJ6SK7EJrpU 6jlnUNQHoQUBP92yVZox3umqArATlOskmoQJew7MvvvnR8h/I1Qpc9w32k/jp+A9NHC2 HOWg== 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 :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=GtGhN2vFp8B0EFvTBeI9PmLFy18zC2hRUr5ioxZCmLQ=; b=GiE/PwaWLpXJZgsCTEOL+LdsoC3JbtAkoNJofIZpw5TCXkaY9dqbfYSGo76+UNaMuk AhowoLNzStG4pb4zX8Vu5+RQoW1XAXuZ9mSvz5seP/E34n4QzcusTc24/ZT0TEX1J3dh FelRpKR1npmEKDjoVgTsHAkykYO6bSkQoZThF3Z7Ahkya++Ytp2jZ4WNmGdVZ4w6hYx1 Izvg9ahOdiUuG2/1hpdfobvl1XtM6wmCxnIefLIOEmSW7PeYFoD0/DyZxa33nGjcTmE+ XntLbNA9K+IBsonAb2I7pM1m96ZsDin4mvUhD6Xj7kOqFFneph1Q8/GQSEC15kiaogA+ WKBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=mF8Ri8/A; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s7-v6si1088042plp.57.2018.01.19.12.43.17; Fri, 19 Jan 2018 12:43:31 -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=fail header.i=@gmail.com header.s=20161025 header.b=mF8Ri8/A; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756404AbeASUmY (ORCPT + 99 others); Fri, 19 Jan 2018 15:42:24 -0500 Received: from mail-oi0-f68.google.com ([209.85.218.68]:39685 "EHLO mail-oi0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756276AbeASUmS (ORCPT ); Fri, 19 Jan 2018 15:42:18 -0500 Received: by mail-oi0-f68.google.com with SMTP id t8so1999488oie.6 for ; Fri, 19 Jan 2018 12:42:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=GtGhN2vFp8B0EFvTBeI9PmLFy18zC2hRUr5ioxZCmLQ=; b=mF8Ri8/Ag5sAHdMPXDg3nrfXowSD6s9WWn1ooOY1YRMSsZB4Aw0hUljXAsCveG5nPU HjQOwLxHnQcVSJ+k/4FtzOo1WN9pGTzZ+QI9j0ZeMoH5DuZggMEKya8eLatmLb7Q2qEr EMZuiM+MMrjYTBZ84cEvPIGUVI0EYnrpovS2xzIsYNF3XMpBpmC1Ydb3LRCHaQmYzVBE Sxr1Ou1mZhTXDEFgLxuu0cfIZe6tP48Dy9tu/hbiLJEmYQh5DXtxTOG+OrBv83/9RqK/ Lk2nd+vzY3ioBQkyvziizRtJ8GqueqaMv4UtjP8b7WEzqyCpPqDyktxVNwkpV1US/Pha pFIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=GtGhN2vFp8B0EFvTBeI9PmLFy18zC2hRUr5ioxZCmLQ=; b=GR28yJMFAM6D9wNovIdVj9dPkKoOQ/+MWYeAgOfXV9tE2L8s12n03bHhTr7siYBwJ6 AGVALbE6YIV0inV5ewjd0rqE1bBpszlquxpIQ2oR4NZ/Uuu0WUP9osmNfKoTlGiUrDAd GYn1hMaUkVWvyUpWJtdPCtiT94NmTTCcIXck2X7TPIav9RtG2NplVogy7ZF1ltgsv0iN L8iFIjdMH7BVx0lO6RhdEBlGlrbsqzD1+HBz+JC8fVTIVcF29jt6r4cURrxwa76Ht1ne N1QWJGFajkGiSf/PS5h1GXQJxRL3rEflpz4OJ92vb7ygvjFU8IRA9PitC7VBbAkoSGTM lW+w== X-Gm-Message-State: AKwxytdgUXlJxWNqzgHMFBpzQiSqtaSYX/LKozBYeeBb+fQynT2Wl/3r +HJAno/aapZqLHTJEAs0USM/J+TjlJ8VwA4hcTc= X-Received: by 10.202.79.199 with SMTP id d190mr5729759oib.98.1516394538003; Fri, 19 Jan 2018 12:42:18 -0800 (PST) MIME-Version: 1.0 Received: by 10.157.68.119 with HTTP; Fri, 19 Jan 2018 12:42:17 -0800 (PST) In-Reply-To: <20180119173044.8013-1-fancer.lancer@gmail.com> References: <20180119173044.8013-1-fancer.lancer@gmail.com> From: Arnd Bergmann Date: Fri, 19 Jan 2018 21:42:17 +0100 X-Google-Sender-Auth: QnhxVNBPDYbRRT71FCR4FWo6CL0 Message-ID: Subject: Re: [PATCH] NTB: ntb_perf: fix cast to restricted __le32 To: Serge Semin Cc: jdmason@kudzu.us, Dave Jiang , Allen.Hubbe@gmail.com, "Hook, Gary" , Sergey.Semin@t-platforms.ru, linux-ntb@googlegroups.com, Linux Kernel Mailing List 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 On Fri, Jan 19, 2018 at 6:30 PM, Serge Semin wrote: > 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. > There's got to be a better way to do this than sprinkling lots of __force typecasts throughout the code. It looks like all those casts are about ntb_peer_spad_read()/ntb_peer_msg_write() calls, so why not change those function prototypes to work on __le32 types? There should also be some form of documentation regarding why you need to swap the data twice, since all the ntb drivers later end up doing another cpu_to_le32() on the little-endian data. Arnd