All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ben Widawsky <ben.widawsky@intel.com>
To: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Cc: Jonathan Cameron <Jonathan.Cameron@huawei.com>,
	linux-cxl@vger.kernel.org, linux-pci@vger.kernel.org,
	Dan Williams <dan.j.williams@intel.com>,
	Bjorn Helgaas <helgaas@kernel.org>,
	Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>,
	Chris Browy <cbrowy@avery-design.com>,
	linux-acpi@vger.kernel.org, alison.schofield@intel.com,
	vishal.l.verma@intel.com, ira.weiny@intel.com,
	linuxarm@huawei.com, Fangjian <f.fangjian@huawei.com>
Subject: Re: [RFC PATCH v2 3/4] cxl/mem: Add CDAT table reading from DOE
Date: Wed, 14 Apr 2021 11:50:58 -0700	[thread overview]
Message-ID: <20210414185058.ls5sbp3cow7synqe@intel.com> (raw)
In-Reply-To: <YHcxChBDpxoopJT8@dhcp-10-154-113-106.vpn.oracle.com>

On 21-04-14 14:14:34, Konrad Rzeszutek Wilk wrote:
> > +static int cdat_to_buffer(struct pcie_doe *doe, u32 *buffer, size_t length)
> > +{
> > +	int entry_handle = 0;
> > +	int rc;
> > +
> > +	do {
> > +		u32 cdat_request_pl = CDAT_DOE_REQ(entry_handle);
> > +		u32 cdat_response_pl[32];
> > +		struct pcie_doe_exchange ex = {
> > +			.vid = PCI_DVSEC_VENDOR_ID_CXL,
> > +			.protocol = CXL_DOE_PROTOCOL_TABLE_ACCESS,
> > +			.request_pl = &cdat_request_pl,
> > +			.request_pl_sz = sizeof(cdat_request_pl),
> > +			.response_pl = cdat_response_pl,
> > +			.response_pl_sz = sizeof(cdat_response_pl),
> > +		};
> > +		size_t entry_dw;
> > +		u32 *entry;
> > +
> > +		rc = pcie_doe_sync(doe, &ex);
> > +		if (rc < 0)
> > +			return rc;
> > +
> > +		entry = cdat_response_pl + 1;
> > +		entry_dw = rc / sizeof(u32);
> 
> Could you >> 2?

What's the reasoning for >> 2? As someone who regularly does this because of
habit, using divide is generally a lot more implicitly descriptive.

> > +		/* Skip Header */
> > +		entry_dw -= 1;
> > +		entry_dw = min(length / 4, entry_dw);
> 
> Ditto here on length?
> 
> Also should you double check that length is not greater than
> sizeof(cdat_respone_pl)?
> 
> > +		memcpy(buffer, entry, entry_dw * sizeof(u32));
> > +		length -= entry_dw * sizeof(u32);
> 
> Would it be just easier to convert length at the start to be >> 2
> instead of this * and / ?
> 

Same as above. Assuming the compiler isn't braindead, I think it reads better as
it is.

> 
> > +		buffer += entry_dw;
> > +		entry_handle = FIELD_GET(CXL_DOE_TABLE_ACCESS_ENTRY_HANDLE, cdat_response_pl[0]);
> > +
> > +	} while (entry_handle != 0xFFFF);
> > +
> > +	return 0;
> > +}
> > +

  reply	other threads:[~2021-04-14 18:51 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-13 16:01 [RFC PATCH v2 0/4] PCI Data Object Exchange support + CXL CDAT Jonathan Cameron
2021-04-13 16:01 ` [RFC PATCH v2 1/4] PCI: Add vendor define ID for the PCI SIG Jonathan Cameron
2021-04-13 16:34   ` Bjorn Helgaas
2021-04-13 18:21     ` Jonathan Cameron
2021-04-13 18:38       ` Bjorn Helgaas
2021-04-13 16:01 ` [RFC PATCH v2 2/4] PCI/doe: Initial support PCI Data Object Exchange Jonathan Cameron
2021-04-13 19:49   ` Bjorn Helgaas
2021-04-13 16:01 ` [RFC PATCH v2 3/4] cxl/mem: Add CDAT table reading from DOE Jonathan Cameron
2021-04-13 23:18   ` kernel test robot
2021-04-14  0:30   ` kernel test robot
2021-04-14 18:14   ` Konrad Rzeszutek Wilk
2021-04-14 18:50     ` Ben Widawsky [this message]
2021-04-13 16:01 ` [RFC PATCH v2 4/4] cxl/mem: Add a debug parser for CDAT commands Jonathan Cameron
2021-04-14  4:09 [RFC PATCH v2 3/4] cxl/mem: Add CDAT table reading from DOE kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210414185058.ls5sbp3cow7synqe@intel.com \
    --to=ben.widawsky@intel.com \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=alison.schofield@intel.com \
    --cc=cbrowy@avery-design.com \
    --cc=dan.j.williams@intel.com \
    --cc=f.fangjian@huawei.com \
    --cc=helgaas@kernel.org \
    --cc=ira.weiny@intel.com \
    --cc=konrad.wilk@oracle.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-cxl@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linuxarm@huawei.com \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=vishal.l.verma@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.