From: Paolo Bonzini <pbonzini@redhat.com>
To: "Hervé Poussineau" <hpoussin@reactos.org>, qemu-devel@nongnu.org
Cc: Leon Alrae <leon.alrae@imgtec.com>,
Laurent@Vivier.EU, Aurelien Jarno <aurelien@aurel32.net>
Subject: Re: [Qemu-devel] [PATCH 1/8] rc4030: create custom DMA address space
Date: Thu, 26 Mar 2015 15:27:23 +0100 [thread overview]
Message-ID: <5514174B.9010406@redhat.com> (raw)
In-Reply-To: <1425593606-5909-2-git-send-email-hpoussin@reactos.org>
On 05/03/2015 23:13, Hervé Poussineau wrote:
> +static const MemoryRegionOps rc4030_dma_tt_ops = {
> + .impl.min_access_size = 4,
> + .impl.max_access_size = 4,
> + .impl.max_access_size = 4,
> +};
> +
> +static void rc4030_dma_tt_update(rc4030State *s, uint32_t new_tl_base,
> + uint32_t new_tl_limit)
> +{
> + int entries, i;
> + dma_pagetable_entry *dma_tl_contents;
> +
> + if (s->dma_tl_limit) {
> + /* write old dma tl table to physical memory */
> + memory_region_del_subregion(get_system_memory(), &s->dma_tt);
> + cpu_physical_memory_write(s->dma_tl_limit & 0x7fffffff,
> + memory_region_get_ram_ptr(&s->dma_tt),
> + s->dma_tl_limit);
You would need object_unparent(&s->dma_tt) here.
However, this breaks the rules for memory region lifetime (see
docs/memory.txt).
One solution is to warn here for a large dma_tl_limit and always create
a 4K ROMD region. Here you can create an alias into the actual dma_tt
region and add/remove/unparent that alias. Aliases can be created and
unparented at will.
> @@ -733,7 +793,16 @@ static void rc4030_do_dma(void *opaque, int n, uint8_t *buf, int len, int is_wri
> dma_addr = s->dma_regs[n][DMA_REG_ADDRESS];
>
> /* Read/write data at right place */
> - rc4030_dma_memory_rw(opaque, dma_addr, buf, len, is_write);
> + for (i = 0; i < len; ) {
> + int ncpy = DMA_PAGESIZE - (dma_addr & (DMA_PAGESIZE - 1));
> + if (ncpy > len - i) {
> + ncpy = len - i;
> + }
> + address_space_rw(&s->dma_as, dma_addr, buf + i, ncpy, is_write);
> +
> + dma_addr += ncpy;
> + i += ncpy;
> + }
>
> s->dma_regs[n][DMA_REG_ENABLE] |= DMA_FLAG_TC_INTR;
> s->dma_regs[n][DMA_REG_COUNT] -= len;
The loop should not be necessary, address_space_rw does the same.
Paolo
> @@ -800,6 +869,7 @@ void *rc4030_init(qemu_irq timer, qemu_irq jazz_bus,
> MemoryRegion *sysmem)
> {
> rc4030State *s;
> + int i;
>
> s = g_malloc0(sizeof(rc4030State));
>
> @@ -821,5 +891,15 @@ void *rc4030_init(qemu_irq timer, qemu_irq jazz_bus,
> "rc4030.jazzio", 0x00001000);
> memory_region_add_subregion(sysmem, 0xf0000000, &s->iomem_jazzio);
>
> + memory_region_init(&s->dma_tt, NULL, "dma_tt", 0);
> + memory_region_init(&s->dma_mr, NULL, "dma", INT32_MAX);
> + for (i = 0; i < MAX_TL_ENTRIES; ++i) {
> + memory_region_init_alias(&s->dma_mrs[i], NULL, "dma-alias",
> + get_system_memory(), 0, DMA_PAGESIZE);
> + memory_region_set_enabled(&s->dma_mrs[i], false);
> + memory_region_add_subregion(&s->dma_mr, i * DMA_PAGESIZE,
> + &s->dma_mrs[i]);
> + }
> + address_space_init(&s->dma_as, &s->dma_mr, "rc4030_dma");
> return s;
> }
>
next prev parent reply other threads:[~2015-03-26 14:27 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-05 22:13 [Qemu-devel] [PATCH 0/8] net/dp8393x improvements Hervé Poussineau
2015-03-05 22:13 ` [Qemu-devel] [PATCH 1/8] rc4030: create custom DMA address space Hervé Poussineau
2015-03-25 14:45 ` Paolo Bonzini
2015-03-25 19:10 ` Hervé Poussineau
2015-03-26 14:15 ` Paolo Bonzini
2015-03-26 14:27 ` Paolo Bonzini [this message]
2015-03-05 22:13 ` [Qemu-devel] [PATCH 2/8] rc4030: use AddressSpace and address_space_rw in users Hervé Poussineau
2015-03-05 22:13 ` [Qemu-devel] [PATCH 3/8] net/dp8393x: always calculate proper checksums Hervé Poussineau
2015-03-05 22:13 ` [Qemu-devel] [PATCH 4/8] net/dp8393x: do not use old_mmio accesses Hervé Poussineau
2015-03-05 22:13 ` [Qemu-devel] [PATCH 5/8] net/dp8393x: use dp8393x_ prefix for all functions Hervé Poussineau
2015-03-05 22:13 ` [Qemu-devel] [PATCH 6/8] net/dp8393x: QOM'ify Hervé Poussineau
2015-03-05 22:13 ` [Qemu-devel] [PATCH 7/8] net/dp8393x: add PROM to store MAC address Hervé Poussineau
2015-03-05 22:13 ` [Qemu-devel] [PATCH 8/8] net/dp8393x: add load/save support Hervé Poussineau
2015-03-25 14:13 ` [Qemu-devel] [PATCH 0/8] net/dp8393x improvements Leon Alrae
2015-04-29 14:56 ` Leon Alrae
2015-05-14 21:11 ` Hervé Poussineau
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=5514174B.9010406@redhat.com \
--to=pbonzini@redhat.com \
--cc=Laurent@Vivier.EU \
--cc=aurelien@aurel32.net \
--cc=hpoussin@reactos.org \
--cc=leon.alrae@imgtec.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.