Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp2186473rwi; Fri, 28 Oct 2022 04:13:54 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7pzb7vprTYa0cDFDUHQy1NAep1gVNzFavLNn18e9XbOlVs2QPbjRHTK/hkdD4oAhrkOnmg X-Received: by 2002:a17:907:3e06:b0:733:693:600e with SMTP id hp6-20020a1709073e0600b007330693600emr44824167ejc.410.1666955634304; Fri, 28 Oct 2022 04:13:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666955634; cv=none; d=google.com; s=arc-20160816; b=JD5y5c6MU3/txqWmg8z4J5SY8c94u4GK38ylezZzRi9N/MYOWZD3crPRIzE4QNCOzR dQnl7cIU9R/oFjPO35/cb20Pnf9D2scOAUOo7Cgf9udtYgXAfxQEkgp7vb910nlKa6cl gf1fo+iTkAlZGyFX5vXeNkWsYeu1sxv6D6w2A1yK4ZIBys+2U+Nafr/B1LVa+Fnp5SJp i4STY+MrJnBY+9XrvY/4ys+LCJq83bY1Rfnp20B0b3qUg7ZILzTVXymEMXqZ2CRoJMb0 CkuCpS9gjYETF7EC6dbG5qMuvoeBP+iDDfEwpFAgKUvuk9GTiP/6388B/3A8x5TTqekS EUuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=ccqIL5SHWfgcf9gYrp0T9AJEDNgbEFyLA7s1nTzANVE=; b=rB1AkLrm8G4h27qILzOM71KlIKbs5g8IaWS6QTpiGoOoixIxqIWjlaoqPr8um9CeRR elFzzd5aPj0rF9DYb0WULEgX3tqqvwY/qgmYr8l79UvqpM8rWbmBQceOhEMqlMyKB/6B uz6WwFao5KWOd+37fjiHvN1fcGkDTJLh5f3OYPQgK6sqZAnHLLdmcgFlSAKGOO+1GOj+ KAn5OUWtJZJ8fR2TQ2fpBL+aBNP8JjetEHfO1ZFnvD6pLknLEGisY7ptHZxv163+1iDV 49iZwJFBKkO2lPq1xjI2Dz5YZtsGJTFOpTp3lt7BIvH1LRNjJ7uFiG7YqejllMbsu/vf +Tmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@igel-co-jp.20210112.gappssmtp.com header.s=20210112 header.b="RGD/dF0Z"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i17-20020a1709061e5100b0078dcd30bc94si3549920ejj.529.2022.10.28.04.13.19; Fri, 28 Oct 2022 04:13:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@igel-co-jp.20210112.gappssmtp.com header.s=20210112 header.b="RGD/dF0Z"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229730AbiJ1K4c (ORCPT + 99 others); Fri, 28 Oct 2022 06:56:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229441AbiJ1K43 (ORCPT ); Fri, 28 Oct 2022 06:56:29 -0400 Received: from mail-vs1-xe33.google.com (mail-vs1-xe33.google.com [IPv6:2607:f8b0:4864:20::e33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7ACB65A835 for ; Fri, 28 Oct 2022 03:56:27 -0700 (PDT) Received: by mail-vs1-xe33.google.com with SMTP id z189so4123890vsb.4 for ; Fri, 28 Oct 2022 03:56:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=igel-co-jp.20210112.gappssmtp.com; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=ccqIL5SHWfgcf9gYrp0T9AJEDNgbEFyLA7s1nTzANVE=; b=RGD/dF0ZuZ6Nwrx6PZCQHZMvt1h95JhYB2QNxD9vk2/wUOJphy06EFNlVcng8Up10i diJ6HSg8zvAA4XnboRDwmIYGyyue6EESzfU+xto8Gfd8rcpj2RZmgYeSgpkefvMXLjju O/0qmaigEFRvPZvS/iRVqcUtvmwl9OMdLVDpxu5+lcjRb5A2j4uGdCmdy74ePDzG/Qef Bt4ICf7HUASZKo5v5IwKUCMTCnAQkivbAKcpbdXX/J4JDQNtISAaXk+qbABMzcO7Gcux KTqLGP1QnPejJ6ok+VSKQxgvZ7cn/h7AnfVWBW5hETymBOVatabXUyW690qftxgfY49d ZIUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ccqIL5SHWfgcf9gYrp0T9AJEDNgbEFyLA7s1nTzANVE=; b=gTiCtwRPffnNUuEC8s1GOqPjTOg9cDKYQolhNlES6NUi5F28z105RxtA0SGaukL9Ib JIv1Hy4DiK4CpeqxOX2sNgYPpLOJ/wzTNLWwpobEorkltVacz2uJ6AxSBkd47o8uB7Ih nrA/33k7WyS+aTv2i1wUq3aFkF+piOvVRRt1mPnvI+ZB5qqexcvmk2bkvy5ZlInXafC1 pVkH+SiComUyWPtnVVP/60xM5iSlwC5deXJtPRiqaYmXmYZ/YIGDrvALEwI3IC5dufKZ ZFFGBPliXlazW9w+N/FJw4cspR0O03JmD/tfngOUJ6YElJl6uPZcsoYpamv4T8cCpcr+ RsOQ== X-Gm-Message-State: ACrzQf0bx3HxWocR8u9uEzynmrzuQA3ZmeJoBXzqTzaJoxDlC9Fbrj0u W5qnCp2eOMtQeGXoWjEi5dZCvsKXsCv1VDpjZexMVg== X-Received: by 2002:a67:fb41:0:b0:3a6:9b59:4b58 with SMTP id e1-20020a67fb41000000b003a69b594b58mr26051417vsr.39.1666954586524; Fri, 28 Oct 2022 03:56:26 -0700 (PDT) MIME-Version: 1.0 References: <20220922092357.123732-1-mie@igel.co.jp> <20221025142143.GA109941@thinkpad> <20221027151220.GC76627@thinkpad> <20221027160932.GD76627@thinkpad> In-Reply-To: From: Shunsuke Mie Date: Fri, 28 Oct 2022 19:56:15 +0900 Message-ID: Subject: Re: [EXT] Re: [PATCH v2] PCI: endpoint: pci-epf-{,v}ntb: fix a check for no epc alignment constraint To: Frank Li Cc: Manivannan Sadhasivam , Jon Mason , Dave Jiang , Allen Hubbe , "kishon@kernel.org" , Lorenzo Pieralisi , =?UTF-8?Q?Krzysztof_Wilczy=C5=84ski?= , Bjorn Helgaas , "ntb@lists.linux.dev" , "linux-pci@vger.kernel.org" , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 2022=E5=B9=B410=E6=9C=8828=E6=97=A5(=E9=87=91) 1:25 Frank Li : > > > > > -----Original Message----- > > From: Manivannan Sadhasivam > > Sent: Thursday, October 27, 2022 11:10 AM > > To: Frank Li > > Cc: Shunsuke Mie ; Jon Mason ; Dave > > Jiang ; Allen Hubbe ; > > kishon@kernel.org; Lorenzo Pieralisi ; Krzysztof > > Wilczy=C5=84ski ; Bjorn Helgaas ; > > ntb@lists.linux.dev; linux-pci@vger.kernel.org; linux-kernel@vger.kerne= l.org > > Subject: Re: [EXT] Re: [PATCH v2] PCI: endpoint: pci-epf-{,v}ntb: fix a= check for > > no epc alignment constraint > > > > Caution: EXT Email > > > > [Added Kishon's new email address and removed the old one] > > > > On Thu, Oct 27, 2022 at 03:34:11PM +0000, Frank Li wrote: > > > > > > > > > > -----Original Message----- > > > > From: Manivannan Sadhasivam > > > > Sent: Thursday, October 27, 2022 10:12 AM > > > > To: Frank Li > > > > Cc: Shunsuke Mie ; Jon Mason ; > > Dave > > > > Jiang ; Allen Hubbe ; > > Kishon > > > > Vijay Abraham I ; Lorenzo Pieralisi > > ; > > > > Krzysztof Wilczy=C5=84ski ; Bjorn Helgaas > > > > ; ntb@lists.linux.dev; linux-pci@vger.kernel.o= rg; > > > > linux-kernel@vger.kernel.org > > > > Subject: Re: [EXT] Re: [PATCH v2] PCI: endpoint: pci-epf-{,v}ntb: f= ix a check > > for > > > > no epc alignment constraint > > > > > > > > Caution: EXT Email > > > > > > > > On Thu, Oct 27, 2022 at 02:35:56PM +0000, Frank Li wrote: > > > > > > > > > > > > > > > > -----Original Message----- > > > > > > From: Shunsuke Mie > > > > > > Sent: Wednesday, October 26, 2022 8:43 PM > > > > > > To: Frank Li > > > > > > Cc: Manivannan Sadhasivam ; > > Jon > > > > > > Mason ; Dave Jiang ; > > Allen > > > > > > Hubbe ; Kishon Vijay Abraham I > > ; > > > > > > Lorenzo Pieralisi ; Krzysztof Wilczy=C5= =84ski > > > > > > ; Bjorn Helgaas ; > > > > > > ntb@lists.linux.dev; linux-pci@vger.kernel.org; linux- > > > > kernel@vger.kernel.org > > > > > > Subject: Re: [EXT] Re: [PATCH v2] PCI: endpoint: pci-epf-{,v}nt= b: fix a > > check > > > > for > > > > > > no epc alignment constraint > > > > > > > > > > > > Caution: EXT Email > > > > > > > > > > > > Hi Frank, > > > > > > > > > > > > 2022=E5=B9=B410=E6=9C=8826=E6=97=A5(=E6=B0=B4) 1:07 Frank Li : > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -----Original Message----- > > > > > > > > From: Manivannan Sadhasivam > > > > > > > > > > Sent: Tuesday, October 25, 2022 9:22 AM > > > > > > > > To: Shunsuke Mie > > > > > > > > Cc: Jon Mason ; Dave Jiang > > > > ; > > > > > > > > Allen Hubbe ; Kishon Vijay Abraham I > > > > > > > > ; Lorenzo Pieralisi ; > > Krzysztof > > > > > > > > Wilczy=C5=84ski ; Bjorn Helgaas > > ; > > > > > > > > ntb@lists.linux.dev; linux-pci@vger.kernel.org; linux- > > > > > > kernel@vger.kernel.org > > > > > > > > Subject: [EXT] Re: [PATCH v2] PCI: endpoint: pci-epf-{,v}nt= b: fix a > > check > > > > for > > > > > > no > > > > > > > > epc alignment constraint > > > > > > > > > > > > > > > > Caution: EXT Email > > > > > > > > > > > > > > > > On Thu, Sep 22, 2022 at 06:23:57PM +0900, Shunsuke Mie wrot= e: > > > > > > > > > Some PCI endpoint controllers have no alignment constrain= ts, > > and > > > > the > > > > > > > > > epc_features->align becomes 0. In this case, IS_ALIGNED()= in > > > > > > > > > > > > > > [Frank Li] why not set epc_features->align 1 > > > > > > > no alignment constraints should mean align to byte. > > > > > > It is one of the solutions too I think. But in that case, we n= eed to > > > > > > write epc_features->align =3D 1 to all epc drivers, dwc, qcom, = rcar, > > > > > > tegra, and etc. > > > > > > > > > > > > I think that my change is better. > > > > > > > > > > I think it should be based on what original term defined. > > > > > It should be fixed at where make mistake. > > > > > > > > > > > > > 1byte is the default alignment that drivers can assume, why do you = want > > > > drivers > > > > to set them explicitly when they do not want any special alignment? > > > > > > What's definition of not alignment by align variable? > > > Using both 0 and 1 as no alignment is not good enough. > > > > > > I grep whole kernel driver directory, not one use > > > If (align && IS_ALIGNED(x, align)) statement. > > > > I can see multiple hits: > > > > lib/ubsan.c > > drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c > > drivers/gpu/drm/i915/i915_vma.c > > drivers/nvdimm/pfn_devs.c > > drivers/misc/pci_endpoint_test.c > > > > But in most of the places, the alignment is guaranteed to be set by the= client > > drivers because they might be read from the hardware register or fixed = for > > an > > IP. But in this case, I don't think we should _force_ the drivers to se= t > > alignment to 1 (default) if they don't really care about it. > > I keep my opinion. I think EP controller have not reported correct data. > Hardware register also can be set 0 as no alignment means. > It broken "align" conversion. It is certainly true. In addition, I don't think it is a good design for the framework to require the same check for all ep function drivers. like this patch. But I can't be determined, so I'm going to look into other drivers/subsystems to find a common and better way. > If most people prefer this way, I suggest change api document at > Include/linux/pci-epc.h to explicitly said 0 is validate option. Yes. If we take the way, I'll add the explanation. > > > > Thanks, > > Mani > > > > > > > > There are a common convention, align is 2^n > > > > > > > > > > > > > > I think this patch is fine. > > > > > > > > Thanks, > > > > Mani > > > > > > > > > Are there other place use align =3D=3D 0 means no alignment in ke= rnel? > > > > > > > > > > > > > > > > > > > > epf_ntb_config_spad_bar_alloc() doesn't work well. Check = for > > this > > > > > > before > > > > > > > > > IS_ALIGNED(). > > > > > > > > > > > > > > > > > > Signed-off-by: Shunsuke Mie > > > > > > > > > > > > > > > > Reviewed-by: Manivannan Sadhasivam > > > > > > > > > > > > > > > > > > > > > > > > Thanks, > > > > > > > > Mani > > > > > > > > > > > > > > > > > --- > > > > > > > > > Changes in v2: > > > > > > > > > * Fix the commit message in phrasings and words. > > > > > > > > > --- > > > > > > > > > --- > > > > > > > > > drivers/pci/endpoint/functions/pci-epf-ntb.c | 2 +- > > > > > > > > > drivers/pci/endpoint/functions/pci-epf-vntb.c | 2 +- > > > > > > > > > 2 files changed, 2 insertions(+), 2 deletions(-) > > > > > > > > > > > > > > > > > > diff --git a/drivers/pci/endpoint/functions/pci-epf-ntb.c > > > > > > > > b/drivers/pci/endpoint/functions/pci-epf-ntb.c > > > > > > > > > index 9a00448c7e61..f74155ee8d72 100644 > > > > > > > > > --- a/drivers/pci/endpoint/functions/pci-epf-ntb.c > > > > > > > > > +++ b/drivers/pci/endpoint/functions/pci-epf-ntb.c > > > > > > > > > @@ -1021,7 +1021,7 @@ static int > > > > > > epf_ntb_config_spad_bar_alloc(struct > > > > > > > > epf_ntb *ntb, > > > > > > > > > peer_size =3D peer_epc_features->bar_fixed_size[pee= r_barno]; > > > > > > > > > > > > > > > > > > /* Check if epc_features is populated incorrectly *= / > > > > > > > > > - if ((!IS_ALIGNED(size, align))) > > > > > > > > > + if (align && (!IS_ALIGNED(size, align))) > > > > > > > > > return -EINVAL; > > > > > > > > > > > > > > > > > > spad_count =3D ntb->spad_count; > > > > > > > > > diff --git a/drivers/pci/endpoint/functions/pci-epf-vntb.= c > > > > > > > > b/drivers/pci/endpoint/functions/pci-epf-vntb.c > > > > > > > > > index 0ea85e1d292e..5e346c0a0f05 100644 > > > > > > > > > --- a/drivers/pci/endpoint/functions/pci-epf-vntb.c > > > > > > > > > +++ b/drivers/pci/endpoint/functions/pci-epf-vntb.c > > > > > > > > > @@ -418,7 +418,7 @@ static int > > > > epf_ntb_config_spad_bar_alloc(struct > > > > > > > > epf_ntb *ntb) > > > > > > > > > size =3D epc_features->bar_fixed_size[barno]; > > > > > > > > > align =3D epc_features->align; > > > > > > > > > > > > > > > > > > - if ((!IS_ALIGNED(size, align))) > > > > > > > > > + if (align && !IS_ALIGNED(size, align)) > > > > > > > > > return -EINVAL; > > > > > > > > > > > > > > > > > > spad_count =3D ntb->spad_count; > > > > > > > > > -- > > > > > > > > > 2.17.1 > > > > > > > > > > > > > > > > > > > > > > > > > -- > > > > > > > > =E0=AE=AE=E0=AE=A3=E0=AE=BF=E0=AE=B5=E0=AE=A3=E0=AF=8D=E0= =AE=A3=E0=AE=A9=E0=AF=8D =E0=AE=9A=E0=AE=A4=E0=AE=BE=E0=AE=9A=E0=AE=BF=E0= =AE=B5=E0=AE=AE=E0=AF=8D > > > > > > > > > > > > Best, > > > > > > Shunsuke > > > > > > > > -- > > > > =E0=AE=AE=E0=AE=A3=E0=AE=BF=E0=AE=B5=E0=AE=A3=E0=AF=8D=E0=AE=A3=E0= =AE=A9=E0=AF=8D =E0=AE=9A=E0=AE=A4=E0=AE=BE=E0=AE=9A=E0=AE=BF=E0=AE=B5=E0= =AE=AE=E0=AF=8D > > > > -- > > =E0=AE=AE=E0=AE=A3=E0=AE=BF=E0=AE=B5=E0=AE=A3=E0=AF=8D=E0=AE=A3=E0=AE= =A9=E0=AF=8D =E0=AE=9A=E0=AE=A4=E0=AE=BE=E0=AE=9A=E0=AE=BF=E0=AE=B5=E0=AE= =AE=E0=AF=8D Best, Shunsuke