Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp2430114ybk; Mon, 11 May 2020 22:17:38 -0700 (PDT) X-Google-Smtp-Source: APiQypJzI5D/5XpJfXnf9DGXvMsdZ9CiRSJzGbJp41BcIUeLm3sEbWgz3KGXUrLY9pXRmQ5kCONe X-Received: by 2002:a05:6402:333:: with SMTP id q19mr16922618edw.186.1589260657876; Mon, 11 May 2020 22:17:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589260657; cv=none; d=google.com; s=arc-20160816; b=tZ9zFKEVLakEDufyE0w6EWDor3kUJpevpgV7IC4VdHcX4+U3eyjH8Y9Em9Xhhfzi+C zhDem8Ibrh9hg+brH9u2yEfExgVQy8c4qUAAVeHN5v5iIv68HzC76zOFxXz0L70kxA6f BkEJXvRhJr4v5V/qbUdAGMrwVY9vWj9QRnoy3uYP13YS4R6kdQ3UfTtR7GGXZtvhpq09 3wqkbCOx4Om+A2qJ7DfBZN1V8qZyDU+hQx21sAW5YBv52JwrrfNjc1mzwnmNsKkmA/Vr F6K6IgGpuHdqAHcenXF7GSHcgzp7FYk37I7arrBPePLM5fJjR9Fw72fA6vhbb2Ei0QCY +qzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=3KgDwL4jTZSbdM6dDCdBrk9zZ/jBRwWTO1ICAFFMTh0=; b=kOckHNzxX/7En/JiT7PVa+TgJ7YDf7pPf9sNWAlE1PfgcGuWl47DIdMZjdhQT/xjaS 4yn4wujea1L60dNgjmYoziOsyBP9WyZiwTJr8qwsehPvWtZOoZAspmjO+Va5PV4fTOne DI/w1DVJBKU02ibCw33mEUCQWPUYuUAmkPcnyIAfc5vukZu/W+KPWGc3hnEoMyKZIb/D 9eVld/12unsFx7ezp04lp7J8kXqeCC0DFGRwTSuKkiQL1V58DGCqEMoyl/Zd+Q1R0xsn sZ797OGIElyKX3nzHRCP4PAz5Hn26tunn8hjkdevjAOlUOh2iT2YXITrd2HOtcMO+ymV L3QQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vDQXBNad; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m9si6682205eja.420.2020.05.11.22.17.15; Mon, 11 May 2020 22:17:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vDQXBNad; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728800AbgELFO6 (ORCPT + 99 others); Tue, 12 May 2020 01:14:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36084 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1725776AbgELFO5 (ORCPT ); Tue, 12 May 2020 01:14:57 -0400 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1B30C05BD09 for ; Mon, 11 May 2020 22:14:56 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id j21so5611096pgb.7 for ; Mon, 11 May 2020 22:14:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=3KgDwL4jTZSbdM6dDCdBrk9zZ/jBRwWTO1ICAFFMTh0=; b=vDQXBNadfhjrgUfrXrCJgVZpGlN+Kp3lQw+DWHzORFIQTAcoT0bfWrgrz+Ocp+W8+T NJv5/81yfNou3cTJWqF70oPbScunuoEUyPRwmjitVjZEBqgzhcHwSelPI1Wijhoa+Dlo dNXZOsz3asKOSfXnAcyJX2BtSoNmcXAuz4HWD0UJe4QifVJWuqqzv3WxKAgKndlnyrE6 mxGViQZz0mnbVDlB0/50UKcCjLE1CGegw/WYZqDtNZOHwM3KET5O1wAw0e+JRBPKTkCH 69FawH6DE/JZXsMKfux5NRSCfpCV8IjZampjQ/yK2fH3AFI83ncwh7+mtec/Uw/TJhc9 CpDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=3KgDwL4jTZSbdM6dDCdBrk9zZ/jBRwWTO1ICAFFMTh0=; b=RI3OyVlUKvdrEaEQ209NGHNX5yzlXWzwXMoJFlN3Z22VLD4eb4JOHf2GdhrTYB+iEF MVGvPGHNz5nyTxoun25b9xYk7ES3b5K2S6sJH4EfeEGVLxchd9cgyCfXGj4QlW5540Sx kHJEs/p6oRpQAJ0877YQC+dtGU0M4So2bhV9ZtTjsqpyZ82i9I80yFzz7tW/emVoIY5k 5JNYJjK7AxNwYgb4v9CQgG0oPuZzlz30WPJsVu+zNhGdtAuvs6ApOFY9SP6SvFxAkDNN leH06/0EYMxZP0kj3Jmcz4eXRrIxAwBdqvcRL3r7wDwJ2uf1pq+Yfjtv1lXrQhJ6fZ86 kJuQ== X-Gm-Message-State: AGi0Pua/mzG6x0KYCTZ/MmiB9ojkz/usifzDjAUAXGXiXN7dTxBh7tjh 0JPWb/lhabog7hvj9vpwXLL4gD06HFQ= X-Received: by 2002:a63:c306:: with SMTP id c6mr18129415pgd.311.1589260495916; Mon, 11 May 2020 22:14:55 -0700 (PDT) Received: from builder.lan (104-188-17-28.lightspeed.sndgca.sbcglobal.net. [104.188.17.28]) by smtp.gmail.com with ESMTPSA id c63sm10806244pfc.2.2020.05.11.22.14.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 May 2020 22:14:55 -0700 (PDT) Date: Mon, 11 May 2020 22:13:21 -0700 From: Bjorn Andersson To: rishabhb@codeaurora.org Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, ohad@wizery.com, mathieu.poirier@linaro.org, tsoni@codeaurora.org, psodagud@codeaurora.org, sidgup@codeaurora.org, linux-remoteproc-owner@vger.kernel.org Subject: Re: [PATCH 2/3] remoteproc: Add inline coredump functionality Message-ID: <20200512051321.GA16107@builder.lan> References: <1587062312-4939-1-git-send-email-rishabhb@codeaurora.org> <1587062312-4939-2-git-send-email-rishabhb@codeaurora.org> <20200507202121.GK2329931@builder.lan> <7deb97ab40dd36d5a51111147cf4c14e@codeaurora.org> <20200512003028.GA2165@builder.lan> <7396b8707d4cf38173f2d1b3968e7fc6@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7396b8707d4cf38173f2d1b3968e7fc6@codeaurora.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon 11 May 17:41 PDT 2020, rishabhb@codeaurora.org wrote: > On 2020-05-11 17:30, Bjorn Andersson wrote: > > On Mon 11 May 17:11 PDT 2020, rishabhb@codeaurora.org wrote: > > > On 2020-05-07 13:21, Bjorn Andersson wrote: > > > > On Thu 16 Apr 11:38 PDT 2020, Rishabh Bhatnagar wrote: > > > > > diff --git a/drivers/remoteproc/remoteproc_coredump.c > > > > > b/drivers/remoteproc/remoteproc_coredump.c [..] > > > > > +static ssize_t rproc_read_dump(char *buffer, loff_t offset, size_t > > > > > count, > > > > > + void *data, size_t header_size) > > > > > +{ > > > > > + void *device_mem; > > > > > + size_t data_left, copy_size, bytes_left = count; > > > > > + unsigned long addr; > > > > > + struct rproc_coredump_state *dump_state = data; > > > > > + struct rproc *rproc = dump_state->rproc; > > > > > + void *elfcore = dump_state->header; > > > > > + > > > > > + /* Copy the header first */ > > > > > + if (offset < header_size) { > > > > > + copy_size = header_size - offset; > > > > > + copy_size = min(copy_size, bytes_left); > > > > > + > > > > > + memcpy(buffer, elfcore + offset, copy_size); > > > > > + offset += copy_size; > > > > > + bytes_left -= copy_size; > > > > > + buffer += copy_size; > > > > > + } > > > > > > > > Perhaps you can take inspiration from devcd_readv() here? > > > > > > > > > + > > > > > + while (bytes_left) { > > > > > + addr = resolve_addr(offset - header_size, > > > > > + &rproc->dump_segments, &data_left); > > > > > + /* EOF check */ > > > > > + if (data_left == 0) { > > > > > > > > Afaict data_left denotes the amount of data left in this particular > > > > segment, rather than in the entire core. > > > > > > > Yes, but it only returns 0 when the final segment has been copied > > > completely. Otherwise it gives data left to copy for every segment > > > and moves to next segment once the current one is copied. > > > > You're right. > > > > > > I think you should start by making bytes_left the minimum of the core > > > > size and @count and then have this loop as long as bytes_left, copying > > > > data to the buffer either from header or an appropriate segment based on > > > > the current offset. > > > > > > > That would require an extra function that calculates entire core size, > > > as its not available right now. Do you see any missed corner cases > > > with this > > > approach? > > > > You're looping over all the segments as you're building the header > > anyways, so you could simply store this in the dump_state. I think this > > depend more on the ability to reuse the read function between inline and > > default coredump. > > > > Regards, > > Bjorn > > Wouldn't the first if condition take care of "default" dump as it is? > The header_size in that case would involve the 'header + all segments'. Correct. Regards, Bjorn