aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
Diffstat (limited to 'arch')
-rw-r--r--arch/powerpc/platforms/cell/spufs/file.c216
1 files changed, 76 insertions, 140 deletions
diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c
index 985c86bb16d0..b93a0275a217 100644
--- a/arch/powerpc/platforms/cell/spufs/file.c
+++ b/arch/powerpc/platforms/cell/spufs/file.c
@@ -1076,6 +1076,36 @@ static const struct file_operations spufs_signal2_nosched_fops = {
1076 .mmap = spufs_signal2_mmap, 1076 .mmap = spufs_signal2_mmap,
1077}; 1077};
1078 1078
1079/*
1080 * This is a wrapper around DEFINE_SIMPLE_ATTRIBUTE which does the
1081 * work of acquiring (or not) the SPU context before calling through
1082 * to the actual get routine. The set routine is called directly.
1083 */
1084#define SPU_ATTR_NOACQUIRE 0
1085#define SPU_ATTR_ACQUIRE 1
1086#define SPU_ATTR_ACQUIRE_SAVED 2
1087
1088#define DEFINE_SPUFS_ATTRIBUTE(__name, __get, __set, __fmt, __acquire) \
1089static u64 __##__get(void *data) \
1090{ \
1091 struct spu_context *ctx = data; \
1092 u64 ret; \
1093 \
1094 if (__acquire == SPU_ATTR_ACQUIRE) { \
1095 spu_acquire(ctx); \
1096 ret = __get(ctx); \
1097 spu_release(ctx); \
1098 } else if (__acquire == SPU_ATTR_ACQUIRE_SAVED) { \
1099 spu_acquire_saved(ctx); \
1100 ret = __get(ctx); \
1101 spu_release_saved(ctx); \
1102 } else \
1103 ret = __get(ctx); \
1104 \
1105 return ret; \
1106} \
1107DEFINE_SIMPLE_ATTRIBUTE(__name, __##__get, __set, __fmt);
1108
1079static void spufs_signal1_type_set(void *data, u64 val) 1109static void spufs_signal1_type_set(void *data, u64 val)
1080{ 1110{
1081 struct spu_context *ctx = data; 1111 struct spu_context *ctx = data;
@@ -1085,24 +1115,13 @@ static void spufs_signal1_type_set(void *data, u64 val)
1085 spu_release(ctx); 1115 spu_release(ctx);
1086} 1116}
1087 1117
1088static u64 __spufs_signal1_type_get(struct spu_context *ctx) 1118static u64 spufs_signal1_type_get(struct spu_context *ctx)
1089{ 1119{
1090 return ctx->ops->signal1_type_get(ctx); 1120 return ctx->ops->signal1_type_get(ctx);
1091} 1121}
1122DEFINE_SPUFS_ATTRIBUTE(spufs_signal1_type, spufs_signal1_type_get,
1123 spufs_signal1_type_set, "%llu", SPU_ATTR_ACQUIRE);
1092 1124
1093static u64 spufs_signal1_type_get(void *data)
1094{
1095 struct spu_context *ctx = data;
1096 u64 ret;
1097
1098 spu_acquire(ctx);
1099 ret = __spufs_signal1_type_get(ctx);
1100 spu_release(ctx);
1101
1102 return ret;
1103}
1104DEFINE_SIMPLE_ATTRIBUTE(spufs_signal1_type, spufs_signal1_type_get,
1105 spufs_signal1_type_set, "%llu");
1106 1125
1107static void spufs_signal2_type_set(void *data, u64 val) 1126static void spufs_signal2_type_set(void *data, u64 val)
1108{ 1127{
@@ -1113,24 +1132,12 @@ static void spufs_signal2_type_set(void *data, u64 val)
1113 spu_release(ctx); 1132 spu_release(ctx);
1114} 1133}
1115 1134
1116static u64 __spufs_signal2_type_get(struct spu_context *ctx) 1135static u64 spufs_signal2_type_get(struct spu_context *ctx)
1117{ 1136{
1118 return ctx->ops->signal2_type_get(ctx); 1137 return ctx->ops->signal2_type_get(ctx);
1119} 1138}
1120 1139DEFINE_SPUFS_ATTRIBUTE(spufs_signal2_type, spufs_signal2_type_get,
1121static u64 spufs_signal2_type_get(void *data) 1140 spufs_signal2_type_set, "%llu", SPU_ATTR_ACQUIRE);
1122{
1123 struct spu_context *ctx = data;
1124 u64 ret;
1125
1126 spu_acquire(ctx);
1127 ret = __spufs_signal2_type_get(ctx);
1128 spu_release(ctx);
1129
1130 return ret;
1131}
1132DEFINE_SIMPLE_ATTRIBUTE(spufs_signal2_type, spufs_signal2_type_get,
1133 spufs_signal2_type_set, "%llu");
1134 1141
1135#if SPUFS_MMAP_4K 1142#if SPUFS_MMAP_4K
1136static unsigned long spufs_mss_mmap_nopfn(struct vm_area_struct *vma, 1143static unsigned long spufs_mss_mmap_nopfn(struct vm_area_struct *vma,
@@ -1606,22 +1613,12 @@ static void spufs_npc_set(void *data, u64 val)
1606 spu_release(ctx); 1613 spu_release(ctx);
1607} 1614}
1608 1615
1609static u64 __spufs_npc_get(struct spu_context *ctx) 1616static u64 spufs_npc_get(struct spu_context *ctx)
1610{ 1617{
1611 return ctx->ops->npc_read(ctx); 1618 return ctx->ops->npc_read(ctx);
1612} 1619}
1613 1620DEFINE_SPUFS_ATTRIBUTE(spufs_npc_ops, spufs_npc_get, spufs_npc_set,
1614static u64 spufs_npc_get(void *data) 1621 "0x%llx\n", SPU_ATTR_ACQUIRE);
1615{
1616 struct spu_context *ctx = data;
1617 u64 ret;
1618 spu_acquire(ctx);
1619 ret = __spufs_npc_get(ctx);
1620 spu_release(ctx);
1621 return ret;
1622}
1623DEFINE_SIMPLE_ATTRIBUTE(spufs_npc_ops, spufs_npc_get, spufs_npc_set,
1624 "0x%llx\n")
1625 1622
1626static void spufs_decr_set(void *data, u64 val) 1623static void spufs_decr_set(void *data, u64 val)
1627{ 1624{
@@ -1632,23 +1629,13 @@ static void spufs_decr_set(void *data, u64 val)
1632 spu_release_saved(ctx); 1629 spu_release_saved(ctx);
1633} 1630}
1634 1631
1635static u64 __spufs_decr_get(struct spu_context *ctx) 1632static u64 spufs_decr_get(struct spu_context *ctx)
1636{ 1633{
1637 struct spu_lscsa *lscsa = ctx->csa.lscsa; 1634 struct spu_lscsa *lscsa = ctx->csa.lscsa;
1638 return lscsa->decr.slot[0]; 1635 return lscsa->decr.slot[0];
1639} 1636}
1640 1637DEFINE_SPUFS_ATTRIBUTE(spufs_decr_ops, spufs_decr_get, spufs_decr_set,
1641static u64 spufs_decr_get(void *data) 1638 "0x%llx\n", SPU_ATTR_ACQUIRE_SAVED);
1642{
1643 struct spu_context *ctx = data;
1644 u64 ret;
1645 spu_acquire_saved(ctx);
1646 ret = __spufs_decr_get(ctx);
1647 spu_release_saved(ctx);
1648 return ret;
1649}
1650DEFINE_SIMPLE_ATTRIBUTE(spufs_decr_ops, spufs_decr_get, spufs_decr_set,
1651 "0x%llx\n")
1652 1639
1653static void spufs_decr_status_set(void *data, u64 val) 1640static void spufs_decr_status_set(void *data, u64 val)
1654{ 1641{
@@ -1661,25 +1648,16 @@ static void spufs_decr_status_set(void *data, u64 val)
1661 spu_release_saved(ctx); 1648 spu_release_saved(ctx);
1662} 1649}
1663 1650
1664static u64 __spufs_decr_status_get(struct spu_context *ctx) 1651static u64 spufs_decr_status_get(struct spu_context *ctx)
1665{ 1652{
1666 if (ctx->csa.priv2.mfc_control_RW & MFC_CNTL_DECREMENTER_RUNNING) 1653 if (ctx->csa.priv2.mfc_control_RW & MFC_CNTL_DECREMENTER_RUNNING)
1667 return SPU_DECR_STATUS_RUNNING; 1654 return SPU_DECR_STATUS_RUNNING;
1668 else 1655 else
1669 return 0; 1656 return 0;
1670} 1657}
1671 1658DEFINE_SPUFS_ATTRIBUTE(spufs_decr_status_ops, spufs_decr_status_get,
1672static u64 spufs_decr_status_get(void *data) 1659 spufs_decr_status_set, "0x%llx\n",
1673{ 1660 SPU_ATTR_ACQUIRE_SAVED);
1674 struct spu_context *ctx = data;
1675 u64 ret;
1676 spu_acquire_saved(ctx);
1677 ret = __spufs_decr_status_get(ctx);
1678 spu_release_saved(ctx);
1679 return ret;
1680}
1681DEFINE_SIMPLE_ATTRIBUTE(spufs_decr_status_ops, spufs_decr_status_get,
1682 spufs_decr_status_set, "0x%llx\n")
1683 1661
1684static void spufs_event_mask_set(void *data, u64 val) 1662static void spufs_event_mask_set(void *data, u64 val)
1685{ 1663{
@@ -1690,25 +1668,17 @@ static void spufs_event_mask_set(void *data, u64 val)
1690 spu_release_saved(ctx); 1668 spu_release_saved(ctx);
1691} 1669}
1692 1670
1693static u64 __spufs_event_mask_get(struct spu_context *ctx) 1671static u64 spufs_event_mask_get(struct spu_context *ctx)
1694{ 1672{
1695 struct spu_lscsa *lscsa = ctx->csa.lscsa; 1673 struct spu_lscsa *lscsa = ctx->csa.lscsa;
1696 return lscsa->event_mask.slot[0]; 1674 return lscsa->event_mask.slot[0];
1697} 1675}
1698 1676
1699static u64 spufs_event_mask_get(void *data) 1677DEFINE_SPUFS_ATTRIBUTE(spufs_event_mask_ops, spufs_event_mask_get,
1700{ 1678 spufs_event_mask_set, "0x%llx\n",
1701 struct spu_context *ctx = data; 1679 SPU_ATTR_ACQUIRE_SAVED);
1702 u64 ret;
1703 spu_acquire_saved(ctx);
1704 ret = __spufs_event_mask_get(ctx);
1705 spu_release_saved(ctx);
1706 return ret;
1707}
1708DEFINE_SIMPLE_ATTRIBUTE(spufs_event_mask_ops, spufs_event_mask_get,
1709 spufs_event_mask_set, "0x%llx\n")
1710 1680
1711static u64 __spufs_event_status_get(struct spu_context *ctx) 1681static u64 spufs_event_status_get(struct spu_context *ctx)
1712{ 1682{
1713 struct spu_state *state = &ctx->csa; 1683 struct spu_state *state = &ctx->csa;
1714 u64 stat; 1684 u64 stat;
@@ -1717,19 +1687,8 @@ static u64 __spufs_event_status_get(struct spu_context *ctx)
1717 return state->spu_chnldata_RW[0]; 1687 return state->spu_chnldata_RW[0];
1718 return 0; 1688 return 0;
1719} 1689}
1720 1690DEFINE_SPUFS_ATTRIBUTE(spufs_event_status_ops, spufs_event_status_get,
1721static u64 spufs_event_status_get(void *data) 1691 NULL, "0x%llx\n", SPU_ATTR_ACQUIRE_SAVED)
1722{
1723 struct spu_context *ctx = data;
1724 u64 ret = 0;
1725
1726 spu_acquire_saved(ctx);
1727 ret = __spufs_event_status_get(ctx);
1728 spu_release_saved(ctx);
1729 return ret;
1730}
1731DEFINE_SIMPLE_ATTRIBUTE(spufs_event_status_ops, spufs_event_status_get,
1732 NULL, "0x%llx\n")
1733 1692
1734static void spufs_srr0_set(void *data, u64 val) 1693static void spufs_srr0_set(void *data, u64 val)
1735{ 1694{
@@ -1740,44 +1699,32 @@ static void spufs_srr0_set(void *data, u64 val)
1740 spu_release_saved(ctx); 1699 spu_release_saved(ctx);
1741} 1700}
1742 1701
1743static u64 spufs_srr0_get(void *data) 1702static u64 spufs_srr0_get(struct spu_context *ctx)
1744{ 1703{
1745 struct spu_context *ctx = data;
1746 struct spu_lscsa *lscsa = ctx->csa.lscsa; 1704 struct spu_lscsa *lscsa = ctx->csa.lscsa;
1747 u64 ret; 1705 return lscsa->srr0.slot[0];
1748 spu_acquire_saved(ctx);
1749 ret = lscsa->srr0.slot[0];
1750 spu_release_saved(ctx);
1751 return ret;
1752} 1706}
1753DEFINE_SIMPLE_ATTRIBUTE(spufs_srr0_ops, spufs_srr0_get, spufs_srr0_set, 1707DEFINE_SPUFS_ATTRIBUTE(spufs_srr0_ops, spufs_srr0_get, spufs_srr0_set,
1754 "0x%llx\n") 1708 "0x%llx\n", SPU_ATTR_ACQUIRE_SAVED)
1755 1709
1756static u64 spufs_id_get(void *data) 1710static u64 spufs_id_get(struct spu_context *ctx)
1757{ 1711{
1758 struct spu_context *ctx = data;
1759 u64 num; 1712 u64 num;
1760 1713
1761 spu_acquire(ctx);
1762 if (ctx->state == SPU_STATE_RUNNABLE) 1714 if (ctx->state == SPU_STATE_RUNNABLE)
1763 num = ctx->spu->number; 1715 num = ctx->spu->number;
1764 else 1716 else
1765 num = (unsigned int)-1; 1717 num = (unsigned int)-1;
1766 spu_release(ctx);
1767 1718
1768 return num; 1719 return num;
1769} 1720}
1770DEFINE_SIMPLE_ATTRIBUTE(spufs_id_ops, spufs_id_get, NULL, "0x%llx\n") 1721DEFINE_SPUFS_ATTRIBUTE(spufs_id_ops, spufs_id_get, NULL, "0x%llx\n",
1722 SPU_ATTR_ACQUIRE)
1771 1723
1772static u64 __spufs_object_id_get(struct spu_context *ctx) 1724static u64 spufs_object_id_get(struct spu_context *ctx)
1773{
1774 return ctx->object_id;
1775}
1776
1777static u64 spufs_object_id_get(void *data)
1778{ 1725{
1779 /* FIXME: Should there really be no locking here? */ 1726 /* FIXME: Should there really be no locking here? */
1780 return __spufs_object_id_get((struct spu_context *)data); 1727 return ctx->object_id;
1781} 1728}
1782 1729
1783static void spufs_object_id_set(void *data, u64 id) 1730static void spufs_object_id_set(void *data, u64 id)
@@ -1786,26 +1733,15 @@ static void spufs_object_id_set(void *data, u64 id)
1786 ctx->object_id = id; 1733 ctx->object_id = id;
1787} 1734}
1788 1735
1789DEFINE_SIMPLE_ATTRIBUTE(spufs_object_id_ops, spufs_object_id_get, 1736DEFINE_SPUFS_ATTRIBUTE(spufs_object_id_ops, spufs_object_id_get,
1790 spufs_object_id_set, "0x%llx\n"); 1737 spufs_object_id_set, "0x%llx\n", SPU_ATTR_NOACQUIRE);
1791 1738
1792static u64 __spufs_lslr_get(struct spu_context *ctx) 1739static u64 spufs_lslr_get(struct spu_context *ctx)
1793{ 1740{
1794 return ctx->csa.priv2.spu_lslr_RW; 1741 return ctx->csa.priv2.spu_lslr_RW;
1795} 1742}
1796 1743DEFINE_SPUFS_ATTRIBUTE(spufs_lslr_ops, spufs_lslr_get, NULL, "0x%llx\n",
1797static u64 spufs_lslr_get(void *data) 1744 SPU_ATTR_ACQUIRE_SAVED);
1798{
1799 struct spu_context *ctx = data;
1800 u64 ret;
1801
1802 spu_acquire_saved(ctx);
1803 ret = __spufs_lslr_get(ctx);
1804 spu_release_saved(ctx);
1805
1806 return ret;
1807}
1808DEFINE_SIMPLE_ATTRIBUTE(spufs_lslr_ops, spufs_lslr_get, NULL, "0x%llx\n")
1809 1745
1810static int spufs_info_open(struct inode *inode, struct file *file) 1746static int spufs_info_open(struct inode *inode, struct file *file)
1811{ 1747{
@@ -2230,23 +2166,23 @@ struct tree_descr spufs_dir_nosched_contents[] = {
2230struct spufs_coredump_reader spufs_coredump_read[] = { 2166struct spufs_coredump_reader spufs_coredump_read[] = {
2231 { "regs", __spufs_regs_read, NULL, sizeof(struct spu_reg128[128])}, 2167 { "regs", __spufs_regs_read, NULL, sizeof(struct spu_reg128[128])},
2232 { "fpcr", __spufs_fpcr_read, NULL, sizeof(struct spu_reg128) }, 2168 { "fpcr", __spufs_fpcr_read, NULL, sizeof(struct spu_reg128) },
2233 { "lslr", NULL, __spufs_lslr_get, 19 }, 2169 { "lslr", NULL, spufs_lslr_get, 19 },
2234 { "decr", NULL, __spufs_decr_get, 19 }, 2170 { "decr", NULL, spufs_decr_get, 19 },
2235 { "decr_status", NULL, __spufs_decr_status_get, 19 }, 2171 { "decr_status", NULL, spufs_decr_status_get, 19 },
2236 { "mem", __spufs_mem_read, NULL, LS_SIZE, }, 2172 { "mem", __spufs_mem_read, NULL, LS_SIZE, },
2237 { "signal1", __spufs_signal1_read, NULL, sizeof(u32) }, 2173 { "signal1", __spufs_signal1_read, NULL, sizeof(u32) },
2238 { "signal1_type", NULL, __spufs_signal1_type_get, 19 }, 2174 { "signal1_type", NULL, spufs_signal1_type_get, 19 },
2239 { "signal2", __spufs_signal2_read, NULL, sizeof(u32) }, 2175 { "signal2", __spufs_signal2_read, NULL, sizeof(u32) },
2240 { "signal2_type", NULL, __spufs_signal2_type_get, 19 }, 2176 { "signal2_type", NULL, spufs_signal2_type_get, 19 },
2241 { "event_mask", NULL, __spufs_event_mask_get, 19 }, 2177 { "event_mask", NULL, spufs_event_mask_get, 19 },
2242 { "event_status", NULL, __spufs_event_status_get, 19 }, 2178 { "event_status", NULL, spufs_event_status_get, 19 },
2243 { "mbox_info", __spufs_mbox_info_read, NULL, sizeof(u32) }, 2179 { "mbox_info", __spufs_mbox_info_read, NULL, sizeof(u32) },
2244 { "ibox_info", __spufs_ibox_info_read, NULL, sizeof(u32) }, 2180 { "ibox_info", __spufs_ibox_info_read, NULL, sizeof(u32) },
2245 { "wbox_info", __spufs_wbox_info_read, NULL, 4 * sizeof(u32)}, 2181 { "wbox_info", __spufs_wbox_info_read, NULL, 4 * sizeof(u32)},
2246 { "dma_info", __spufs_dma_info_read, NULL, sizeof(struct spu_dma_info)}, 2182 { "dma_info", __spufs_dma_info_read, NULL, sizeof(struct spu_dma_info)},
2247 { "proxydma_info", __spufs_proxydma_info_read, 2183 { "proxydma_info", __spufs_proxydma_info_read,
2248 NULL, sizeof(struct spu_proxydma_info)}, 2184 NULL, sizeof(struct spu_proxydma_info)},
2249 { "object-id", NULL, __spufs_object_id_get, 19 }, 2185 { "object-id", NULL, spufs_object_id_get, 19 },
2250 { "npc", NULL, __spufs_npc_get, 19 }, 2186 { "npc", NULL, spufs_npc_get, 19 },
2251 { NULL }, 2187 { NULL },
2252}; 2188};