From patchwork Mon Oct 15 06:32:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Kardashevskiy X-Patchwork-Id: 983911 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42YTBz16k9z9s3T for ; Mon, 15 Oct 2018 17:32:43 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.ru Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 42YTBy3nyRzF38y for ; Mon, 15 Oct 2018 17:32:42 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.ru X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=ozlabs.ru (client-ip=107.173.13.209; helo=ozlabs.ru; envelope-from=aik@ozlabs.ru; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.ru Received: from ozlabs.ru (unknown [107.173.13.209]) by lists.ozlabs.org (Postfix) with ESMTP id 42YTBq52NwzF31L for ; Mon, 15 Oct 2018 17:32:33 +1100 (AEDT) Received: from vpl1.ozlabs.ibm.com (localhost [IPv6:::1]) by ozlabs.ru (Postfix) with ESMTP id A577FAE80007; Mon, 15 Oct 2018 02:32:29 -0400 (EDT) From: Alexey Kardashevskiy To: skiboot@lists.ozlabs.org Date: Mon, 15 Oct 2018 17:32:27 +1100 Message-Id: <20181015063227.37271-1-aik@ozlabs.ru> X-Mailer: git-send-email 2.11.0 Subject: [Skiboot] [PATCH skiboot] npu2: Clear XTS_BDF_MAP when destroying context for next init_context X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Alistair Popple , Reza Arbab MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" Once programmed into the NPU, the NPU2_XTS_PID_MAP register content does not change and if we try calling opal_npu_init_context() with a different MSR (which is going to happen when GPU+NPU virtualization becomes available), that will fail. This clears XTS_BDF_MAP when the context is destroyed. Signed-off-by: Alexey Kardashevskiy --- The alternative would be making opal_npu_destroy_context() a no-op and making opal_npu_init_context() do this if a new MSR is different from the already programmed one. Opinions? --- hw/npu2.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/hw/npu2.c b/hw/npu2.c index d7d9435..a8fc021 100644 --- a/hw/npu2.c +++ b/hw/npu2.c @@ -2068,7 +2068,7 @@ static int opal_npu_destroy_context(uint64_t phb_id, uint64_t pid __unused, struct phb *phb = pci_get_phb(phb_id); struct npu2 *p; uint64_t xts_bdf; - int rc = 0; + int rc = 0, id; if (!phb || phb->phb_type != phb_type_npu_v2) return OPAL_PARAMETER; @@ -2085,9 +2085,13 @@ static int opal_npu_destroy_context(uint64_t phb_id, uint64_t pid __unused, } /* - * The bdf/pid table only contains wildcard entries, so we don't - * need to remove anything here. + * The bdf/pid table contains wildcard entries but also contains + * MSR bits which will change when a device is passed through to + * a KVM guest or vice versa so we need to remove the mapping here. */ + id = GETFIELD(NPU2_XTS_BDF_MAP_LPARSHORT, xts_bdf); + NPU2DBG(p, "XTS_PID_MAP[%03d] = 0 (destroy)\n", id); + npu2_write(p, NPU2_XTS_PID_MAP + id*0x20, 0); unlock(&p->lock); return rc;