@@ -50,6 +50,20 @@ static inline struct efx_mcdi_iface *efx_mcdi(struct efx_nic *efx)
5050 return & nic_data -> mcdi ;
5151}
5252
53+ static inline void
54+ efx_mcdi_readd (struct efx_nic * efx , efx_dword_t * value , unsigned reg )
55+ {
56+ struct siena_nic_data * nic_data = efx -> nic_data ;
57+ value -> u32 [0 ] = (__force __le32 )__raw_readl (nic_data -> mcdi_smem + reg );
58+ }
59+
60+ static inline void
61+ efx_mcdi_writed (struct efx_nic * efx , const efx_dword_t * value , unsigned reg )
62+ {
63+ struct siena_nic_data * nic_data = efx -> nic_data ;
64+ __raw_writel ((__force u32 )value -> u32 [0 ], nic_data -> mcdi_smem + reg );
65+ }
66+
5367void efx_mcdi_init (struct efx_nic * efx )
5468{
5569 struct efx_mcdi_iface * mcdi ;
@@ -70,8 +84,8 @@ static void efx_mcdi_copyin(struct efx_nic *efx, unsigned cmd,
7084 const u8 * inbuf , size_t inlen )
7185{
7286 struct efx_mcdi_iface * mcdi = efx_mcdi (efx );
73- unsigned pdu = FR_CZ_MC_TREG_SMEM + MCDI_PDU (efx );
74- unsigned doorbell = FR_CZ_MC_TREG_SMEM + MCDI_DOORBELL (efx );
87+ unsigned pdu = MCDI_PDU (efx );
88+ unsigned doorbell = MCDI_DOORBELL (efx );
7589 unsigned int i ;
7690 efx_dword_t hdr ;
7791 u32 xflags , seqno ;
@@ -92,38 +106,36 @@ static void efx_mcdi_copyin(struct efx_nic *efx, unsigned cmd,
92106 MCDI_HEADER_SEQ , seqno ,
93107 MCDI_HEADER_XFLAGS , xflags );
94108
95- efx_writed (efx , & hdr , pdu );
109+ efx_mcdi_writed (efx , & hdr , pdu );
96110
97- for (i = 0 ; i < inlen ; i += 4 ) {
98- _efx_writed (efx , * ((__le32 * )(inbuf + i )), pdu + 4 + i );
99- /* use wmb() within loop to inhibit write combining */
100- wmb ();
101- }
111+ for (i = 0 ; i < inlen ; i += 4 )
112+ efx_mcdi_writed (efx , (const efx_dword_t * )(inbuf + i ),
113+ pdu + 4 + i );
102114
103115 /* ring the doorbell with a distinctive value */
104- _efx_writed ( efx , ( __force __le32 ) 0x45789abc , doorbell );
105- wmb ( );
116+ EFX_POPULATE_DWORD_1 ( hdr , EFX_DWORD_0 , 0x45789abc );
117+ efx_mcdi_writed ( efx , & hdr , doorbell );
106118}
107119
108120static void efx_mcdi_copyout (struct efx_nic * efx , u8 * outbuf , size_t outlen )
109121{
110122 struct efx_mcdi_iface * mcdi = efx_mcdi (efx );
111- unsigned int pdu = FR_CZ_MC_TREG_SMEM + MCDI_PDU (efx );
123+ unsigned int pdu = MCDI_PDU (efx );
112124 int i ;
113125
114126 BUG_ON (atomic_read (& mcdi -> state ) == MCDI_STATE_QUIESCENT );
115127 BUG_ON (outlen & 3 || outlen >= 0x100 );
116128
117129 for (i = 0 ; i < outlen ; i += 4 )
118- * (( __le32 * )(outbuf + i )) = _efx_readd ( efx , pdu + 4 + i );
130+ efx_mcdi_readd ( efx , ( efx_dword_t * )(outbuf + i ), pdu + 4 + i );
119131}
120132
121133static int efx_mcdi_poll (struct efx_nic * efx )
122134{
123135 struct efx_mcdi_iface * mcdi = efx_mcdi (efx );
124136 unsigned int time , finish ;
125137 unsigned int respseq , respcmd , error ;
126- unsigned int pdu = FR_CZ_MC_TREG_SMEM + MCDI_PDU (efx );
138+ unsigned int pdu = MCDI_PDU (efx );
127139 unsigned int rc , spins ;
128140 efx_dword_t reg ;
129141
@@ -149,8 +161,7 @@ static int efx_mcdi_poll(struct efx_nic *efx)
149161
150162 time = get_seconds ();
151163
152- rmb ();
153- efx_readd (efx , & reg , pdu );
164+ efx_mcdi_readd (efx , & reg , pdu );
154165
155166 /* All 1's indicates that shared memory is in reset (and is
156167 * not a valid header). Wait for it to come out reset before
@@ -177,7 +188,7 @@ static int efx_mcdi_poll(struct efx_nic *efx)
177188 respseq , mcdi -> seqno );
178189 rc = EIO ;
179190 } else if (error ) {
180- efx_readd (efx , & reg , pdu + 4 );
191+ efx_mcdi_readd (efx , & reg , pdu + 4 );
181192 switch (EFX_DWORD_FIELD (reg , EFX_DWORD_0 )) {
182193#define TRANSLATE_ERROR (name ) \
183194 case MC_CMD_ERR_ ## name: \
@@ -211,21 +222,21 @@ static int efx_mcdi_poll(struct efx_nic *efx)
211222/* Test and clear MC-rebooted flag for this port/function */
212223int efx_mcdi_poll_reboot (struct efx_nic * efx )
213224{
214- unsigned int addr = FR_CZ_MC_TREG_SMEM + MCDI_REBOOT_FLAG (efx );
225+ unsigned int addr = MCDI_REBOOT_FLAG (efx );
215226 efx_dword_t reg ;
216227 uint32_t value ;
217228
218229 if (efx_nic_rev (efx ) < EFX_REV_SIENA_A0 )
219230 return false;
220231
221- efx_readd (efx , & reg , addr );
232+ efx_mcdi_readd (efx , & reg , addr );
222233 value = EFX_DWORD_FIELD (reg , EFX_DWORD_0 );
223234
224235 if (value == 0 )
225236 return 0 ;
226237
227238 EFX_ZERO_DWORD (reg );
228- efx_writed (efx , & reg , addr );
239+ efx_mcdi_writed (efx , & reg , addr );
229240
230241 if (value == MC_STATUS_DWORD_ASSERT )
231242 return - EINTR ;
0 commit comments