From: Halil Pasic <pasic@linux.ibm.com>
To: Cornelia Huck <cohuck@redhat.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>,
linux-s390@vger.kernel.org, Thomas Huth <thuth@redhat.com>,
Claudio Imbrenda <imbrenda@linux.ibm.com>,
Sebastian Ott <sebott@linux.ibm.com>,
kvm@vger.kernel.org, "Michael S. Tsirkin" <mst@redhat.com>,
Farhan Ali <alifm@linux.ibm.com>,
Eric Farman <farman@linux.ibm.com>,
virtualization@lists.linux-foundation.org,
Christoph Hellwig <hch@infradead.org>,
Martin Schwidefsky <schwidefsky@de.ibm.com>,
Michael Mueller <mimu@linux.ibm.com>,
Viktor Mihajlovski <mihajlov@linux.ibm.com>,
Janosch Frank <frankja@linux.ibm.com>
Subject: Re: [PATCH 05/10] s390/cio: introduce DMA pools to cio
Date: Sun, 12 May 2019 20:22:56 +0200 [thread overview]
Message-ID: <20190512202256.5517592d.pasic@linux.ibm.com> (raw)
In-Reply-To: <20190510161013.7e697337.cohuck@redhat.com>
On Fri, 10 May 2019 16:10:13 +0200
Cornelia Huck <cohuck@redhat.com> wrote:
> On Fri, 10 May 2019 00:11:12 +0200
> Halil Pasic <pasic@linux.ibm.com> wrote:
>
> > On Thu, 9 May 2019 12:11:06 +0200
> > Cornelia Huck <cohuck@redhat.com> wrote:
> >
> > > On Wed, 8 May 2019 23:22:10 +0200
> > > Halil Pasic <pasic@linux.ibm.com> wrote:
> > >
> > > > On Wed, 8 May 2019 15:18:10 +0200 (CEST)
> > > > Sebastian Ott <sebott@linux.ibm.com> wrote:
> > >
> > > > > > @@ -1063,6 +1163,7 @@ static int __init css_bus_init(void)
> > > > > > unregister_reboot_notifier(&css_reboot_notifier);
> > > > > > goto out_unregister;
> > > > > > }
> > > > > > + cio_dma_pool_init();
> > > > >
> > > > > This is too late for early devices (ccw console!).
> > > >
> > > > You have already raised concern about this last time (thanks). I think,
> > > > I've addressed this issue: the cio_dma_pool is only used by the airq
> > > > stuff. I don't think the ccw console needs it. Please have an other look
> > > > at patch #6, and explain your concern in more detail if it persists.
> > >
> > > What about changing the naming/adding comments here, so that (1) folks
> > > aren't confused by the same thing in the future and (2) folks don't try
> > > to use that pool for something needed for the early ccw consoles?
> > >
> >
> > I'm all for clarity! Suggestions for better names?
>
> css_aiv_dma_pool, maybe? Or is there other cross-device stuff that may
> need it?
>
Ouch! I was considering to use cio_dma_zalloc() for the adapter
interruption vectors but I ended up between the two chairs in the end.
So with this series there are no uses for cio_dma pool.
I don't feel strongly about this going one way the other.
Against getting rid of the cio_dma_pool and sticking with the speaks
dma_alloc_coherent() that we waste a DMA page per vector, which is a
non obvious side effect.
What speaks against cio_dma_pool is that it is slightly more code, and
this currently can not be used for very early stuff, which I don't
think is relevant. What also used to speak against it is that
allocations asking for more than a page would just fail, but I addressed
that in the patch I've hacked up on top of the series, and I'm going to
paste below. While at it I addressed some other issues as well.
I've also got code that deals with AIRQ_IV_CACHELINE by turning the
kmem_cache into a dma_pool.
Cornelia, Sebastian which approach do you prefer:
1) get rid of cio_dma_pool and AIRQ_IV_CACHELINE, and waste a page per
vector, or
2) go with the approach taken by the patch below?
Regards,
Halil
-----------------------8<---------------------------------------------
From: Halil Pasic <pasic@linux.ibm.com>
Date: Sun, 12 May 2019 18:08:05 +0200
Subject: [PATCH] WIP: use cio dma pool for airqs
Let's not waste a DMA page per adapter interrupt bit vector.
---
Lightly tested...
---
arch/s390/include/asm/airq.h | 1 -
drivers/s390/cio/airq.c | 10 +++-------
drivers/s390/cio/css.c | 18 +++++++++++++++---
3 files changed, 18 insertions(+), 11 deletions(-)
diff --git a/arch/s390/include/asm/airq.h b/arch/s390/include/asm/airq.h
index 1492d48..981a3eb 100644
--- a/arch/s390/include/asm/airq.h
+++ b/arch/s390/include/asm/airq.h
@@ -30,7 +30,6 @@ void unregister_adapter_interrupt(struct airq_struct *airq);
/* Adapter interrupt bit vector */
struct airq_iv {
unsigned long *vector; /* Adapter interrupt bit vector */
- dma_addr_t vector_dma; /* Adapter interrupt bit vector dma */
unsigned long *avail; /* Allocation bit mask for the bit vector */
unsigned long *bitlock; /* Lock bit mask for the bit vector */
unsigned long *ptr; /* Pointer associated with each bit */
diff --git a/drivers/s390/cio/airq.c b/drivers/s390/cio/airq.c
index 7a5c0a0..f11f437 100644
--- a/drivers/s390/cio/airq.c
+++ b/drivers/s390/cio/airq.c
@@ -136,8 +136,7 @@ struct airq_iv *airq_iv_create(unsigned long bits, unsigned long flags)
goto out;
iv->bits = bits;
size = iv_size(bits);
- iv->vector = dma_alloc_coherent(cio_get_dma_css_dev(), size,
- &iv->vector_dma, GFP_KERNEL);
+ iv->vector = cio_dma_zalloc(size);
if (!iv->vector)
goto out_free;
if (flags & AIRQ_IV_ALLOC) {
@@ -172,8 +171,7 @@ struct airq_iv *airq_iv_create(unsigned long bits, unsigned long flags)
kfree(iv->ptr);
kfree(iv->bitlock);
kfree(iv->avail);
- dma_free_coherent(cio_get_dma_css_dev(), size, iv->vector,
- iv->vector_dma);
+ cio_dma_free(iv->vector, size);
kfree(iv);
out:
return NULL;
@@ -189,9 +187,7 @@ void airq_iv_release(struct airq_iv *iv)
kfree(iv->data);
kfree(iv->ptr);
kfree(iv->bitlock);
- kfree(iv->vector);
- dma_free_coherent(cio_get_dma_css_dev(), iv_size(iv->bits),
- iv->vector, iv->vector_dma);
+ cio_dma_free(iv->vector, iv_size(iv->bits));
kfree(iv->avail);
kfree(iv);
}
diff --git a/drivers/s390/cio/css.c b/drivers/s390/cio/css.c
index 7087cc3..88d9c92 100644
--- a/drivers/s390/cio/css.c
+++ b/drivers/s390/cio/css.c
@@ -1063,7 +1063,10 @@ struct gen_pool *cio_gp_dma_create(struct device *dma_dev, int nr_pages)
static void __gp_dma_free_dma(struct gen_pool *pool,
struct gen_pool_chunk *chunk, void *data)
{
- dma_free_coherent((struct device *) data, PAGE_SIZE,
+
+ size_t chunk_size = chunk->end_addr - chunk->start_addr + 1;
+
+ dma_free_coherent((struct device *) data, chunk_size,
(void *) chunk->start_addr,
(dma_addr_t) chunk->phys_addr);
}
@@ -1088,13 +1091,15 @@ void *cio_gp_dma_zalloc(struct gen_pool *gp_dma, struct device *dma_dev,
{
dma_addr_t dma_addr;
unsigned long addr = gen_pool_alloc(gp_dma, size);
+ size_t chunk_size;
if (!addr) {
+ chunk_size = round_up(size, PAGE_SIZE);
addr = (unsigned long) dma_alloc_coherent(dma_dev,
- PAGE_SIZE, &dma_addr, CIO_DMA_GFP);
+ chunk_size, &dma_addr, CIO_DMA_GFP);
if (!addr)
return NULL;
- gen_pool_add_virt(gp_dma, addr, dma_addr, PAGE_SIZE, -1);
+ gen_pool_add_virt(gp_dma, addr, dma_addr, chunk_size, -1);
addr = gen_pool_alloc(gp_dma, size);
}
return (void *) addr;
@@ -1108,6 +1113,13 @@ void cio_gp_dma_free(struct gen_pool *gp_dma, void *cpu_addr, size_t size)
gen_pool_free(gp_dma, (unsigned long) cpu_addr, size);
}
+/**
+ * Allocate dma memory from the css global pool. Intended for memory not
+ * specific to any single device within the css.
+ *
+ * Caution: Not suitable for early stuff like console.
+ *
+ */
void *cio_dma_zalloc(size_t size)
{
return cio_gp_dma_zalloc(cio_dma_pool, cio_get_dma_css_dev(), size);
--
2.5.5
next prev parent reply other threads:[~2019-05-12 18:22 UTC|newest]
Thread overview: 88+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-04-26 18:32 [PATCH 00/10] s390: virtio: support protected virtualization Halil Pasic
2019-04-26 18:32 ` [PATCH 01/10] virtio/s390: use vring_create_virtqueue Halil Pasic
[not found] ` <20190503111724.70c6ec37.cohuck@redhat.com>
2019-05-03 20:04 ` Michael S. Tsirkin
2019-05-04 14:03 ` Halil Pasic
2019-05-05 11:15 ` Cornelia Huck
2019-05-07 13:58 ` Christian Borntraeger
2019-05-08 20:12 ` Halil Pasic
2019-05-10 14:07 ` Cornelia Huck
2019-05-12 16:47 ` Michael S. Tsirkin
2019-05-13 9:52 ` Cornelia Huck
2019-05-13 12:27 ` Michael Mueller
2019-05-13 12:29 ` Cornelia Huck
2019-04-26 18:32 ` [PATCH 02/10] virtio/s390: DMA support for virtio-ccw Halil Pasic
2019-04-26 18:32 ` [PATCH 03/10] virtio/s390: enable packed ring Halil Pasic
[not found] ` <20190503114450.2512b121.cohuck@redhat.com>
2019-05-05 15:13 ` Thomas Huth
2019-04-26 18:32 ` [PATCH 04/10] s390/mm: force swiotlb for protected virtualization Halil Pasic
2019-04-26 19:27 ` Christoph Hellwig
2019-04-29 13:59 ` Halil Pasic
2019-04-29 14:05 ` Christian Borntraeger
2019-05-13 12:50 ` Michael Mueller
2019-05-08 13:15 ` Claudio Imbrenda
2019-05-09 22:34 ` Halil Pasic
2019-05-15 14:15 ` Michael Mueller
[not found] ` <ad23f5e7-dc78-04af-c892-47bbc65134c6@linux.ibm.com>
2019-05-09 18:05 ` Jason J. Herne
2019-05-10 7:49 ` Claudio Imbrenda
2019-04-26 18:32 ` [PATCH 05/10] s390/cio: introduce DMA pools to cio Halil Pasic
2019-05-08 13:18 ` Sebastian Ott
2019-05-08 21:22 ` Halil Pasic
2019-05-09 8:40 ` Sebastian Ott
2019-05-09 10:11 ` Cornelia Huck
2019-05-09 22:11 ` Halil Pasic
2019-05-10 14:10 ` Cornelia Huck
2019-05-12 18:22 ` Halil Pasic [this message]
2019-05-13 13:29 ` Cornelia Huck
2019-05-15 17:12 ` Halil Pasic
2019-05-16 6:13 ` Cornelia Huck
2019-05-16 13:59 ` Sebastian Ott
2019-05-20 12:13 ` Halil Pasic
2019-05-21 8:46 ` Michael Mueller
2019-05-22 12:07 ` Sebastian Ott
2019-05-22 22:12 ` Halil Pasic
2019-05-23 15:17 ` Halil Pasic
2019-04-26 18:32 ` [PATCH 06/10] s390/cio: add basic protected virtualization support Halil Pasic
2019-05-08 13:46 ` Sebastian Ott
2019-05-08 13:54 ` Christoph Hellwig
2019-05-08 21:08 ` Halil Pasic
2019-05-09 8:52 ` Sebastian Ott
2019-05-08 14:23 ` Pierre Morel
2019-05-13 9:41 ` Cornelia Huck
2019-05-14 14:47 ` Jason J. Herne
2019-05-15 21:08 ` Halil Pasic
2019-05-16 6:32 ` Cornelia Huck
2019-05-16 13:42 ` Halil Pasic
2019-05-16 13:54 ` Cornelia Huck
2019-05-15 20:51 ` Halil Pasic
2019-05-16 6:29 ` Cornelia Huck
2019-05-18 18:11 ` Halil Pasic
2019-05-20 10:21 ` Cornelia Huck
2019-05-20 12:34 ` Halil Pasic
2019-05-20 13:43 ` Cornelia Huck
2019-04-26 18:32 ` [PATCH 07/10] s390/airq: use DMA memory for adapter interrupts Halil Pasic
2019-05-08 13:58 ` Sebastian Ott
2019-05-09 11:37 ` Cornelia Huck
2019-05-13 12:59 ` Cornelia Huck
2019-04-26 18:32 ` [PATCH 08/10] virtio/s390: add indirection to indicators access Halil Pasic
2019-05-08 14:31 ` Pierre Morel
2019-05-09 12:01 ` Pierre Morel
2019-05-09 18:26 ` Halil Pasic
2019-05-10 7:43 ` Pierre Morel
2019-05-10 11:54 ` Halil Pasic
2019-05-10 15:36 ` Pierre Morel
2019-05-13 10:15 ` Cornelia Huck
2019-05-16 15:24 ` Pierre Morel
2019-04-26 18:32 ` [PATCH 09/10] virtio/s390: use DMA memory for ccw I/O and classic notifiers Halil Pasic
2019-05-08 14:46 ` Pierre Morel
2019-05-09 13:30 ` Pierre Morel
2019-05-09 18:30 ` Halil Pasic
2019-05-13 13:54 ` Cornelia Huck
2019-04-26 18:32 ` [PATCH 10/10] virtio/s390: make airq summary indicators DMA Halil Pasic
2019-05-08 15:11 ` Pierre Morel
2019-05-15 13:33 ` Michael Mueller
2019-05-15 17:23 ` Halil Pasic
2019-05-13 12:20 ` Cornelia Huck
2019-05-15 13:43 ` Michael Mueller
2019-05-15 13:50 ` Cornelia Huck
2019-05-15 17:18 ` Halil Pasic
[not found] ` <20190503115511.17a1f6d1.cohuck@redhat.com>
2019-05-03 13:33 ` [PATCH 00/10] s390: virtio: support protected virtualization Cornelia Huck
2019-05-04 13:58 ` Halil Pasic
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=20190512202256.5517592d.pasic@linux.ibm.com \
--to=pasic@linux.ibm.com \
--cc=alifm@linux.ibm.com \
--cc=cohuck@redhat.com \
--cc=farman@linux.ibm.com \
--cc=frankja@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hch@infradead.org \
--cc=imbrenda@linux.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=mihajlov@linux.ibm.com \
--cc=mimu@linux.ibm.com \
--cc=mst@redhat.com \
--cc=schwidefsky@de.ibm.com \
--cc=sebott@linux.ibm.com \
--cc=thuth@redhat.com \
--cc=virtualization@lists.linux-foundation.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).