@@ -1978,8 +1978,9 @@ static ssize_t __spufs_mbox_info_read(struct spu_context *ctx,
1978
1978
static ssize_t spufs_mbox_info_read (struct file * file , char __user * buf ,
1979
1979
size_t len , loff_t * pos )
1980
1980
{
1981
- int ret ;
1982
1981
struct spu_context * ctx = file -> private_data ;
1982
+ u32 stat , data ;
1983
+ int ret ;
1983
1984
1984
1985
if (!access_ok (buf , len ))
1985
1986
return - EFAULT ;
@@ -1988,11 +1989,16 @@ static ssize_t spufs_mbox_info_read(struct file *file, char __user *buf,
1988
1989
if (ret )
1989
1990
return ret ;
1990
1991
spin_lock (& ctx -> csa .register_lock );
1991
- ret = __spufs_mbox_info_read (ctx , buf , len , pos );
1992
+ stat = ctx -> csa .prob .mb_stat_R ;
1993
+ data = ctx -> csa .prob .pu_mb_R ;
1992
1994
spin_unlock (& ctx -> csa .register_lock );
1993
1995
spu_release_saved (ctx );
1994
1996
1995
- return ret ;
1997
+ /* EOF if there's no entry in the mbox */
1998
+ if (!(stat & 0x0000ff ))
1999
+ return 0 ;
2000
+
2001
+ return simple_read_from_buffer (buf , len , pos , & data , sizeof (data ));
1996
2002
}
1997
2003
1998
2004
static const struct file_operations spufs_mbox_info_fops = {
@@ -2019,6 +2025,7 @@ static ssize_t spufs_ibox_info_read(struct file *file, char __user *buf,
2019
2025
size_t len , loff_t * pos )
2020
2026
{
2021
2027
struct spu_context * ctx = file -> private_data ;
2028
+ u32 stat , data ;
2022
2029
int ret ;
2023
2030
2024
2031
if (!access_ok (buf , len ))
@@ -2028,11 +2035,16 @@ static ssize_t spufs_ibox_info_read(struct file *file, char __user *buf,
2028
2035
if (ret )
2029
2036
return ret ;
2030
2037
spin_lock (& ctx -> csa .register_lock );
2031
- ret = __spufs_ibox_info_read (ctx , buf , len , pos );
2038
+ stat = ctx -> csa .prob .mb_stat_R ;
2039
+ data = ctx -> csa .priv2 .puint_mb_R ;
2032
2040
spin_unlock (& ctx -> csa .register_lock );
2033
2041
spu_release_saved (ctx );
2034
2042
2035
- return ret ;
2043
+ /* EOF if there's no entry in the ibox */
2044
+ if (!(stat & 0xff0000 ))
2045
+ return 0 ;
2046
+
2047
+ return simple_read_from_buffer (buf , len , pos , & data , sizeof (data ));
2036
2048
}
2037
2049
2038
2050
static const struct file_operations spufs_ibox_info_fops = {
@@ -2041,6 +2053,11 @@ static const struct file_operations spufs_ibox_info_fops = {
2041
2053
.llseek = generic_file_llseek ,
2042
2054
};
2043
2055
2056
+ static size_t spufs_wbox_info_cnt (struct spu_context * ctx )
2057
+ {
2058
+ return (4 - ((ctx -> csa .prob .mb_stat_R & 0x00ff00 ) >> 8 )) * sizeof (u32 );
2059
+ }
2060
+
2044
2061
static ssize_t __spufs_wbox_info_read (struct spu_context * ctx ,
2045
2062
char __user * buf , size_t len , loff_t * pos )
2046
2063
{
@@ -2049,7 +2066,7 @@ static ssize_t __spufs_wbox_info_read(struct spu_context *ctx,
2049
2066
u32 wbox_stat ;
2050
2067
2051
2068
wbox_stat = ctx -> csa .prob .mb_stat_R ;
2052
- cnt = 4 - (( wbox_stat & 0x00ff00 ) >> 8 );
2069
+ cnt = spufs_wbox_info_cnt ( ctx );
2053
2070
for (i = 0 ; i < cnt ; i ++ ) {
2054
2071
data [i ] = ctx -> csa .spu_mailbox_data [i ];
2055
2072
}
@@ -2062,7 +2079,8 @@ static ssize_t spufs_wbox_info_read(struct file *file, char __user *buf,
2062
2079
size_t len , loff_t * pos )
2063
2080
{
2064
2081
struct spu_context * ctx = file -> private_data ;
2065
- int ret ;
2082
+ u32 data [ARRAY_SIZE (ctx -> csa .spu_mailbox_data )];
2083
+ int ret , count ;
2066
2084
2067
2085
if (!access_ok (buf , len ))
2068
2086
return - EFAULT ;
@@ -2071,11 +2089,13 @@ static ssize_t spufs_wbox_info_read(struct file *file, char __user *buf,
2071
2089
if (ret )
2072
2090
return ret ;
2073
2091
spin_lock (& ctx -> csa .register_lock );
2074
- ret = __spufs_wbox_info_read (ctx , buf , len , pos );
2092
+ count = spufs_wbox_info_cnt (ctx );
2093
+ memcpy (& data , & ctx -> csa .spu_mailbox_data , sizeof (data ));
2075
2094
spin_unlock (& ctx -> csa .register_lock );
2076
2095
spu_release_saved (ctx );
2077
2096
2078
- return ret ;
2097
+ return simple_read_from_buffer (buf , len , pos , & data ,
2098
+ count * sizeof (u32 ));
2079
2099
}
2080
2100
2081
2101
static const struct file_operations spufs_wbox_info_fops = {
@@ -2084,27 +2104,33 @@ static const struct file_operations spufs_wbox_info_fops = {
2084
2104
.llseek = generic_file_llseek ,
2085
2105
};
2086
2106
2087
- static ssize_t __spufs_dma_info_read (struct spu_context * ctx ,
2088
- char __user * buf , size_t len , loff_t * pos )
2107
+ static void spufs_get_dma_info (struct spu_context * ctx ,
2108
+ struct spu_dma_info * info )
2089
2109
{
2090
- struct spu_dma_info info ;
2091
- struct mfc_cq_sr * qp , * spuqp ;
2092
2110
int i ;
2093
2111
2094
- info . dma_info_type = ctx -> csa .priv2 .spu_tag_status_query_RW ;
2095
- info . dma_info_mask = ctx -> csa .lscsa -> tag_mask .slot [0 ];
2096
- info . dma_info_status = ctx -> csa .spu_chnldata_RW [24 ];
2097
- info . dma_info_stall_and_notify = ctx -> csa .spu_chnldata_RW [25 ];
2098
- info . dma_info_atomic_command_status = ctx -> csa .spu_chnldata_RW [27 ];
2112
+ info -> dma_info_type = ctx -> csa .priv2 .spu_tag_status_query_RW ;
2113
+ info -> dma_info_mask = ctx -> csa .lscsa -> tag_mask .slot [0 ];
2114
+ info -> dma_info_status = ctx -> csa .spu_chnldata_RW [24 ];
2115
+ info -> dma_info_stall_and_notify = ctx -> csa .spu_chnldata_RW [25 ];
2116
+ info -> dma_info_atomic_command_status = ctx -> csa .spu_chnldata_RW [27 ];
2099
2117
for (i = 0 ; i < 16 ; i ++ ) {
2100
- qp = & info . dma_info_command_data [i ];
2101
- spuqp = & ctx -> csa .priv2 .spuq [i ];
2118
+ struct mfc_cq_sr * qp = & info -> dma_info_command_data [i ];
2119
+ struct mfc_cq_sr * spuqp = & ctx -> csa .priv2 .spuq [i ];
2102
2120
2103
2121
qp -> mfc_cq_data0_RW = spuqp -> mfc_cq_data0_RW ;
2104
2122
qp -> mfc_cq_data1_RW = spuqp -> mfc_cq_data1_RW ;
2105
2123
qp -> mfc_cq_data2_RW = spuqp -> mfc_cq_data2_RW ;
2106
2124
qp -> mfc_cq_data3_RW = spuqp -> mfc_cq_data3_RW ;
2107
2125
}
2126
+ }
2127
+
2128
+ static ssize_t __spufs_dma_info_read (struct spu_context * ctx ,
2129
+ char __user * buf , size_t len , loff_t * pos )
2130
+ {
2131
+ struct spu_dma_info info ;
2132
+
2133
+ spufs_get_dma_info (ctx , & info );
2108
2134
2109
2135
return simple_read_from_buffer (buf , len , pos , & info ,
2110
2136
sizeof info );
@@ -2114,6 +2140,7 @@ static ssize_t spufs_dma_info_read(struct file *file, char __user *buf,
2114
2140
size_t len , loff_t * pos )
2115
2141
{
2116
2142
struct spu_context * ctx = file -> private_data ;
2143
+ struct spu_dma_info info ;
2117
2144
int ret ;
2118
2145
2119
2146
if (!access_ok (buf , len ))
@@ -2123,11 +2150,12 @@ static ssize_t spufs_dma_info_read(struct file *file, char __user *buf,
2123
2150
if (ret )
2124
2151
return ret ;
2125
2152
spin_lock (& ctx -> csa .register_lock );
2126
- ret = __spufs_dma_info_read (ctx , buf , len , pos );
2153
+ spufs_get_dma_info (ctx , & info );
2127
2154
spin_unlock (& ctx -> csa .register_lock );
2128
2155
spu_release_saved (ctx );
2129
2156
2130
- return ret ;
2157
+ return simple_read_from_buffer (buf , len , pos , & info ,
2158
+ sizeof (info ));
2131
2159
}
2132
2160
2133
2161
static const struct file_operations spufs_dma_info_fops = {
@@ -2136,32 +2164,39 @@ static const struct file_operations spufs_dma_info_fops = {
2136
2164
.llseek = no_llseek ,
2137
2165
};
2138
2166
2167
+ static void spufs_get_proxydma_info (struct spu_context * ctx ,
2168
+ struct spu_proxydma_info * info )
2169
+ {
2170
+ int i ;
2171
+
2172
+ info -> proxydma_info_type = ctx -> csa .prob .dma_querytype_RW ;
2173
+ info -> proxydma_info_mask = ctx -> csa .prob .dma_querymask_RW ;
2174
+ info -> proxydma_info_status = ctx -> csa .prob .dma_tagstatus_R ;
2175
+
2176
+ for (i = 0 ; i < 8 ; i ++ ) {
2177
+ struct mfc_cq_sr * qp = & info -> proxydma_info_command_data [i ];
2178
+ struct mfc_cq_sr * puqp = & ctx -> csa .priv2 .puq [i ];
2179
+
2180
+ qp -> mfc_cq_data0_RW = puqp -> mfc_cq_data0_RW ;
2181
+ qp -> mfc_cq_data1_RW = puqp -> mfc_cq_data1_RW ;
2182
+ qp -> mfc_cq_data2_RW = puqp -> mfc_cq_data2_RW ;
2183
+ qp -> mfc_cq_data3_RW = puqp -> mfc_cq_data3_RW ;
2184
+ }
2185
+ }
2186
+
2139
2187
static ssize_t __spufs_proxydma_info_read (struct spu_context * ctx ,
2140
2188
char __user * buf , size_t len , loff_t * pos )
2141
2189
{
2142
2190
struct spu_proxydma_info info ;
2143
- struct mfc_cq_sr * qp , * puqp ;
2144
2191
int ret = sizeof info ;
2145
- int i ;
2146
2192
2147
2193
if (len < ret )
2148
2194
return - EINVAL ;
2149
2195
2150
2196
if (!access_ok (buf , len ))
2151
2197
return - EFAULT ;
2152
2198
2153
- info .proxydma_info_type = ctx -> csa .prob .dma_querytype_RW ;
2154
- info .proxydma_info_mask = ctx -> csa .prob .dma_querymask_RW ;
2155
- info .proxydma_info_status = ctx -> csa .prob .dma_tagstatus_R ;
2156
- for (i = 0 ; i < 8 ; i ++ ) {
2157
- qp = & info .proxydma_info_command_data [i ];
2158
- puqp = & ctx -> csa .priv2 .puq [i ];
2159
-
2160
- qp -> mfc_cq_data0_RW = puqp -> mfc_cq_data0_RW ;
2161
- qp -> mfc_cq_data1_RW = puqp -> mfc_cq_data1_RW ;
2162
- qp -> mfc_cq_data2_RW = puqp -> mfc_cq_data2_RW ;
2163
- qp -> mfc_cq_data3_RW = puqp -> mfc_cq_data3_RW ;
2164
- }
2199
+ spufs_get_proxydma_info (ctx , & info );
2165
2200
2166
2201
return simple_read_from_buffer (buf , len , pos , & info ,
2167
2202
sizeof info );
@@ -2171,17 +2206,19 @@ static ssize_t spufs_proxydma_info_read(struct file *file, char __user *buf,
2171
2206
size_t len , loff_t * pos )
2172
2207
{
2173
2208
struct spu_context * ctx = file -> private_data ;
2209
+ struct spu_proxydma_info info ;
2174
2210
int ret ;
2175
2211
2176
2212
ret = spu_acquire_saved (ctx );
2177
2213
if (ret )
2178
2214
return ret ;
2179
2215
spin_lock (& ctx -> csa .register_lock );
2180
- ret = __spufs_proxydma_info_read (ctx , buf , len , pos );
2216
+ spufs_get_proxydma_info (ctx , & info );
2181
2217
spin_unlock (& ctx -> csa .register_lock );
2182
2218
spu_release_saved (ctx );
2183
2219
2184
- return ret ;
2220
+ return simple_read_from_buffer (buf , len , pos , & info ,
2221
+ sizeof (info ));
2185
2222
}
2186
2223
2187
2224
static const struct file_operations spufs_proxydma_info_fops = {
0 commit comments