i.MX FEC and SD changes
cover i.MX FEC and SD changes
Hi everyone,
This patchset is a spin-off from original i.MX7 support submission found here [1], containing all of the patchest that are more or less agreed upon and are ready (hopefully!) for inclusion.
Changes since [1]:
- Rx buffer in FEC was moved from stack to heap to allow worry-free expansion to 16K limit.
- Added more comments explaining rather convoluted bit-moving in eSHDC emuation code
- Triple Tx ring DMA "VMState" code was changed to follow Peter's recommendations (avoiding the need to incrememnt the version_id)
- FSL_IMX25_FEC_SIZE is used as a size of FEC's register file
- Removed leftover code from "imx_fec: Change queue flushing heuristics"
[1] https://lists.gnu.org/archive/html/qemu-arm/2017-11/msg00045.html
Andrey Smirnov (13):
imx_fec: Do not link to netdev
imx_fec: Refactor imx_eth_enable_rx()
imx_fec: Change queue flushing heuristicsw
imx_fec: Move Tx frame buffer away from the stack
imx_fec: Use ENET_FTRL to determine truncation length
imx_fec: Use MIN instead of explicit ternary operator
imx_fec: Emulate SHIFT16 in ENETx_RACC
imx_fec: Add support for multiple Tx DMA rings
imx_fec: Use correct length for packet size
imx_fec: Fix a typo in imx_enet_receive()
imx_fec: Reserve full FSL_IMX25_FEC_SIZE page for the register file
sdhci: Add i.MX specific subtype of SDHCI
sdhci: Implement write method of ACMD12ERRSTS register
hw/arm/fsl-imx6.c | 1 + hw/net/imx_fec.c | 210 ++++++++++++++++++++++++++++++++--------- hw/sd/sdhci-internal.h | 19 ++++ hw/sd/sdhci.c | 231 ++++++++++++++++++++++++++++++++++++++++++++- include/hw/arm/fsl-imx25.h | 1 - include/hw/net/imx_fec.h | 27 +++++- include/hw/sd/sdhci.h | 8 ++ 7 files changed, 444 insertions(+), 53 deletions(-)
Signature · 1 line
2.14.3
PATCH 1/13 imx_fec: Do not link to netdev
Binding to a particular netdev doesn't seem to belong to this layer and should probably be done as a part of board or SoC specific code.
Convert all of the users of this IP block to useqdev_set_nic_properties() instead.
--- hw/arm/fsl-imx6.c | 1 + hw/net/imx_fec.c | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-)
hw/arm/fsl-imx6.c +1 -0
@@ -385,6 +385,7 @@ static void fsl_imx6_realize(DeviceState *dev, Error **errp) spi_table[i].irq)); } +qdev_set_nic_properties (DEVICE (&s->eth), &nd_table[0 ]);object_property_set_bool (OBJECT (&s->eth), true,"realized" , &err);if (err) {error_propagate (errp, err);
hw/net/imx_fec.c +0 -2
@@ -1171,8 +1171,6 @@ static void imx_eth_realize(DeviceState *dev, Error **errp)qemu_macaddr_default_if_unset (&s->conf.macaddr); - s->conf.peers.ncs[0 ] = nd_table[0 ].netdev; - s->nic =qemu_new_nic (&imx_eth_net_info, &s->conf,object_get_typename (OBJECT (dev)),DEVICE (dev)->id, s);
Signature · 1 line
2.14.3
PATCH 2/13 imx_fec: Refactor imx_eth_enable_rx()
In reply to Andrey SmirnovRefactor imx_eth_enable_rx() to have more meaningfull variable name than 'tmp' and to reduce number of logical negations done.
--- hw/net/imx_fec.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
hw/net/imx_fec.c +4 -4
@@ -536,19 +536,19 @@ static void imx_eth_do_tx(IMXFECState *s)static void imx_eth_enable_rx (IMXFECState *s) {IMXFECBufDesc bd; -bool tmp; +bool rx_ring_full;imx_fec_read_bd (&bd, s->rx_descriptor); - tmp = ((bd.flags &ENET_BD_E ) !=0 ); + rx_ring_full = !(bd.flags &ENET_BD_E ); -if (!tmp) { +if (rx_ring_full) {FEC_PRINTF ("RX buffer full\n" ); }else if (!s->regs[ENET_RDAR ]) {qemu_flush_queued_packets (qemu_get_queue (s->nic)); } - s->regs[ENET_RDAR ] = tmp ?ENET_RDAR_RDAR :0 ; + s->regs[ENET_RDAR ] = rx_ring_full ?0 :ENET_RDAR_RDAR ; }static void imx_eth_reset (DeviceState *d)
Signature · 1 line
2.14.3
PATCH 3/13 imx_fec: Change queue flushing heuristics
In reply to Andrey SmirnovIn current implementation, packet queue flushing logic seem to suffer from a deadlock like scenario if a packet is received by the interface before before Rx ring is initialized by Guest's driver. Consider the following sequence of events:
1. A QEMU instance is started against a TAP device on Linux host, running Linux guest, e. g., something to the effect of:
qemu-system-arm \
-net nic,model=imx.fec,netdev=lan0 \
netdev tap,id=lan0,ifname=tap0,script=no,downscript=no \
... rest of the arguments ...
2. Once QEMU starts, but before guest reaches the point where FEC deriver is done initializing the HW, Guest, via TAP interface, receives a number of multicast MDNS packets from Host (not necessarily true for every OS, but it happens at least on Fedora 25)
3. Recieving a packet in such a state results in imx_eth_can_receive() returning '0', which in turn causes tap_send() to disable corresponding event (tap.c:203)
4. Once Guest's driver reaches the point where it is ready to recieve packets it prepares Rx ring descriptors and writes ENET_RDAR_RDAR to ENET_RDAR register to indicate to HW that more descriptors are ready. And at this points emulation layer does this:
s->regs[index] = ENET_RDAR_RDAR;
imx_eth_enable_rx(s);
which, combined with:
if (!s->regs[ENET_RDAR]) {
qemu_flush_queued_packets(qemu_get_queue(s->nic));
}
results in Rx queue never being flushed and corresponding I/O event beign disabled.
To prevent the problem, change the code to always flush packet queue when ENET_RDAR transitions 0 -> ENET_RDAR_RDAR.
--- hw/net/imx_fec.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
hw/net/imx_fec.c +6 -6
@@ -533,7 +533,7 @@ static void imx_eth_do_tx(IMXFECState *s) } } -static void imx_eth_enable_rx (IMXFECState *s) +static void imx_eth_enable_rx (IMXFECState *s,bool flush) {IMXFECBufDesc bd;bool rx_ring_full;
@@ -544,7 +544,7 @@ static void imx_eth_enable_rx(IMXFECState *s)if (rx_ring_full) {FEC_PRINTF ("RX buffer full\n" ); - }else if (!s->regs[ENET_RDAR ]) { + }else if (flush) {qemu_flush_queued_packets (qemu_get_queue (s->nic)); }
@@ -807,7 +807,7 @@ static void imx_eth_write(void *opaque, hwaddr offset, uint64_t value,if (s->regs[ENET_ECR ] &ENET_ECR_ETHEREN ) {if (!s->regs[index]) { s->regs[index] =ENET_RDAR_RDAR ; -imx_eth_enable_rx (s); +imx_eth_enable_rx (s, true); } }else { s->regs[index] =0 ;
@@ -930,7 +930,7 @@ static int imx_eth_can_receive(NetClientState *nc)FEC_PRINTF ("\n" ); -return s->regs[ENET_RDAR ] ?1 :0 ; +return !!s->regs[ENET_RDAR ]; } static ssize_t imx_fec_receive(NetClientState *nc, const uint8_t *buf,
@@ -1020,7 +1020,7 @@ static ssize_t imx_fec_receive(NetClientState *nc, const uint8_t *buf, } } s->rx_descriptor = addr; -imx_eth_enable_rx (s); +imx_eth_enable_rx (s, false);imx_eth_update (s);return len; }
@@ -1116,7 +1116,7 @@ static ssize_t imx_enet_receive(NetClientState *nc, const uint8_t *buf, } } s->rx_descriptor = addr; -imx_eth_enable_rx (s); +imx_eth_enable_rx (s, false);imx_eth_update (s);return len; }
Signature · 1 line
2.14.3
PATCH 4/13 imx_fec: Move Tx frame buffer away from the stack
In reply to Andrey SmirnovMake Tx frame assembly buffer to be a paort of IMXFECState structure to avoid a concern about having large data buffer on the stack.
--- hw/net/imx_fec.c | 22 +++++++++++----------- include/hw/net/imx_fec.h | 3 +++ 2 files changed, 14 insertions(+), 11 deletions(-)
hw/net/imx_fec.c +11 -11
@@ -405,8 +405,7 @@ static void imx_eth_update(IMXFECState *s)static void imx_fec_do_tx (IMXFECState *s) {int frame_size =0 , descnt =0 ; -uint8_t frame[ENET_MAX_FRAME_SIZE ]; -uint8_t *ptr = frame; +uint8_t *ptr = s->frame;uint32_t addr = s->tx_descriptor;while (descnt++ <IMX_MAX_DESC ) {
@@ -431,8 +430,8 @@ static void imx_fec_do_tx(IMXFECState *s) frame_size += len;if (bd.flags &ENET_BD_L ) {/* Last buffer in frame. */ -qemu_send_packet (qemu_get_queue (s->nic), frame, frame_size); - ptr = frame; +qemu_send_packet (qemu_get_queue (s->nic), s->frame, frame_size); + ptr = s->frame; frame_size =0 ; s->regs[ENET_EIR ] |=ENET_INT_TXF ; }
@@ -456,8 +455,7 @@ static void imx_fec_do_tx(IMXFECState *s)static void imx_enet_do_tx (IMXFECState *s) {int frame_size =0 , descnt =0 ; -uint8_t frame[ENET_MAX_FRAME_SIZE ]; -uint8_t *ptr = frame; +uint8_t *ptr = s->frame;uint32_t addr = s->tx_descriptor;while (descnt++ <IMX_MAX_DESC ) {
@@ -482,13 +480,13 @@ static void imx_enet_do_tx(IMXFECState *s) frame_size += len;if (bd.flags &ENET_BD_L ) {if (bd.option &ENET_BD_PINS ) { -struct ip_header *ip_hd =PKT_GET_IP_HDR (frame); +struct ip_header *ip_hd =PKT_GET_IP_HDR (s->frame);if (IP_HEADER_VERSION (ip_hd) ==4 ) { -net_checksum_calculate (frame, frame_size); +net_checksum_calculate (s->frame, frame_size); } }if (bd.option &ENET_BD_IINS ) { -struct ip_header *ip_hd =PKT_GET_IP_HDR (frame); +struct ip_header *ip_hd =PKT_GET_IP_HDR (s->frame);/* We compute checksum only for IPv4 frames */ if (IP_HEADER_VERSION (ip_hd) ==4 ) {uint16_t csum;
@@ -498,8 +496,10 @@ static void imx_enet_do_tx(IMXFECState *s) } }/* Last buffer in frame. */ -qemu_send_packet (qemu_get_queue (s->nic), frame, len); - ptr = frame; + +qemu_send_packet (qemu_get_queue (s->nic), s->frame, len); + ptr = s->frame; + frame_size =0 ;if (bd.option &ENET_BD_TX_INT ) { s->regs[ENET_EIR ] |=ENET_INT_TXF ;
include/hw/net/imx_fec.h +3 -0
@@ -252,6 +252,9 @@ typedef struct IMXFECState {uint32_t phy_int_mask;bool is_fec; + +/* Buffer used to assemble a Tx frame */ + uint8_t frame[ENET_MAX_FRAME_SIZE]; } IMXFECState;#endif
Signature · 1 line
2.14.3
PATCH 5/13 imx_fec: Use ENET_FTRL to determine truncation length
In reply to Andrey SmirnovFrame truncation length, TRUNC_FL, is determined by the contents of ENET_FTRL register, so convert the code to use it instead of a hardcoded constant.
To avoid the case where TRUNC_FL is greater that ENET_MAX_FRAME_SIZE, increase the value of the latter to its theoretical maximum of 16K.
--- hw/net/imx_fec.c | 4 ++-- include/hw/net/imx_fec.h | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-)
hw/net/imx_fec.c +2 -2
@@ -1052,8 +1052,8 @@ static ssize_t imx_enet_receive(NetClientState *nc, const uint8_t *buf, crc_ptr = (uint8_t *) &crc;/* Huge frames are truncted. */ -if (size >ENET_MAX_FRAME_SIZE ) { - size =ENET_MAX_FRAME_SIZE ; +if (size > s->regs[ENET_FTRL ]) { + size = s->regs[ENET_FTRL ]; flags |=ENET_BD_TR |ENET_BD_LG ; }
include/hw/net/imx_fec.h +2 -1
@@ -86,7 +86,6 @@#define ENET_TCCR3 393#define ENET_MAX 400 -#define ENET_MAX_FRAME_SIZE 2032/* EIR and EIMR */ #define ENET_INT_HB (1 << 31)
@@ -155,6 +154,8 @@#define ENET_RCR_NLC (1 << 30)#define ENET_RCR_GRS (1 << 31) +#define ENET_MAX_FRAME_SIZE (1 << ENET_RCR_MAX_FL_LENGTH) +/* TCR */ #define ENET_TCR_GTS (1 << 0)#define ENET_TCR_FDEN (1 << 2)
Signature · 1 line
2.14.3
PATCH 6/13 imx_fec: Use MIN instead of explicit ternary operator
In reply to Andrey Smirnov--- hw/net/imx_fec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/net/imx_fec.c +1 -1
@@ -1076,7 +1076,7 @@ static ssize_t imx_enet_receive(NetClientState *nc, const uint8_t *buf, TYPE_IMX_FEC, __func__);break ; } - buf_len = (size <= s->regs[ENET_MRBR ]) ? size : s->regs[ENET_MRBR ]; + buf_len =MIN (size, s->regs[ENET_MRBR ]); bd.length = buf_len; size -= buf_len;
Signature · 1 line
2.14.3
PATCH 7/13 imx_fec: Emulate SHIFT16 in ENETx_RACC
In reply to Andrey SmirnovNeeded to support latest Linux kernel driver which relies on that functionality.
--- hw/net/imx_fec.c | 23 +++++++++++++++++++++++ include/hw/net/imx_fec.h | 2 ++ 2 files changed, 25 insertions(+)
hw/net/imx_fec.c +23 -0
@@ -1037,6 +1037,7 @@ static ssize_t imx_enet_receive(NetClientState *nc, const uint8_t *buf,uint8_t *crc_ptr;unsigned int buf_len;size_t size = len; +bool shift16 = s->regs[ENET_RACC ] &ENET_RACC_SHIFT16 ;FEC_PRINTF ("len %d\n" , (int )size);
@@ -1051,6 +1052,10 @@ static ssize_t imx_enet_receive(NetClientState *nc, const uint8_t *buf, crc =cpu_to_be32 (crc32 (~0 , buf, size)); crc_ptr = (uint8_t *) &crc; +if (shift16) { + size +=2 ; + } +/* Huge frames are truncted. */ if (size > s->regs[ENET_FTRL ]) { size = s->regs[ENET_FTRL ];
@@ -1087,6 +1092,24 @@ static ssize_t imx_enet_receive(NetClientState *nc, const uint8_t *buf, buf_len += size -4 ; } buf_addr = bd.data; + +if (shift16) { +/* +* If SHIFT16 bit of ENETx_RACC register is set we need to +* align the payload to 4-byte boundary. +*/ +const uint8_t zeros[2 ] = {0 }; + +dma_memory_write (&address_space_memory, buf_addr, + zeros,sizeof (zeros)); + + buf_addr +=sizeof (zeros); + buf_len -=sizeof (zeros); + +/* We only do this once per Ethernet frame */ + shift16 = false; + } +dma_memory_write (&address_space_memory, buf_addr, buf, buf_len); buf += buf_len;if (size <4 ) {
include/hw/net/imx_fec.h +2 -0
@@ -170,6 +170,8 @@#define ENET_TWFR_TFWR_LENGTH (6)#define ENET_TWFR_STRFWD (1 << 8) +#define ENET_RACC_SHIFT16 BIT(7) +/* Buffer Descriptor. */ typedef struct { uint16_t length;
Signature · 1 line
2.14.3
PATCH 8/13 imx_fec: Add support for multiple Tx DMA rings
In reply to Andrey SmirnovMore recent version of the IP block support more than one Tx DMA ring, so add the code implementing that feature.
--- hw/net/imx_fec.c | 133 ++++++++++++++++++++++++++++++++++++++++------- include/hw/net/imx_fec.h | 18 ++++++- 2 files changed, 130 insertions(+), 21 deletions(-)
hw/net/imx_fec.c +114 -19
@@ -196,6 +196,31 @@ static const char *imx_eth_reg_name(IMXFECState *s, uint32_t index) } } +/* +* Versions of this device with more than one TX descriptor save the +* 2nd and 3rd descriptors in a subsection, to maintain migration +* compatibility with previous versions of the device that only +* supported a single descriptor. +*/ +static bool imx_eth_is_multi_tx_ring (void *opaque) +{ +IMXFECState *s =IMX_FEC (opaque); + +return s->tx_ring_num >1 ; +} + +static const VMStateDescription vmstate_imx_eth_txdescs = { + .name ="imx.fec/txdescs" , + .version_id =1 , + .minimum_version_id =1 , + .needed = imx_eth_is_multi_tx_ring, + .fields = (VMStateField []) { +VMSTATE_UINT32 (tx_descriptor[1 ], IMXFECState), +VMSTATE_UINT32 (tx_descriptor[2 ], IMXFECState), +VMSTATE_END_OF_LIST () + } +}; +static const VMStateDescription vmstate_imx_eth = { .name =TYPE_IMX_FEC , .version_id =2 ,
@@ -203,15 +228,18 @@ static const VMStateDescription vmstate_imx_eth = { .fields = (VMStateField[]) {VMSTATE_UINT32_ARRAY (regs, IMXFECState,ENET_MAX ),VMSTATE_UINT32 (rx_descriptor, IMXFECState), -VMSTATE_UINT32 (tx_descriptor, IMXFECState), - +VMSTATE_UINT32 (tx_descriptor[0 ], IMXFECState),VMSTATE_UINT32 (phy_status, IMXFECState),VMSTATE_UINT32 (phy_control, IMXFECState),VMSTATE_UINT32 (phy_advertise, IMXFECState),VMSTATE_UINT32 (phy_int, IMXFECState),VMSTATE_UINT32 (phy_int_mask, IMXFECState),VMSTATE_END_OF_LIST () - } + }, + .subsections = (const VMStateDescription * []) { + &vmstate_imx_eth_txdescs, +NULL + }, };#define PHY_INT_ENERGYON (1 << 7)
@@ -406,7 +434,7 @@ static void imx_fec_do_tx(IMXFECState *s) {int frame_size =0 , descnt =0 ;uint8_t *ptr = s->frame; -uint32_t addr = s->tx_descriptor; +uint32_t addr = s->tx_descriptor[0 ];while (descnt++ <IMX_MAX_DESC ) {IMXFECBufDesc bd;
@@ -447,16 +475,47 @@ static void imx_fec_do_tx(IMXFECState *s) } } - s->tx_descriptor = addr; + s->tx_descriptor[0 ] = addr;imx_eth_update (s); } -static void imx_enet_do_tx (IMXFECState *s) +static void imx_enet_do_tx (IMXFECState *s,uint32_t index) {int frame_size =0 , descnt =0 ; +uint8_t *ptr = s->frame; -uint32_t addr = s->tx_descriptor; +uint32_t addr, int_txb, int_txf, tdsr; +size_t ring; + +switch (index) { +case ENET_TDAR : + ring =0 ; + int_txb =ENET_INT_TXB ; + int_txf =ENET_INT_TXF ; + tdsr =ENET_TDSR ; +break ; +case ENET_TDAR1 : + ring =1 ; + int_txb =ENET_INT_TXB1 ; + int_txf =ENET_INT_TXF1 ; + tdsr =ENET_TDSR1 ; +break ; +case ENET_TDAR2 : + ring =2 ; + int_txb =ENET_INT_TXB2 ; + int_txf =ENET_INT_TXF2 ; + tdsr =ENET_TDSR2 ; +break ; +default : +qemu_log_mask (LOG_GUEST_ERROR , +"%s: bogus value for index %x\n" , + __func__, index); +abort (); +break ; + } + + addr = s->tx_descriptor[ring];while (descnt++ <IMX_MAX_DESC ) {IMXENETBufDesc bd;
@@ -502,32 +561,32 @@ static void imx_enet_do_tx(IMXFECState *s) frame_size =0 ;if (bd.option &ENET_BD_TX_INT ) { - s->regs[ENET_EIR ] |=ENET_INT_TXF ; + s->regs[ENET_EIR ] |= int_txf; } }if (bd.option &ENET_BD_TX_INT ) { - s->regs[ENET_EIR ] |=ENET_INT_TXB ; + s->regs[ENET_EIR ] |= int_txb; } bd.flags &= ~ENET_BD_R ;/* Write back the modified descriptor. */ imx_enet_write_bd (&bd, addr);/* Advance to the next descriptor. */ if ((bd.flags &ENET_BD_W ) !=0 ) { - addr = s->regs[ENET_TDSR ]; + addr = s->regs[tdsr]; }else { addr +=sizeof (bd); } } - s->tx_descriptor = addr; + s->tx_descriptor[ring] = addr;imx_eth_update (s); } -static void imx_eth_do_tx (IMXFECState *s) +static void imx_eth_do_tx (IMXFECState *s,uint32_t index) {if (!s->is_fec && (s->regs[ENET_ECR ] &ENET_ECR_EN1588 )) { -imx_enet_do_tx (s); +imx_enet_do_tx (s, index); }else {imx_fec_do_tx (s); }
@@ -585,7 +644,7 @@ static void imx_eth_reset(DeviceState *d) } s->rx_descriptor =0 ; - s->tx_descriptor =0 ; +memset (s->tx_descriptor,0 ,sizeof (s->tx_descriptor));/* We also reset the PHY */ phy_reset (s);
@@ -791,6 +850,7 @@ static void imx_eth_write(void *opaque, hwaddr offset, uint64_t value, unsigned size) {IMXFECState *s =IMX_FEC (opaque); +const bool single_tx_ring = !imx_eth_is_multi_tx_ring (s);uint32_t index = offset >>2 ; FEC_PRINTF("reg[%s] <= 0x%" PRIx32 "\n", imx_eth_reg_name(s, index),
@@ -813,10 +873,18 @@ static void imx_eth_write(void *opaque, hwaddr offset, uint64_t value, s->regs[index] =0 ; }break ; -case ENET_TDAR : +case ENET_TDAR1 :/* FALLTHROUGH */ +case ENET_TDAR2 :/* FALLTHROUGH */ +if (unlikely (single_tx_ring)) { +qemu_log_mask (LOG_GUEST_ERROR , +"[%s]%s: trying to access TDAR2 or TDAR1\n" , +TYPE_IMX_FEC , __func__); +return ; + } +case ENET_TDAR :/* FALLTHROUGH */ if (s->regs[ENET_ECR ] &ENET_ECR_ETHEREN ) { s->regs[index] =ENET_TDAR_TDAR ; -imx_eth_do_tx (s); +imx_eth_do_tx (s, index); } s->regs[index] =0 ;break ;
@@ -828,8 +896,12 @@ static void imx_eth_write(void *opaque, hwaddr offset, uint64_t value,if ((s->regs[index] &ENET_ECR_ETHEREN ) ==0 ) { s->regs[ENET_RDAR ] =0 ; s->rx_descriptor = s->regs[ENET_RDSR ]; - s->regs[ENET_TDAR ] =0 ; - s->tx_descriptor = s->regs[ENET_TDSR ]; + s->regs[ENET_TDAR ] =0 ; + s->regs[ENET_TDAR1 ] =0 ; + s->regs[ENET_TDAR2 ] =0 ; + s->tx_descriptor[0 ] = s->regs[ENET_TDSR ]; + s->tx_descriptor[1 ] = s->regs[ENET_TDSR1 ]; + s->tx_descriptor[2 ] = s->regs[ENET_TDSR2 ]; }break ;case ENET_MMFR :
@@ -907,7 +979,29 @@ static void imx_eth_write(void *opaque, hwaddr offset, uint64_t value, }else { s->regs[index] = value & ~7 ; } - s->tx_descriptor = s->regs[index]; + s->tx_descriptor[0 ] = s->regs[index]; +break ; +case ENET_TDSR1 : +if (unlikely (single_tx_ring)) { +qemu_log_mask (LOG_GUEST_ERROR , +"[%s]%s: trying to access TDSR1\n" , +TYPE_IMX_FEC , __func__); +return ; + } + + s->regs[index] = value & ~7 ; + s->tx_descriptor[1 ] = s->regs[index]; +break ; +case ENET_TDSR2 : +if (unlikely (single_tx_ring)) { +qemu_log_mask (LOG_GUEST_ERROR , +"[%s]%s: trying to access TDSR2\n" , +TYPE_IMX_FEC , __func__); +return ; + } + + s->regs[index] = value & ~7 ; + s->tx_descriptor[2 ] = s->regs[index];break ;case ENET_MRBR : s->regs[index] = value &0x00003ff0 ;
@@ -1203,6 +1297,7 @@ static void imx_eth_realize(DeviceState *dev, Error **errp)static Property imx_eth_properties[] = {DEFINE_NIC_PROPERTIES (IMXFECState, conf), +DEFINE_PROP_UINT32 ("tx-ring-num" , IMXFECState, tx_ring_num,1 ),DEFINE_PROP_END_OF_LIST (), };
include/hw/net/imx_fec.h +16 -2
@@ -52,6 +52,8 @@#define ENET_TFWR 81#define ENET_FRBR 83#define ENET_FRSR 84 +#define ENET_TDSR1 89 +#define ENET_TDSR2 92#define ENET_RDSR 96#define ENET_TDSR 97#define ENET_MRBR 98
@@ -66,6 +68,8 @@#define ENET_FTRL 108#define ENET_TACC 112#define ENET_RACC 113 +#define ENET_TDAR1 121 +#define ENET_TDAR2 123#define ENET_MIIGSK_CFGR 192#define ENET_MIIGSK_ENR 194#define ENET_ATCR 256
@@ -105,13 +109,18 @@#define ENET_INT_WAKEUP (1 << 17)#define ENET_INT_TS_AVAIL (1 << 16)#define ENET_INT_TS_TIMER (1 << 15) +#define ENET_INT_TXF2 (1 << 7) +#define ENET_INT_TXB2 (1 << 6) +#define ENET_INT_TXF1 (1 << 3) +#define ENET_INT_TXB1 (1 << 2)#define ENET_INT_MAC (ENET_INT_HB | ENET_INT_BABR | ENET_INT_BABT | \ ENET_INT_GRA | ENET_INT_TXF | ENET_INT_TXB | \ ENET_INT_RXF | ENET_INT_RXB | ENET_INT_MII | \ ENET_INT_EBERR | ENET_INT_LC | ENET_INT_RL | \ ENET_INT_UN | ENET_INT_PLR | ENET_INT_WAKEUP | \ - ENET_INT_TS_AVAIL) + ENET_INT_TS_AVAIL | ENET_INT_TXF1 | \ + ENET_INT_TXB1 | ENET_INT_TXF2 | ENET_INT_TXB2)/* RDAR */ #define ENET_RDAR_RDAR (1 << 24)
@@ -234,6 +243,9 @@ typedef struct {#define ENET_BD_BDU (1 << 31) +#define ENET_TX_RING_NUM 3 + + typedef struct IMXFECState { /*< private >*/ SysBusDevice parent_obj;
@@ -246,7 +258,9 @@ typedef struct IMXFECState {uint32_t regs[ENET_MAX ];uint32_t rx_descriptor; -uint32_t tx_descriptor; + +uint32_t tx_descriptor[ENET_TX_RING_NUM ]; +uint32_t tx_ring_num;uint32_t phy_status;uint32_t phy_control;
Signature · 1 line
2.14.3
PATCH 9/13 imx_fec: Use correct length for packet size
In reply to Andrey SmirnovUse 'frame_size' instead of 'len' when calling qemu_send_packet(), failing to do so results in malformed packets send in case when that packed is fragmented into multiple DMA transactions.
--- hw/net/imx_fec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/net/imx_fec.c +1 -1
@@ -556,7 +556,7 @@ static void imx_enet_do_tx(IMXFECState *s, uint32_t index) }/* Last buffer in frame. */ -qemu_send_packet (qemu_get_queue (s->nic), s->frame, len); +qemu_send_packet (qemu_get_queue (s->nic), s->frame, frame_size); ptr = s->frame; frame_size =0 ;
Signature · 1 line
2.14.3
PATCH 10/13 imx_fec: Fix a typo in imx_enet_receive()
In reply to Andrey Smirnov--- hw/net/imx_fec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/net/imx_fec.c +1 -1
@@ -1150,7 +1150,7 @@ static ssize_t imx_enet_receive(NetClientState *nc, const uint8_t *buf, size +=2 ; } -/* Huge frames are truncted. */ +/* Huge frames are truncated. */ if (size > s->regs[ENET_FTRL ]) { size = s->regs[ENET_FTRL ]; flags |=ENET_BD_TR |ENET_BD_LG ;
Signature · 1 line
2.14.3
Re: [Qemu-devel] [PATCH 10/13] imx_fec: Fix a typo in imx_enet_receive()
Quoted 16 lines · Andrey Smirnov
Cc Peter Maydell <[email protected]>Cc Jason Wang <[email protected]>Cc Philippe Mathieu-Daudé <[email protected]>Signed-off-by Andrey Smirnov <[email protected]>--- hw/net/imx_fec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)hw/net/imx_fec.c +0
-0
hw/net/imx_fec.c static ssize_t imx_enet_receive(NetClientState *nc, const uint8_t *buf, · line 1156
Quoted 8 lines
hw/net/imx_fec.c +1
-1@@ -1150,7 +1150,7 @@ static ssize_t imx_enet_receive(NetClientState *nc, const uint8_t *buf, size +=2 ; } -/* Huge frames are truncted. */ +/* Huge frames are truncated. */ if (size > s->regs[ENET_FTRL ]) { size = s->regs[ENET_FTRL ]; flags |=ENET_BD_TR |ENET_BD_LG ;
thanks
-- PMM
PATCH 11/13 imx_fec: Reserve full FSL_IMX25_FEC_SIZE page for the register file
In reply to Andrey SmirnovSome i.MX SoCs (e.g. i.MX7) have FEC registers going as far as offset 0x614, so to avoid getting aborts when accessing those on QEMU, extend the register file to cover FSL_IMX25_FEC_SIZE(16K) of address space instead of just 1K.
--- hw/net/imx_fec.c | 2 +- include/hw/arm/fsl-imx25.h | 1 - include/hw/net/imx_fec.h | 1 + 3 files changed, 2 insertions(+), 2 deletions(-)
hw/net/imx_fec.c +1 -1
@@ -1281,7 +1281,7 @@ static void imx_eth_realize(DeviceState *dev, Error **errp)SysBusDevice *sbd =SYS_BUS_DEVICE (dev);memory_region_init_io (&s->iomem,OBJECT (dev), &imx_eth_ops, s, -TYPE_IMX_FEC ,0x400 ); +TYPE_IMX_FEC ,FSL_IMX25_FEC_SIZE );sysbus_init_mmio (sbd, &s->iomem);sysbus_init_irq (sbd, &s->irq[0 ]);sysbus_init_irq (sbd, &s->irq[1 ]);
include/hw/arm/fsl-imx25.h +0 -1
@@ -192,7 +192,6 @@ typedef struct FslIMX25State {#define FSL_IMX25_UART5_ADDR 0x5002C000#define FSL_IMX25_UART5_SIZE 0x4000#define FSL_IMX25_FEC_ADDR 0x50038000 -#define FSL_IMX25_FEC_SIZE 0x4000#define FSL_IMX25_CCM_ADDR 0x53F80000#define FSL_IMX25_CCM_SIZE 0x4000#define FSL_IMX25_GPT4_ADDR 0x53F84000
include/hw/net/imx_fec.h +1 -0
@@ -245,6 +245,7 @@ typedef struct {#define ENET_TX_RING_NUM 3 +#define FSL_IMX25_FEC_SIZE 0x4000 typedef struct IMXFECState { /*< private >*/
Signature · 1 line
2.14.3
Re: [Qemu-arm] [PATCH 11/13] imx_fec: Reserve full FSL_IMX25_FEC_SIZE page for the register file
Quoted 5 lines · Andrey Smirnov
Some i.MX SoCs (e.g. i.MX7) have FEC registers going as far as offset
0x614, so to avoid getting aborts when accessing those on QEMU, extend the register file to coverFSL_IMX25_FEC_SIZE(16K)of address space instead of just 1K.
Quoted 7 lines
Cc Peter Maydell <[email protected]>Cc Jason Wang <[email protected]>Cc Philippe Mathieu-Daudé <[email protected]>Signed-off-by Andrey Smirnov <[email protected]>
thanks
-- PMM
PATCH 12/13 sdhci: Add i.MX specific subtype of SDHCI
In reply to Andrey SmirnovIP block found on several generations of i.MX family does not use vanilla SDHCI implementation and it comes with a number of quirks.
Introduce i.MX SDHCI subtype of SDHCI block to add code necessary to support unmodified Linux guest driver.
--- hw/sd/sdhci-internal.h | 19 +++++ hw/sd/sdhci.c | 228 ++++++++++++++++++++++++++++++++++++++++++++++++- include/hw/sd/sdhci.h | 8 ++ 3 files changed, 253 insertions(+), 2 deletions(-)
hw/sd/sdhci-internal.h +19 -0
@@ -85,12 +85,18 @@/* R/W Host control Register 0x0 */ #define SDHC_HOSTCTL 0x28 +#define SDHC_CTRL_LED 0x01#define SDHC_CTRL_DMA_CHECK_MASK 0x18#define SDHC_CTRL_SDMA 0x00#define SDHC_CTRL_ADMA1_32 0x08#define SDHC_CTRL_ADMA2_32 0x10#define SDHC_CTRL_ADMA2_64 0x18#define SDHC_DMA_TYPE (x) ((x) & SDHC_CTRL_DMA_CHECK_MASK) +#define SDHC_CTRL_4BITBUS 0x02 +#define SDHC_CTRL_8BITBUS 0x20 +#define SDHC_CTRL_CDTEST_INS 0x40 +#define SDHC_CTRL_CDTEST_EN 0x80 +/* R/W Power Control Register 0x0 */ #define SDHC_PWRCON 0x29
@@ -229,4 +235,17 @@ enum {extern const VMStateDescription sdhci_vmstate; + +#define ESDHC_MIX_CTRL 0x48 +#define ESDHC_VENDOR_SPEC 0xc0 +#define ESDHC_DLL_CTRL 0x60 + +#define ESDHC_TUNING_CTRL 0xcc +#define ESDHC_TUNE_CTRL_STATUS 0x68 +#define ESDHC_WTMK_LVL 0x44 + +#define ESDHC_CTRL_4BITBUS (0x1 << 1) +#define ESDHC_CTRL_8BITBUS (0x2 << 1) + +#endif
hw/sd/sdhci.c +226 -2
257 lines not on this page · raw message
include/hw/sd/sdhci.h +8 -0
@@ -39,6 +39,7 @@ typedef struct SDHCIState { };SDBus sdbus;MemoryRegion iomem; +const MemoryRegionOps *io_ops;QEMUTimer *insert_timer;/* timer for 'changing' sd card. */ QEMUTimer *transfer_timer;
@@ -83,8 +84,13 @@ typedef struct SDHCIState {/* Force Event Auto CMD12 Error Interrupt Reg - write only */ /* Force Event Error Interrupt Register- write only */ /* RO Host Controller Version Register always reads as 0x2401 */ + +unsigned long quirks; } SDHCIState; +/* Controller does not provide transfer-complete interrupt when not busy */ +#define SDHCI_QUIRK_NO_BUSY_IRQ BIT(14) +#define TYPE_PCI_SDHCI "sdhci-pci"#define PCI_SDHCI (obj) OBJECT_CHECK(SDHCIState, (obj), TYPE_PCI_SDHCI)
@@ -92,4 +98,6 @@ typedef struct SDHCIState {#define SYSBUS_SDHCI (obj) \ OBJECT_CHECK(SDHCIState, (obj), TYPE_SYSBUS_SDHCI) +#define TYPE_IMX_USDHC "imx-usdhc" +#endif /* SDHCI_H */
Signature · 1 line
2.14.3
Re: [Qemu-arm] [PATCH 12/13] sdhci: Add i.MX specific subtype of SDHCI
Quoted 15 lines · Andrey Smirnov
IP block found on several generations of i.MX family does not use vanilla SDHCI implementation and it comes with a number of quirks.
Introduce i.MX SDHCI subtype of SDHCI block to add code necessary to support unmodified Linux guest driver.
Cc Peter Maydell <[email protected]>Cc Jason Wang <[email protected]>Cc Philippe Mathieu-Daudé <[email protected]>Signed-off-by Andrey Smirnov <[email protected]>---
hw/sd/sdhci.c static const TypeInfo sdhci_bus_info = { · line 1426
Quoted 3 lines
hw/sd/sdhci.c +3
-0+case ESDHC_DLL_CTRL : +case ESDHC_TUNE_CTRL_STATUS : +case 0x6c :
Isn't there a name we can give 0x6c ?
Quoted 64 lines
hw/sd/sdhci.c +64
-0+case ESDHC_TUNING_CTRL : +case ESDHC_VENDOR_SPEC : +case ESDHC_MIX_CTRL : +case ESDHC_WTMK_LVL : + ret =0 ; +break ; + } + +return ret; +} + +static void +usdhc_write (void *opaque,hwaddr offset,uint64_t val,unsigned size) +{ +SDHCIState *s =SYSBUS_SDHCI (opaque); +uint8_t hostctl; +uint32_t value = (uint32_t )val; + +switch (offset) { +case ESDHC_DLL_CTRL : +case ESDHC_TUNE_CTRL_STATUS : +case 0x6c : +case ESDHC_TUNING_CTRL : +case ESDHC_WTMK_LVL : +case ESDHC_VENDOR_SPEC : +break ; + +case SDHC_HOSTCTL : +/* +* Here's What ESDHCI has at offset 0x28 (SDHC_HOSTCTL) +* +* 7 6 5 4 3 2 1 0 +* |-----------+--------+--------+-----------+----------+---------| +* | Card | Card | Endian | DATA3 | Data | Led | +* | Detect | Detect | Mode | as Card | Transfer | Control | +* | Signal | Test | | Detection | Width | | +* | Selection | Level | | Pin | | | +* |-----------+--------+--------+-----------+----------+---------| +* +* and 0x29 +* +* 15 10 9 8 +* |----------+------| +* | Reserved | DMA | +* | | Sel. | +* | | | +* |----------+------| +* +* and here's what SDCHI spec expects those offsets to be: +* +* 0x28 (Host Control Register) +* +* 7 6 5 4 3 2 1 0 +* |--------+--------+----------+------+--------+----------+---------| +* | Card | Card | Extended | DMA | High | Data | LED | +* | Detect | Detect | Data | Sel. | Speed | Transfer | Control | +* | Signal | Test | Transfer | | Enable | Width | | +* | Sel. | Level | Width | | | | | +* |--------+--------+----------+------+--------+----------+---------| +* +* and 0x29 (Power Control Register) +* +* |----------------------------------| +* | Power Control Register |
hw/sd/sdhci.c static const TypeInfo sdhci_bus_info = { · line 1500
Quoted 10 lines
hw/sd/sdhci.c +10
-0+* | | +* | Description omitted, | +* | since it has no analog in ESDHCI | +* | | +* |----------------------------------| +* +* Since offsets 0x2A and 0x2B should be compatible between +* both IP specs we only need to reconcile least 16-bit of the +* word we've been given. +*/
Thanks for this explanation, it's very helpful in figuring out what's going on.
hw/sd/sdhci.c static const TypeInfo sdhci_bus_info = { · line 1579
Quoted 12 lines
hw/sd/sdhci.c +12
-0+case SDHC_BLKSIZE : +/* +* ESDHCI does not implement "Host SDMA Buffer Boundary", and +* Linux driver will try to zero this field out which will +* break the rest of SDHCI emulation. +* +* Linux defaults to maximum possible setting (512K boundary) +* and it seems to be the only option that i.MX IP implements, +* so we artificially set it to that value. +*/ + val |=0x7 <<12 ; +/* FALLTHROUGH */
We generally write this lowercase: /* fallthrough */
Quoted 19 lines
hw/sd/sdhci.c +5
-0+default : +sdhci_write (opaque, offset, val, size); +break ; + } +}include/hw/sd/sdhci.h +1
-0@@ -39,6 +39,7 @@ typedef struct SDHCIState { };SDBus sdbus;MemoryRegion iomem; +const MemoryRegionOps *io_ops;QEMUTimer *insert_timer;/* timer for 'changing' sd card. */ QEMUTimer *transfer_timer;
include/hw/sd/sdhci.h typedef struct SDHCIState { · line 88
Quoted 5 lines
include/hw/sd/sdhci.h +2
-0@@ -83,8 +84,13 @@ typedef struct SDHCIState {/* Force Event Auto CMD12 Error Interrupt Reg - write only */ /* Force Event Error Interrupt Register- write only */ /* RO Host Controller Version Register always reads as 0x2401 */ + +unsigned long quirks;
I asked for this not to be unsigned long in the last round of review.
include/hw/sd/sdhci.h typedef struct SDHCIState { · line 92
Quoted 4 lines
include/hw/sd/sdhci.h +2
-0} SDHCIState; +/* Controller does not provide transfer-complete interrupt when not busy */ +#define SDHCI_QUIRK_NO_BUSY_IRQ BIT(14)
I asked for a comment saying we're following the Linux kernel's quirk bit numbering in the last round of review.
Quoted 12 lines
include/hw/sd/sdhci.h +3
-1+#define TYPE_PCI_SDHCI "sdhci-pci"#define PCI_SDHCI (obj) OBJECT_CHECK(SDHCIState, (obj), TYPE_PCI_SDHCI)@@ -92,4 +98,6 @@ typedef struct SDHCIState {#define SYSBUS_SDHCI (obj) \ OBJECT_CHECK(SDHCIState, (obj), TYPE_SYSBUS_SDHCI) +#define TYPE_IMX_USDHC "imx-usdhc" +#endif /* SDHCI_H */ --
Quoted 1 line
2.14.3
Otherwise
thanks
-- PMM
Re: [Qemu-arm] [PATCH 12/13] sdhci: Add i.MX specific subtype of SDHCI
Quoted 16 lines · Peter Maydell
Quoted 14 lines · Andrey Smirnov
IP block found on several generations of i.MX family does not use vanilla SDHCI implementation and it comes with a number of quirks.
Introduce i.MX SDHCI subtype of SDHCI block to add code necessary to support unmodified Linux guest driver.
Cc Peter Maydell <[email protected]>Cc Jason Wang <[email protected]>Cc Philippe Mathieu-Daudé <[email protected]>Signed-off-by Andrey Smirnov <[email protected]>---
Quoted 6 lines
hw/sd/sdhci.c static const TypeInfo sdhci_bus_info = { · line 1426
Quoted 3 lines
hw/sd/sdhci.c +3
-0+case ESDHC_DLL_CTRL : +case ESDHC_TUNE_CTRL_STATUS : +case 0x6c :Isn't there a name we can give
0x6c?
Unfortunately, not that I know of. It's a mystery register not listed in RM and the only place I can found it being mentioned is in Linux driver as a part of errata ESDHC_FLAG_ERR004536 fix, where it is used nameless as well.
Quoted 91 lines
Quoted 64 lines
hw/sd/sdhci.c +64
-0+case ESDHC_TUNING_CTRL : +case ESDHC_VENDOR_SPEC : +case ESDHC_MIX_CTRL : +case ESDHC_WTMK_LVL : + ret =0 ; +break ; + } + +return ret; +} + +static void +usdhc_write (void *opaque,hwaddr offset,uint64_t val,unsigned size) +{ +SDHCIState *s =SYSBUS_SDHCI (opaque); +uint8_t hostctl; +uint32_t value = (uint32_t )val; + +switch (offset) { +case ESDHC_DLL_CTRL : +case ESDHC_TUNE_CTRL_STATUS : +case 0x6c : +case ESDHC_TUNING_CTRL : +case ESDHC_WTMK_LVL : +case ESDHC_VENDOR_SPEC : +break ; + +case SDHC_HOSTCTL : +/* +* Here's What ESDHCI has at offset 0x28 (SDHC_HOSTCTL) +* +* 7 6 5 4 3 2 1 0 +* |-----------+--------+--------+-----------+----------+---------| +* | Card | Card | Endian | DATA3 | Data | Led | +* | Detect | Detect | Mode | as Card | Transfer | Control | +* | Signal | Test | | Detection | Width | | +* | Selection | Level | | Pin | | | +* |-----------+--------+--------+-----------+----------+---------| +* +* and 0x29 +* +* 15 10 9 8 +* |----------+------| +* | Reserved | DMA | +* | | Sel. | +* | | | +* |----------+------| +* +* and here's what SDCHI spec expects those offsets to be: +* +* 0x28 (Host Control Register) +* +* 7 6 5 4 3 2 1 0 +* |--------+--------+----------+------+--------+----------+---------| +* | Card | Card | Extended | DMA | High | Data | LED | +* | Detect | Detect | Data | Sel. | Speed | Transfer | Control | +* | Signal | Test | Transfer | | Enable | Width | | +* | Sel. | Level | Width | | | | | +* |--------+--------+----------+------+--------+----------+---------| +* +* and 0x29 (Power Control Register) +* +* |----------------------------------| +* | Power Control Register | hw/sd/sdhci.c static const TypeInfo sdhci_bus_info = { · line 1500
Quoted 10 lines
hw/sd/sdhci.c +10
-0+* | | +* | Description omitted, | +* | since it has no analog in ESDHCI | +* | | +* |----------------------------------| +* +* Since offsets 0x2A and 0x2B should be compatible between +* both IP specs we only need to reconcile least 16-bit of the +* word we've been given. +*/ Thanks for this explanation, it's very helpful in figuring out what's going on.
hw/sd/sdhci.c static const TypeInfo sdhci_bus_info = { · line 1579
Quoted 12 lines
hw/sd/sdhci.c +12
-0+case SDHC_BLKSIZE : +/* +* ESDHCI does not implement "Host SDMA Buffer Boundary", and +* Linux driver will try to zero this field out which will +* break the rest of SDHCI emulation. +* +* Linux defaults to maximum possible setting (512K boundary) +* and it seems to be the only option that i.MX IP implements, +* so we artificially set it to that value. +*/ + val |=0x7 <<12 ; +/* FALLTHROUGH */
Quoted 2 lines
We generally write this lowercase: /* fallthrough */
OK, will fix in v2.
Quoted 16 lines
Quoted 16 lines
hw/sd/sdhci.c +5
-0+default : +sdhci_write (opaque, offset, val, size); +break ; + } +}include/hw/sd/sdhci.h +1
-0@@ -39,6 +39,7 @@ typedef struct SDHCIState { };SDBus sdbus;MemoryRegion iomem; +const MemoryRegionOps *io_ops;
Quoted 11 lines
include/hw/sd/sdhci.h typedef struct SDHCIState { · line 88
Quoted 8 lines
include/hw/sd/sdhci.h +2
-0QEMUTimer *insert_timer;/* timer for 'changing' sd card. */ QEMUTimer *transfer_timer;@@ -83,8 +84,13 @@ typedef struct SDHCIState {/* Force Event Auto CMD12 Error Interrupt Reg - write only */ /* Force Event Error Interrupt Register- write only */ /* RO Host Controller Version Register always reads as 0x2401 */ + +unsigned long quirks;I asked for this not to be unsigned long in the last round of review.
Ugh, missed this one, sorry about that. Will fix in v2.
Quoted 8 lines
include/hw/sd/sdhci.h typedef struct SDHCIState { · line 92
Quoted 4 lines
include/hw/sd/sdhci.h +2
-0} SDHCIState; +/* Controller does not provide transfer-complete interrupt when not busy */ +#define SDHCI_QUIRK_NO_BUSY_IRQ BIT(14)I asked for a comment saying we're following the Linux kernel's quirk bit numbering in the last round of review.
My bad, will fix in v 2.
Thanks,
Andrey Smirnov
Re: [Qemu-arm] [PATCH 12/13] sdhci: Add i.MX specific subtype of SDHCI
Hi Andrey,
Quoted 2 lines · Andrey Smirnov
Quoted 1 line · Peter Maydell
On 11 December 2017 at 21:30, Andrey Smirnov <[email protected]> wrote:
[...]
Quoted 11 lines
Quoted 6 lines
hw/sd/sdhci.c static const TypeInfo sdhci_bus_info = { · line 1426
Quoted 3 lines
hw/sd/sdhci.c +3
-0+case ESDHC_DLL_CTRL : +case ESDHC_TUNE_CTRL_STATUS : +case 0x6c :Isn't there a name we can give
0x6c?Unfortunately, not that I know of. It's a mystery register not listed in RM and the only place I can found it being mentioned is in Linux driver as a part of errata
ESDHC_FLAG_ERR004536fix, where it is used nameless as well.
This sets the SD CLK/RCLK frequency (10-bit) for the 104MB/sec bus speed (UHS-I mode).
The "Sampling Clock Tuning Procedure" figure in the Spec v3 is helpful.
In my tree (where I work on UHS-I/II) I have:
#define SDHC_PRESET_SDR104 0x6cFIELD(SDHC_PRESET_SDR104, CLKFREQ, 0, 10); /* since v3 */
FIELD(SDHC_PRESET_SDR104, CLKGEN, 10, 1); /* since v3 */ FIELD(SDHC_PRESET_SDR104, DRIVE_STRENGTH, 14, 2); /* since v3 (UHS-I
only) */
Regards,
Phil.
Re: [Qemu-arm] [PATCH 12/13] sdhci: Add i.MX specific subtype of SDHCI
Quoted 18 lines · Philippe Mathieu-Daudé
Hi Andrey,
Quoted 2 lines · Andrey Smirnov
Quoted 1 line · Peter Maydell
On 11 December 2017 at 21:30, Andrey Smirnov <[email protected]> wrote:
[...]
Quoted 11 lines
Quoted 6 lines
hw/sd/sdhci.c static const TypeInfo sdhci_bus_info = { · line 1426
Quoted 3 lines
hw/sd/sdhci.c +3
-0+case ESDHC_DLL_CTRL : +case ESDHC_TUNE_CTRL_STATUS : +case 0x6c :Isn't there a name we can give
0x6c?Unfortunately, not that I know of. It's a mystery register not listed in RM and the only place I can found it being mentioned is in Linux driver as a part of errata
ESDHC_FLAG_ERR004536fix, where it is used nameless as well.
Quoted 5 lines
This sets the SD CLK/RCLK frequency (10-bit) for the 104MB/sec bus speed (UHS-I mode).
The "Sampling Clock Tuning Procedure" figure in the Spec v3 is helpful.
I am a bit hesitant to agree that this is indeed the case. ERR004536 errata's title is "uSDHC: ADMA Length Mismatch Error may occur for longer read latencies" and recommented workaround is "Use SDMA (or ADMA1) in case the AHB latency is larger than the “minimal time for one block”. On top of that corresponding code in Linux
(https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/mmc/host/sdhci-esdhc-imx.c?h=v4.15-rc3#n1061)
doesn't seem to use it as a 10-bit frequency field, treating it more like a single-bit flag.
Thanks,
Andrey Smirnov
Re: [Qemu-arm] [PATCH 12/13] sdhci: Add i.MX specific subtype of SDHCI
Quoted 20 lines · Andrey Smirnov
Quoted 13 lines · Philippe Mathieu-Daudé
[...]
Quoted 11 lines
Quoted 6 lines
hw/sd/sdhci.c static const TypeInfo sdhci_bus_info = { · line 1426
Quoted 3 lines
hw/sd/sdhci.c +3
-0+case ESDHC_DLL_CTRL : +case ESDHC_TUNE_CTRL_STATUS : +case 0x6c :Isn't there a name we can give
0x6c?Unfortunately, not that I know of. It's a mystery register not listed in RM and the only place I can found it being mentioned is in Linux driver as a part of errata
ESDHC_FLAG_ERR004536fix, where it is used nameless as well.Quoted 5 lines
This sets the SD CLK/RCLK frequency (10-bit) for the 104MB/sec bus speed (UHS-I mode).
The "Sampling Clock Tuning Procedure" figure in the Spec v3 is helpful.
Quoted 8 lines
I am a bit hesitant to agree that this is indeed the case. ERR004536 errata's title is "uSDHC: ADMA Length Mismatch Error may occur for longer read latencies" and recommented workaround is "Use SDMA (or ADMA1) in case the AHB latency is larger than the “minimal time for one block”. On top of that corresponding code in Linux
(https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/mmc/host/sdhci-esdhc-imx.c?h=v4.15-rc3#n1061)
doesn't seem to use it as a 10-bit frequency field, treating it more like a single-bit flag.
Ok, I'll have a better look when applying these SD patches on top of my current SD tree.
Regards,
Phil.
PATCH 13/13 sdhci: Implement write method of ACMD12ERRSTS register
In reply to Andrey Smirnov--- hw/sd/sdhci.c | 3 +++ 1 file changed, 3 insertions(+)
hw/sd/sdhci.c +3 -0
@@ -1139,6 +1139,9 @@ sdhci_write(void *opaque, hwaddr offset, uint64_t val, unsigned size) s->admasysaddr = (s->admasysaddr & (0x00000000FFFFFFFFULL | ((uint64_t )mask <<32 ))) | ((uint64_t )value <<32 );break ; +case SDHC_ACMD12ERRSTS : +MASKED_WRITE (s->acmd12errsts, mask, value); +break ;case SDHC_FEAER : s->acmd12errsts |= value; s->errintsts |= (value >>16 ) & s->errintstsen;
Signature · 1 line
2.14.3
Quoted 18 lines · Andrey Smirnov
Hi everyone,
This patchset is a spin-off from original i.MX7 support submission found here [1], containing all of the patchest that are more or less agreed upon and are ready (hopefully!) for inclusion.
Changes since [1]:
- Rx buffer in FEC was moved from stack to heap to allow worry-free expansion to 16K limit.
- Added more comments explaining rather convoluted bit-moving in eSHDC emuation code
- Triple Tx ring DMA "VMState" code was changed to follow Peter's recommendations (avoiding the need to incrememnt the
version_id)
Quoted 6 lines
-
FSL_IMX25_FEC_SIZEis used as a size of FEC's register file- Removed leftover code from "
imx_fec: Change queue flushing heuristics"[1] https://lists.gnu.org/archive/html/qemu-arm/2017-11/msg00045.html
Hi; thanks for sending this set separately. Patch 4 ("Move Tx frame buffer away from the stack") seems to have got lost -- it isn't in the mailing list archives or my mailbox. Could you try resending that one?
Incidentally we should use the new i.MX SDHCI controller in the
imx6: coincidentally somebody ran into this bug recently:
https://stackoverflow.com/questions/47538951/qemu-freescale-i-mx6-duallite-sabre-root-filesystem-does-not-mount/47552596
I'll retest that this patchset works with my imx6 image, and send a patch to sit on top of it to switch imx6 over to TYPE_IMX_USDHC.
thanks
-- PMM
Hi Andrey, Peter,
Quoted 6 lines · Peter Maydell
Quoted 5 lines · Andrey Smirnov
Hi everyone,
This patchset is a spin-off from original i.MX7 support submission found here [1], containing all of the patchest that are more or less agreed upon and are ready (hopefully!) for inclusion.
[...]
Quoted 6 lines
Incidentally we should use the new i.MX SDHCI controller in the
imx6: coincidentally somebody ran into this bug recently:
https://stackoverflow.com/questions/47538951/qemu-freescale-i-mx6-duallite-sabre-root-filesystem-does-not-mount/47552596I'll retest that this patchset works with my imx6 image, and send a patch to sit on top of it to switch imx6 over to
TYPE_IMX_USDHC.
If you don't mind, I'd like to take the patches 12/13 (SDHCI) and adapt them to the SDHCI series I'm working on, to avoid a big diverge/clash.
Regards,
Phil.
Quoted 14 lines · Philippe Mathieu-Daudé
Hi Andrey, Peter,
Quoted 6 lines · Peter Maydell
Quoted 5 lines · Andrey Smirnov
Hi everyone,
This patchset is a spin-off from original i.MX7 support submission found here [1], containing all of the patchest that are more or less agreed upon and are ready (hopefully!) for inclusion.
[...]
Quoted 4 lines
Incidentally we should use the new i.MX SDHCI controller in the
imx6: coincidentally somebody ran into this bug recently:
https://stackoverflow.com/questions/47538951/qemu-freescale-i-mx6-duallite-sabre-root-filesystem-does-not-mount/47552596
Quoted 6 lines
Quoted 2 lines
I'll retest that this patchset works with my imx6 image, and send a patch to sit on top of it to switch imx6 over to
TYPE_IMX_USDHC.If you don't mind, I'd like to take the patches 12/13 (SDHCI) and adapt them to the SDHCI series I'm working on, to avoid a big diverge/clash.
I am fine with patches going in either way. I'll submit a v2 of my patchset and if we decide to push SD portion of it as a part of your work, then you can just pick those from there.
Thanks,
Andrey Smirnov
Quoted 21 lines · Peter Maydell
Quoted 20 lines · Andrey Smirnov
Hi everyone,
This patchset is a spin-off from original i.MX7 support submission found here [1], containing all of the patchest that are more or less agreed upon and are ready (hopefully!) for inclusion.
Changes since [1]:
- Rx buffer in FEC was moved from stack to heap to allow worry-free expansion to 16K limit.
- Added more comments explaining rather convoluted bit-moving in eSHDC emuation code
- Triple Tx ring DMA "VMState" code was changed to follow Peter's recommendations (avoiding the need to incrememnt the
version_id)-
FSL_IMX25_FEC_SIZEis used as a size of FEC's register file
Quoted 9 lines
Quoted 4 lines
- Removed leftover code from "
imx_fec: Change queue flushing heuristics"[1] https://lists.gnu.org/archive/html/qemu-arm/2017-11/msg00045.html
Hi; thanks for sending this set separately. Patch 4 ("Move Tx frame buffer away from the stack") seems to have got lost -- it isn't in the mailing list archives or my mailbox. Could you try resending that one?
My bad, I forgot to add correct Cc tags to that one. I am a bit surprised it's not in the archive since it did have correct To: info, but it doesn't matter. I'll make sure this patch is sent out in v2.
Quoted 7 lines
Incidentally we should use the new i.MX SDHCI controller in the
imx6: coincidentally somebody ran into this bug recently:
https://stackoverflow.com/questions/47538951/qemu-freescale-i-mx6-duallite-sabre-root-filesystem-does-not-mount/47552596I'll retest that this patchset works with my imx6 image, and send a patch to sit on top of it to switch imx6 over to
TYPE_IMX_USDHC.
Out of curiosity, I gave emulating SD on i.MX6 a try and it mostly worked (there were other unrelated to SD problems). I'll include what I came up with and we can go from there.
Thanks,
Andrey Smirnov