net/sfc/base: report correct partition write chunk size
authorAndy Moreton <amoreton@solarflare.com>
Thu, 16 Nov 2017 08:03:58 +0000 (08:03 +0000)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 16 Jan 2018 17:47:49 +0000 (18:47 +0100)
If the firmware reports a non-zero write chunk size then nvram writes
may fail if a different granularity is used (e.g. for MUM firmware on
Sorrento).

Signed-off-by: Andy Moreton <amoreton@solarflare.com>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
drivers/net/sfc/base/ef10_nvram.c

index fdd7646..a70838b 100644 (file)
@@ -2310,16 +2310,27 @@ ef10_nvram_partn_rw_start(
        __in                    uint32_t partn,
        __out                   size_t *chunk_sizep)
 {
+       uint32_t write_size = 0;
        efx_rc_t rc;
 
-       if ((rc = ef10_nvram_partn_lock(enp, partn)) != 0)
+       if ((rc = efx_mcdi_nvram_info(enp, partn, NULL, NULL,
+           NULL, &write_size)) != 0)
                goto fail1;
 
-       if (chunk_sizep != NULL)
-               *chunk_sizep = EF10_NVRAM_CHUNK;
+       if ((rc = ef10_nvram_partn_lock(enp, partn)) != 0)
+               goto fail2;
+
+       if (chunk_sizep != NULL) {
+               if (write_size == 0)
+                       *chunk_sizep = EF10_NVRAM_CHUNK;
+               else
+                       *chunk_sizep = write_size;
+       }
 
        return (0);
 
+fail2:
+       EFSYS_PROBE(fail2);
 fail1:
        EFSYS_PROBE1(fail1, efx_rc_t, rc);