From patchwork Mon Feb 13 07:08:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 653184 Delivered-To: patch@linaro.org Received: by 2002:adf:f90f:0:0:0:0:0 with SMTP id b15csp2267490wrr; Sun, 12 Feb 2023 23:13:44 -0800 (PST) X-Google-Smtp-Source: AK7set9rAxZVEwg9S+ZG0USW4QJtCbCjKMWrxE5+GY1pMDk1/7wtjusdmPr1z4+G29KxsSJcXisL X-Received: by 2002:ac8:5955:0:b0:3b3:7d5:a752 with SMTP id 21-20020ac85955000000b003b307d5a752mr40078394qtz.50.1676272424512; Sun, 12 Feb 2023 23:13:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676272424; cv=none; d=google.com; s=arc-20160816; b=d3AuhQqG2F5Fo4AvTMN7/8hjizR++EG9DaX/RFqNZbLVDIZbc766R/y6xuui5KuL+s l/rsgFXASJPkqIjZ0ITiR+rGaPBIAxU+UF+DVO6LmbR8Em2HWKENSOjYaQ8IkhnE7Y4Q L/+rNAQiUJyhE+Mkrk/HLLnH7uCgbR7z3Th68b9NseWPYquzPQtK9PYoj49RB/2ytRrA eU16OnNujz+AfRbNWGATa7Qd7+JyDRt5GRb0eucSkUDGCUKWBv850wf+TMY7BAm2T+jI r+xf/IhW6wz8HlrtAFTGIpYxWJEoiYCKwhDEdkyyf0Xf5BEFpUESnFWvCMoKqTdysOH7 XTYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=bInkmnburNvSek0igY2MOEI+V86XMbjL1VMr60EEqDs=; b=IVuGEos0aZe+kjkULW2lbPNrL/BM5f+MV+mpdqZREQWd4NmlXAZ/yFA72iAbE1h909 YwTAnkKQPgpSCzhjC74DGamamfLH6ws2zHdP76uEt0E0ItJXx9/dMU5jyCLGctFVINUt EyW+12NDPo/W1VbgnpLJ68LRgUCWsAsEjLm/reLxSiDyKfOQ57O2dTnXhpZP0jWVsWty bnWzhABYVMTzKGQwBpgopPnb6gnChIfj2M52QENCVmM6tBsd2t6TcILfUeCXX4TQ1KoS e8VOAwEuvanB6Pj8aVNSnUNvr/fbzTPEOEyn4DvzrkSsUcEtTCv1pPmfLmw5ajw6TK4Z tjCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NdZ2jjxH; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 17-20020ac85911000000b003b1db7f5648si9228853qty.189.2023.02.12.23.13.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 12 Feb 2023 23:13:44 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NdZ2jjxH; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pRSyt-0004gV-7w; Mon, 13 Feb 2023 02:10:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pRSyF-0003Di-MD for qemu-devel@nongnu.org; Mon, 13 Feb 2023 02:09:52 -0500 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pRSyB-00022Z-Kl for qemu-devel@nongnu.org; Mon, 13 Feb 2023 02:09:50 -0500 Received: by mail-wr1-x42b.google.com with SMTP id by3so9741306wrb.10 for ; Sun, 12 Feb 2023 23:09:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=bInkmnburNvSek0igY2MOEI+V86XMbjL1VMr60EEqDs=; b=NdZ2jjxHfwKHVO3zxd9GWFL/7DG4seCf3p1lLGLysBNRih2X39+4ns8/RaqThZKT+D yJ8kv2NHjwfUnK0zfQAM420F2LUFUIiX/s7fg+fFcxZmpilm2EPyvL6qgdGdZf1qfLXX vE8XDRqb3cK9iwlfk+J0apqoKKOl13UsLSAtk9TUQnBCa4GatpguXldyht7KpgwsVLN9 rnWczNb6TBF+dDLy7ATcAVbTrCR5KuAzaANS+0waGYK9zNspH7BLn3msI/oQzeqUe3WL X8k/kdODFYyScOykY8GIn5eZ4uQrvKHIvquWXmyUYaFp87C+2ZnHN1A+UVyp1jRIMkA6 ytEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bInkmnburNvSek0igY2MOEI+V86XMbjL1VMr60EEqDs=; b=HfR3Olsp2RintwGpOSEEc0w4T9AHRsR4rOGG3fL+99ThnE3oND1mIazSuuYpP6zmpa iO9R5PjUNPn9p+cP3ogmGT3Zur82W7iMrQu0n+KN+QgqtUVMzU4yifTgBJdIp9hobrH2 P3GXAj61/CcmRoVMsZOs4lQWxNj1HTb/gVqhwJ0Ze0W5xaFMwzA7XA6S+TGjeomFvigH KxZXMivDF4HCgVHMXfK9OUGAZRFQooxn5Uh9RXmUmaeD+X1c7szojuwRZUIGHsAMfguK q9T/M1SByOsdVgb4sdDPIMS2RRVVxRrpV5LCdl5dAZtktWcxUxYNpmjsnEmZwQ99GeJI p87w== X-Gm-Message-State: AO0yUKUGuMms2gYgCqNF7Ijrs+MoI6jMlQC4t+RImF/2Tr0/WrfFw8pb 1rDQGHiJq9GCCYKqY8p5DL62JUZX/hWVZHy3 X-Received: by 2002:a5d:6707:0:b0:2c3:d69a:1da7 with SMTP id o7-20020a5d6707000000b002c3d69a1da7mr18641043wru.0.1676272186099; Sun, 12 Feb 2023 23:09:46 -0800 (PST) Received: from localhost.localdomain ([81.0.6.76]) by smtp.gmail.com with ESMTPSA id u10-20020a5d514a000000b002c3e28d0343sm9540429wrt.85.2023.02.12.23.09.44 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 12 Feb 2023 23:09:45 -0800 (PST) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Eduardo Habkost Cc: qemu-block@nongnu.org, Thomas Huth , Li Qiang , qemu-s390x@nongnu.org, Hu Tao , Gonglei Arei , Cao jin , xiaoqiang zhao , Paolo Bonzini , Richard Henderson , =?utf-8?q?Philippe_Mathie?= =?utf-8?q?u-Daud=C3=A9?= , Alex Williamson , Eric Farman , Matthew Rosato Subject: [PATCH v2 16/19] hw/vfio/ccw: Replace DO_UPCAST(VFIOCCWDevice) by VFIO_CCW() Date: Mon, 13 Feb 2023 08:08:17 +0100 Message-Id: <20230213070820.76881-17-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230213070820.76881-1-philmd@linaro.org> References: <20230213070820.76881-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42b; envelope-from=philmd@linaro.org; helo=mail-wr1-x42b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Use the VFIO_CCW() QOM type-checking macro to avoid DO_UPCAST(). Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Eric Farman --- hw/vfio/ccw.c | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/hw/vfio/ccw.c b/hw/vfio/ccw.c index 0354737666..a8aa5b48c4 100644 --- a/hw/vfio/ccw.c +++ b/hw/vfio/ccw.c @@ -76,8 +76,7 @@ struct VFIODeviceOps vfio_ccw_ops = { static IOInstEnding vfio_ccw_handle_request(SubchDev *sch) { - S390CCWDevice *cdev = sch->driver_data; - VFIOCCWDevice *vcdev = DO_UPCAST(VFIOCCWDevice, cdev, cdev); + VFIOCCWDevice *vcdev = VFIO_CCW(sch->driver_data); struct ccw_io_region *region = vcdev->io_region; int ret; @@ -125,8 +124,7 @@ again: static IOInstEnding vfio_ccw_handle_store(SubchDev *sch) { - S390CCWDevice *cdev = sch->driver_data; - VFIOCCWDevice *vcdev = DO_UPCAST(VFIOCCWDevice, cdev, cdev); + VFIOCCWDevice *vcdev = VFIO_CCW(sch->driver_data); SCHIB *schib = &sch->curr_status; struct ccw_schib_region *region = vcdev->schib_region; SCHIB *s; @@ -170,8 +168,7 @@ static IOInstEnding vfio_ccw_handle_store(SubchDev *sch) static int vfio_ccw_handle_clear(SubchDev *sch) { - S390CCWDevice *cdev = sch->driver_data; - VFIOCCWDevice *vcdev = DO_UPCAST(VFIOCCWDevice, cdev, cdev); + VFIOCCWDevice *vcdev = VFIO_CCW(sch->driver_data); struct ccw_cmd_region *region = vcdev->async_cmd_region; int ret; @@ -210,8 +207,7 @@ again: static int vfio_ccw_handle_halt(SubchDev *sch) { - S390CCWDevice *cdev = sch->driver_data; - VFIOCCWDevice *vcdev = DO_UPCAST(VFIOCCWDevice, cdev, cdev); + VFIOCCWDevice *vcdev = VFIO_CCW(sch->driver_data); struct ccw_cmd_region *region = vcdev->async_cmd_region; int ret; @@ -252,8 +248,8 @@ again: static void vfio_ccw_reset(DeviceState *dev) { CcwDevice *ccw_dev = DO_UPCAST(CcwDevice, parent_obj, dev); - S390CCWDevice *cdev = DO_UPCAST(S390CCWDevice, parent_obj, ccw_dev); - VFIOCCWDevice *vcdev = DO_UPCAST(VFIOCCWDevice, cdev, cdev); + S390CCWDevice *cdev = S390_CCW_DEVICE(ccw_dev); + VFIOCCWDevice *vcdev = VFIO_CCW(cdev); ioctl(vcdev->vdev.fd, VFIO_DEVICE_RESET); } @@ -588,9 +584,10 @@ static void vfio_ccw_put_device(VFIOCCWDevice *vcdev) static void vfio_ccw_get_device(VFIOGroup *group, VFIOCCWDevice *vcdev, Error **errp) { - char *name = g_strdup_printf("%x.%x.%04x", vcdev->cdev.hostid.cssid, - vcdev->cdev.hostid.ssid, - vcdev->cdev.hostid.devid); + S390CCWDevice *cdev = S390_CCW_DEVICE(vcdev); + char *name = g_strdup_printf("%x.%x.%04x", cdev->hostid.cssid, + cdev->hostid.ssid, + cdev->hostid.devid); VFIODevice *vbasedev; QLIST_FOREACH(vbasedev, &group->device_list, next) { @@ -611,14 +608,14 @@ static void vfio_ccw_get_device(VFIOGroup *group, VFIOCCWDevice *vcdev, */ vcdev->vdev.ram_block_discard_allowed = true; - if (vfio_get_device(group, vcdev->cdev.mdevid, &vcdev->vdev, errp)) { + if (vfio_get_device(group, cdev->mdevid, &vcdev->vdev, errp)) { goto out_err; } vcdev->vdev.ops = &vfio_ccw_ops; vcdev->vdev.type = VFIO_DEVICE_TYPE_CCW; vcdev->vdev.name = name; - vcdev->vdev.dev = &vcdev->cdev.parent_obj.parent_obj; + vcdev->vdev.dev = &cdev->parent_obj.parent_obj; return; @@ -657,9 +654,9 @@ static void vfio_ccw_realize(DeviceState *dev, Error **errp) { VFIOGroup *group; CcwDevice *ccw_dev = DO_UPCAST(CcwDevice, parent_obj, dev); - S390CCWDevice *cdev = DO_UPCAST(S390CCWDevice, parent_obj, ccw_dev); - VFIOCCWDevice *vcdev = DO_UPCAST(VFIOCCWDevice, cdev, cdev); + S390CCWDevice *cdev = S390_CCW_DEVICE(ccw_dev); S390CCWDeviceClass *cdc = S390_CCW_DEVICE_GET_CLASS(cdev); + VFIOCCWDevice *vcdev = VFIO_CCW(cdev); Error *err = NULL; /* Call the class init function for subchannel. */ @@ -729,9 +726,9 @@ out_err_propagate: static void vfio_ccw_unrealize(DeviceState *dev) { CcwDevice *ccw_dev = DO_UPCAST(CcwDevice, parent_obj, dev); - S390CCWDevice *cdev = DO_UPCAST(S390CCWDevice, parent_obj, ccw_dev); - VFIOCCWDevice *vcdev = DO_UPCAST(VFIOCCWDevice, cdev, cdev); + S390CCWDevice *cdev = S390_CCW_DEVICE(ccw_dev); S390CCWDeviceClass *cdc = S390_CCW_DEVICE_GET_CLASS(cdev); + VFIOCCWDevice *vcdev = VFIO_CCW(cdev); VFIOGroup *group = vcdev->vdev.group; vfio_ccw_unregister_irq_notifier(vcdev, VFIO_CCW_REQ_IRQ_INDEX);