linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] eeprom: ee1004: Move selected page detection to a separate function
@ 2019-05-06 13:15 Jean Delvare
  2019-05-06 13:16 ` [PATCH 2/2] eeprom: ee1004: Deal with nack on page selection Jean Delvare
  0 siblings, 1 reply; 5+ messages in thread
From: Jean Delvare @ 2019-05-06 13:15 UTC (permalink / raw)
  To: LKML; +Cc: Linux I2C, Arnd Bergmann, Greg Kroah-Hartman, Jarkko Nikula

No functional change, this is in preparation for future needs.

Signed-off-by: Jean Delvare <jdelvare@suse.de>
Tested-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/misc/eeprom/ee1004.c |   31 +++++++++++++++++++++----------
 1 file changed, 21 insertions(+), 10 deletions(-)

--- linux-5.0.orig/drivers/misc/eeprom/ee1004.c	2019-05-06 11:23:14.833319076 +0200
+++ linux-5.0/drivers/misc/eeprom/ee1004.c	2019-05-06 11:56:58.478375343 +0200
@@ -57,6 +57,24 @@ MODULE_DEVICE_TABLE(i2c, ee1004_ids);
 
 /*-------------------------------------------------------------------------*/
 
+static int ee1004_get_current_page(void)
+{
+	int err;
+
+	err = i2c_smbus_read_byte(ee1004_set_page[0]);
+	if (err == -ENXIO) {
+		/* Nack means page 1 is selected */
+		return 1;
+	}
+	if (err < 0) {
+		/* Anything else is a real error, bail out */
+		return err;
+	}
+
+	/* Ack means page 0 is selected, returned value meaningless */
+	return 0;
+}
+
 static ssize_t ee1004_eeprom_read(struct i2c_client *client, char *buf,
 				  unsigned int offset, size_t count)
 {
@@ -190,17 +208,10 @@ static int ee1004_probe(struct i2c_clien
 	}
 
 	/* Remember current page to avoid unneeded page select */
-	err = i2c_smbus_read_byte(ee1004_set_page[0]);
-	if (err == -ENXIO) {
-		/* Nack means page 1 is selected */
-		ee1004_current_page = 1;
-	} else if (err < 0) {
-		/* Anything else is a real error, bail out */
+	err = ee1004_get_current_page();
+	if (err < 0)
 		goto err_clients;
-	} else {
-		/* Ack means page 0 is selected, returned value meaningless */
-		ee1004_current_page = 0;
-	}
+	ee1004_current_page = err;
 	dev_dbg(&client->dev, "Currently selected page: %d\n",
 		ee1004_current_page);
 	mutex_unlock(&ee1004_bus_lock);


-- 
Jean Delvare
SUSE L3 Support

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 2/2] eeprom: ee1004: Deal with nack on page selection
  2019-05-06 13:15 [PATCH 1/2] eeprom: ee1004: Move selected page detection to a separate function Jean Delvare
@ 2019-05-06 13:16 ` Jean Delvare
  2019-05-06 14:03   ` Jarkko Nikula
  0 siblings, 1 reply; 5+ messages in thread
From: Jean Delvare @ 2019-05-06 13:16 UTC (permalink / raw)
  To: LKML; +Cc: Linux I2C, Arnd Bergmann, Greg Kroah-Hartman, Jarkko Nikula

Some EE1004 implementations will not properly ack page selection
commands. They still set the page correctly, so there is no actual
error. Deal with this case gracefully by checking the currently
selected page after we receive a nack. If the page is set right then
we can continue.

Signed-off-by: Jean Delvare <jdelvare@suse.de>
Tested-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/misc/eeprom/ee1004.c |   12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

--- linux-5.0.orig/drivers/misc/eeprom/ee1004.c	2019-05-06 11:57:14.333572368 +0200
+++ linux-5.0/drivers/misc/eeprom/ee1004.c	2019-05-06 15:11:06.009718220 +0200
@@ -1,7 +1,7 @@
 /*
  * ee1004 - driver for DDR4 SPD EEPROMs
  *
- * Copyright (C) 2017 Jean Delvare
+ * Copyright (C) 2017-2019 Jean Delvare
  *
  * Based on the at24 driver:
  * Copyright (C) 2005-2007 David Brownell
@@ -124,6 +124,16 @@ static ssize_t ee1004_read(struct file *
 			/* Data is ignored */
 			status = i2c_smbus_write_byte(ee1004_set_page[page],
 						      0x00);
+			if (status == -ENXIO) {
+				/*
+				 * Don't give up just yet. Some memory
+				 * modules will select the page but not
+				 * ack the command. Check which page is
+				 * selected now.
+				 */
+				if (ee1004_get_current_page() == page)
+					status = 0;
+			}
 			if (status < 0) {
 				dev_err(dev, "Failed to select page %d (%d)\n",
 					page, status);

-- 
Jean Delvare
SUSE L3 Support

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] eeprom: ee1004: Deal with nack on page selection
  2019-05-06 13:16 ` [PATCH 2/2] eeprom: ee1004: Deal with nack on page selection Jean Delvare
@ 2019-05-06 14:03   ` Jarkko Nikula
  2019-05-06 14:30     ` Dreamcat4
  2019-05-06 15:16     ` Jean Delvare
  0 siblings, 2 replies; 5+ messages in thread
From: Jarkko Nikula @ 2019-05-06 14:03 UTC (permalink / raw)
  To: Jean Delvare, LKML; +Cc: Linux I2C, Arnd Bergmann, Greg Kroah-Hartman

On 5/6/19 4:16 PM, Jean Delvare wrote:
> Some EE1004 implementations will not properly ack page selection
> commands. They still set the page correctly, so there is no actual
> error. Deal with this case gracefully by checking the currently
> selected page after we receive a nack. If the page is set right then
> we can continue.
> 
> Signed-off-by: Jean Delvare <jdelvare@suse.de>
> Tested-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
> Cc: Arnd Bergmann <arnd@arndb.de>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
>   drivers/misc/eeprom/ee1004.c |   12 +++++++++++-
>   1 file changed, 11 insertions(+), 1 deletion(-)
> 
Does Dreamcat4 deserve reported and tested by tags here? I guess 
anonymous address is fine with those tags?

(I re-tested these two patches on top of v5.1 and they make decode-dimms 
working on a machine with 2-4 * Crucial DD4 dimms)

-- 
Jarkko

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] eeprom: ee1004: Deal with nack on page selection
  2019-05-06 14:03   ` Jarkko Nikula
@ 2019-05-06 14:30     ` Dreamcat4
  2019-05-06 15:16     ` Jean Delvare
  1 sibling, 0 replies; 5+ messages in thread
From: Dreamcat4 @ 2019-05-06 14:30 UTC (permalink / raw)
  To: Jarkko Nikula
  Cc: Jean Delvare, LKML, Linux I2C, Arnd Bergmann, Greg Kroah-Hartman

Don't mind either way, please do as you see fit

On Mon, May 6, 2019 at 3:04 PM Jarkko Nikula
<jarkko.nikula@linux.intel.com> wrote:
>
> On 5/6/19 4:16 PM, Jean Delvare wrote:
> > Some EE1004 implementations will not properly ack page selection
> > commands. They still set the page correctly, so there is no actual
> > error. Deal with this case gracefully by checking the currently
> > selected page after we receive a nack. If the page is set right then
> > we can continue.
> >
> > Signed-off-by: Jean Delvare <jdelvare@suse.de>
> > Tested-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
> > Cc: Arnd Bergmann <arnd@arndb.de>
> > Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > ---
> >   drivers/misc/eeprom/ee1004.c |   12 +++++++++++-
> >   1 file changed, 11 insertions(+), 1 deletion(-)
> >
> Does Dreamcat4 deserve reported and tested by tags here? I guess
> anonymous address is fine with those tags?
>
> (I re-tested these two patches on top of v5.1 and they make decode-dimms
> working on a machine with 2-4 * Crucial DD4 dimms)
>
> --
> Jarkko

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/2] eeprom: ee1004: Deal with nack on page selection
  2019-05-06 14:03   ` Jarkko Nikula
  2019-05-06 14:30     ` Dreamcat4
@ 2019-05-06 15:16     ` Jean Delvare
  1 sibling, 0 replies; 5+ messages in thread
From: Jean Delvare @ 2019-05-06 15:16 UTC (permalink / raw)
  To: Jarkko Nikula; +Cc: LKML, Linux I2C, Arnd Bergmann, Greg Kroah-Hartman

On Mon, 6 May 2019 17:03:20 +0300, Jarkko Nikula wrote:
> On 5/6/19 4:16 PM, Jean Delvare wrote:
> > Some EE1004 implementations will not properly ack page selection
> > commands. They still set the page correctly, so there is no actual
> > error. Deal with this case gracefully by checking the currently
> > selected page after we receive a nack. If the page is set right then
> > we can continue.
> > 
> > Signed-off-by: Jean Delvare <jdelvare@suse.de>
> > Tested-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
> > Cc: Arnd Bergmann <arnd@arndb.de>
> > Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > ---
> >   drivers/misc/eeprom/ee1004.c |   12 +++++++++++-
> >   1 file changed, 11 insertions(+), 1 deletion(-)
>
> Does Dreamcat4 deserve reported and tested by tags here? I guess 
> anonymous address is fine with those tags?

My assumption is that someone who posts anonymously in the first place
has no desire to be credited for anything or even mentioned anywhere.

> (I re-tested these two patches on top of v5.1 and they make decode-dimms 
> working on a machine with 2-4 * Crucial DD4 dimms)

Thank you very much.

-- 
Jean Delvare
SUSE L3 Support

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-05-06 15:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-06 13:15 [PATCH 1/2] eeprom: ee1004: Move selected page detection to a separate function Jean Delvare
2019-05-06 13:16 ` [PATCH 2/2] eeprom: ee1004: Deal with nack on page selection Jean Delvare
2019-05-06 14:03   ` Jarkko Nikula
2019-05-06 14:30     ` Dreamcat4
2019-05-06 15:16     ` Jean Delvare

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).