Search Linux Wireless

Re: [PATCH 2/2] wifi: brcmfmac: add support for CYW55572 PCIe chipset

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Marek,

kernel test robot noticed the following build warnings:

[auto build test WARNING on wireless-next/main]
[also build test WARNING on wireless/main linus/master v6.11-rc4 next-20240819]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Marek-Vasut/wifi-brcmfmac-add-support-for-CYW55572-PCIe-chipset/20240819-041807
base:   https://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless-next.git main
patch link:    https://lore.kernel.org/r/20240818201533.89669-2-marex%40denx.de
patch subject: [PATCH 2/2] wifi: brcmfmac: add support for CYW55572 PCIe chipset
config: loongarch-randconfig-r123-20240819 (https://download.01.org/0day-ci/archive/20240819/202408191646.1lqp64ie-lkp@xxxxxxxxx/config)
compiler: loongarch64-linux-gcc (GCC) 14.1.0
reproduce: (https://download.01.org/0day-ci/archive/20240819/202408191646.1lqp64ie-lkp@xxxxxxxxx/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202408191646.1lqp64ie-lkp@xxxxxxxxx/

sparse warnings: (new ones prefixed by >>)
>> drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c:1664:29: sparse: sparse: incorrect type in assignment (different base types) @@     expected unsigned int [usertype] signature @@     got restricted __le32 [usertype] @@
   drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c:1664:29: sparse:     expected unsigned int [usertype] signature
   drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c:1664:29: sparse:     got restricted __le32 [usertype]
>> drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c:1665:25: sparse: sparse: incorrect type in assignment (different base types) @@     expected unsigned int [usertype] count @@     got restricted __le32 [usertype] @@
   drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c:1665:25: sparse:     expected unsigned int [usertype] count
   drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c:1665:25: sparse:     got restricted __le32 [usertype]
>> drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c:1841:40: sparse: sparse: incorrect type in argument 3 (different base types) @@     expected unsigned int [usertype] value @@     got restricted __le32 [usertype] @@
   drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c:1841:40: sparse:     expected unsigned int [usertype] value
   drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c:1841:40: sparse:     got restricted __le32 [usertype]

vim +1664 drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c

  1649	
  1650	
  1651	static void
  1652	brcmf_pcie_write_rand(struct brcmf_pciedev_info *devinfo, u32 nvram_csm)
  1653	{
  1654		struct brcmf_rand_metadata rand_data;
  1655		u8 rand_buf[BRCMF_ENTROPY_HOST_LEN];
  1656		u32 count = BRCMF_ENTROPY_HOST_LEN;
  1657		u32 address;
  1658	
  1659		address = devinfo->ci->rambase +
  1660			  (devinfo->ci->ramsize - BRCMF_NVRAM_OFFSET_TCM) -
  1661			  ((nvram_csm & 0xffff) * BRCMF_NVRAM_COMPRS_FACTOR) -
  1662			  sizeof(rand_data);
  1663		memset(rand_buf, 0, BRCMF_ENTROPY_HOST_LEN);
> 1664		rand_data.signature = cpu_to_le32(BRCMF_NVRAM_RNG_SIGNATURE);
> 1665		rand_data.count = cpu_to_le32(count);
  1666		memcpy_toio(devinfo->tcm + address, &rand_data, sizeof(rand_data));
  1667		address -= count;
  1668		get_random_bytes(rand_buf, count);
  1669		memcpy_toio(devinfo->tcm + address, rand_buf, count);
  1670	}
  1671	
  1672	static int
  1673	brcmf_pcie_init_share_ram_info(struct brcmf_pciedev_info *devinfo,
  1674				       u32 sharedram_addr)
  1675	{
  1676		struct brcmf_bus *bus = dev_get_drvdata(&devinfo->pdev->dev);
  1677		struct brcmf_pcie_shared_info *shared;
  1678		u32 addr;
  1679	
  1680		shared = &devinfo->shared;
  1681		shared->tcm_base_address = sharedram_addr;
  1682	
  1683		shared->flags = brcmf_pcie_read_tcm32(devinfo, sharedram_addr);
  1684		shared->version = (u8)(shared->flags & BRCMF_PCIE_SHARED_VERSION_MASK);
  1685		brcmf_dbg(PCIE, "PCIe protocol version %d\n", shared->version);
  1686		if ((shared->version > BRCMF_PCIE_MAX_SHARED_VERSION) ||
  1687		    (shared->version < BRCMF_PCIE_MIN_SHARED_VERSION)) {
  1688			brcmf_err(bus, "Unsupported PCIE version %d\n",
  1689				  shared->version);
  1690			return -EINVAL;
  1691		}
  1692	
  1693		/* check firmware support dma indicies */
  1694		if (shared->flags & BRCMF_PCIE_SHARED_DMA_INDEX) {
  1695			if (shared->flags & BRCMF_PCIE_SHARED_DMA_2B_IDX)
  1696				devinfo->dma_idx_sz = sizeof(u16);
  1697			else
  1698				devinfo->dma_idx_sz = sizeof(u32);
  1699		}
  1700	
  1701		addr = sharedram_addr + BRCMF_SHARED_MAX_RXBUFPOST_OFFSET;
  1702		shared->max_rxbufpost = brcmf_pcie_read_tcm16(devinfo, addr);
  1703		if (shared->max_rxbufpost == 0)
  1704			shared->max_rxbufpost = BRCMF_DEF_MAX_RXBUFPOST;
  1705	
  1706		addr = sharedram_addr + BRCMF_SHARED_RX_DATAOFFSET_OFFSET;
  1707		shared->rx_dataoffset = brcmf_pcie_read_tcm32(devinfo, addr);
  1708	
  1709		addr = sharedram_addr + BRCMF_SHARED_HTOD_MB_DATA_ADDR_OFFSET;
  1710		shared->htod_mb_data_addr = brcmf_pcie_read_tcm32(devinfo, addr);
  1711	
  1712		addr = sharedram_addr + BRCMF_SHARED_DTOH_MB_DATA_ADDR_OFFSET;
  1713		shared->dtoh_mb_data_addr = brcmf_pcie_read_tcm32(devinfo, addr);
  1714	
  1715		addr = sharedram_addr + BRCMF_SHARED_RING_INFO_ADDR_OFFSET;
  1716		shared->ring_info_addr = brcmf_pcie_read_tcm32(devinfo, addr);
  1717	
  1718		brcmf_dbg(PCIE, "max rx buf post %d, rx dataoffset %d\n",
  1719			  shared->max_rxbufpost, shared->rx_dataoffset);
  1720	
  1721		brcmf_pcie_bus_console_init(devinfo);
  1722		brcmf_pcie_bus_console_read(devinfo, false);
  1723	
  1724		return 0;
  1725	}
  1726	
  1727	struct brcmf_random_seed_footer {
  1728		__le32 length;
  1729		__le32 magic;
  1730	};
  1731	
  1732	#define BRCMF_RANDOM_SEED_MAGIC		0xfeedc0de
  1733	#define BRCMF_RANDOM_SEED_LENGTH	0x100
  1734	
  1735	static noinline_for_stack void
  1736	brcmf_pcie_provide_random_bytes(struct brcmf_pciedev_info *devinfo, u32 address)
  1737	{
  1738		u8 randbuf[BRCMF_RANDOM_SEED_LENGTH];
  1739	
  1740		get_random_bytes(randbuf, BRCMF_RANDOM_SEED_LENGTH);
  1741		memcpy_toio(devinfo->tcm + address, randbuf, BRCMF_RANDOM_SEED_LENGTH);
  1742	}
  1743	
  1744	static int brcmf_pcie_download_fw_nvram(struct brcmf_pciedev_info *devinfo,
  1745						const struct firmware *fw, void *nvram,
  1746						u32 nvram_len)
  1747	{
  1748		struct brcmf_bus *bus = dev_get_drvdata(&devinfo->pdev->dev);
  1749		struct trx_header_le *trx = (struct trx_header_le *)fw->data;
  1750		u32 fw_size;
  1751		u32 sharedram_addr;
  1752		u32 sharedram_addr_written;
  1753		u32 loop_counter;
  1754		int err;
  1755		u32 address;
  1756		u32 resetintr;
  1757		u32 nvram_lenw;
  1758		u32 nvram_csm;
  1759	
  1760		brcmf_dbg(PCIE, "Halt ARM.\n");
  1761		err = brcmf_pcie_enter_download_state(devinfo);
  1762		if (err)
  1763			return err;
  1764	
  1765		brcmf_dbg(PCIE, "Download FW %s\n", devinfo->fw_name);
  1766		address = devinfo->ci->rambase;
  1767		fw_size = fw->size;
  1768		if (trx->magic == cpu_to_le32(TRX_MAGIC)) {
  1769			address -= sizeof(struct trx_header_le);
  1770			fw_size = le32_to_cpu(trx->len);
  1771		}
  1772		memcpy_toio(devinfo->tcm + address, (void *)fw->data, fw_size);
  1773	
  1774		resetintr = get_unaligned_le32(fw->data);
  1775		release_firmware(fw);
  1776	
  1777		if (devinfo->ci->blhs) {
  1778			err = devinfo->ci->blhs->post_fwdl(devinfo->ci);
  1779			if (err) {
  1780				brcmf_err(bus, "FW download failed, err=%d\n", err);
  1781				return err;
  1782			}
  1783	
  1784			err = devinfo->ci->blhs->chk_validation(devinfo->ci);
  1785			if (err) {
  1786				brcmf_err(bus, "FW valication failed, err=%d\n", err);
  1787				return err;
  1788			}
  1789		} else {
  1790			/* reset last 4 bytes of RAM address. to be used for shared
  1791			 * area. This identifies when FW is running
  1792			 */
  1793			brcmf_pcie_write_ram32(devinfo, devinfo->ci->ramsize - 4, 0);
  1794		}
  1795	
  1796		if (nvram) {
  1797			brcmf_dbg(PCIE, "Download NVRAM %s\n", devinfo->nvram_name);
  1798			address = devinfo->ci->rambase + devinfo->ci->ramsize -
  1799				  nvram_len;
  1800	
  1801			if (devinfo->ci->blhs)
  1802				address -= 4;
  1803			memcpy_toio(devinfo->tcm + address, nvram, nvram_len);
  1804	
  1805			/* Convert nvram_len to words to determine the length token */
  1806			nvram_lenw = nvram_len / 4;
  1807			/* subtract word used to store the token itself on non-blhs devices */
  1808			if (!devinfo->ci->blhs)
  1809				nvram_lenw -= 1;
  1810			nvram_csm = (~nvram_lenw << 16) | (nvram_lenw & 0x0000FFFF);
  1811			brcmf_fw_nvram_free(nvram);
  1812	
  1813			if (devinfo->otp.valid) {
  1814				size_t rand_len = BRCMF_RANDOM_SEED_LENGTH;
  1815				struct brcmf_random_seed_footer footer = {
  1816					.length = cpu_to_le32(rand_len),
  1817					.magic = cpu_to_le32(BRCMF_RANDOM_SEED_MAGIC),
  1818				};
  1819	
  1820				/* Some Apple chips/firmwares expect a buffer of random
  1821				 * data to be present before NVRAM
  1822				 */
  1823				brcmf_dbg(PCIE, "Download random seed\n");
  1824	
  1825				address -= sizeof(footer);
  1826				memcpy_toio(devinfo->tcm + address, &footer,
  1827					    sizeof(footer));
  1828	
  1829				address -= rand_len;
  1830				brcmf_pcie_provide_random_bytes(devinfo, address);
  1831			}
  1832		} else {
  1833			nvram_csm = 0;
  1834			brcmf_dbg(PCIE, "No matching NVRAM file found %s\n",
  1835				  devinfo->nvram_name);
  1836		}
  1837	
  1838		if (devinfo->ci->chip == CY_CC_55572_CHIP_ID) {
  1839			/* Write the length token to the last word of RAM address */
  1840			brcmf_pcie_write_ram32(devinfo, devinfo->ci->ramsize - 4,
> 1841					       cpu_to_le32(nvram_csm));
  1842	
  1843			/* Write random numbers to TCM for randomizing heap address */
  1844			brcmf_pcie_write_rand(devinfo, nvram_csm);
  1845		}
  1846	
  1847		sharedram_addr_written = brcmf_pcie_read_ram32(devinfo,
  1848							       devinfo->ci->ramsize -
  1849							       4);
  1850		brcmf_dbg(PCIE, "Bring ARM in running state\n");
  1851		err = brcmf_pcie_exit_download_state(devinfo, resetintr);
  1852		if (err)
  1853			return err;
  1854	
  1855		brcmf_dbg(PCIE, "Wait for FW init\n");
  1856		sharedram_addr = sharedram_addr_written;
  1857		loop_counter = BRCMF_PCIE_FW_UP_TIMEOUT / 50;
  1858		while ((sharedram_addr == sharedram_addr_written) && (loop_counter)) {
  1859			msleep(50);
  1860			sharedram_addr = brcmf_pcie_read_ram32(devinfo,
  1861							       devinfo->ci->ramsize -
  1862							       4);
  1863			loop_counter--;
  1864		}
  1865		if (sharedram_addr == sharedram_addr_written) {
  1866			brcmf_err(bus, "FW failed to initialize\n");
  1867			return -ENODEV;
  1868		}
  1869		if (sharedram_addr < devinfo->ci->rambase ||
  1870		    sharedram_addr >= devinfo->ci->rambase + devinfo->ci->ramsize) {
  1871			brcmf_err(bus, "Invalid shared RAM address 0x%08x\n",
  1872				  sharedram_addr);
  1873			return -ENODEV;
  1874		}
  1875		brcmf_dbg(PCIE, "Shared RAM addr: 0x%08x\n", sharedram_addr);
  1876	
  1877		return (brcmf_pcie_init_share_ram_info(devinfo, sharedram_addr));
  1878	}
  1879	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki




[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Wireless Personal Area Network]     [Linux Bluetooth]     [Wireless Regulations]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Hiking]     [MIPS Linux]     [ARM Linux]     [Linux RAID]

  Powered by Linux