From patchwork Fri Oct 9 03:51:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 1378972 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.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4C6vMD5JKtz9sTc for ; Fri, 9 Oct 2020 14:54:00 +1100 (AEDT) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=ozlabs.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.a=rsa-sha256 header.s=201707 header.b=Bf9Nq6Ew; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 4C6vMD3LZ6zDqCZ for ; Fri, 9 Oct 2020 14:54:00 +1100 (AEDT) X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [IPv6:2401:3900:2:1::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4C6vK15TpMzDqBy for ; Fri, 9 Oct 2020 14:52:05 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.a=rsa-sha256 header.s=201707 header.b=Bf9Nq6Ew; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 4C6vK12DfDz9sTL; Fri, 9 Oct 2020 14:52:05 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1602215525; bh=3x4EPVXdaRVyx0vSjugf6HMVOKq+5LZlmzOJZREEARI=; h=From:To:Cc:Subject:Date:From; b=Bf9Nq6EwyXIcuFXuj6OmayjZ8CRuvt6ir5c2SVU/tLb7Kf59zljvGeG4FQLhy2W8d f4uK4x620R9nK0j99TNWbjGEG/gT62tjk1Pj65V7h+sybz2CJAfnNDMswdLD0UF/Bd S1aiSaIocr/x/BRbty0SvdTA92hrRpemNAfl/4NYuEMywx6FUOGPVXeenyxJ633IE/ UHODJwKGd7ZaOjAdj2jZXD6JPufxzkurgYyUjd3pB+PhK+m9dFVTvQ3mk/orsx2QK5 85U5yK1oTEl2nMs2oyljrjLczxOndobzGa33EUf4LogmPf8RcAeMVLPYJgQkl2iQkK 0Pm9JC2gIN2Qg== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Fri, 9 Oct 2020 14:51:55 +1100 Message-Id: <20201009035155.310250-1-amitay@ozlabs.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Subject: [Pdbg] [PATCH] libpdbg: Do not free sbefifo during release of all targets X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "mailing list for https://github.com/open-power/pdbg development" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Amitay Isaacs Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Pdbg releases all targets before exiting. P9 core/thread targets when released use scoms for special wakeup. However, when using sbefifo backend, sbefifo driver is released before core/thread targets. This casuses segfault as scom access tries to use already free'd sbefifo context. Correct fix is to add reference counting on sbefifo context and free only when all the refernces have been released. A quick and dirty fix here is to drop freeing sbefifo context. Proper fix will be implemented later. Signed-off-by: Amitay Isaacs Reviewed-by: Joel Stanley --- libpdbg/sbefifo.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libpdbg/sbefifo.c b/libpdbg/sbefifo.c index 6e45088..9d68853 100644 --- a/libpdbg/sbefifo.c +++ b/libpdbg/sbefifo.c @@ -647,9 +647,11 @@ static int sbefifo_probe(struct pdbg_target *target) static void sbefifo_release(struct pdbg_target *target) { - struct sbefifo *sf = target_to_sbefifo(target); - - sbefifo_disconnect(sf->sf_ctx); + /* + * FIXME: Need to add reference counting for sbefifo context, so it is + * not freed till every last hwunit using sbefifo driver has been + * released. + */ } static struct mem sbefifo_mem = {