From patchwork Tue Oct 2 06:04:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amitay Isaacs X-Patchwork-Id: 977651 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 42PTP41W3Jz9sCw for ; Tue, 2 Oct 2018 16:13:44 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (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.b="Z7tv0AJx"; 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 42PTP36hFYzF3FW for ; Tue, 2 Oct 2018 16:13:43 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=ozlabs.org header.i=@ozlabs.org header.b="Z7tv0AJx"; dkim-atps=neutral X-Original-To: pdbg@lists.ozlabs.org Delivered-To: pdbg@lists.ozlabs.org Received: from ozlabs.org (bilbo.ozlabs.org [203.11.71.1]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 42PTBd24PBzF3D0 for ; Tue, 2 Oct 2018 16:04:41 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (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.b="Z7tv0AJx"; dkim-atps=neutral Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPSA id 42PTBc54sjz9shy; Tue, 2 Oct 2018 16:04:40 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ozlabs.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ozlabs.org; s=201707; t=1538460280; bh=xZtJV6TQewEXatSTLxrxHiIgbKvmxH1UPOHin4G6CFc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z7tv0AJxlvt39VHWt2SbCesC9O+WxUAgJUrrV67bamvGLlxYEPcUxRK7T2LAtniS5 M3N0hhQVOk6GMenOPBK1YIrQW4bvn+q4A4GqqwHlPcKd2yShtyvXskOLiMyp3qbriH JrH4fBRm6YkakIwSE5HAy4JJvPhaM2i6Qh8IQJ70DIQIcvzy4KSoFfulXpJ/ZxzAPQ 1QdswsY7w1FoqxTHBpYJk+9AotJrAKXvNZtr4AtukMdHyF5dYr1Rxet1G99vJW466X ubB5yqI4ggD/h2nNGoX8o8W65J0XjnXz6NfZpw8LZSnWgVWMo7GOZ9jdg+AnT3ZTRv TwpRlG9tF/KPg== From: Amitay Isaacs To: pdbg@lists.ozlabs.org Date: Tue, 2 Oct 2018 16:04:28 +1000 Message-Id: <20181002060430.3344784-8-amitay@ozlabs.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181002060430.3344784-1-amitay@ozlabs.org> References: <20181002060430.3344784-1-amitay@ozlabs.org> Subject: [Pdbg] [PATCH 07/10] main: Switch to path based target selection 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 MIME-Version: 1.0 Errors-To: pdbg-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Pdbg" Drop the old target selection code. Signed-off-by: Amitay Isaacs --- src/main.c | 82 +++++++----------------------------------------------- 1 file changed, 10 insertions(+), 72 deletions(-) diff --git a/src/main.c b/src/main.c index 38cd0ea..feb24fa 100644 --- a/src/main.c +++ b/src/main.c @@ -73,10 +73,6 @@ static int i2c_addr = 0x50; #define MAX_LINUX_CPUS (MAX_PROCESSORS * MAX_CHIPS * MAX_THREADS) -static int **processorsel[MAX_PROCESSORS]; -static int *chipsel[MAX_PROCESSORS][MAX_CHIPS]; -static int threadsel[MAX_PROCESSORS][MAX_CHIPS][MAX_THREADS]; - #define MAX_PATH_ARGS 16 static const char *pathsel[MAX_PATH_ARGS]; @@ -522,19 +518,12 @@ static bool parse_options(int argc, char *argv[]) void target_select(struct pdbg_target *target) { - /* We abuse the private data pointer atm to indicate the target is - * selected */ - pdbg_target_priv_set(target, (void *) 1); -} - -void target_unselect(struct pdbg_target *target) -{ - pdbg_target_priv_set(target, NULL); + path_target_add(target); } bool target_selected(struct pdbg_target *target) { - return (bool) pdbg_target_priv(target); + return path_target_selected(target); } /* Returns the sum of return codes. This can be used to count how many targets the callback was run on. */ @@ -600,10 +589,8 @@ void for_each_target_release(char *class) } } -static bool target_selection(void) +static bool target_selection(const char *prog) { - struct pdbg_target *fsi, *pib, *chip, *thread; - switch (backend) { #ifdef TARGET_ARM case I2C: @@ -670,63 +657,17 @@ static bool target_selection(void) return false; } - /* At this point we should have a device-tree loaded. We want - * to walk the tree and disabled nodes we don't care about - * prior to probing. */ - pdbg_for_each_class_target("pib", pib) { - int proc_index = pdbg_target_index(pib); - - if (backend == I2C && device_node) - pdbg_set_target_property(pib, "bus", device_node, strlen(device_node) + 1); - - if (processorsel[proc_index]) { - target_select(pib); - pdbg_for_each_target("core", pib, chip) { - int chip_index = pdbg_target_index(chip); - if (pdbg_parent_index(chip, "pib") != proc_index) - continue; - - if (chipsel[proc_index][chip_index]) { - target_select(chip); - pdbg_for_each_target("thread", chip, thread) { - int thread_index = pdbg_target_index(thread); - if (threadsel[proc_index][chip_index][thread_index]) - target_select(thread); - else - target_unselect(thread); - } - } else - target_unselect(chip); - } - - /* This is kinda broken as we're overloading what '-c' - * means - it's now up to each command to select targets - * based on core/chiplet. We really need a better - * solution to target selection. */ - pdbg_for_each_target("chiplet", pib, chip) { - int chip_index = pdbg_target_index(chip); - if (chipsel[proc_index][chip_index]) { - target_select(chip); - } else - target_unselect(chip); - } - } else - target_unselect(pib); - } - - pdbg_for_each_class_target("fsi", fsi) { - int index = pdbg_target_index(fsi); - if (processorsel[index]) - target_select(fsi); - else - target_unselect(fsi); - } - if (pathsel_count) { if (!path_target_parse(pathsel, pathsel_count)) return false; } + if (!path_target_present()) { + printf("No valid targets found or specified. Try adding -p/-c/-t options to specify a target.\n"); + printf("Alternatively run '%s -a probe' to get a list of all valid targets\n", basename(prog)); + return false; + } + return true; } @@ -819,7 +760,7 @@ int main(int argc, char *argv[]) device_node = default_target(backend); /* Disable unselected targets */ - if (!target_selection()) + if (!target_selection(argv[0])) return 1; atexit(atexit_release); @@ -853,8 +794,5 @@ found_action: if (rc > 0) return 0; - printf("No valid targets found or specified. Try adding -p/-c/-t options to specify a target.\n"); - printf("Alternatively run '%s -a probe' to get a list of all valid targets\n", - basename(argv[0])); return 1; }