From patchwork Wed Jan 30 13:22:06 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cornelia Huck X-Patchwork-Id: 10788557 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 27C566C2 for ; Wed, 30 Jan 2019 13:22:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1586F2EE02 for ; Wed, 30 Jan 2019 13:22:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 139D82EE0C; Wed, 30 Jan 2019 13:22:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8F7FA2EE11 for ; Wed, 30 Jan 2019 13:22:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730726AbfA3NWS (ORCPT ); Wed, 30 Jan 2019 08:22:18 -0500 Received: from mx1.redhat.com ([209.132.183.28]:42408 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725768AbfA3NWS (ORCPT ); Wed, 30 Jan 2019 08:22:18 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AA61783F44; Wed, 30 Jan 2019 13:22:17 +0000 (UTC) Received: from localhost (dhcp-192-213.str.redhat.com [10.33.192.213]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E22AF60C6E; Wed, 30 Jan 2019 13:22:14 +0000 (UTC) From: Cornelia Huck To: Halil Pasic , Eric Farman , Farhan Ali , Pierre Morel Cc: linux-s390@vger.kernel.org, kvm@vger.kernel.org, qemu-devel@nongnu.org, qemu-s390x@nongnu.org, Alex Williamson , Cornelia Huck Subject: [PATCH v3 0/6] vfio-ccw: support hsch/csch (kernel part) Date: Wed, 30 Jan 2019 14:22:06 +0100 Message-Id: <20190130132212.7376-1-cohuck@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 30 Jan 2019 13:22:18 +0000 (UTC) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP [This is the Linux kernel part, git tree is available at https://git.kernel.org/pub/scm/linux/kernel/git/kvms390/vfio-ccw.git vfio-ccw-eagain-caps-v3 The companion QEMU patches are available at https://github.com/cohuck/qemu vfio-ccw-caps This is the previously posted v2 version, which should continue to work.] Currently, vfio-ccw only relays START SUBCHANNEL requests to the real device. This tends to work well for the most common 'good path' scenarios; however, as we emulate {HALT,CLEAR} SUBCHANNEL in QEMU, things like clearing pending requests at the device is currently not supported. This may be a problem for e.g. error recovery. This patch series introduces capabilities (similar to what vfio-pci uses) and exposes a new async region for handling hsch/csch. Lightly tested (I can interact with a dasd as before, and reserve/release seems to work well.) Not sure if there is a better way to test this, ideas welcome. Changes v2->v3: - Unb0rked patch 1, improved scope - Split out the new mutex from patch 2 into new patch 3; added missing locking and hopefully improved description - Patch 2 now reworks the state handling by splitting the BUSY state into CP_PROCESSING and CP_PENDING - Patches 3 and 5 adapted on top of the reworked patches; hsch/csch are allowed in CP_PENDING, but not in CP_PROCESSING (did not add any R-b due to that) - Added missing free in patch 5 - Probably some small changes I forgot to note down Changes v1->v2: - New patch 1: make it safe to use the cp accessors at any time; this should avoid problems with unsolicited interrupt handling - New patch 2: handle concurrent accesses to the io region; the idea is to return -EAGAIN to userspace more often (so it can simply retry) - also handle concurrent accesses to the async io region - change VFIO_REGION_TYPE_CCW - merge events for halt and clear to a single async event; this turned out to make the code quite a bit simpler - probably some small changes I forgot to note down Cornelia Huck (6): vfio-ccw: make it safe to access channel programs vfio-ccw: rework ssch state handling vfio-ccw: protect the I/O region vfio-ccw: add capabilities chain s390/cio: export hsch to modules vfio-ccw: add handling for async channel instructions drivers/s390/cio/Makefile | 3 +- drivers/s390/cio/ioasm.c | 1 + drivers/s390/cio/vfio_ccw_async.c | 88 ++++++++++++ drivers/s390/cio/vfio_ccw_cp.c | 20 ++- drivers/s390/cio/vfio_ccw_cp.h | 2 + drivers/s390/cio/vfio_ccw_drv.c | 57 ++++++-- drivers/s390/cio/vfio_ccw_fsm.c | 143 ++++++++++++++++++- drivers/s390/cio/vfio_ccw_ops.c | 210 +++++++++++++++++++++++----- drivers/s390/cio/vfio_ccw_private.h | 48 ++++++- include/uapi/linux/vfio.h | 4 + include/uapi/linux/vfio_ccw.h | 12 ++ 11 files changed, 531 insertions(+), 57 deletions(-) create mode 100644 drivers/s390/cio/vfio_ccw_async.c Reviewed-by: Eric Farman