Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752830AbdLETMA (ORCPT ); Tue, 5 Dec 2017 14:12:00 -0500 Received: from ale.deltatee.com ([207.54.116.67]:52344 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752047AbdLETL5 (ORCPT ); Tue, 5 Dec 2017 14:11:57 -0500 To: Serge Semin , Jon Mason Cc: Dave Jiang , "Hubbe, Allen" , "S-k, Shyam-sundar" , "Yu, Xiangliang" , Gary R Hook , Sergey.Semin@t-platforms.ru, linux-ntb , linux-kernel References: <20171203191736.3399-1-fancer.lancer@gmail.com> <20171203191736.3399-2-fancer.lancer@gmail.com> <20171205173154.GB1701@mobilestation> From: Logan Gunthorpe Message-ID: Date: Tue, 5 Dec 2017 12:11:48 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <20171205173154.GB1701@mobilestation> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 172.16.1.162 X-SA-Exim-Rcpt-To: linux-kernel@vger.kernel.org, linux-ntb@googlegroups.com, Sergey.Semin@t-platforms.ru, gary.hook@amd.com, Xiangliang.Yu@amd.com, Shyam-sundar.S-k@amd.com, Allen.Hubbe@emc.com, dave.jiang@intel.com, jdmason@kudzu.us, fancer.lancer@gmail.com X-SA-Exim-Mail-From: logang@deltatee.com Subject: Re: [PATCH v2 01/15] NTB: Rename NTB messaging API methods X-SA-Exim-Version: 4.2.1 (built Tue, 02 Aug 2016 21:08:31 +0000) X-SA-Exim-Scanned: Yes (on ale.deltatee.com) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2018 Lines: 41 On 05/12/17 10:31 AM, Serge Semin wrote: >>> -static int idt_ntb_msg_read(struct ntb_dev *ntb, int midx, int *pidx, u32 *msg) >>> +static u32 idt_ntb_msg_read(struct ntb_dev *ntb, int *pidx, int midx) >>> { >>> struct idt_ntb_dev *ndev = to_ndev_ntb(ntb); >>> >>> if (midx < 0 || IDT_MSG_CNT <= midx) >>> - return -EINVAL; >>> + return (u32)-1; >> >> Please don't do this. If this is an error return standard error >> number. And why are we casting to an unsigned int now? >> > > We discussed these changes on the v1 series. Additionally I asked similar > question sometime ago even before the patchset was introduced. > This patch is made to provide the Message interface similar to the Scratchpad > one. I didn't introduce anything new or unjustified. As you can see the > spad_read/peer_spad_read methods return u32 type too. As well as the > Intel/AMD callbacks. The functions are intentionally made to return FFs > in case if some of the passed arguments get out from the allowed limits. > In such circumstances the return value emulates a situation like if user would > reference an invalid PCIe MMIO address. Since the 32-bits register can in general > have any value including -errno ones, then returning an error within the NTB API > would be incorrect. I remember Allen described it this way. > Nobody argued about it last time. If you think it's incorrect, then it should be > changed in both Scratchpad and Message register interfaces. I agree with Jon to not make this change. The original interface is better. Making the interface similar to spad_read() has no value especially seeing it makes it less correct. As you mention, *msg can be any value (even -1) so this restricts the values possible message values (making future potential hidden bugs) and removes error information (making debugging more difficult). I haven't really looked into it but, if anything, it would make sense to make the spad_read function more like this one. Logan