2019-05-06 13:16:54

by Jean Delvare

[permalink] [raw]
Subject: [PATCH 1/2] eeprom: ee1004: Move selected page detection to a separate function

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

Signed-off-by: Jean Delvare <[email protected]>
Tested-by: Jarkko Nikula <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
---
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


2019-05-06 13:18:21

by Jean Delvare

[permalink] [raw]
Subject: [PATCH 2/2] eeprom: ee1004: Deal with nack on page selection

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 <[email protected]>
Tested-by: Jarkko Nikula <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
---
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

2019-05-06 14:05:33

by Jarkko Nikula

[permalink] [raw]
Subject: Re: [PATCH 2/2] eeprom: ee1004: Deal with nack on page selection

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 <[email protected]>
> Tested-by: Jarkko Nikula <[email protected]>
> Cc: Arnd Bergmann <[email protected]>
> Cc: Greg Kroah-Hartman <[email protected]>
> ---
> 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

2019-05-06 14:32:19

by Dreamcat4

[permalink] [raw]
Subject: Re: [PATCH 2/2] eeprom: ee1004: Deal with nack on page selection

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

On Mon, May 6, 2019 at 3:04 PM Jarkko Nikula
<[email protected]> 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 <[email protected]>
> > Tested-by: Jarkko Nikula <[email protected]>
> > Cc: Arnd Bergmann <[email protected]>
> > Cc: Greg Kroah-Hartman <[email protected]>
> > ---
> > 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

2019-05-06 15:19:26

by Jean Delvare

[permalink] [raw]
Subject: Re: [PATCH 2/2] eeprom: ee1004: Deal with nack on page selection

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 <[email protected]>
> > Tested-by: Jarkko Nikula <[email protected]>
> > Cc: Arnd Bergmann <[email protected]>
> > Cc: Greg Kroah-Hartman <[email protected]>
> > ---
> > 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