From: Igor Mitsyanko <i.mitsyanko@samsung.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: e.voevodin@samsung.com, qemu-devel@nongnu.org,
"Peter A. G. Crosthwaite" <peter.crosthwaite@petalogix.com>,
kyungmin.park@samsung.com, d.solodkiy@samsung.com,
edgar.iglesias@gmail.com, m.kozlov@samsung.com,
john.williams@petalogix.com
Subject: Re: [Qemu-devel] [PATCH v6 1/4] hw: introduce standard SD host controller
Date: Mon, 06 Aug 2012 15:28:13 +0400 [thread overview]
Message-ID: <501FAA4D.80400@samsung.com> (raw)
In-Reply-To: <CAFEAcA9F25AssxwDYrW2tH_SMyPYJuMeRgxm30d5BLHymPH=DQ@mail.gmail.com>
On 08/06/2012 02:30 PM, Peter Maydell wrote:
> On 6 August 2012 04:25, Peter A. G. Crosthwaite
> <peter.crosthwaite@petalogix.com> wrote:
>
>> +static void sdhci_sdma_transfer_multi_blocks(SDHCIState *s)
>> +{
>> + bool page_aligned = false;
>> + unsigned int n, begin;
>> + const uint16_t block_size = s->blksize & 0x0fff;
>> + uint32_t boundary_chk = 1 << (((s->blksize & 0xf000) >> 12) + 12);
>> + uint32_t boundary_count = boundary_chk - (s->sdmasysad % boundary_chk);
>> +
>> + /* XXX: Some sd/mmc drivers (for example, u-boot-slp) do not account for
>> + * possible stop at page boundary if initial address is not page aligned,
>> + * allow them to work properly */
>> + if ((s->sdmasysad % boundary_chk) == 0) {
>> + page_aligned = true;
>> + }
> It's not quite clear to me what this comment is indicating. Is it
> a bit of behaviour which is "not specified but behave as hardware
> happens to do because software is accidentally relying on it", or
> are we behaving differently from hardware here?
Spec states that DMA transfer should stop when controller detects a
carry out of specified address bits and interrupt should be generated to
stimulate software to update DMA address register. There's no way to
disable this behaviour, software can only regulate boundary size through
bits in BLKSIZE register (4K - 512K). That's how it was implemented
initially, but it caused u-boot mmc driver (which works fine on real
hardware) to hang.
The reason for hang is that when u-boot performs large continuous data
transfer (>512K) to an arbitrary (non page-aligned) address, it doesn't
care about "stop at page boundary" interrupt at all. It just loops
forefer, waiting for a DMA transfer completion, which will never
complete if it stopped at page boundary until software updates address
register.
The fact that it somehow manages to work on hardware got me thinking
that it only applies to initially aligned addresses.
>> +static void get_adma_description(SDHCIState *s, ADMADescr *dscr)
>> +{
>> + uint32_t adma1 = 0;
>> + uint64_t adma2 = 0;
>> + target_phys_addr_t entry_addr = (target_phys_addr_t)s->admasysaddr;
>> +
>> + switch (SDHC_DMA_TYPE(s->hostctl)) {
>> + case SDHC_CTRL_ADMA2_32:
>> + cpu_physical_memory_read(entry_addr, (uint8_t *)&adma2, sizeof(adma2));
>> + dscr->addr = (target_phys_addr_t)((adma2 >> 32) & 0xfffffffc);
>> + dscr->length = (uint16_t)((adma2 >> 16) & 0xFFFF);
>> + dscr->attr = (uint8_t)(adma2 & 0x3F);
> Does the SDHCI spec define that these words are interpreted like
> this regardless of system endianness, or is this an accidental
> assumption of little-endian behaviour?
Spec never says it explicitly, but it's quite obvious that descriptor
table has a little endian format. There is even a comment in linux SDHCI
driver that says:
/*
* The spec does not specify endianness of descriptor table.
* We currently guess that it is LE.
*/
>
> -- PMM
>
next prev parent reply other threads:[~2012-08-06 11:28 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-06 3:25 [Qemu-devel] [PATCH v6 0/4] Standard SD host controller model Peter A. G. Crosthwaite
2012-08-06 3:25 ` [Qemu-devel] [PATCH v6 1/4] hw: introduce standard SD host controller Peter A. G. Crosthwaite
2012-08-06 10:30 ` Peter Maydell
2012-08-06 11:28 ` Igor Mitsyanko [this message]
2012-08-06 11:29 ` Peter Maydell
2012-08-06 11:15 ` Peter Maydell
2012-08-06 11:45 ` Igor Mitsyanko
2012-08-07 6:31 ` Peter Crosthwaite
2012-08-10 11:56 ` Peter Crosthwaite
2012-08-06 12:35 ` Igor Mitsyanko
2012-08-06 3:25 ` [Qemu-devel] [PATCH v6 2/4] exynos4210: Added SD host controller model Peter A. G. Crosthwaite
2012-08-06 10:56 ` Peter Maydell
2012-08-06 12:29 ` Igor Mitsyanko
2012-09-18 2:41 ` Peter Crosthwaite
2012-09-18 6:42 ` Igor Mitsyanko
2012-08-06 3:25 ` [Qemu-devel] [PATCH v6 3/4] vl.c: allow for repeated -sd arguments Peter A. G. Crosthwaite
2012-08-06 3:25 ` [Qemu-devel] [PATCH v6 4/4] xilinx_zynq: Added SD controllers Peter A. G. Crosthwaite
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=501FAA4D.80400@samsung.com \
--to=i.mitsyanko@samsung.com \
--cc=d.solodkiy@samsung.com \
--cc=e.voevodin@samsung.com \
--cc=edgar.iglesias@gmail.com \
--cc=john.williams@petalogix.com \
--cc=kyungmin.park@samsung.com \
--cc=m.kozlov@samsung.com \
--cc=peter.crosthwaite@petalogix.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).