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

drm/nvc0-/gr: share headers between fermi and kepler graphics code

v2: Ben Skeggs <bskeggs@redhat.com>
- de-inline nv_icmd, triggers some gcc issue causing ctxnv[ce]0.c to
take a *very* *very* long time to build on some configs.

Signed-off-by: Ben Skeggs <bskeggs@redhat.com>

+143 -204
+21 -28
drivers/gpu/drm/nouveau/core/engine/graph/ctxnvc0.c
··· 27 27 #include <core/mm.h> 28 28 #include "nvc0.h" 29 29 30 - static void 30 + void 31 31 nv_icmd(struct drm_device *priv, u32 icmd, u32 data) 32 32 { 33 33 nv_wr32(priv, 0x400204, data); 34 34 nv_wr32(priv, 0x400200, icmd); 35 35 while (nv_rd32(priv, 0x400700) & 2) {} 36 - } 37 - 38 - static void 39 - nv_mthd(struct drm_device *priv, u32 class, u32 mthd, u32 data) 40 - { 41 - nv_wr32(priv, 0x40448c, data); 42 - nv_wr32(priv, 0x404488, 0x80000000 | (mthd << 14) | class); 43 36 } 44 37 45 38 static void ··· 1816 1823 1817 1824 for (tp = 0, id = 0; tp < 4; tp++) { 1818 1825 for (gpc = 0; gpc < oprv->gpc_nr; gpc++) { 1819 - if (tp < oprv->tp_nr[gpc]) { 1820 - nv_wr32(priv, TP_UNIT(gpc, tp, 0x698), id); 1821 - nv_wr32(priv, TP_UNIT(gpc, tp, 0x4e8), id); 1826 + if (tp < oprv->tpc_nr[gpc]) { 1827 + nv_wr32(priv, TPC_UNIT(gpc, tp, 0x698), id); 1828 + nv_wr32(priv, TPC_UNIT(gpc, tp, 0x4e8), id); 1822 1829 nv_wr32(priv, GPC_UNIT(gpc, 0x0c10 + tp * 4), id); 1823 - nv_wr32(priv, TP_UNIT(gpc, tp, 0x088), id); 1830 + nv_wr32(priv, TPC_UNIT(gpc, tp, 0x088), id); 1824 1831 id++; 1825 1832 } 1826 1833 1827 - nv_wr32(priv, GPC_UNIT(gpc, 0x0c08), oprv->tp_nr[gpc]); 1828 - nv_wr32(priv, GPC_UNIT(gpc, 0x0c8c), oprv->tp_nr[gpc]); 1834 + nv_wr32(priv, GPC_UNIT(gpc, 0x0c08), oprv->tpc_nr[gpc]); 1835 + nv_wr32(priv, GPC_UNIT(gpc, 0x0c8c), oprv->tpc_nr[gpc]); 1829 1836 } 1830 1837 } 1831 1838 1832 1839 tmp = 0; 1833 1840 for (i = 0; i < oprv->gpc_nr; i++) 1834 - tmp |= oprv->tp_nr[i] << (i * 4); 1841 + tmp |= oprv->tpc_nr[i] << (i * 4); 1835 1842 nv_wr32(priv, 0x406028, tmp); 1836 1843 nv_wr32(priv, 0x405870, tmp); 1837 1844 ··· 1843 1850 nv_wr32(priv, 0x40587c, 0x00000000); 1844 1851 1845 1852 if (1) { 1846 - u8 tpnr[GPC_MAX], data[TP_MAX]; 1853 + u8 tpnr[GPC_MAX], data[TPC_MAX]; 1847 1854 1848 - memcpy(tpnr, oprv->tp_nr, sizeof(oprv->tp_nr)); 1855 + memcpy(tpnr, oprv->tpc_nr, sizeof(oprv->tpc_nr)); 1849 1856 memset(data, 0x1f, sizeof(data)); 1850 1857 1851 1858 gpc = -1; 1852 - for (tp = 0; tp < oprv->tp_total; tp++) { 1859 + for (tp = 0; tp < oprv->tpc_total; tp++) { 1853 1860 do { 1854 1861 gpc = (gpc + 1) % oprv->gpc_nr; 1855 1862 } while (!tpnr[gpc]); ··· 1867 1874 u8 shift, ntpcv; 1868 1875 1869 1876 /* calculate first set of magics */ 1870 - memcpy(tpnr, oprv->tp_nr, sizeof(oprv->tp_nr)); 1877 + memcpy(tpnr, oprv->tpc_nr, sizeof(oprv->tpc_nr)); 1871 1878 1872 1879 gpc = -1; 1873 - for (tp = 0; tp < oprv->tp_total; tp++) { 1880 + for (tp = 0; tp < oprv->tpc_total; tp++) { 1874 1881 do { 1875 1882 gpc = (gpc + 1) % oprv->gpc_nr; 1876 1883 } while (!tpnr[gpc]); ··· 1884 1891 1885 1892 /* and the second... */ 1886 1893 shift = 0; 1887 - ntpcv = oprv->tp_total; 1894 + ntpcv = oprv->tpc_total; 1888 1895 while (!(ntpcv & (1 << 4))) { 1889 1896 ntpcv <<= 1; 1890 1897 shift++; ··· 1897 1904 data2[1] |= ((1 << (i + 5)) % ntpcv) << ((i - 1) * 5); 1898 1905 1899 1906 /* GPC_BROADCAST */ 1900 - nv_wr32(priv, 0x418bb8, (oprv->tp_total << 8) | 1907 + nv_wr32(priv, 0x418bb8, (oprv->tpc_total << 8) | 1901 1908 oprv->magic_not_rop_nr); 1902 1909 for (i = 0; i < 6; i++) 1903 1910 nv_wr32(priv, 0x418b08 + (i * 4), data[i]); 1904 1911 1905 1912 /* GPC_BROADCAST.TP_BROADCAST */ 1906 - nv_wr32(priv, 0x419bd0, (oprv->tp_total << 8) | 1913 + nv_wr32(priv, 0x419bd0, (oprv->tpc_total << 8) | 1907 1914 oprv->magic_not_rop_nr | 1908 1915 data2[0]); 1909 1916 nv_wr32(priv, 0x419be4, data2[1]); ··· 1911 1918 nv_wr32(priv, 0x419b00 + (i * 4), data[i]); 1912 1919 1913 1920 /* UNK78xx */ 1914 - nv_wr32(priv, 0x4078bc, (oprv->tp_total << 8) | 1921 + nv_wr32(priv, 0x4078bc, (oprv->tpc_total << 8) | 1915 1922 oprv->magic_not_rop_nr); 1916 1923 for (i = 0; i < 6; i++) 1917 1924 nv_wr32(priv, 0x40780c + (i * 4), data[i]); ··· 1921 1928 u32 tp_mask = 0, tp_set = 0; 1922 1929 u8 tpnr[GPC_MAX], a, b; 1923 1930 1924 - memcpy(tpnr, oprv->tp_nr, sizeof(oprv->tp_nr)); 1931 + memcpy(tpnr, oprv->tpc_nr, sizeof(oprv->tpc_nr)); 1925 1932 for (gpc = 0; gpc < oprv->gpc_nr; gpc++) 1926 - tp_mask |= ((1 << oprv->tp_nr[gpc]) - 1) << (gpc * 8); 1933 + tp_mask |= ((1 << oprv->tpc_nr[gpc]) - 1) << (gpc * 8); 1927 1934 1928 1935 for (i = 0, gpc = -1, b = -1; i < 32; i++) { 1929 - a = (i * (oprv->tp_total - 1)) / 32; 1936 + a = (i * (oprv->tpc_total - 1)) / 32; 1930 1937 if (a != b) { 1931 1938 b = a; 1932 1939 do { 1933 1940 gpc = (gpc + 1) % oprv->gpc_nr; 1934 1941 } while (!tpnr[gpc]); 1935 - tp = oprv->tp_nr[gpc] - tpnr[gpc]--; 1942 + tp = oprv->tpc_nr[gpc] - tpnr[gpc]--; 1936 1943 1937 1944 tp_set |= 1 << ((gpc * 8) + tp); 1938 1945 }
+3 -18
drivers/gpu/drm/nouveau/core/engine/graph/ctxnve0.c
··· 25 25 #include "drmP.h" 26 26 #include "nouveau_drv.h" 27 27 #include <core/mm.h> 28 - #include "nve0.h" 29 - 30 - static void 31 - nv_icmd(struct drm_device *priv, u32 icmd, u32 data) 32 - { 33 - nv_wr32(priv, 0x400204, data); 34 - nv_wr32(priv, 0x400200, icmd); 35 - while (nv_rd32(priv, 0x400700) & 0x00000002) {} 36 - } 28 + #include "nvc0.h" 37 29 38 30 static void 39 31 nve0_grctx_generate_icmd(struct drm_device *priv) ··· 913 921 nv_icmd(priv, 0x000b0a, 0x00000001); 914 922 nv_icmd(priv, 0x01e100, 0x00000001); 915 923 nv_wr32(priv, 0x400208, 0x00000000); 916 - } 917 - 918 - static void 919 - nv_mthd(struct drm_device *priv, u32 class, u32 mthd, u32 data) 920 - { 921 - nv_wr32(priv, 0x40448c, data); 922 - nv_wr32(priv, 0x404488, 0x80000000 | (mthd << 14) | class); 923 924 } 924 925 925 926 static void ··· 2606 2621 int 2607 2622 nve0_grctx_generate(struct nouveau_channel *chan) 2608 2623 { 2609 - struct nve0_graph_priv *oprv = nv_engine(chan->dev, NVOBJ_ENGINE_GR); 2610 - struct nve0_graph_chan *grch = chan->engctx[NVOBJ_ENGINE_GR]; 2624 + struct nvc0_graph_priv *oprv = nv_engine(chan->dev, NVOBJ_ENGINE_GR); 2625 + struct nvc0_graph_chan *grch = chan->engctx[NVOBJ_ENGINE_GR]; 2611 2626 struct drm_device *priv = chan->dev; 2612 2627 u32 data[6] = {}, data2[2] = {}, tmp; 2613 2628 u32 tpc_set = 0, tpc_mask = 0;
+29 -29
drivers/gpu/drm/nouveau/core/engine/graph/nvc0.c
··· 229 229 nv_wo32(grch->mmio, i++ * 4, 0x00405830); 230 230 nv_wo32(grch->mmio, i++ * 4, magic); 231 231 for (gpc = 0; gpc < priv->gpc_nr; gpc++) { 232 - for (tp = 0; tp < priv->tp_nr[gpc]; tp++) { 233 - u32 reg = TP_UNIT(gpc, tp, 0x520); 232 + for (tp = 0; tp < priv->tpc_nr[gpc]; tp++) { 233 + u32 reg = TPC_UNIT(gpc, tp, 0x520); 234 234 nv_wo32(grch->mmio, i++ * 4, reg); 235 235 nv_wo32(grch->mmio, i++ * 4, magic); 236 236 magic += 0x0324; ··· 243 243 nv_wo32(grch->mmio, i++ * 4, 0x004064c4); 244 244 nv_wo32(grch->mmio, i++ * 4, 0x0086ffff); 245 245 for (gpc = 0; gpc < priv->gpc_nr; gpc++) { 246 - for (tp = 0; tp < priv->tp_nr[gpc]; tp++) { 247 - u32 reg = TP_UNIT(gpc, tp, 0x520); 246 + for (tp = 0; tp < priv->tpc_nr[gpc]; tp++) { 247 + u32 reg = TPC_UNIT(gpc, tp, 0x520); 248 248 nv_wo32(grch->mmio, i++ * 4, reg); 249 249 nv_wo32(grch->mmio, i++ * 4, (1 << 28) | magic); 250 250 magic += 0x0324; 251 251 } 252 - for (tp = 0; tp < priv->tp_nr[gpc]; tp++) { 253 - u32 reg = TP_UNIT(gpc, tp, 0x544); 252 + for (tp = 0; tp < priv->tpc_nr[gpc]; tp++) { 253 + u32 reg = TPC_UNIT(gpc, tp, 0x544); 254 254 nv_wo32(grch->mmio, i++ * 4, reg); 255 255 nv_wo32(grch->mmio, i++ * 4, magic); 256 256 magic += 0x0324; ··· 393 393 nvc0_graph_init_gpc_0(struct drm_device *dev) 394 394 { 395 395 struct nvc0_graph_priv *priv = nv_engine(dev, NVOBJ_ENGINE_GR); 396 - const u32 magicgpc918 = DIV_ROUND_UP(0x00800000, priv->tp_total); 397 - u32 data[TP_MAX / 8]; 396 + const u32 magicgpc918 = DIV_ROUND_UP(0x00800000, priv->tpc_total); 397 + u32 data[TPC_MAX / 8]; 398 398 u8 tpnr[GPC_MAX]; 399 399 int i, gpc, tpc; 400 400 401 - nv_wr32(dev, TP_UNIT(0, 0, 0x5c), 1); /* affects TFB offset queries */ 401 + nv_wr32(dev, TPC_UNIT(0, 0, 0x5c), 1); /* affects TFB offset queries */ 402 402 403 403 /* 404 404 * TP ROP UNKVAL(magic_not_rop_nr) ··· 410 410 */ 411 411 412 412 memset(data, 0x00, sizeof(data)); 413 - memcpy(tpnr, priv->tp_nr, sizeof(priv->tp_nr)); 414 - for (i = 0, gpc = -1; i < priv->tp_total; i++) { 413 + memcpy(tpnr, priv->tpc_nr, sizeof(priv->tpc_nr)); 414 + for (i = 0, gpc = -1; i < priv->tpc_total; i++) { 415 415 do { 416 416 gpc = (gpc + 1) % priv->gpc_nr; 417 417 } while (!tpnr[gpc]); 418 - tpc = priv->tp_nr[gpc] - tpnr[gpc]--; 418 + tpc = priv->tpc_nr[gpc] - tpnr[gpc]--; 419 419 420 420 data[i / 8] |= tpc << ((i % 8) * 4); 421 421 } ··· 427 427 428 428 for (gpc = 0; gpc < priv->gpc_nr; gpc++) { 429 429 nv_wr32(dev, GPC_UNIT(gpc, 0x0914), priv->magic_not_rop_nr << 8 | 430 - priv->tp_nr[gpc]); 431 - nv_wr32(dev, GPC_UNIT(gpc, 0x0910), 0x00040000 | priv->tp_total); 430 + priv->tpc_nr[gpc]); 431 + nv_wr32(dev, GPC_UNIT(gpc, 0x0910), 0x00040000 | priv->tpc_total); 432 432 nv_wr32(dev, GPC_UNIT(gpc, 0x0918), magicgpc918); 433 433 } 434 434 ··· 463 463 nv_wr32(dev, GPC_UNIT(gpc, 0x0900), 0xc0000000); 464 464 nv_wr32(dev, GPC_UNIT(gpc, 0x1028), 0xc0000000); 465 465 nv_wr32(dev, GPC_UNIT(gpc, 0x0824), 0xc0000000); 466 - for (tp = 0; tp < priv->tp_nr[gpc]; tp++) { 467 - nv_wr32(dev, TP_UNIT(gpc, tp, 0x508), 0xffffffff); 468 - nv_wr32(dev, TP_UNIT(gpc, tp, 0x50c), 0xffffffff); 469 - nv_wr32(dev, TP_UNIT(gpc, tp, 0x224), 0xc0000000); 470 - nv_wr32(dev, TP_UNIT(gpc, tp, 0x48c), 0xc0000000); 471 - nv_wr32(dev, TP_UNIT(gpc, tp, 0x084), 0xc0000000); 472 - nv_wr32(dev, TP_UNIT(gpc, tp, 0x644), 0x001ffffe); 473 - nv_wr32(dev, TP_UNIT(gpc, tp, 0x64c), 0x0000000f); 466 + for (tp = 0; tp < priv->tpc_nr[gpc]; tp++) { 467 + nv_wr32(dev, TPC_UNIT(gpc, tp, 0x508), 0xffffffff); 468 + nv_wr32(dev, TPC_UNIT(gpc, tp, 0x50c), 0xffffffff); 469 + nv_wr32(dev, TPC_UNIT(gpc, tp, 0x224), 0xc0000000); 470 + nv_wr32(dev, TPC_UNIT(gpc, tp, 0x48c), 0xc0000000); 471 + nv_wr32(dev, TPC_UNIT(gpc, tp, 0x084), 0xc0000000); 472 + nv_wr32(dev, TPC_UNIT(gpc, tp, 0x644), 0x001ffffe); 473 + nv_wr32(dev, TPC_UNIT(gpc, tp, 0x64c), 0x0000000f); 474 474 } 475 475 nv_wr32(dev, GPC_UNIT(gpc, 0x2c90), 0xffffffff); 476 476 nv_wr32(dev, GPC_UNIT(gpc, 0x2c94), 0xffffffff); ··· 858 858 priv->gpc_nr = nv_rd32(dev, 0x409604) & 0x0000001f; 859 859 priv->rop_nr = (nv_rd32(dev, 0x409604) & 0x001f0000) >> 16; 860 860 for (gpc = 0; gpc < priv->gpc_nr; gpc++) { 861 - priv->tp_nr[gpc] = nv_rd32(dev, GPC_UNIT(gpc, 0x2608)); 862 - priv->tp_total += priv->tp_nr[gpc]; 861 + priv->tpc_nr[gpc] = nv_rd32(dev, GPC_UNIT(gpc, 0x2608)); 862 + priv->tpc_total += priv->tpc_nr[gpc]; 863 863 } 864 864 865 865 /*XXX: these need figuring out... */ 866 866 switch (dev_priv->chipset) { 867 867 case 0xc0: 868 - if (priv->tp_total == 11) { /* 465, 3/4/4/0, 4 */ 868 + if (priv->tpc_total == 11) { /* 465, 3/4/4/0, 4 */ 869 869 priv->magic_not_rop_nr = 0x07; 870 870 } else 871 - if (priv->tp_total == 14) { /* 470, 3/3/4/4, 5 */ 871 + if (priv->tpc_total == 14) { /* 470, 3/3/4/4, 5 */ 872 872 priv->magic_not_rop_nr = 0x05; 873 873 } else 874 - if (priv->tp_total == 15) { /* 480, 3/4/4/4, 6 */ 874 + if (priv->tpc_total == 15) { /* 480, 3/4/4/4, 6 */ 875 875 priv->magic_not_rop_nr = 0x06; 876 876 } 877 877 break; ··· 900 900 901 901 if (!priv->magic_not_rop_nr) { 902 902 NV_ERROR(dev, "PGRAPH: unknown config: %d/%d/%d/%d, %d\n", 903 - priv->tp_nr[0], priv->tp_nr[1], priv->tp_nr[2], 904 - priv->tp_nr[3], priv->rop_nr); 903 + priv->tpc_nr[0], priv->tpc_nr[1], priv->tpc_nr[2], 904 + priv->tpc_nr[3], priv->rop_nr); 905 905 priv->magic_not_rop_nr = 0x00; 906 906 } 907 907
+70 -15
drivers/gpu/drm/nouveau/core/engine/graph/nvc0.h
··· 26 26 #define __NVC0_GRAPH_H__ 27 27 28 28 #define GPC_MAX 4 29 - #define TP_MAX 32 29 + #define TPC_MAX 32 30 30 31 - #define ROP_BCAST(r) (0x408800 + (r)) 32 - #define ROP_UNIT(u, r) (0x410000 + (u) * 0x400 + (r)) 33 - #define GPC_BCAST(r) (0x418000 + (r)) 34 - #define GPC_UNIT(t, r) (0x500000 + (t) * 0x8000 + (r)) 35 - #define TP_UNIT(t, m, r) (0x504000 + (t) * 0x8000 + (m) * 0x800 + (r)) 31 + #define ROP_BCAST(r) (0x408800 + (r)) 32 + #define ROP_UNIT(u, r) (0x410000 + (u) * 0x400 + (r)) 33 + #define GPC_BCAST(r) (0x418000 + (r)) 34 + #define GPC_UNIT(t, r) (0x500000 + (t) * 0x8000 + (r)) 35 + #define TPC_UNIT(t, m, r) (0x504000 + (t) * 0x8000 + (m) * 0x800 + (r)) 36 + 37 + struct nvc0_graph_data { 38 + u32 size; 39 + u32 align; 40 + u32 access; 41 + }; 42 + 43 + struct nvc0_graph_mmio { 44 + u32 addr; 45 + u32 data; 46 + u32 shift; 47 + u32 buffer; 48 + }; 36 49 37 50 struct nvc0_graph_fuc { 38 51 u32 *data; ··· 59 46 struct nvc0_graph_fuc fuc409d; 60 47 struct nvc0_graph_fuc fuc41ac; 61 48 struct nvc0_graph_fuc fuc41ad; 49 + bool firmware; 62 50 63 - u8 gpc_nr; 64 51 u8 rop_nr; 65 - u8 tp_nr[GPC_MAX]; 66 - u8 tp_total; 52 + u8 gpc_nr; 53 + u8 tpc_nr[GPC_MAX]; 54 + u8 tpc_total; 67 55 68 56 u32 grctx_size; 69 57 u32 *grctx_vals; ··· 77 63 struct nvc0_graph_chan { 78 64 struct nouveau_gpuobj *grctx; 79 65 struct nouveau_vma grctx_vma; 80 - struct nouveau_gpuobj *unk408004; /* 0x418810 too */ 66 + struct nouveau_gpuobj *unk408004; /* 0x418808 too */ 81 67 struct nouveau_vma unk408004_vma; 82 68 struct nouveau_gpuobj *unk40800c; /* 0x419004 too */ 83 69 struct nouveau_vma unk40800c_vma; 84 70 struct nouveau_gpuobj *unk418810; /* 0x419848 too */ 85 71 struct nouveau_vma unk418810_vma; 72 + 86 73 struct nouveau_gpuobj *mmio; 87 74 struct nouveau_vma mmio_vma; 88 75 int mmio_nr; 89 76 }; 90 77 91 - int nvc0_grctx_generate(struct nouveau_channel *); 92 - 93 - /* nvc0_graph.c uses this also to determine supported chipsets */ 94 78 static inline u32 95 - nvc0_graph_class(struct drm_device *dev) 79 + nvc0_graph_class(struct drm_device *priv) 96 80 { 97 - struct drm_nouveau_private *dev_priv = dev->dev_private; 81 + struct drm_nouveau_private *dev_priv = priv->dev_private; 98 82 99 83 switch (dev_priv->chipset) { 100 84 case 0xc0: ··· 106 94 case 0xc8: 107 95 case 0xd9: 108 96 return 0x9297; 97 + case 0xe4: 98 + case 0xe7: 99 + return 0xa097; 109 100 default: 110 101 return 0; 111 102 } 112 103 } 104 + 105 + void nv_icmd(struct drm_device *priv, u32 icmd, u32 data); 106 + 107 + static inline void 108 + nv_mthd(struct drm_device *priv, u32 class, u32 mthd, u32 data) 109 + { 110 + nv_wr32(priv, 0x40448c, data); 111 + nv_wr32(priv, 0x404488, 0x80000000 | (mthd << 14) | class); 112 + } 113 + 114 + struct nvc0_grctx { 115 + struct nvc0_graph_priv *priv; 116 + struct nvc0_graph_data *data; 117 + struct nvc0_graph_mmio *mmio; 118 + struct nouveau_gpuobj *chan; 119 + int buffer_nr; 120 + u64 buffer[4]; 121 + u64 addr; 122 + }; 123 + 124 + int nvc0_grctx_generate(struct nouveau_channel *); 125 + int nvc0_grctx_init(struct nvc0_graph_priv *, struct nvc0_grctx *); 126 + void nvc0_grctx_data(struct nvc0_grctx *, u32, u32, u32); 127 + void nvc0_grctx_mmio(struct nvc0_grctx *, u32, u32, u32, u32); 128 + int nvc0_grctx_fini(struct nvc0_grctx *); 129 + 130 + int nve0_grctx_generate(struct nouveau_channel *); 131 + 132 + #define mmio_data(s,a,p) nvc0_grctx_data(&info, (s), (a), (p)) 133 + #define mmio_list(r,d,s,b) nvc0_grctx_mmio(&info, (r), (d), (s), (b)) 134 + 135 + int nvc0_graph_ctor_fw(struct nvc0_graph_priv *, const char *, 136 + struct nvc0_graph_fuc *); 137 + void nvc0_graph_dtor(struct nouveau_object *); 138 + void nvc0_graph_init_fw(struct nvc0_graph_priv *, u32 base, 139 + struct nvc0_graph_fuc *, struct nvc0_graph_fuc *); 140 + int nvc0_graph_context_ctor(struct nouveau_object *, struct nouveau_object *, 141 + struct nouveau_oclass *, void *, u32, 142 + struct nouveau_object **); 143 + void nvc0_graph_context_dtor(struct nouveau_object *); 113 144 114 145 #endif
+20 -20
drivers/gpu/drm/nouveau/core/engine/graph/nve0.c
··· 31 31 #include <core/mm.h> 32 32 #include <engine/fifo.h> 33 33 34 - #include "nve0.h" 34 + #include "nvc0.h" 35 35 36 36 static void 37 37 nve0_graph_ctxctl_debug_unit(struct drm_device *dev, u32 base) ··· 88 88 static int 89 89 nve0_graph_construct_context(struct nouveau_channel *chan) 90 90 { 91 - struct nve0_graph_priv *priv = nv_engine(chan->dev, NVOBJ_ENGINE_GR); 92 - struct nve0_graph_chan *grch = chan->engctx[NVOBJ_ENGINE_GR]; 91 + struct nvc0_graph_priv *priv = nv_engine(chan->dev, NVOBJ_ENGINE_GR); 92 + struct nvc0_graph_chan *grch = chan->engctx[NVOBJ_ENGINE_GR]; 93 93 struct drm_device *dev = chan->dev; 94 94 int ret, i; 95 95 u32 *ctx; ··· 128 128 static int 129 129 nve0_graph_create_context_mmio_list(struct nouveau_channel *chan) 130 130 { 131 - struct nve0_graph_priv *priv = nv_engine(chan->dev, NVOBJ_ENGINE_GR); 132 - struct nve0_graph_chan *grch = chan->engctx[NVOBJ_ENGINE_GR]; 131 + struct nvc0_graph_priv *priv = nv_engine(chan->dev, NVOBJ_ENGINE_GR); 132 + struct nvc0_graph_chan *grch = chan->engctx[NVOBJ_ENGINE_GR]; 133 133 struct drm_device *dev = chan->dev; 134 134 u32 magic[GPC_MAX][2]; 135 135 u16 offset = 0x0000; ··· 220 220 nve0_graph_context_new(struct nouveau_channel *chan, int engine) 221 221 { 222 222 struct drm_device *dev = chan->dev; 223 - struct nve0_graph_priv *priv = nv_engine(dev, engine); 224 - struct nve0_graph_chan *grch; 223 + struct nvc0_graph_priv *priv = nv_engine(dev, engine); 224 + struct nvc0_graph_chan *grch; 225 225 struct nouveau_gpuobj *grctx; 226 226 int ret, i; 227 227 ··· 279 279 static void 280 280 nve0_graph_context_del(struct nouveau_channel *chan, int engine) 281 281 { 282 - struct nve0_graph_chan *grch = chan->engctx[engine]; 282 + struct nvc0_graph_chan *grch = chan->engctx[engine]; 283 283 284 284 nouveau_gpuobj_unmap(&grch->mmio_vma); 285 285 nouveau_gpuobj_unmap(&grch->unk418810_vma); ··· 310 310 static void 311 311 nve0_graph_init_obj418880(struct drm_device *dev) 312 312 { 313 - struct nve0_graph_priv *priv = nv_engine(dev, NVOBJ_ENGINE_GR); 313 + struct nvc0_graph_priv *priv = nv_engine(dev, NVOBJ_ENGINE_GR); 314 314 int i; 315 315 316 316 nv_wr32(dev, GPC_BCAST(0x0880), 0x00000000); ··· 362 362 static void 363 363 nve0_graph_init_gpc_0(struct drm_device *dev) 364 364 { 365 - struct nve0_graph_priv *priv = nv_engine(dev, NVOBJ_ENGINE_GR); 365 + struct nvc0_graph_priv *priv = nv_engine(dev, NVOBJ_ENGINE_GR); 366 366 const u32 magicgpc918 = DIV_ROUND_UP(0x00800000, priv->tpc_total); 367 367 u32 data[TPC_MAX / 8]; 368 368 u8 tpcnr[GPC_MAX]; ··· 400 400 static void 401 401 nve0_graph_init_gpc_1(struct drm_device *dev) 402 402 { 403 - struct nve0_graph_priv *priv = nv_engine(dev, NVOBJ_ENGINE_GR); 403 + struct nvc0_graph_priv *priv = nv_engine(dev, NVOBJ_ENGINE_GR); 404 404 int gpc, tpc; 405 405 406 406 for (gpc = 0; gpc < priv->gpc_nr; gpc++) { ··· 426 426 static void 427 427 nve0_graph_init_rop(struct drm_device *dev) 428 428 { 429 - struct nve0_graph_priv *priv = nv_engine(dev, NVOBJ_ENGINE_GR); 429 + struct nvc0_graph_priv *priv = nv_engine(dev, NVOBJ_ENGINE_GR); 430 430 int rop; 431 431 432 432 for (rop = 0; rop < priv->rop_nr; rop++) { ··· 439 439 440 440 static void 441 441 nve0_graph_init_fuc(struct drm_device *dev, u32 fuc_base, 442 - struct nve0_graph_fuc *code, struct nve0_graph_fuc *data) 442 + struct nvc0_graph_fuc *code, struct nvc0_graph_fuc *data) 443 443 { 444 444 int i; 445 445 ··· 458 458 static int 459 459 nve0_graph_init_ctxctl(struct drm_device *dev) 460 460 { 461 - struct nve0_graph_priv *priv = nv_engine(dev, NVOBJ_ENGINE_GR); 461 + struct nvc0_graph_priv *priv = nv_engine(dev, NVOBJ_ENGINE_GR); 462 462 u32 r000260; 463 463 464 464 /* load fuc microcode */ ··· 613 613 static void 614 614 nve0_graph_trap_isr(struct drm_device *dev, int chid) 615 615 { 616 - struct nve0_graph_priv *priv = nv_engine(dev, NVOBJ_ENGINE_GR); 616 + struct nvc0_graph_priv *priv = nv_engine(dev, NVOBJ_ENGINE_GR); 617 617 u32 trap = nv_rd32(dev, 0x400108); 618 618 int rop; 619 619 ··· 716 716 717 717 static int 718 718 nve0_graph_create_fw(struct drm_device *dev, const char *fwname, 719 - struct nve0_graph_fuc *fuc) 719 + struct nvc0_graph_fuc *fuc) 720 720 { 721 721 struct drm_nouveau_private *dev_priv = dev->dev_private; 722 722 const struct firmware *fw; ··· 735 735 } 736 736 737 737 static void 738 - nve0_graph_destroy_fw(struct nve0_graph_fuc *fuc) 738 + nve0_graph_destroy_fw(struct nvc0_graph_fuc *fuc) 739 739 { 740 740 if (fuc->data) { 741 741 kfree(fuc->data); ··· 746 746 static void 747 747 nve0_graph_destroy(struct drm_device *dev, int engine) 748 748 { 749 - struct nve0_graph_priv *priv = nv_engine(dev, engine); 749 + struct nvc0_graph_priv *priv = nv_engine(dev, engine); 750 750 751 751 nve0_graph_destroy_fw(&priv->fuc409c); 752 752 nve0_graph_destroy_fw(&priv->fuc409d); ··· 769 769 nve0_graph_create(struct drm_device *dev) 770 770 { 771 771 struct drm_nouveau_private *dev_priv = dev->dev_private; 772 - struct nve0_graph_priv *priv; 772 + struct nvc0_graph_priv *priv; 773 773 int ret, gpc, i; 774 774 u32 kepler; 775 775 776 - kepler = nve0_graph_class(dev); 776 + kepler = nvc0_graph_class(dev); 777 777 if (!kepler) { 778 778 NV_ERROR(dev, "PGRAPH: unsupported chipset, please report!\n"); 779 779 return 0;
-94
drivers/gpu/drm/nouveau/core/engine/graph/nve0.h
··· 1 - /* 2 - * Copyright 2012 Red Hat Inc. 3 - * 4 - * Permission is hereby granted, free of charge, to any person obtaining a 5 - * copy of this software and associated documentation files (the "Software"), 6 - * to deal in the Software without restriction, including without limitation 7 - * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 - * and/or sell copies of the Software, and to permit persons to whom the 9 - * Software is furnished to do so, subject to the following conditions: 10 - * 11 - * The above copyright notice and this permission notice shall be included in 12 - * all copies or substantial portions of the Software. 13 - * 14 - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 - * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 - * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 - * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 - * OTHER DEALINGS IN THE SOFTWARE. 21 - * 22 - * Authors: Ben Skeggs 23 - */ 24 - 25 - #ifndef __NVE0_GRAPH_H__ 26 - #define __NVE0_GRAPH_H__ 27 - 28 - #define GPC_MAX 4 29 - #define TPC_MAX 32 30 - 31 - #define ROP_BCAST(r) (0x408800 + (r)) 32 - #define ROP_UNIT(u, r) (0x410000 + (u) * 0x400 + (r)) 33 - #define GPC_BCAST(r) (0x418000 + (r)) 34 - #define GPC_UNIT(t, r) (0x500000 + (t) * 0x8000 + (r)) 35 - #define TPC_UNIT(t, m, r) (0x504000 + (t) * 0x8000 + (m) * 0x800 + (r)) 36 - 37 - struct nve0_graph_fuc { 38 - u32 *data; 39 - u32 size; 40 - }; 41 - 42 - struct nve0_graph_priv { 43 - struct nouveau_exec_engine base; 44 - 45 - struct nve0_graph_fuc fuc409c; 46 - struct nve0_graph_fuc fuc409d; 47 - struct nve0_graph_fuc fuc41ac; 48 - struct nve0_graph_fuc fuc41ad; 49 - 50 - u8 gpc_nr; 51 - u8 rop_nr; 52 - u8 tpc_nr[GPC_MAX]; 53 - u8 tpc_total; 54 - 55 - u32 grctx_size; 56 - u32 *grctx_vals; 57 - struct nouveau_gpuobj *unk4188b4; 58 - struct nouveau_gpuobj *unk4188b8; 59 - 60 - u8 magic_not_rop_nr; 61 - }; 62 - 63 - struct nve0_graph_chan { 64 - struct nouveau_gpuobj *grctx; 65 - struct nouveau_vma grctx_vma; 66 - struct nouveau_gpuobj *unk408004; /* 0x418810 too */ 67 - struct nouveau_vma unk408004_vma; 68 - struct nouveau_gpuobj *unk40800c; /* 0x419004 too */ 69 - struct nouveau_vma unk40800c_vma; 70 - struct nouveau_gpuobj *unk418810; /* 0x419848 too */ 71 - struct nouveau_vma unk418810_vma; 72 - struct nouveau_gpuobj *mmio; 73 - struct nouveau_vma mmio_vma; 74 - int mmio_nr; 75 - }; 76 - 77 - int nve0_grctx_generate(struct nouveau_channel *); 78 - 79 - /* nve0_graph.c uses this also to determine supported chipsets */ 80 - static inline u32 81 - nve0_graph_class(struct drm_device *dev) 82 - { 83 - struct drm_nouveau_private *dev_priv = dev->dev_private; 84 - 85 - switch (dev_priv->chipset) { 86 - case 0xe4: 87 - case 0xe7: 88 - return 0xa097; 89 - default: 90 - return 0; 91 - } 92 - } 93 - 94 - #endif