From owner-svn-src-stable-11@freebsd.org Thu Mar 1 05:06:17 2018 Return-Path: Delivered-To: svn-src-stable-11@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9D146F4AA87; Thu, 1 Mar 2018 05:06:17 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 52B537BD34; Thu, 1 Mar 2018 05:06:17 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3382423DE6; Thu, 1 Mar 2018 05:06:17 +0000 (UTC) (envelope-from eadler@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w2156Hk4010908; Thu, 1 Mar 2018 05:06:17 GMT (envelope-from eadler@FreeBSD.org) Received: (from eadler@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w2156Hil010907; Thu, 1 Mar 2018 05:06:17 GMT (envelope-from eadler@FreeBSD.org) Message-Id: <201803010506.w2156Hil010907@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: eadler set sender to eadler@FreeBSD.org using -f From: Eitan Adler Date: Thu, 1 Mar 2018 05:06:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r330160 - stable/11/sys/dev/iwm X-SVN-Group: stable-11 X-SVN-Commit-Author: eadler X-SVN-Commit-Paths: stable/11/sys/dev/iwm X-SVN-Commit-Revision: 330160 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-11@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for only the 11-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Mar 2018 05:06:17 -0000 Author: eadler Date: Thu Mar 1 05:06:16 2018 New Revision: 330160 URL: https://svnweb.freebsd.org/changeset/base/330160 Log: MFC r308777: [iwm] Sync iwm_nvm_read_chunk() function with Linux iwlwifi. This fixes an error handling detail in iwm_nvm_read_chunk(), where an error response from the firmware for an NVM read shouldn't be fatal if the offset was non-zero. Modified: stable/11/sys/dev/iwm/if_iwm.c Directory Properties: stable/11/ (props changed) Modified: stable/11/sys/dev/iwm/if_iwm.c ============================================================================== --- stable/11/sys/dev/iwm/if_iwm.c Thu Mar 1 05:05:08 2018 (r330159) +++ stable/11/sys/dev/iwm/if_iwm.c Thu Mar 1 05:06:16 2018 (r330160) @@ -1666,8 +1666,10 @@ const int nvm_to_read[] = { #define IWM_NVM_READ_OPCODE 0 /* load nvm chunk response */ -#define IWM_READ_NVM_CHUNK_SUCCEED 0 -#define IWM_READ_NVM_CHUNK_INVALID_ADDRESS 1 +enum { + IWM_READ_NVM_CHUNK_SUCCEED = 0, + IWM_READ_NVM_CHUNK_NOT_VALID_ADDRESS = 1 +}; static int iwm_nvm_read_chunk(struct iwm_softc *sc, uint16_t section, @@ -1684,12 +1686,10 @@ iwm_nvm_read_chunk(struct iwm_softc *sc, uint16_t sect struct iwm_rx_packet *pkt; struct iwm_host_cmd cmd = { .id = IWM_NVM_ACCESS_CMD, - .flags = IWM_CMD_SYNC | IWM_CMD_WANT_SKB | - IWM_CMD_SEND_IN_RFKILL, + .flags = IWM_CMD_WANT_SKB | IWM_CMD_SEND_IN_RFKILL, .data = { &nvm_access_cmd, }, }; - int ret, offset_read; - size_t bytes_read; + int ret, bytes_read, offset_read; uint8_t *resp_data; cmd.len[0] = sizeof(struct iwm_nvm_access_cmd); @@ -1718,9 +1718,26 @@ iwm_nvm_read_chunk(struct iwm_softc *sc, uint16_t sect offset_read = le16toh(nvm_resp->offset); resp_data = nvm_resp->data; if (ret) { - IWM_DPRINTF(sc, IWM_DEBUG_RESET, - "NVM access command failed with status %d\n", ret); - ret = EINVAL; + if ((offset != 0) && + (ret == IWM_READ_NVM_CHUNK_NOT_VALID_ADDRESS)) { + /* + * meaning of NOT_VALID_ADDRESS: + * driver try to read chunk from address that is + * multiple of 2K and got an error since addr is empty. + * meaning of (offset != 0): driver already + * read valid data from another chunk so this case + * is not an error. + */ + IWM_DPRINTF(sc, IWM_DEBUG_EEPROM | IWM_DEBUG_RESET, + "NVM access command failed on offset 0x%x since that section size is multiple 2K\n", + offset); + *len = 0; + ret = 0; + } else { + IWM_DPRINTF(sc, IWM_DEBUG_EEPROM | IWM_DEBUG_RESET, + "NVM access command failed with status %d\n", ret); + ret = EIO; + } goto exit; } @@ -1735,7 +1752,7 @@ iwm_nvm_read_chunk(struct iwm_softc *sc, uint16_t sect if (bytes_read > length) { device_printf(sc->sc_dev, "NVM ACCESS response with too much data " - "(%d bytes requested, %zd bytes received)\n", + "(%d bytes requested, %d bytes received)\n", length, bytes_read); ret = EINVAL; goto exit;