Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Bluetooth: btintel_pcie: Align shared DMA memory to 128 bytes

Align each descriptor/index/context region to 128 bytes before
calculating the total DMA pool size. This ensures the memory layout
shared with firmware meets the 128-byte alignment requirement.

The DMA pool alignment is also set to 128 bytes to match the firmware
expectation for all shared structures.

Signed-off-by: Kiran K <kiran.k@intel.com>
Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

authored by

Kiran K and committed by
Luiz Augusto von Dentz
9e3d074b 42776497

+53 -44
+53 -41
drivers/bluetooth/btintel_pcie.c
··· 37 37 38 38 #define POLL_INTERVAL_US 10 39 39 40 + #define BTINTEL_PCIE_DMA_ALIGN_128B 128 /* 128 byte aligned */ 41 + 40 42 /* Intel Bluetooth PCIe device id table */ 41 43 static const struct pci_device_id btintel_pcie_table[] = { 42 44 /* BlazarI, Wildcat Lake */ ··· 1753 1751 return 0; 1754 1752 } 1755 1753 1756 - static void btintel_pcie_setup_ia(struct btintel_pcie_data *data, 1757 - dma_addr_t p_addr, void *v_addr, 1758 - struct ia *ia) 1759 - { 1760 - /* TR Head Index Array */ 1761 - ia->tr_hia_p_addr = p_addr; 1762 - ia->tr_hia = v_addr; 1763 - 1764 - /* TR Tail Index Array */ 1765 - ia->tr_tia_p_addr = p_addr + sizeof(u16) * BTINTEL_PCIE_NUM_QUEUES; 1766 - ia->tr_tia = v_addr + sizeof(u16) * BTINTEL_PCIE_NUM_QUEUES; 1767 - 1768 - /* CR Head index Array */ 1769 - ia->cr_hia_p_addr = p_addr + (sizeof(u16) * BTINTEL_PCIE_NUM_QUEUES * 2); 1770 - ia->cr_hia = v_addr + (sizeof(u16) * BTINTEL_PCIE_NUM_QUEUES * 2); 1771 - 1772 - /* CR Tail Index Array */ 1773 - ia->cr_tia_p_addr = p_addr + (sizeof(u16) * BTINTEL_PCIE_NUM_QUEUES * 3); 1774 - ia->cr_tia = v_addr + (sizeof(u16) * BTINTEL_PCIE_NUM_QUEUES * 3); 1775 - } 1776 - 1777 1754 static void btintel_pcie_free(struct btintel_pcie_data *data) 1778 1755 { 1779 1756 btintel_pcie_free_rxq_bufs(data, &data->rxq); ··· 1770 1789 size_t total; 1771 1790 dma_addr_t p_addr; 1772 1791 void *v_addr; 1792 + size_t tfd_size, frbd_size, ctx_size, ci_size, urbd0_size, urbd1_size; 1773 1793 1774 1794 /* Allocate the chunk of DMA memory for descriptors, index array, and 1775 1795 * context information, instead of allocating individually. 1776 1796 * The DMA memory for data buffer is allocated while setting up the 1777 1797 * each queue. 1778 1798 * 1779 - * Total size is sum of the following 1799 + * Total size is sum of the following and each of the individual sizes 1800 + * are aligned to 128 bytes before adding up. 1801 + * 1780 1802 * + size of TFD * Number of descriptors in queue 1781 1803 * + size of URBD0 * Number of descriptors in queue 1782 1804 * + size of FRBD * Number of descriptors in queue ··· 1787 1803 * + size of index * Number of queues(2) * type of index array(4) 1788 1804 * + size of context information 1789 1805 */ 1790 - total = (sizeof(struct tfd) + sizeof(struct urbd0)) * BTINTEL_PCIE_TX_DESCS_COUNT; 1791 - total += (sizeof(struct frbd) + sizeof(struct urbd1)) * BTINTEL_PCIE_RX_DESCS_COUNT; 1806 + tfd_size = ALIGN(sizeof(struct tfd) * BTINTEL_PCIE_TX_DESCS_COUNT, 1807 + BTINTEL_PCIE_DMA_ALIGN_128B); 1808 + urbd0_size = ALIGN(sizeof(struct urbd0) * BTINTEL_PCIE_TX_DESCS_COUNT, 1809 + BTINTEL_PCIE_DMA_ALIGN_128B); 1792 1810 1793 - /* Add the sum of size of index array and size of ci struct */ 1794 - total += (sizeof(u16) * BTINTEL_PCIE_NUM_QUEUES * 4) + sizeof(struct ctx_info); 1811 + frbd_size = ALIGN(sizeof(struct frbd) * BTINTEL_PCIE_RX_DESCS_COUNT, 1812 + BTINTEL_PCIE_DMA_ALIGN_128B); 1813 + urbd1_size = ALIGN(sizeof(struct urbd1) * BTINTEL_PCIE_RX_DESCS_COUNT, 1814 + BTINTEL_PCIE_DMA_ALIGN_128B); 1795 1815 1796 - /* Allocate DMA Pool */ 1816 + ci_size = ALIGN(sizeof(u16) * BTINTEL_PCIE_NUM_QUEUES, 1817 + BTINTEL_PCIE_DMA_ALIGN_128B); 1818 + 1819 + ctx_size = ALIGN(sizeof(struct ctx_info), BTINTEL_PCIE_DMA_ALIGN_128B); 1820 + 1821 + total = tfd_size + urbd0_size + frbd_size + urbd1_size + ctx_size + ci_size * 4; 1822 + 1797 1823 data->dma_pool = dma_pool_create(KBUILD_MODNAME, &data->pdev->dev, 1798 - total, BTINTEL_PCIE_DMA_POOL_ALIGNMENT, 0); 1824 + total, BTINTEL_PCIE_DMA_ALIGN_128B, 0); 1799 1825 if (!data->dma_pool) { 1800 1826 err = -ENOMEM; 1801 1827 goto exit_error; ··· 1830 1836 data->txq.tfds_p_addr = p_addr; 1831 1837 data->txq.tfds = v_addr; 1832 1838 1833 - p_addr += (sizeof(struct tfd) * BTINTEL_PCIE_TX_DESCS_COUNT); 1834 - v_addr += (sizeof(struct tfd) * BTINTEL_PCIE_TX_DESCS_COUNT); 1839 + p_addr += tfd_size; 1840 + v_addr += tfd_size; 1835 1841 1836 1842 /* Setup urbd0 */ 1837 1843 data->txq.urbd0s_p_addr = p_addr; 1838 1844 data->txq.urbd0s = v_addr; 1839 1845 1840 - p_addr += (sizeof(struct urbd0) * BTINTEL_PCIE_TX_DESCS_COUNT); 1841 - v_addr += (sizeof(struct urbd0) * BTINTEL_PCIE_TX_DESCS_COUNT); 1846 + p_addr += urbd0_size; 1847 + v_addr += urbd0_size; 1842 1848 1843 1849 /* Setup FRBD*/ 1844 1850 data->rxq.frbds_p_addr = p_addr; 1845 1851 data->rxq.frbds = v_addr; 1846 1852 1847 - p_addr += (sizeof(struct frbd) * BTINTEL_PCIE_RX_DESCS_COUNT); 1848 - v_addr += (sizeof(struct frbd) * BTINTEL_PCIE_RX_DESCS_COUNT); 1853 + p_addr += frbd_size; 1854 + v_addr += frbd_size; 1849 1855 1850 1856 /* Setup urbd1 */ 1851 1857 data->rxq.urbd1s_p_addr = p_addr; 1852 1858 data->rxq.urbd1s = v_addr; 1853 1859 1854 - p_addr += (sizeof(struct urbd1) * BTINTEL_PCIE_RX_DESCS_COUNT); 1855 - v_addr += (sizeof(struct urbd1) * BTINTEL_PCIE_RX_DESCS_COUNT); 1860 + p_addr += urbd1_size; 1861 + v_addr += urbd1_size; 1856 1862 1857 1863 /* Setup data buffers for txq */ 1858 1864 err = btintel_pcie_setup_txq_bufs(data, &data->txq); ··· 1864 1870 if (err) 1865 1871 goto exit_error_txq; 1866 1872 1867 - /* Setup Index Array */ 1868 - btintel_pcie_setup_ia(data, p_addr, v_addr, &data->ia); 1873 + /* TR Head Index Array */ 1874 + data->ia.tr_hia_p_addr = p_addr; 1875 + data->ia.tr_hia = v_addr; 1876 + p_addr += ci_size; 1877 + v_addr += ci_size; 1878 + 1879 + /* TR Tail Index Array */ 1880 + data->ia.tr_tia_p_addr = p_addr; 1881 + data->ia.tr_tia = v_addr; 1882 + p_addr += ci_size; 1883 + v_addr += ci_size; 1884 + 1885 + /* CR Head index Array */ 1886 + data->ia.cr_hia_p_addr = p_addr; 1887 + data->ia.cr_hia = v_addr; 1888 + p_addr += ci_size; 1889 + v_addr += ci_size; 1890 + 1891 + /* CR Tail Index Array */ 1892 + data->ia.cr_tia_p_addr = p_addr; 1893 + data->ia.cr_tia = v_addr; 1894 + p_addr += ci_size; 1895 + v_addr += ci_size; 1869 1896 1870 1897 /* Setup data buffers for dbgc */ 1871 1898 err = btintel_pcie_setup_dbgc(data); ··· 1894 1879 goto exit_error_txq; 1895 1880 1896 1881 /* Setup Context Information */ 1897 - p_addr += sizeof(u16) * BTINTEL_PCIE_NUM_QUEUES * 4; 1898 - v_addr += sizeof(u16) * BTINTEL_PCIE_NUM_QUEUES * 4; 1899 - 1900 1882 data->ci = v_addr; 1901 1883 data->ci_p_addr = p_addr; 1902 1884
-3
drivers/bluetooth/btintel_pcie.h
··· 178 178 /* The size of DMA buffer for TX and RX in bytes */ 179 179 #define BTINTEL_PCIE_BUFFER_SIZE 4096 180 180 181 - /* DMA allocation alignment */ 182 - #define BTINTEL_PCIE_DMA_POOL_ALIGNMENT 256 183 - 184 181 #define BTINTEL_PCIE_TX_WAIT_TIMEOUT_MS 500 185 182 186 183 /* Doorbell vector for TFD */