Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp446803pxv; Thu, 1 Jul 2021 01:36:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz9xSA/4sv7vIQeDkIwMg8gUtqI7qQ0+3UoWmUu1Xpp8IXpNUyrSEaSlqaYvQ69dGjUfIe8 X-Received: by 2002:aa7:db94:: with SMTP id u20mr52475900edt.381.1625128617456; Thu, 01 Jul 2021 01:36:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625128617; cv=none; d=google.com; s=arc-20160816; b=LOjvIzVten1DzAZ4JZIXJd3uVC2qFqXNluiZn14yP107Y4yvjtacd2v7Ys3gBn8Kni L/3wFOBqW1pVeTfeO3LNuFAAoU2LbiekfXXond1o1Dv3OnThjHDPbtXlMmanQPFP1ryn rYXSVtqnkQvo8W94NkEDrLmHbSBOu5uwUU47A5FaThwzFGuProTR3/Vx5mwmGGHLmUfn BquefGpHSeTu/u97V9nyi2udK39YrnCqJxacisj6ssnwJ9I/c8ooMMVk3azu5RzOa0kE h91vYWvv5voMkerVpu/CyXnsNVtwaMxgUh0f0eJJlvMp0zh4msm3kW+QULg3uW+2/Dr8 fCtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=4GJSoHNoFCULHjQHnHOS7LZfku+R0wp2pJa7dFllkR8=; b=iQmNA+fWrnGlxghyYr+6wbPiyGeUEhGnJSCKc4WG6FO0nafGenxUq/cdFtIq/son14 ntiJSXOMQG1fIp+yP5C+qIUeqgpjs120yHn1qiSURQ8O9Ndqp3xa5QM5uchxnPPynCQb QDwKCxvrVVHwz+G7sSf+yv9vaKxbi5g6xRzGsXSK8nE3B4/PAJSxixcyjjXUSOiSrJTa bZx8ylh+lYd+BkwjKa8RzM+clcuqAHraTw2sanS+Ur9ikyYL05BWbpD6m6fNhIwXNsNw tC9HzhEHUNanrfMmKbqaDrdPUYRl5WfJydqwsBa/Th1tkfNexR9xZBE5ZAe7irKhHDpI 9NFg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a16si23788025eds.410.2021.07.01.01.36.13; Thu, 01 Jul 2021 01:36:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235260AbhGAIh0 (ORCPT + 99 others); Thu, 1 Jul 2021 04:37:26 -0400 Received: from mga07.intel.com ([134.134.136.100]:64707 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235159AbhGAIhZ (ORCPT ); Thu, 1 Jul 2021 04:37:25 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10031"; a="272350215" X-IronPort-AV: E=Sophos;i="5.83,313,1616482800"; d="scan'208";a="272350215" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jul 2021 01:34:55 -0700 X-IronPort-AV: E=Sophos;i="5.83,313,1616482800"; d="scan'208";a="457573732" Received: from sneftin-mobl.ger.corp.intel.com (HELO [10.251.163.223]) ([10.251.163.223]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 01 Jul 2021 01:34:52 -0700 Subject: Re: [Intel-wired-lan] [PATCH] driver core: fix e1000e ltr bug To: Yee Li Cc: jesse.brandeburg@intel.com, anthony.l.nguyen@intel.com, davem@davemloft.net, kuba@kernel.org, intel-wired-lan@lists.osuosl.org, linux-kernel@vger.kernel.org, "Ruinskiy, Dima" , "Edri, Michael" , "Efrati, Nir" , "Neftin, Sasha" References: <20210629082128.255988-1-seven.yi.lee@gmail.com> <02ff77ef-e802-8e13-d169-1ab2c250405a@intel.com> <0234b97a-f207-47b0-1545-582ee5282824@intel.com> From: "Neftin, Sasha" Message-ID: <1e15c452-f8be-85fa-e424-b7463cc703eb@intel.com> Date: Thu, 1 Jul 2021 11:34:49 +0300 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 6/30/2021 09:26, Yee Li wrote: > I agree with you. > That's better code. Thank Yee-Li for discovering this problem. I would suggest we (intel) will process a patch to address this problem. Can I put you kindly as "Suggested-by"? > > Neftin, Sasha > > 于2021年6月30日周三 下午2:13写道: > > On 6/29/2021 20:33, Yee Li wrote: > > > > Yes, 18874368ns > 3145728ns. > > But, 0xe40 < 0x1003. > I got you. I would agree, direct comparison is error-prone. (10M is > impacted) > I would suggest do not use convert function. lat_en should rather > presented as lat_enc = scale x value: > Introduce two u16 variables, u16 lat_enc_d and u16 max_ltr_enc_d; > > lat_enc_d = (lat_enc & 0x0x3ff) x (1U << 5*((max_ltr_enc & 0x1c00) > >> 10)) > > max_ltr_enc_d = (max_ltr_enc & 0x0x3ff) x (1U << 5*((max_ltr_enc & > 0x1c00) >> 10)) > > Then: > if (lat_enc_d > max_ltr_enc_d) >         lat_enc = max_ltr_enc; > what do you think? > > > > > So, the final lat_enc is 0xe40. > > (Latency encoded is less than maximum LTR encoded by platform) > > > > Neftin, Sasha >> > > 于 2021年6月29日周二 22:49写道: > > > >     On 6/29/2021 11:21, YeeLi wrote: > >     Yeeli, > >      > In e1000e driver, a PCIe-like device, the max > snoop/no-snoop latency > >      > is the upper limit.So, directly compare the size of > lat_enc and > >      > max_ltr_enc is incorrect. > >      > > >     why? > >      >      In 1000Mbps, 0x8b9 < 0x1003, 189440 ns < 3145728 ns, > correct. > >      > > >      >      In 100Mbps, 0xc3a < 0x1003, 1900544 ns < 3145728 ns, > correct. > >      > > >      >      In 10Mbps, 0xe40 < 0x1003, 18874368 > 3145728, incorrect. > >      > > >     Platform LTR encoded is 0x1003 - right. It is meant 1048576ns > x 3 = > >     3145738ns. > >     Now, > >     for 1000M: 0x08b9 => 185ns x 1024 = 189440ns (you are correct) > >     for 100M: 0x0c3a => 58ns x 32768 = 1900544ns (correct) > >     for 10M: 0x0e41 => 577ns x 32768 = 18907136ns (ok?) > >     18907136ns > 3145738ns, (latency encoded is great than > maximum LTR > >     encoded by platform) - so, there is no point to wait more > than platform > >     required, and lat_enc=max_ltr_enc. It is expected and we sent > right > >     value to the power management controller. > >     What is the problem you try solve? > > > >      > Decoded the lat_enc and max_ltr_enc before compare them is > necessary. > >      > > >      > Signed-off-by: YeeLi > >     >> > >      > --- > >      >   drivers/net/ethernet/intel/e1000e/ich8lan.c | 23 > >     ++++++++++++++++++++- > >      >   1 file changed, 22 insertions(+), 1 deletion(-) > >      > > >      > diff --git a/drivers/net/ethernet/intel/e1000e/ich8lan.c > >     b/drivers/net/ethernet/intel/e1000e/ich8lan.c > >      > index 590ad110d383..3bff1b570b76 100644 > >      > --- a/drivers/net/ethernet/intel/e1000e/ich8lan.c > >      > +++ b/drivers/net/ethernet/intel/e1000e/ich8lan.c > >      > @@ -986,6 +986,27 @@ static s32 > e1000_k1_workaround_lpt_lp(struct > >     e1000_hw *hw, bool link) > >      >       return ret_val; > >      >   } > >      > > >      > +static u32 convert_e1000e_ltr_scale(u32 val) > >      > +{ > >      > +     if (val > 5) > >      > +             return 0; > >      > + > >      > +     return 1U << (5 * val); > >      > +} > >      > + > >      > +static u64 decoded_ltr(u32 val) > >      > +{ > >      > +     u64 decoded_latency; > >      > +     u32 value; > >      > +     u32 scale; > >      > + > >      > +     value = val & 0x03FF; > >      > +     scale = (val & 0x1C00) >> 10; > >      > +     decoded_latency = value * > convert_e1000e_ltr_scale(scale); > >      > + > >      > +     return decoded_latency; > >      > +} > >      > + > >      >   /** > >      >    *  e1000_platform_pm_pch_lpt - Set platform power > management > >     values > >      >    *  @hw: pointer to the HW structure > >      > @@ -1059,7 +1080,7 @@ static s32 > e1000_platform_pm_pch_lpt(struct > >     e1000_hw *hw, bool link) > >      >                                    E1000_PCI_LTR_CAP_LPT + 2, > >     &max_nosnoop); > >      >               max_ltr_enc = max_t(u16, max_snoop, > max_nosnoop); > >      > > >      > -             if (lat_enc > max_ltr_enc) > >      > +             if (decoded_ltr(lat_enc) > > decoded_ltr(max_ltr_enc)) > >      >                       lat_enc = max_ltr_enc; > >      >       } > >      > > >      > > >     sasha > > > sasha