lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230912112640.00007427@Huawei.com>
Date:   Tue, 12 Sep 2023 11:26:40 +0100
From:   Jonathan Cameron <Jonathan.Cameron@...wei.com>
To:     Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>
CC:     <linux-pci@...r.kernel.org>, Bjorn Helgaas <helgaas@...nel.org>,
        "Dennis Dalessandro" <dennis.dalessandro@...nelisnetworks.com>,
        Jason Gunthorpe <jgg@...pe.ca>,
        Leon Romanovsky <leon@...nel.org>,
        <linux-rdma@...r.kernel.org>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 1/8] IB/hfi1: Use FIELD_GET() to extract Link Width

On Mon, 11 Sep 2023 15:14:54 +0300
Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com> wrote:

> Use FIELD_GET() to extract PCIe Negotiated Link Width field instead of
> custom masking and shifting.
> 
> While at it, also fix function's comment.
> 
> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>
> ---
>  drivers/infiniband/hw/hfi1/pcie.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/infiniband/hw/hfi1/pcie.c b/drivers/infiniband/hw/hfi1/pcie.c
> index 08732e1ac966..d497e4c623c1 100644
> --- a/drivers/infiniband/hw/hfi1/pcie.c
> +++ b/drivers/infiniband/hw/hfi1/pcie.c
> @@ -3,6 +3,7 @@
>   * Copyright(c) 2015 - 2019 Intel Corporation.
>   */
>  
> +#include <linux/bitfield.h>
>  #include <linux/pci.h>
>  #include <linux/io.h>
>  #include <linux/delay.h>
> @@ -210,10 +211,10 @@ static u32 extract_speed(u16 linkstat)
>  	return speed;
>  }
>  
> -/* return the PCIe link speed from the given link status */
> +/* return the PCIe Link Width from the given link status */
>  static u32 extract_width(u16 linkstat)
>  {
> -	return (linkstat & PCI_EXP_LNKSTA_NLW) >> PCI_EXP_LNKSTA_NLW_SHIFT;
> +	return FIELD_GET(PCI_EXP_LNKSTA_NLW, linkstat);

The helper seems like overkill now.  Maybe just push this code inline
and drop the wrapper.  I don't think the comment is necessary after
that as we are putting it in a bus_width field and the register is
obviously link status from the naming.

	dd->lbus_width = FIELD_GET(PCI_EXP_LINKSTA_NLW, linkstat);

>  }
>  
>  /* read the link status and set dd->{lbus_width,lbus_speed,lbus_info} */

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ