Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp982103rwi; Thu, 27 Oct 2022 09:41:56 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5Z8JLsJcsgdLRpkiA9k3XzSCoeph9CbsPLupDR9XxqRiAgyzmT2Vd6F//7ihH98GtkBigU X-Received: by 2002:a63:6b44:0:b0:46a:fa55:b6a0 with SMTP id g65-20020a636b44000000b0046afa55b6a0mr43110904pgc.614.1666888916010; Thu, 27 Oct 2022 09:41:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666888916; cv=none; d=google.com; s=arc-20160816; b=j+A+TsOLaHDdLMRnZPhre+T8IMklnJumS+J7abRD6P96PYcYB0iVzxAUKCGh+nDaNB Y6131eQTbqO96cshh6O2qNkHmp4QjXPvttGLfG/8RDC1/aMWz9mpfnlGk1FHZC/HbBgz yhKwdJsXnm7MUb+XnSPNbUKI7tezXFmWEgCoB3D/39SbDZSRrCLV70/wA7RLrcQSlp92 KZdZtS3a7R6lRKpLwNR1IAnQzCzHDO966meVDFEpAxMnqpCDVav9p8cPrYMasNxwdvJo //LHu3TFf3gJFegQp64XNOPFhESz+8XohXtlfs1qlRvOOlCLJcHNGqSG+zOVlQY6eCzY 8Qrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=cs6Se82l4PDsSj9I2mLI3f+GZ/GJF+Opr2Jjis5B+58=; b=Nopeo84XABMALvFF+KmKdydLvrHpxElLFQm9ysCmISyd7RJioh7nA7dI5eREwQVBXi LyGYXf0PLV2sPeUCwknwO36edrG7A1HqFjWuDOL0xKBC2+5lombC1iXbxLaTgU6f7yLy oB/+AiH39jlehNGh6mSBoTnIYKnnwRlBj/9c/99k9/rWwRQMPfzGVv99ZpfYW/RxtNwI 2XFNsQs4dZFoVVGepuBVmloiFfs3oO3rlmY+uXbqJIIQewIdnwhowZ3ujlGKhZglX1tC 3vhm6vp7Tr7ccJx0o2sqGgDR/iSHlimsl7qkxPuoGEf6RpPptLa/OTmqiEfzUZosPgYt ioDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="gr/x3Rmw"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b5-20020a170902e94500b00186ada43088si1993303pll.517.2022.10.27.09.41.43; Thu, 27 Oct 2022 09:41:55 -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=@linaro.org header.s=google header.b="gr/x3Rmw"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236331AbiJ0QJp (ORCPT + 99 others); Thu, 27 Oct 2022 12:09:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236380AbiJ0QJl (ORCPT ); Thu, 27 Oct 2022 12:09:41 -0400 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C1876342 for ; Thu, 27 Oct 2022 09:09:39 -0700 (PDT) Received: by mail-pj1-x1033.google.com with SMTP id l22-20020a17090a3f1600b00212fbbcfb78so6905221pjc.3 for ; Thu, 27 Oct 2022 09:09:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=cs6Se82l4PDsSj9I2mLI3f+GZ/GJF+Opr2Jjis5B+58=; b=gr/x3Rmw+ft/dWHSYXxVElM0ozip0qNvQoiaAb7SE3U23IY75AgH/lPJDcqT0638Ts KreY/MOQbHmTECj/j0eOSRu2dYoVj8QWWkrdhhF0zwCgqMm4Vb2P+VSLd/ZOEOdLpvPw N3cXmnt7x8itiPJ83eQQdCPR102fH5oJvdYV8Km7l48+hRK+ZiJbHT9YL9biHiH4gRGG pNRa2Dwd5DMHE8olSf37Q54BHys2n/JF58TJC1E34xWi6p61LXWrt4NXDGqzBv19Vj3f zw0eE/aO+D6k3bNTuYNBx5y+1k1QHVXR5642U/tDnaMj5t4/CuDfFZOvDrUnIfcDLroJ Yl+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=cs6Se82l4PDsSj9I2mLI3f+GZ/GJF+Opr2Jjis5B+58=; b=W41CuTc1Sjim0exs1DOYHgfrTE7Wopr9MaRPX+ESjSt2H1d6G1z9FxAktipmpPjZ7V F2KQKtuyl90ZSiVDnDdl78DecCCHvVWupgXO6gNQEmWtnhUAcQzVDf5cw74vQ5nTz7Rf SiI+mcV9g+WpRKQVxfimJ61pMB661mYN8nuaaVYqgBgx78vYzfXVIedl0MCSwqGqK+J2 /1pYGLZLEFpXHwuQzPkINf+5IFtxRHfkl51kLvYWbUMeg6oteO1AwCGIVqTccYLHiTMP McARMMeYtePJI2/3jOFwDdMEhLODrhYZwoaBfc2i1h00R6pf+TxQ78xeXm7nDkAksDA6 u2dg== X-Gm-Message-State: ACrzQf0cplNS4WOysGfzPBchTIXYNul1xwmL7POGG3zasOJpKAk9u2PE +yeFtavJeG9JQvGZZjm7SITp X-Received: by 2002:a17:902:f684:b0:17f:95cc:af8 with SMTP id l4-20020a170902f68400b0017f95cc0af8mr50148643plg.91.1666886979301; Thu, 27 Oct 2022 09:09:39 -0700 (PDT) Received: from thinkpad ([117.202.186.162]) by smtp.gmail.com with ESMTPSA id d1-20020a170902cec100b0018661d627d7sm1410039plg.59.2022.10.27.09.09.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Oct 2022 09:09:38 -0700 (PDT) Date: Thu, 27 Oct 2022 21:39:32 +0530 From: Manivannan Sadhasivam To: Frank Li Cc: Shunsuke Mie , Jon Mason , Dave Jiang , Allen Hubbe , kishon@kernel.org, Lorenzo Pieralisi , Krzysztof =?utf-8?Q?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}ntb: fix a check for no epc alignment constraint Message-ID: <20221027160932.GD76627@thinkpad> References: <20220922092357.123732-1-mie@igel.co.jp> <20221025142143.GA109941@thinkpad> <20221027151220.GC76627@thinkpad> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham 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 [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ński ; 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}ntb: fix 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ński > > > > ; 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}ntb: fix a check > > for > > > > no epc alignment constraint > > > > > > > > Caution: EXT Email > > > > > > > > Hi Frank, > > > > > > > > 2022年10月26日(水) 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ński ; 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}ntb: fix a check > > for > > > > no > > > > > > epc alignment constraint > > > > > > > > > > > > Caution: EXT Email > > > > > > > > > > > > On Thu, Sep 22, 2022 at 06:23:57PM +0900, Shunsuke Mie wrote: > > > > > > > Some PCI endpoint controllers have no alignment constraints, 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 need to > > > > write epc_features->align = 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 set alignment to 1 (default) if they don't really care about it. 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 == 0 means no alignment in kernel? > > > > > > > > > > > > > > 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 = peer_epc_features->bar_fixed_size[peer_barno]; > > > > > > > > > > > > > > /* Check if epc_features is populated incorrectly */ > > > > > > > - if ((!IS_ALIGNED(size, align))) > > > > > > > + if (align && (!IS_ALIGNED(size, align))) > > > > > > > return -EINVAL; > > > > > > > > > > > > > > spad_count = 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 = epc_features->bar_fixed_size[barno]; > > > > > > > align = epc_features->align; > > > > > > > > > > > > > > - if ((!IS_ALIGNED(size, align))) > > > > > > > + if (align && !IS_ALIGNED(size, align)) > > > > > > > return -EINVAL; > > > > > > > > > > > > > > spad_count = ntb->spad_count; > > > > > > > -- > > > > > > > 2.17.1 > > > > > > > > > > > > > > > > > > > -- > > > > > > மணிவண்ணன் சதாசிவம் > > > > > > > > Best, > > > > Shunsuke > > > > -- > > மணிவண்ணன் சதாசிவம் -- மணிவண்ணன் சதாசிவம்