Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp2589942ybh; Mon, 5 Aug 2019 03:33:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqxrl1kpV3u0ZK/bdx2t3Yzagunkjns9rWv/Ni0tahiE6t8Iubuf10nxdzk8q3AZARuFhj0O X-Received: by 2002:a17:90a:3724:: with SMTP id u33mr17260193pjb.19.1565001217705; Mon, 05 Aug 2019 03:33:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565001217; cv=none; d=google.com; s=arc-20160816; b=yt5yOXiDzHoEPOaBCRG5S/ttaLc1EdxgIT7KJcxBeENJfHv5MUpVPgwNHspQ3cnRDi g3VbSQOuDL1pymWVnluW4fWdZOuYFoncUd8sEbfaStWEnSEuUz/kOvgyDyjFW5SvLZHU L6XGdKQIjHU/3YfvdrvdwDIGRWQiaNjtG2FkRfqMXO87PycfmsgKyr7zjs0Iqih1z8gf 0E3xojpMOHYqC/U275tIKijomiRhH6LVggsan6IWhLZwPGU1wqd2Q28gti5VA34HdioB JjtNDCfLCjkGavEGLG3Cr7GTQqEEoYVNiT/mJM0+bKlUJsIue0YqjyHjr1+c3PTQjm2j +eQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=2t8NpBMFz+vZWj7uMv0mNnSRA2UuSvBBLYkX3l+9iFg=; b=V6pSPL8FdDlv8Qh/uUuE7OhOhoHuBfMEBTs5cU17fhAzcMuuzyYRqVVAD9Yz/MXPpi e4FVGHtv858eUTagtjuurF95VYTGyLIeySowtJId7KrX0yezdoOlrGXpfA5h4CFl/fVC iKArfRjCaGqLpuk8LyvCoivSOc1C4YYs4sEezfWZ6OoQmmGNOLZqCEIsvUdsit9zNHuL FSjrPpCqSelbKj10R4idmr1M8Qb1HJWG4bBBMDwcGa1hZ8MdgYittnN4zATsdMZji5Yn I+kUShfTJGL8w4yhL17/idTf0WDbSveB3roGFIkSsP9i4p+Yo/W4Yv0hkrEQKQeu9pIn WW5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=OlUQn9n1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t14si40518981ply.347.2019.08.05.03.33.21; Mon, 05 Aug 2019 03:33:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=OlUQn9n1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728337AbfHEKcF (ORCPT + 99 others); Mon, 5 Aug 2019 06:32:05 -0400 Received: from mail-ed1-f65.google.com ([209.85.208.65]:33613 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727739AbfHEKcF (ORCPT ); Mon, 5 Aug 2019 06:32:05 -0400 Received: by mail-ed1-f65.google.com with SMTP id i11so14683396edq.0 for ; Mon, 05 Aug 2019 03:32:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=2t8NpBMFz+vZWj7uMv0mNnSRA2UuSvBBLYkX3l+9iFg=; b=OlUQn9n1XfLu7teP0KKGlghRXxE6YfdgOYBt+po0ODAQAZtrX33RsFC7JrwnExa8cL MSNWxapbzgtY/jV/tmPXt03VuurAMp7FYIh6dN5w7vOK4bqXapuRztsQMw4XbnFxCq5j qi6USnwHuwJmQK4LdK0w4JDAEpdOA4Bo7Sw3s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=2t8NpBMFz+vZWj7uMv0mNnSRA2UuSvBBLYkX3l+9iFg=; b=aUqXB3I1pT16EjL3xeZQDIGYuBua8YnezugTj0NGiAcBP4m1TDYyxJDTs6qzOWcwW1 EWy5Tv5bliGtwiLTr8y4MzJr3wZXW+YdV9M3d9ZapZk1rkO3F47UXheIoUX/4hkXy/x4 QVGoRb6ClD7N8QuwWMWlczBMxnRNIz0l785KmG8hyvinm7M7QEP7OtictPjBJ9vxSIF0 hKfR4obbhXLgHxxAO/QdOYLFlpHxMJR6ptn4V2HwsYSWCaqZ4BMFChRvIYIr4PcoD+Uy UTR36NE23zWj/7pRHcTiEJCFnlIZCswiw/x6yvzsa0Ib2uHYbFAQBbIX62pvyPAbYsQb 1gwA== X-Gm-Message-State: APjAAAXc+WjoKUHvYImO7mx4o3aF31HXZmQZyWf2vVkmZ/gurOkcC3QZ qtraPCbI81I3rawLbuUr5qYAd2PR45a0Otez1dfdkg== X-Received: by 2002:a17:906:644c:: with SMTP id l12mr112559234ejn.142.1565001123236; Mon, 05 Aug 2019 03:32:03 -0700 (PDT) MIME-Version: 1.0 References: <20190709072547.217957-1-pihsun@chromium.org> <20190709072547.217957-3-pihsun@chromium.org> In-Reply-To: From: Pi-Hsun Shih Date: Mon, 5 Aug 2019 18:31:26 +0800 Message-ID: Subject: Re: [PATCH v13 2/5] remoteproc/mediatek: add SCP support for mt8183 To: Alexandre Courbot Cc: Ohad Ben-Cohen , Nicolas Boichat , Erin Lo , "open list:REMOTE PROCESSOR REMOTEPROC SUBSYSTEM" , open list , Bjorn Andersson , "moderated list:ARM/Mediatek SoC support" , Matthias Brugger , "moderated list:ARM/Mediatek SoC support" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Thanks for the review. I'll address most of the comments in the next version. On Mon, Jul 22, 2019 at 5:37 PM Alexandre Courbot wrote: > > Hi Pi-Hsun, > > On Tue, Jul 9, 2019 at 4:27 PM Pi-Hsun Shih wrote: > > +static void *scp_da_to_va(struct rproc *rproc, u64 da, int len) > > +{ > > + struct mtk_scp *scp = (struct mtk_scp *)rproc->priv; > > + int offset; > > + > > + if (da < scp->sram_size) { > > + offset = da; > > + if (offset >= 0 && ((offset + len) < scp->sram_size)) > > + return (__force void *)(scp->sram_base + offset); > > + } else if (da >= scp->sram_size && > > + da < (scp->sram_size + MAX_CODE_SIZE)) { > > + offset = da; > > This line looks suspicious. Shouldn't it be > > offset = da - scp->sram_size? > Actually the whole "else if (...)" is not used. Would remove this in next version. > > + > > +/* > > + * Copy src to dst, where dst is in SCP SRAM region. > > + * Since AP access of SCP SRAM don't support byte write, this always write a > > + * full word at a time, and may cause some extra bytes to be written at the > > + * beginning & ending of dst. > > + */ > > +void scp_memcpy_aligned(void *dst, const void *src, unsigned int len) > > +{ > > + void *ptr; > > + u32 val; > > + unsigned int i = 0; > > + > > + if (!IS_ALIGNED((unsigned long)dst, 4)) { > > + ptr = (void *)ALIGN_DOWN((unsigned long)dst, 4); > > + i = 4 - (dst - ptr); > > + val = readl_relaxed(ptr); > > + memcpy((u8 *)&val + (4 - i), src, i); > > + writel_relaxed(val, ptr); > > + } > > + > > + while (i + 4 <= len) { > > + val = *((u32 *)(src + i)); > > + writel_relaxed(val, dst + i); > > If dst is not aligned to 4, this is going to write to an address that > is not a multiple of 4, even though it writes a long. Is this ok? > Typically limitations in write size come with alignment limitations. > If dst is not aligned to 4, the first if (!IS_ALIGNED(...)) block should make that the (dst + i) is a multiple of 4, so the write here is aligned. > > + i += 4; > > + } > > + if (i < len) { > > + val = readl_relaxed(dst + i); > > + memcpy(&val, src + i, len - i); > > + writel_relaxed(val, dst + i); > > + } > > +} > > +EXPORT_SYMBOL_GPL(scp_memcpy_aligned); > > IIUC this function's symbol does not need to be exported since it is > only used in the current kernel module. > I've tried to remove this EXPORT line, but then there would be error while compiling: ERROR: "scp_memcpy_aligned" [drivers/remoteproc/mtk_scp.ko] undefined! I think it's because the mtk_scp.c and mtk_scp_ipi.c both use the scp_memcpy_aligned, but is compiled as separate .o files. So the EXPORT_SYMBOL is needed.