From patchwork Wed Aug 29 01:50:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rashmica Gupta X-Patchwork-Id: 963200 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 420TBN5qjWz9s4Z for ; Wed, 29 Aug 2018 11:51:40 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Q2nRAatE"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 420TBN3gPlzF1Zs for ; Wed, 29 Aug 2018 11:51:40 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Q2nRAatE"; dkim-atps=neutral X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::534; helo=mail-pg1-x534.google.com; envelope-from=rashmica.g@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Q2nRAatE"; dkim-atps=neutral Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 420TB02cDjzDrRN for ; Wed, 29 Aug 2018 11:51:20 +1000 (AEST) Received: by mail-pg1-x534.google.com with SMTP id y3-v6so363955pgv.0 for ; Tue, 28 Aug 2018 18:51:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=7MwA6agLgjK11S8EHY0d+LMkJOYa4wbpoOUop05RR0M=; b=Q2nRAatEW/UY/M3MqGsdRyr6vWNeBXN20Ytmz3JSPRxUeTjnVa3NHEH0hCVaHNnJw/ H9ZNwS6gFFG5m0aINZGTQSUFtzhQX67bXw12cwfNytpX9cztlbiDam1bje7IFB7UK5/j 4ouCG46FspC460xNBVBk0E1+BclanWgjKsVp11F7P/dUuPKeadTMpEfuexJAwuMX542/ BIpsTnf2MYbFekB7DoqvtkN3VuNSqPT2DtsRL9f73kDrgyGZeMXWei9pP5a9YHCTApYr Nd49iS/Ea7GMfBH74Z9qsAY067LleORC23ZP1aQz4UpWugid12wrP/VZKqjIufz1eHeQ N44A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=7MwA6agLgjK11S8EHY0d+LMkJOYa4wbpoOUop05RR0M=; b=LC1Ohf5ULxD5EPi5WhTIzSgAfUA96QxgULs4r5GOA2mdtghN1Gw1PfpsN5PKx3XSCq ayK3u71mT+h23x8bAuPmNPbi+gfTnDPt1XNu2JYTrFQ+ihz28nndUD9Wrndoo9mnlyT/ 6bw9iGnH+kU4TythUf1hklP+9mxa3ZO0UKeLNo0fCUmZzcduw+AcAoy3iFjHffFsvrOr BMjZtxRx2ANtatA3eUb0y3CXlDW33MQbjyMEQLy0qGa+5x7sWKZBn6y+EPajlKkyBODL imp68x6u0wzSIX06HOWfmbaKr/R9KAxM6Re83+WlBGkhcqqpgYt6gV2OBJAyeGxamhOn +kvQ== X-Gm-Message-State: APzg51CPtC1kSobVuwXSuBYtICHkak1orrsVnubjy//uADEG0+iIaC12 8AKtC1hQ5nrP89sbqWEzCZ9liU6F X-Google-Smtp-Source: ANB0VdYq8LMuUVouQXw/OqdxoMZE4l/zO1n3lOXpAJnJZbSku6VCa3a44NyIGrUYkJwgbHoF7x8zDw== X-Received: by 2002:a62:5ec3:: with SMTP id s186-v6mr3800043pfb.146.1535507478493; Tue, 28 Aug 2018 18:51:18 -0700 (PDT) Received: from rashmica.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id t14-v6sm3082571pgu.0.2018.08.28.18.51.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 28 Aug 2018 18:51:18 -0700 (PDT) From: Rashmica Gupta To: pdbg@lists.ozlabs.org Date: Wed, 29 Aug 2018 11:50:36 +1000 Message-Id: <20180829015047.7355-9-rashmica.g@gmail.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180829015047.7355-1-rashmica.g@gmail.com> References: <20180829015047.7355-1-rashmica.g@gmail.com> Subject: [Pdbg] [PATCH 08/19] libpdbg: Check if scom controllers are exposed X-BeenThere: pdbg@lists.ozlabs.org X-Mailman-Version: 2.1.27 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: npiggin@gmail.com MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" If CONFIG_SCOM_DEBUGFS is not set in the running kernel then the scom controllers are not exposed and so using getscom won't work. Add check for /sys/kernel/debug/powerpc/scom to give a more useful error message. Signed-off-by: Rashmica Gupta --- libpdbg/host.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/libpdbg/host.c b/libpdbg/host.c index 483e048..eb627be 100644 --- a/libpdbg/host.c +++ b/libpdbg/host.c @@ -95,7 +95,15 @@ static int host_pib_probe(struct pdbg_target *target) if (chip_id == -1) goto out; - if (asprintf(&access_fn, "%s/%08x/access", XSCOM_BASE_PATH, chip_id) < 0) + /* This check should probably be done earlier */ + if (access(XSCOM_BASE_PATH, F_OK) == -1) + { + PR_ERROR("Can not access %s. ", XSCOM_BASE_PATH); + PR_ERROR("Is CONFIG_SCOM_DEBUGFS set? "); + PR_ERROR("You may need to re-run the command as root.\n"); + } + + if (asprintf(&access_fn, "%s/%08d/access", XSCOM_BASE_PATH, chip_id) < 0) goto out; *fd = open(access_fn, O_RDWR);