Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp1481351iog; Tue, 14 Jun 2022 07:00:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwVlXnZBHpf7mIsC6MVNzoABYrVhoqyZmeOGtAFuvlzDVQn2Fgy5f6ka4oe1DbkTNnT660l X-Received: by 2002:a05:6a02:28d:b0:408:8cbf:2a0c with SMTP id bk13-20020a056a02028d00b004088cbf2a0cmr4723527pgb.422.1655215227331; Tue, 14 Jun 2022 07:00:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655215227; cv=none; d=google.com; s=arc-20160816; b=Up8/75DmseNrjZNhCfkqZFtnqxi5UCQ9+9afcRMW/wb5LYB89WKqSYEHTNS1KGpAC4 8+fhoEZlk4oPxr8/SY1wjuu++FiNCih7L0cVoW7pLSD0Zm7pooNn89OcaS+LdSaypdGD JktHPcwzwIPBE/co9AhhW/Mvy9KBTjx8RvBZZYTeZc3Imkbre11D8mCfNckmFzDuwXlZ wppfbjGim2ak5R0oV3BLZ7wLI4/Jo9gt2GllOj14JrYLgZtoMGm4t424kGKMovtlNkcb 12toWHW47AjOPfUJPUy7L7YHocOwGE7InQ+NisrTUdeDMKC721HGueNUZsyGXO4y7HGx VJ/A== 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=3Xu1TVBYRcZuysxhskfLCMFc4Yp94zk2m1a++7NFqeI=; b=Ey7HZHhkKhcH1z7HsDIK1zvUKurQlWw5D26isQE+m43WY+q3CM0uyJLAt7cUgKftSI ufbpOoJT3ro3gU//7EeR3mVLYFy6lVE98lSfPSHwe0bvDheBVu1YcK37o+6neJAQiSre iUgkkoupCGQpMoRCEZ0OrTGBB6sbCLWFBEsFrvUGmPF+usnO7DlLHE9gmaaKg53Z0gIB ttj//Cb0smomNVjInK5zy2N/9mNPvtKdLm5UY3y0dYYPtymLUddbEsI8Qr1TUb14F4qW Z3JJ5gj00U0IlA5g7/HC+zpz9KFKXnCdJCQwebo9G7YGIj0Pts+OuxN9G0WXi2v/HgCZ rI+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=CS2bDpa3; 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 h123-20020a636c81000000b003fd157f7e9dsi12509864pgc.857.2022.06.14.07.00.13; Tue, 14 Jun 2022 07:00:27 -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=CS2bDpa3; 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 S243596AbiFNNyq (ORCPT + 99 others); Tue, 14 Jun 2022 09:54:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39574 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242763AbiFNNyo (ORCPT ); Tue, 14 Jun 2022 09:54:44 -0400 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C9693969A for ; Tue, 14 Jun 2022 06:54:43 -0700 (PDT) Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 25EDBsws016577; Tue, 14 Jun 2022 13:54:23 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=3Xu1TVBYRcZuysxhskfLCMFc4Yp94zk2m1a++7NFqeI=; b=CS2bDpa3S8FJVpX63TtGOyVNZ40X7diFbEZ/jM37zayBX8oum3WQWdbF1FTqd4KK/OTh omAU0EhQ7W82dgmAVSCA0NMT943t1UIeNkQ/7eOokDUzqjQzx1OsgaDvvP45RAzlGSF+ ce4G8sUMRi2Z/qpIRruWGZczB5e0I/oF5RAaeydadmoMG9NKg/l5XkSmy+zN6z6YazT4 50IBQyG8zuQrpwOy6po3jEPZchSFVxsKsjG2z3XDblum1KuKdkAHBnGSpp7SezF98G+n EqyEf/ACsIsVzBeuVMXyVgfY65iUeEAaFCe3NtBfFuq9EytGpdQFXCDoZKcAsb8QjADL 4Q== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3gppw30v8v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 14 Jun 2022 13:54:22 +0000 Received: from m0098417.ppops.net (m0098417.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 25EDCRpK023102; Tue, 14 Jun 2022 13:54:22 GMT Received: from ppma03fra.de.ibm.com (6b.4a.5195.ip4.static.sl-reverse.com [149.81.74.107]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3gppw30v6g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 14 Jun 2022 13:54:21 +0000 Received: from pps.filterd (ppma03fra.de.ibm.com [127.0.0.1]) by ppma03fra.de.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 25EDpW7O018398; Tue, 14 Jun 2022 13:54:20 GMT Received: from b06avi18626390.portsmouth.uk.ibm.com (b06avi18626390.portsmouth.uk.ibm.com [9.149.26.192]) by ppma03fra.de.ibm.com with ESMTP id 3gmjp8uer8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 14 Jun 2022 13:54:20 +0000 Received: from d06av26.portsmouth.uk.ibm.com (d06av26.portsmouth.uk.ibm.com [9.149.105.62]) by b06avi18626390.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 25EDrlKn14483728 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 14 Jun 2022 13:53:47 GMT Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 18175AE04D; Tue, 14 Jun 2022 13:54:17 +0000 (GMT) Received: from d06av26.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AB6BCAE045; Tue, 14 Jun 2022 13:54:16 +0000 (GMT) Received: from pomme.tlslab.ibm.com (unknown [9.101.4.33]) by d06av26.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 14 Jun 2022 13:54:16 +0000 (GMT) From: Laurent Dufour To: mpe@ellerman.id.au, benh@kernel.crashing.org, paulus@samba.org, nathanl@linux.ibm.com, haren@linux.vnet.ibm.com, npiggin@gmail.com Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/4] powerpc/mobility: Wait for memory transfer to complete Date: Tue, 14 Jun 2022 15:54:11 +0200 Message-Id: <20220614135414.37746-2-ldufour@linux.ibm.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220614135414.37746-1-ldufour@linux.ibm.com> References: <20220614135414.37746-1-ldufour@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-GUID: t0WGa64z3ZCsxUrXz9LbcP7lCKbLRyP5 X-Proofpoint-ORIG-GUID: XBJXLNv07H4sVam13KFDHL1buAc3dBGP X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.874,Hydra:6.0.517,FMLib:17.11.64.514 definitions=2022-06-14_04,2022-06-13_01,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 bulkscore=0 adultscore=0 phishscore=0 spamscore=0 clxscore=1015 mlxscore=0 impostorscore=0 mlxlogscore=999 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2206140054 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. 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..179bbd4ae881 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. Treat anything else as an error. + */ + 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