All of lore.kernel.org
 help / color / mirror / Atom feed
From: Xu Yilun <yilun.xu@intel.com>
To: broonie@kernel.org, lee.jones@linaro.org, linux-kernel@vger.kernel.org
Cc: trix@redhat.com, yilun.xu@intel.com,
	matthew.gerlach@linux.intel.com, russell.h.weight@intel.com,
	lgoncalv@redhat.com, hao.wu@intel.com
Subject: [PATCH v2 2/3] regmap: spi-avmm: start with the last SOP on phy rx buffer parsing
Date: Thu, 16 Jul 2020 18:42:53 +0800	[thread overview]
Message-ID: <1594896174-18826-3-git-send-email-yilun.xu@intel.com> (raw)
In-Reply-To: <1594896174-18826-1-git-send-email-yilun.xu@intel.com>

From: Matthew Gerlach <matthew.gerlach@linux.intel.com>

This patch works around a bug in the SPI Slave to Avalon Master bridge.
The SPI slave will send an unexpected extra SOP in the following case.

One in approximately one million read requests results in an apparant
stall on the avalon bus where the SPI slave inserts IDLE characters. When
the stall is over, the slave sends an extra SOP character instead of the
0x7c indicating channel. The other characters are correct.

To eliminate the impact of the bug, this patch changes to look for the
last SOP as the start point of the valid phy rx data.

Signed-off-by: Matthew Gerlach <matthew.gerlach@linux.intel.com>
Signed-off-by: Xu Yilun <yilun.xu@intel.com>
Signed-off-by: Luis Claudio R. Goncalves <lgoncalv@redhat.com>
Signed-off-by: Tom Rix <trix@redhat.com>
---
v2: no change.
---
 drivers/base/regmap/regmap-spi-avmm.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/base/regmap/regmap-spi-avmm.c b/drivers/base/regmap/regmap-spi-avmm.c
index ab329d2..632e018 100644
--- a/drivers/base/regmap/regmap-spi-avmm.c
+++ b/drivers/base/regmap/regmap-spi-avmm.c
@@ -433,14 +433,14 @@ static int pkt_phy_rx_parse(struct device *dev,
 {
 	char *b, *p;
 
-	b = phy_buf;
 	p = trans_buf;
 
-	/* Find the SOP */
-	while (b < phy_buf + phy_len && *b != PKT_SOP)
-		b++;
+	/* Find the last SOP */
+	b = (phy_buf + phy_len) - 1;
+	while (b >= phy_buf && *b != PKT_SOP)
+		b--;
 
-	if (b >= phy_buf + phy_len) {
+	if (b < phy_buf) {
 		dev_err(dev, "%s no SOP\n", __func__);
 		return -EINVAL;
 	}
-- 
2.7.4


  parent reply	other threads:[~2020-07-16 10:46 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-16 10:42 [PATCH v2 0/3] add regmap-spi-avmm & Intel Max10 BMC chip support Xu Yilun
2020-07-16 10:42 ` [PATCH v2 1/3] regmap: add Intel SPI Slave to AVMM Bus Bridge support Xu Yilun
2020-07-17 18:15   ` Mark Brown
2020-07-20 17:11     ` Xu Yilun
2020-07-22 11:32       ` Mark Brown
2020-07-23  1:30         ` Xu Yilun
2020-07-16 10:42 ` Xu Yilun [this message]
2020-07-17 12:11   ` [PATCH v2 2/3] regmap: spi-avmm: start with the last SOP on phy rx buffer parsing Mark Brown
2020-07-16 10:42 ` [PATCH v2 3/3] mfd: intel-m10-bmc: add Max10 BMC chip support for Intel FPGA PAC Xu Yilun
2020-07-17  9:45   ` Lee Jones
2020-07-21  3:26     ` Xu Yilun
2020-07-17 18:16   ` Mark Brown
2020-07-21  3:47     ` Xu Yilun
2020-07-21  3:50       ` Xu Yilun

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=1594896174-18826-3-git-send-email-yilun.xu@intel.com \
    --to=yilun.xu@intel.com \
    --cc=broonie@kernel.org \
    --cc=hao.wu@intel.com \
    --cc=lee.jones@linaro.org \
    --cc=lgoncalv@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matthew.gerlach@linux.intel.com \
    --cc=russell.h.weight@intel.com \
    --cc=trix@redhat.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.