Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.7 required=3.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D0908C433F5 for ; Sun, 19 Sep 2021 03:25:04 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 19C67610E9 for ; Sun, 19 Sep 2021 03:25:03 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 19C67610E9 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=sina.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 99B0E6E18E; Sun, 19 Sep 2021 03:25:01 +0000 (UTC) X-Greylist: delayed 322 seconds by postgrey-1.36 at gabe; Sun, 19 Sep 2021 03:24:59 UTC Received: from r3-23.sinamail.sina.com.cn (r3-23.sinamail.sina.com.cn [202.108.3.23]) by gabe.freedesktop.org (Postfix) with SMTP id CD92B6E18E for ; Sun, 19 Sep 2021 03:24:59 +0000 (UTC) Received: from unknown (HELO localhost.localdomain)([123.115.166.15]) by sina.com (172.16.97.23) with ESMTP id 6146AC440001A880; Sun, 19 Sep 2021 11:19:34 +0800 (CST) X-Sender: hdanton@sina.com X-Auth-ID: hdanton@sina.com X-SMAIL-MID: 83412854919335 From: Hillf Danton To: Alexandre Bailon Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: Re: [RFC PATCH 2/4] DRM: Add support of AI Processor Unit (APU) Date: Sun, 19 Sep 2021 11:19:24 +0800 Message-Id: <20210919031924.4426-1-hdanton@sina.com> In-Reply-To: <20210917125945.620097-3-abailon@baylibre.com> References: <20210917125945.620097-1-abailon@baylibre.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On Fri, 17 Sep 2021 14:59:43 +0200 Alexandre Bailon wrote: > +static DEFINE_IDA(req_ida); > +static LIST_HEAD(complete_node); I see accesses to complete_node in apu_drm_callback(), apu_job_timedout() and ioctl_gem_dequeue() without working out the serialization to avoid list corruption. Can you add a comment to specify it? > + > +int apu_drm_callback(struct apu_core *apu_core, void *data, int len) > +{ > + struct apu_request *apu_req, *tmp; > + struct apu_dev_request *hdr = data; > + unsigned long flags; > + > + spin_lock_irqsave(&apu_core->ctx_lock, flags); > + list_for_each_entry_safe(apu_req, tmp, &apu_core->requests, node) { > + struct apu_job *job = apu_req->job; > + > + if (job && hdr->id == job->id) { > + kref_get(&job->refcount); > + job->result = hdr->result; > + if (job->size_out) > + memcpy(job->data_out, hdr->data + job->size_in, > + min(job->size_out, hdr->size_out)); > + job->size_out = hdr->size_out; > + list_add(&job->node, &complete_node); > + list_del(&apu_req->node); > + ida_simple_remove(&req_ida, hdr->id); > + kfree(apu_req); > + drm_send_event(job->apu_drm->drm, > + &job->event->pending_event); > + dma_fence_signal_locked(job->done_fence); > + } > + } > + spin_unlock_irqrestore(&apu_core->ctx_lock, flags); > + > + return 0; > +}