Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2877069rwd; Fri, 16 Jun 2023 09:15:41 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6cqfy1shnqXsI4AqUo2QVugwUOOFrVJwCpyTE+bUQU2ZZIdwNSYzeL75/X1uTXplLGgD2F X-Received: by 2002:a05:6a00:1783:b0:666:b0e7:10ca with SMTP id s3-20020a056a00178300b00666b0e710camr3011449pfg.31.1686932140849; Fri, 16 Jun 2023 09:15:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686932140; cv=none; d=google.com; s=arc-20160816; b=gU6e5mo9QBrqquT9+B+HVibRC2u2FZolllJJ3q9WY6ADR/8sCnmHpNK7w2Y+vqlkQO ac5sakjObJG+ai3MutQGj8FRi6MVyBMt01Lo4X4WAJxW4NPWILDJSKPoq5oLjtzeOTW5 s0kUo+AI0KtrOwfs98q/Sa5o+eRHehKlYCwkonVXqnMtndYcChI+r16/xedPEcCqfHB4 iGOywbjT6m5sBBnGc2kkmStKGeMSEiodDuGJWgg504BGonEZ/CVOiQoTio/v8QaLLPoV 91nbsZwvJz6jzQqDc45ZkagXQF68ytP/4omLGAJs7wHkZnp4jZHASTASbLKXsSkun+0E MFvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=CzwnfOF1ja/e5mLA4mIEKI2Z3p6xi+l8eoSzrupGgWQ=; b=Qm0P5KF89RkoP+CJABo78uBe9po6ThAaCycwyPT4SgJsMJ8YKYwllqc40ESXEEJTv5 +c0//gu6pKwg1QbWAdZA+DXIuLtrnJAri1A0gqDoV/Uhh6yxZL0IevA132U95EZ1BFp6 qK9Mpd8N4RGf6rviSXWHv9xqPO/YToEXveQ1h5kjMvbbm3uFSaQU73XOIHnI8JH+E8f5 ptYuccjBzQ/raYseoC60Om7DMwt36tttDJjpnr9OYlCZW1O0DU8ugYFVDazqqMLCDll1 JRGJ2h/4mkw9zOf2VYCRkKsxJ7Q8fdHZGssCrq7Dx0r+r3gZmiaF5ISnFX1dMDzp/xZA 0wyw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y9-20020aa79ae9000000b0066669c4e9e9si1827687pfp.143.2023.06.16.09.15.26; Fri, 16 Jun 2023 09:15:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232080AbjFPPtU (ORCPT + 99 others); Fri, 16 Jun 2023 11:49:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229538AbjFPPtS (ORCPT ); Fri, 16 Jun 2023 11:49:18 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A6BD8295C for ; Fri, 16 Jun 2023 08:49:16 -0700 (PDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 6F2291FB; Fri, 16 Jun 2023 08:50:00 -0700 (PDT) Received: from [10.57.85.251] (unknown [10.57.85.251]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1404F3F71E; Fri, 16 Jun 2023 08:49:14 -0700 (PDT) Message-ID: <84a7b27a-8a46-5f9c-105d-e00f066131e0@arm.com> Date: Fri, 16 Jun 2023 16:49:10 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: [PATCH 1/8] ethosu: Add Arm Ethos-U driver Content-Language: en-GB To: Alison Wang , gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: leoyang.li@nxp.com, xuelin.shi@nxp.com, xiaofeng.ren@nxp.com, feng.guo@nxp.com References: <20230616055913.2360-1-alison.wang@nxp.com> <20230616055913.2360-2-alison.wang@nxp.com> From: Robin Murphy In-Reply-To: <20230616055913.2360-2-alison.wang@nxp.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2023-06-16 06:59, Alison Wang wrote: [...] > +/* > + * The 'dma-ranges' device tree property for shared dma memory does not seem > + * to be fully supported for coherent memory. Therefor we apply the DMA range > + * offset ourselves. > + */ NAK - if there's a bug in the core code, that wants to be fixed, not bodged around by individual drivers. However from the look of the code here, the driver appears to be misusing the property in an incorrect manner anyway. But of course there's no devicetree binding here, so we don't even really know what it thinks it expects... :/ I'd also agree with Greg that this is definitely not a firmware driver. IIUC it's not so much a driver for the Ethos-U NPU itself, but one for this particular subsystem configuration where requests to the NPU are proxied through a dedicated Cortex-M core. As such, if you don't think it belongs in drivers/accel, then drivers/remoteproc might be the next most relevant choice. Also, is there a more specific name for this particular subsystem, or is there a general expectation that this is the only way an Ethos-U should ever be exposed to Linux, and it should never have direct access to the hardware (as it would with an Ethos-N), and thus there's no chance of ending up with multiple different "Ethos-U" drivers in future? Thanks, Robin. > +static dma_addr_t ethosu_buffer_dma_ranges(struct device *dev, > + dma_addr_t dma_addr, > + size_t dma_buf_size) > +{ > + struct device_node *node = dev->of_node; > + const __be32 *ranges; > + int len; > + int naddr; > + int nsize; > + int inc; > + int i; > + > + if (!node) > + return dma_addr; > + > + /* Get the #address-cells and #size-cells properties */ > + naddr = of_n_addr_cells(node); > + nsize = of_n_size_cells(node); > + > + /* Read the 'dma-ranges' property */ > + ranges = of_get_property(node, "dma-ranges", &len); > + if (!ranges || len <= 0) > + return dma_addr; > + > + dev_dbg(dev, "ranges=%p, len=%d, naddr=%d, nsize=%d\n", > + ranges, len, naddr, nsize); > + > + len /= sizeof(*ranges); > + inc = naddr + naddr + nsize; > + > + for (i = 0; (i + inc) <= len; i += inc) { > + dma_addr_t daddr; > + dma_addr_t paddr; > + dma_addr_t size; > + > + daddr = of_read_number(&ranges[i], naddr); > + paddr = of_read_number(&ranges[i + naddr], naddr); > + size = of_read_number(&ranges[i + naddr + naddr], nsize); > + > + dev_dbg(dev, "daddr=0x%llx, paddr=0x%llx, size=0x%llx\n", > + daddr, paddr, size); > + > + if (dma_addr >= paddr && > + (dma_addr + dma_buf_size) < (paddr + size)) > + return dma_addr + daddr - paddr; > + } > + > + return dma_addr; > +}