From patchwork Mon May 25 09:41:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cornelia Huck X-Patchwork-Id: 11568491 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DA9591391 for ; Mon, 25 May 2020 09:41:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C305E2078B for ; Mon, 25 May 2020 09:41:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="h5wYo54f" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389643AbgEYJlk (ORCPT ); Mon, 25 May 2020 05:41:40 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:58091 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2389581AbgEYJlj (ORCPT ); Mon, 25 May 2020 05:41:39 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1590399698; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GwAQWjknu5aqoj+9iR6IdbLB0DqmhZ9ytf1Doe/RLuA=; b=h5wYo54fFUd1cPK3VH3ARcztSM5LTT5gVDQnwgffoJUbQMHOmh+Z4dP8E33dYEmeusSj/j cQO819+cg5/NT4i+HoCXSZDdCkZh93CzN0QLAP7Dr7ZOA9fp0uqSLSfmiRKQ7h0XTuuKO0 cIeTE1y7uNfLywD3meSzKKeYDb9qRUQ= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-416-J4onAdIJMXyCcU4v8NIJMg-1; Mon, 25 May 2020 05:41:35 -0400 X-MC-Unique: J4onAdIJMXyCcU4v8NIJMg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6146C86ABD5; Mon, 25 May 2020 09:41:34 +0000 (UTC) Received: from localhost (ovpn-112-215.ams2.redhat.com [10.36.112.215]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2318A5C1C5; Mon, 25 May 2020 09:41:31 +0000 (UTC) From: Cornelia Huck To: Heiko Carstens , Vasily Gorbik , Christian Borntraeger Cc: Eric Farman , Halil Pasic , linux-s390@vger.kernel.org, kvm@vger.kernel.org, Farhan Ali , Cornelia Huck Subject: [PULL 04/10] vfio-ccw: Register a chp_event callback for vfio-ccw Date: Mon, 25 May 2020 11:41:09 +0200 Message-Id: <20200525094115.222299-5-cohuck@redhat.com> In-Reply-To: <20200525094115.222299-1-cohuck@redhat.com> References: <20200525094115.222299-1-cohuck@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Farhan Ali Register the chp_event callback to receive channel path related events for the subchannels managed by vfio-ccw. Signed-off-by: Farhan Ali Signed-off-by: Eric Farman Reviewed-by: Cornelia Huck Message-Id: <20200505122745.53208-3-farman@linux.ibm.com> Signed-off-by: Cornelia Huck --- drivers/s390/cio/vfio_ccw_drv.c | 47 +++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/drivers/s390/cio/vfio_ccw_drv.c b/drivers/s390/cio/vfio_ccw_drv.c index 8715c1c2f1e1..fb1275a7d1f5 100644 --- a/drivers/s390/cio/vfio_ccw_drv.c +++ b/drivers/s390/cio/vfio_ccw_drv.c @@ -19,6 +19,7 @@ #include +#include "chp.h" #include "ioasm.h" #include "css.h" #include "vfio_ccw_private.h" @@ -262,6 +263,51 @@ static int vfio_ccw_sch_event(struct subchannel *sch, int process) return rc; } +static int vfio_ccw_chp_event(struct subchannel *sch, + struct chp_link *link, int event) +{ + struct vfio_ccw_private *private = dev_get_drvdata(&sch->dev); + int mask = chp_ssd_get_mask(&sch->ssd_info, link); + int retry = 255; + + if (!private || !mask) + return 0; + + VFIO_CCW_MSG_EVENT(2, "%pUl (%x.%x.%04x): mask=0x%x event=%d\n", + mdev_uuid(private->mdev), sch->schid.cssid, + sch->schid.ssid, sch->schid.sch_no, + mask, event); + + if (cio_update_schib(sch)) + return -ENODEV; + + switch (event) { + case CHP_VARY_OFF: + /* Path logically turned off */ + sch->opm &= ~mask; + sch->lpm &= ~mask; + if (sch->schib.pmcw.lpum & mask) + cio_cancel_halt_clear(sch, &retry); + break; + case CHP_OFFLINE: + /* Path is gone */ + if (sch->schib.pmcw.lpum & mask) + cio_cancel_halt_clear(sch, &retry); + break; + case CHP_VARY_ON: + /* Path logically turned on */ + sch->opm |= mask; + sch->lpm |= mask; + break; + case CHP_ONLINE: + /* Path became available */ + sch->lpm |= mask & sch->opm; + break; + } + + return 0; +} + static struct css_device_id vfio_ccw_sch_ids[] = { { .match_flags = 0x1, .type = SUBCHANNEL_TYPE_IO, }, { /* end of list */ }, @@ -279,6 +325,7 @@ static struct css_driver vfio_ccw_sch_driver = { .remove = vfio_ccw_sch_remove, .shutdown = vfio_ccw_sch_shutdown, .sch_event = vfio_ccw_sch_event, + .chp_event = vfio_ccw_chp_event, }; static int __init vfio_ccw_debug_init(void)