Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp3059081rdh; Thu, 28 Sep 2023 00:54:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGArWvupY16jE9gE0oLweSZIf4oey2+OpXX58ce/ZlZltbOKnfdNXp6Npz95X0BE9QTJmQo X-Received: by 2002:a17:903:4291:b0:1c6:f56:932b with SMTP id ju17-20020a170903429100b001c60f56932bmr356263plb.37.1695887697586; Thu, 28 Sep 2023 00:54:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695887697; cv=none; d=google.com; s=arc-20160816; b=Jy4o+4yg5n6VrjwPoVRBMpsTaB3UnWrm/KOKMHHaFXxM4/HXQqphUimjALXlrZa+Yh AWQRvfUbPfTlfGXN2Pvmkv66B8rPVGGm3yH04NsYaQaJqksL8EZ2j7biyeD3Y4SkpdRf GMfgTqjP7X6iGm0/srgz2MG+k1RQH2YWrWpIxiuyCP8+IujcQFbicj6ffuQ6O/iXwb8e LV1olumz+awHlagUN0QrKqbkwNa5Rq6gfaSDCrjwLXbbvzH/dWDZ56lMhNwDVUvAB2bI R/xPcS04O/a7+kIVsx/LZ7RUqfEB8CpAQzADN5RQiJNbHX/3880KgRWB1sLPh7YdEkLv v4Ow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=ySPayOKp0+oXbpFAKYzRAJWJs+ldAd6gTYob9Dlooak=; fh=bOQt7K7gSuOrKcG7NDi4mRy91TP0k94r/yiYQG3NfYE=; b=x96eXVwWVHND5B8h+t7qHY+1OsiWOX6RgLcKnTNkwt9x8wVoEvg1vWEV2DFBkH6ooz neODKryTri6gcNPcd0IUX16YnAZ+1Lo26zLQwmTKW35maMJsgmCW+BclZHQyj3V/jtr7 Rhf2SwksXKkYOQZ1ueUhyIFXxMnkyq6lcTqVF+XURZRBcJIYCU6HHaiYIq1A1Lj/F5Nv ewhoj0g3bGiULoPZwGcSQmoJsu3cRXaC0WJgw6KnEDH0VfdRtiaXW5+XkPAeFQEeRkfm Ss28y/aIKq8UIn/2SVHbw1+EFfYmbET9JV5FuoHnDR9B3LeBC97rqYhf0+8tzGIUV7Py 2jgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ERtMggmn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id ik28-20020a170902ab1c00b001b9c3498526si5882430plb.433.2023.09.28.00.54.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 00:54:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ERtMggmn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id 44106806C625; Thu, 28 Sep 2023 00:41:46 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230295AbjI1Hl3 (ORCPT + 99 others); Thu, 28 Sep 2023 03:41:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229539AbjI1Hl1 (ORCPT ); Thu, 28 Sep 2023 03:41:27 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA2D1AC; Thu, 28 Sep 2023 00:41:25 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 666E4C433C8; Thu, 28 Sep 2023 07:41:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1695886885; bh=D9ts5MC2FywiLZJu5dLAwNpd7njTHE/n9uAshJDLqp4=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=ERtMggmnq7Sp96lpebNUtkqJs8EMkeU+GVUNnsQPHXtIfwOVL+fBlnsUoWsmN+2fr Lj02o4Odf6TyQn0f0lqGcxIdSS1Xeo8Eo7ia2TTJCi+OeOZoQ16ql5mgbT0afO37MD oGivHeRe8qH14OtZY8rvxsOSGm2iIbeKBzk6IeyKRKT6mKsGHfPMBxPo9NjkffJuwM QlX6RBMiE0UNeAgI8NE7HM418FkHIrc9jOO5hcIpVmGe/XAoM8kkvssK1GzzkoNg/9 f7mY88bi5Rg7QqmjAw5f26ZYQ/qT38hBeqwi3PZn/RQlEp8gWNqxgXHDuGMaFv4AsZ v5jIDFsi+GZ0Q== Received: by mail-yw1-f178.google.com with SMTP id 00721157ae682-59f1dff5298so146596027b3.3; Thu, 28 Sep 2023 00:41:25 -0700 (PDT) X-Gm-Message-State: AOJu0Yz9wMOmQG9QAhOLOm8CUWMVadYLbhN14+rWpxOOi/KpDyZRGQBi al/Z6G9z49iGPkOvG6ZhpG11rMUf7mIoSKPP03k= X-Received: by 2002:a81:ab46:0:b0:59b:eb8:c38a with SMTP id d6-20020a81ab46000000b0059b0eb8c38amr363373ywk.30.1695886884509; Thu, 28 Sep 2023 00:41:24 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Oded Gabbay Date: Thu, 28 Sep 2023 10:40:58 +0300 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: kernel.org 6.5.4 , NPU driver, --not support (RFC) To: Cancan Chang Cc: Jagan Teki , linux-media , linux-kernel , Dave Airlie , Daniel Vetter Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Thu, 28 Sep 2023 00:41:46 -0700 (PDT) On Thu, Sep 28, 2023 at 10:25=E2=80=AFAM Cancan Chang wrote: > > =E2=80=9CCould you please post a link to the driver's source code ? > In addition, could you please elaborate which userspace libraries > exists that work with your driver ? Are any of them open-source ?=E2=80= =9D > --- We will prepare the adla driver link after the holiday on October 6th= . > It's a pity that there is no open-source userspace library. > But you can probably understand it through a workflow, which can be = simplified as: > 1. create model context > ret =3D ioctl(context->fd, ADLAK_IOCTL_REGISTER_NETWORK, &desc)= ; > 2. set inputs > 3. inference > ret =3D ioctl(context->fd, ADLAK_IOCTL_INVOKE, &invoke_dec); What happens if you call this again without waiting for the previous inference to complete ? Oded > 4. wait for the inference to complete > ret =3D ioctl(context->fd, ADLAK_IOCTL_WAIT_UNTIL_FINISH, &sta= t_req_desc); > 5. destroy model context > ret =3D ioctl(context->fd, ADLAK_IOCTL_DESTROY_NETWORK, &submi= t_del); > > > thanks > > > ________________________________________ > =E5=8F=91=E4=BB=B6=E4=BA=BA: Oded Gabbay > =E5=8F=91=E9=80=81=E6=97=B6=E9=97=B4: 2023=E5=B9=B49=E6=9C=8828=E6=97=A5 = 13:28 > =E6=94=B6=E4=BB=B6=E4=BA=BA: Cancan Chang > =E6=8A=84=E9=80=81: Jagan Teki; linux-media; linux-kernel; Dave Airlie; D= aniel Vetter > =E4=B8=BB=E9=A2=98: Re: kernel.org 6.5.4 , NPU driver, --not support (RFC= ) > > [ EXTERNAL EMAIL ] > > On Wed, Sep 27, 2023 at 10:01=E2=80=AFAM Cancan Chang wrote: > > > > =E2=80=9COr do you handle one cmd at a time, where the user sends a cmd= buffer > > to the driver and the driver then submit it by writing to a couple of > > registers and polls on some status register until its done, or waits > > for an interrupt to mark it as done ?=E2=80=9D > > --- yes=EF=BC=8C user sends a cmd buffer to driver, and driver trigge= rs hardware by writing to register, > > and then, waits for an interrupt to mark it as done. > > > > My current driver is very different from drm, so I want to know if = I have to switch to drm=EF=BC=9F > Could you please post a link to the driver's source code ? > In addition, could you please elaborate which userspace libraries > exists that work with your driver ? Are any of them open-source ? > > > Maybe I can refer to /driver/accel/habanalabs. > That's definitely a possibility. > > Oded > > > > thanks > > > > ________________________________________ > > =E5=8F=91=E4=BB=B6=E4=BA=BA: Oded Gabbay > > =E5=8F=91=E9=80=81=E6=97=B6=E9=97=B4: 2023=E5=B9=B49=E6=9C=8826=E6=97= =A5 20:54 > > =E6=94=B6=E4=BB=B6=E4=BA=BA: Cancan Chang > > =E6=8A=84=E9=80=81: Jagan Teki; linux-media; linux-kernel; Dave Airlie;= Daniel Vetter > > =E4=B8=BB=E9=A2=98: Re: kernel.org 6.5.4 , NPU driver, --not support (R= FC) > > > > [ EXTERNAL EMAIL ] > > > > On Mon, Sep 25, 2023 at 12:29=E2=80=AFPM Cancan Chang wrote: > > > > > > Thank you for your reply from Jagan & Oded. > > > > > > It is very appropritate for my driver to be placed in driver/accel. > > > > > > My accelerator is named ADLA(Amlogic Deep Learning Accelerator). > > > It is an IP in SOC,mainly used for neural network models acceleration= . > > > It will split and compile the neural network model into a private for= mat cmd buffer, > > > and submit this cmd buffer to ADLA hardware. It is not programmable d= evice. > > What exactly does it mean to "submit this cmd buffer to ADLA hardware" = ? > > > > Does your h/w provides queues for the user/driver to put their > > workloads/cmd-bufs on them ? And does it provide some completion queue > > to notify when the work is completed? > > > > Or do you handle one cmd at a time, where the user sends a cmd buffer > > to the driver and the driver then submit it by writing to a couple of > > registers and polls on some status register until its done, or waits > > for an interrupt to mark it as done ? > > > > > > > > ADLA includes four hardware engines: > > > RS engines : working for the reshape operators > > > MAC engines : working for the convolution operators > > > DW engines : working for the planer & Elementwise operators > > > Activation engines : working for activation operators(ReLu,tanh..) > > > > > > By the way, my IP is mainly used for SOC, and the current driver regi= stration is through the platform_driver, > > > is it necessary to switch to drm? > > This probably depends on the answer to my question above. btw, there > > are drivers in drm that handle IPs that are part of an SOC, so > > platform_driver is supported. > > > > Oded > > > > > > > > thanks. > > > > > > ________________________________________ > > > =E5=8F=91=E4=BB=B6=E4=BA=BA: Oded Gabbay > > > =E5=8F=91=E9=80=81=E6=97=B6=E9=97=B4: 2023=E5=B9=B49=E6=9C=8822=E6=97= =A5 23:08 > > > =E6=94=B6=E4=BB=B6=E4=BA=BA: Jagan Teki > > > =E6=8A=84=E9=80=81: Cancan Chang; linux-media; linux-kernel; Dave Air= lie; Daniel Vetter > > > =E4=B8=BB=E9=A2=98: Re: kernel.org 6.5.4 , NPU driver, --not support = (RFC) > > > > > > [=E4=BD=A0=E9=80=9A=E5=B8=B8=E4=B8=8D=E4=BC=9A=E6=94=B6=E5=88=B0=E6= =9D=A5=E8=87=AA ogabbay@kernel.org =E7=9A=84=E7=94=B5=E5=AD=90=E9=82=AE=E4= =BB=B6=E3=80=82=E8=AF=B7=E8=AE=BF=E9=97=AE https://aka.ms/LearnAboutSenderI= dentification=EF=BC=8C=E4=BB=A5=E4=BA=86=E8=A7=A3=E8=BF=99=E4=B8=80=E7=82= =B9=E4=B8=BA=E4=BB=80=E4=B9=88=E5=BE=88=E9=87=8D=E8=A6=81] > > > > > > [ EXTERNAL EMAIL ] > > > > > > On Fri, Sep 22, 2023 at 12:38=E2=80=AFPM Jagan Teki wrote: > > > > > > > > On Fri, 22 Sept 2023 at 15:04, Cancan Chang wrote: > > > > > > > > > > Dear Media Maintainers: > > > > > Thanks for your attention. Before describing my problem=EF= =BC=8Clet me introduce to you what I mean by NPU. > > > > > NPU is Neural Processing Unit, It is designed for deep learn= ing acceleration, It is also called TPU, APU .. > > > > > > > > > > The real problems: > > > > > When I was about to upstream my NPU driver codes to linux m= ainline, i meet two problems: > > > > > 1. According to my research, There is no NPU module path= in the linux (base on linux 6.5.4) , I have searched all linux projects an= d found no organization or comany that has submitted NPU code. Is there a p= ath prepared for NPU driver currently? > > > > > 2. If there is no NPU driver path currently, I am going= to put my NPU driver code in the drivers/media/platform/amlogic/ =EF=BB=BF= , because my NPU driver belongs to amlogic. and amlogic NPU is mainly used = for AI vision applications. Is this plan suitabe for you? > > > > > > > > If I'm correct about the discussion with Oded Gabby before. I think > > > > the drivers/accel/ is proper for AI Accelerators including NPU. > > > > > > > > + Oded in case he can comment. > > > > > > > > Thanks, > > > > Jagan. > > > Thanks Jagan for adding me to this thread. Adding Dave & Daniel as we= ll. > > > > > > Indeed, the drivers/accel is the place for Accelerators, mainly for > > > AI/Deep-Learning accelerators. > > > We currently have 3 drivers there already. > > > > > > The accel subsystem is part of the larger drm subsystem. Basically, t= o > > > get into accel, you need to integrate your driver with the drm at the > > > basic level (registering a device, hooking up with the proper > > > callbacks). ofc the more you use code from drm, the better. > > > You can take a look at the drivers under accel for some examples on > > > how to do that. > > > > > > Could you please describe in a couple of sentences what your > > > accelerator does, which engines it contains, how you program it. i.e. > > > Is it a fixed-function device where you write to a couple of register= s > > > to execute workloads, or is it a fully programmable device where you > > > load compiled code into it (GPU style) ? > > > > > > For better background on the accel subsystem, please read the followi= ng: > > > https://docs.kernel.org/accel/introduction.html > > > This introduction also contains links to other important email thread= s > > > and to Dave Airlie's BOF summary in LPC2022. > > > > > > Thanks, > > > Oded