Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp3020256iog; Mon, 27 Jun 2022 07:35:48 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vuKt4KrlyCytWIhr57KKZjmvXAXUUdMSx35Quop9gtNc//VTZnKMU6i8BNwSeECqFxN4yM X-Received: by 2002:a17:90b:3cd:b0:1ec:a6a0:9c1b with SMTP id go13-20020a17090b03cd00b001eca6a09c1bmr21871815pjb.215.1656340547825; Mon, 27 Jun 2022 07:35:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656340547; cv=none; d=google.com; s=arc-20160816; b=TSnlwCka8lk8+aedkrBLZMl1V6QXB0Mu53UQLy/VyN79oAH9LWFa4/yP3ImF+3dZa1 lrezcQ52uBTrndoetV7wd1t7q7DYBdFaBqW9uYuoGhWHZ/aTqq/uXm/msP8k6TLOBnP1 AoWbKAHavCbXXidth4jqpK3uXoV2tOk61xdzWXwDnBao95nrCpr9+Ir4vzYNC5ZCvHeF MlQPA9JeiKZYKmePu8AsLA68g22Yc+0gX0UXFRcPgWnDMq5h7N1fTx93wQnWH2mO+sxt RVeCK0+ane8oHHjAjMBUM/v9jc0g5gz2PHH016O8L7y/r99PX5jGKYa2L9/3yQ16z+g2 xVVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=67UygGYGf07pEc+brtQSixcAB93afqPeEVm3JWtgZJ0=; b=qghypgycGlmxyiH9pQxPhBDmAV2BnJHIusEGezveOWGZmN07YnZmpvNFdtzaAqRlPF PsFWRFxW9/Ll119Nz8BWUWPRSe0Bod3EJvDNX8wYBcHoqkNeEj3kNX1TD5NPUUb/EpIQ 6dJsSZn1ChY9Ncb9PZv+SNwPnj5Ktpd0eOUoXYx0/iCiXvz1UCyGf4CaWu/+Admas4sC b2NHDjRqbrBJMVF4gSRxJOfNd9ijkslwkMmsfAPsv3X6jqcChYprLlyjmgHAfFQWxxYN wy/nUJfUit0YWT4Up/JTKF8xR/diWK2BB5G/Iim4LiLoseKt8ipq7jGIpxGYQB5t+Bbn pXoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=clXhOhyr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l5-20020a170903120500b0016a44f6174bsi17778537plh.593.2022.06.27.07.35.34; Mon, 27 Jun 2022 07:35:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=clXhOhyr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236445AbiF0Nyh (ORCPT + 99 others); Mon, 27 Jun 2022 09:54:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236376AbiF0Ny3 (ORCPT ); Mon, 27 Jun 2022 09:54:29 -0400 Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 130C26410; Mon, 27 Jun 2022 06:54:29 -0700 (PDT) Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25RDN0Ok003909; Mon, 27 Jun 2022 13:53:55 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=67UygGYGf07pEc+brtQSixcAB93afqPeEVm3JWtgZJ0=; b=clXhOhyrBidlGNqht7ose0Q/ZuQ5uSoYb18IyS8C5dG9psWqmSv9cRskKVDSrpEcQsoU 4qRmA+27bwzQWiYHC/3/O+Z0DwAJxPwHLdO4TROb2MAzykqm2dLmmlozeHiLLFE+DzeT ZP7Y13Woa6SDp4vhaj+0Nx8DXnOBvE3dFTGS9eM1tFNuPvieA1/5ZyFBBIzO1yJE7czk tOau5q6MC/x7Fg59qeMNJmD57NMyW6Z6mg+SWFBVSw3zKGvFzV2JLyiUxqOlNAuwUsx/ efKESalzY9R8W9/EHJoM2q5gjslqv9MeLoZ2YlBHDfVG2jRAcOJvNHJqndFVpS6y0IOb Zg== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3gydcv8vpp-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 27 Jun 2022 13:53:55 +0000 Received: from m0098404.ppops.net (m0098404.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 25RDrJml018788; Mon, 27 Jun 2022 13:53:54 GMT Received: from ppma02fra.de.ibm.com (47.49.7a9f.ip4.static.sl-reverse.com [159.122.73.71]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3gydcv8vn8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 27 Jun 2022 13:53:54 +0000 Received: from pps.filterd (ppma02fra.de.ibm.com [127.0.0.1]) by ppma02fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 25RDocMu016916; Mon, 27 Jun 2022 13:53:52 GMT Received: from b06cxnps3075.portsmouth.uk.ibm.com (d06relay10.portsmouth.uk.ibm.com [9.149.109.195]) by ppma02fra.de.ibm.com with ESMTP id 3gwt08tasq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 27 Jun 2022 13:53:52 +0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06cxnps3075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 25RDrmd112583268 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 27 Jun 2022 13:53:49 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E08F9AE051; Mon, 27 Jun 2022 13:53:48 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6772FAE045; Mon, 27 Jun 2022 13:53:48 +0000 (GMT) Received: from pomme.tlslab.ibm.com (unknown [9.101.4.33]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Mon, 27 Jun 2022 13:53:48 +0000 (GMT) From: Laurent Dufour To: wim@linux-watchdog.org, linux@roeck-us.net, mpe@ellerman.id.au, benh@kernel.crashing.org, paulus@samba.org, nathanl@linux.ibm.com, haren@linux.vnet.ibm.com, npiggin@gmail.com Cc: linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-watchdog@vger.kernel.org Subject: [PATCH v3 1/4] powerpc/mobility: wait for memory transfer to complete Date: Mon, 27 Jun 2022 15:53:44 +0200 Message-Id: <20220627135347.32624-2-ldufour@linux.ibm.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220627135347.32624-1-ldufour@linux.ibm.com> References: <20220627135347.32624-1-ldufour@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: tKZzxeAgc2eR1r6hcefJLj1ZgdKtJxkm X-Proofpoint-GUID: nVTSqCxsugdSdiw8pPPP8wB9BjKPByIg X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.883,Hydra:6.0.517,FMLib:17.11.122.1 definitions=2022-06-27_06,2022-06-24_01,2022-06-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 bulkscore=0 adultscore=0 spamscore=0 mlxscore=0 clxscore=1015 phishscore=0 mlxlogscore=976 suspectscore=0 malwarescore=0 impostorscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2206270059 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In pseries_migration_partition(), loop until the memory transfer is complete. This way the calling drmgr process will not exit earlier, allowing callbacks to be run only once the migration is fully completed. If reading the VASI state is done after the hypervisor has completed the migration, the HCALL is returning H_PARAMETER. We can safely assume that the memory transfer is achieved if this happens. This will also allow to manage the NMI watchdog state in the next commits. Reviewed-by: Nathan Lynch Signed-off-by: Laurent Dufour --- arch/powerpc/platforms/pseries/mobility.c | 42 +++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/platforms/pseries/mobility.c b/arch/powerpc/platforms/pseries/mobility.c index 78f3f74c7056..907a779074d6 100644 --- a/arch/powerpc/platforms/pseries/mobility.c +++ b/arch/powerpc/platforms/pseries/mobility.c @@ -427,6 +427,43 @@ static int wait_for_vasi_session_suspending(u64 handle) return ret; } +static void wait_for_vasi_session_completed(u64 handle) +{ + unsigned long state = 0; + int ret; + + pr_info("waiting for memory transfert to complete...\n"); + + /* + * Wait for transition from H_VASI_RESUMED to H_VASI_COMPLETED. + */ + while (true) { + ret = poll_vasi_state(handle, &state); + + /* + * If the memory transfer is already complete and the migration + * has been cleaned up by the hypervisor, H_PARAMETER is return, + * which is translate in EINVAL by poll_vasi_state(). + */ + if (ret == -EINVAL || (!ret && state == H_VASI_COMPLETED)) { + pr_info("memory transfert completed.\n"); + break; + } + + if (ret) { + pr_err("H_VASI_STATE return error (%d)\n", ret); + break; + } + + if (state != H_VASI_RESUMED) { + pr_err("unexpected H_VASI_STATE result %lu\n", state); + break; + } + + msleep(500); + } +} + static void prod_single(unsigned int target_cpu) { long hvrc; @@ -673,9 +710,10 @@ static int pseries_migrate_partition(u64 handle) vas_migration_handler(VAS_SUSPEND); ret = pseries_suspend(handle); - if (ret == 0) + if (ret == 0) { post_mobility_fixup(); - else + wait_for_vasi_session_completed(handle); + } else pseries_cancel_migration(handle, ret); vas_migration_handler(VAS_RESUME); -- 2.36.1