From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9E692C04AA7 for ; Mon, 13 May 2019 13:54:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 75F2F21019 for ; Mon, 13 May 2019 13:54:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729725AbfEMNy2 (ORCPT ); Mon, 13 May 2019 09:54:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37310 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729040AbfEMNy1 (ORCPT ); Mon, 13 May 2019 09:54:27 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 55EC1309266F; Mon, 13 May 2019 13:54:27 +0000 (UTC) Received: from gondolin (dhcp-192-222.str.redhat.com [10.33.192.222]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6A251102BCEB; Mon, 13 May 2019 13:54:21 +0000 (UTC) Date: Mon, 13 May 2019 15:54:19 +0200 From: Cornelia Huck To: Halil Pasic Cc: kvm@vger.kernel.org, linux-s390@vger.kernel.org, Martin Schwidefsky , Sebastian Ott , virtualization@lists.linux-foundation.org, "Michael S. Tsirkin" , Christoph Hellwig , Thomas Huth , Christian Borntraeger , Viktor Mihajlovski , Vasily Gorbik , Janosch Frank , Claudio Imbrenda , Farhan Ali , Eric Farman Subject: Re: [PATCH 09/10] virtio/s390: use DMA memory for ccw I/O and classic notifiers Message-ID: <20190513155419.5b9d9ba4.cohuck@redhat.com> In-Reply-To: <20190426183245.37939-10-pasic@linux.ibm.com> References: <20190426183245.37939-1-pasic@linux.ibm.com> <20190426183245.37939-10-pasic@linux.ibm.com> Organization: Red Hat GmbH MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Mon, 13 May 2019 13:54:27 +0000 (UTC) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On Fri, 26 Apr 2019 20:32:44 +0200 Halil Pasic wrote: > Before virtio-ccw could get away with not using DMA API for the pieces of > memory it does ccw I/O with. With protected virtualization this has to > change, since the hypervisor needs to read and sometimes also write these > pieces of memory. > > The hypervisor is supposed to poke the classic notifiers, if these are > used, out of band with regards to ccw I/O. So these need to be allocated > as DMA memory (which is shared memory for protected virtualization > guests). > > Let us factor out everything from struct virtio_ccw_device that needs to > be DMA memory in a satellite that is allocated as such. > > Note: The control blocks of I/O instructions do not need to be shared. > These are marshalled by the ultravisor. > > Signed-off-by: Halil Pasic > --- > drivers/s390/virtio/virtio_ccw.c | 177 +++++++++++++++++++++------------------ > 1 file changed, 96 insertions(+), 81 deletions(-) > > @@ -176,6 +180,22 @@ static struct virtio_ccw_device *to_vc_device(struct virtio_device *vdev) > return container_of(vdev, struct virtio_ccw_device, vdev); > } > > +static inline void *__vc_dma_alloc(struct virtio_device *vdev, size_t size) > +{ > + return ccw_device_dma_zalloc(to_vc_device(vdev)->cdev, size); > +} > + > +static inline void __vc_dma_free(struct virtio_device *vdev, size_t size, > + void *cpu_addr) > +{ > + return ccw_device_dma_free(to_vc_device(vdev)->cdev, cpu_addr, size); > +} Hm, why do these use leading underscores? Also, maybe make the _free function safe for NULL to simplify the cleanup paths? > + > +#define vc_dma_alloc_struct(vdev, ptr) \ > + ({ptr = __vc_dma_alloc(vdev, sizeof(*(ptr))); }) > +#define vc_dma_free_struct(vdev, ptr) \ > + __vc_dma_free(vdev, sizeof(*(ptr)), (ptr)) I find these a bit ugly... does adding a wrapper help that much? > + > static void drop_airq_indicator(struct virtqueue *vq, struct airq_info *info) > { > unsigned long i, flags;