Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp2662111iob; Mon, 16 May 2022 03:27:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzJhbdRMRRkLwsT2uReOCRBmM375imu3mfthDbR2XH2t5gPYdTj2TcBypMr/FvHMxegMh56 X-Received: by 2002:a17:907:6e21:b0:6f5:15bc:d782 with SMTP id sd33-20020a1709076e2100b006f515bcd782mr14412270ejc.690.1652696840442; Mon, 16 May 2022 03:27:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652696840; cv=none; d=google.com; s=arc-20160816; b=y2O5kUsW6qQwhGyg1q4bS/R3tQo/Jc8MTggkfoNQJsySjHMsRn+w7di/SUMD+GMpPY 59CAkUvlVQ6Ll+F7e9/kN24K0QOKAIPBiJlP1dTn8PXg7ZR7d4LTs/dEs3kxd23k2VwI Ch+QXwif4g7OiySSd6vzZaPrX1o1c6t17nBNOJRhc4ndbZC+ncBIaCwYLklTD094lyp6 C/0/A2JQW7J0n+gCsPOTU7bXbETyk0CzZP7DET5PfEq5F5z5So68dqFIr9JdZiZ8RnJb 5ZM4CqY5CR3doRWU1SCFWcKrmB5Gilcg4vUJP6arWUlfmu++z9wIzuVaGXBo6esp04ar Jagw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=GN36Sq29tndBQ4PitufvQoYicK+sGcL7xxa4gTV6Sco=; b=ohE4vI+HP0NTGJh8OLhgv5w9yXQtbH0ExfnmeqjoC9HOJCqctiC0rcTWf5MBn475K/ AQo6ntrXa5+M86QISIDCGAzlHOQt67KphkIf5p0IolW+zy/biW86xTWUpzInKnGl1wIw 9P20rbrRtGn1ZpxY7T9xEnQNfq/akxlFuFh4Mtl5aNxtbbhxe8dvGky3Qb6FRjfEyvvA afy12UN3Kn2slgMYnC6Me9aY01AQ5SZxIBYBZE/fffAr6Y92XmzKH7DIoJSVPV6ZFfGS sgAeUoAspJfWuQ7gD2hrlNdJx1VrkpPK9s/EX74IoyMRFX/sgjASPs0YwZoI5GTb+6ZB T6Uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@kapsi.fi header.s=20161220 header.b=qbibZvci; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qk6-20020a1709077f8600b006dffb6427bdsi10385621ejc.269.2022.05.16.03.26.54; Mon, 16 May 2022 03:27:20 -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; dkim=fail header.i=@kapsi.fi header.s=20161220 header.b=qbibZvci; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242132AbiEPIxx (ORCPT + 99 others); Mon, 16 May 2022 04:53:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242059AbiEPIxk (ORCPT ); Mon, 16 May 2022 04:53:40 -0400 Received: from mail.kapsi.fi (mail.kapsi.fi [IPv6:2001:67c:1be8::25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 842A713F60; Mon, 16 May 2022 01:53:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=kapsi.fi; s=20161220; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=GN36Sq29tndBQ4PitufvQoYicK+sGcL7xxa4gTV6Sco=; b=qbibZvciFI4PN8ZmuQN7Pa6bfO ACytLQGtllE6kQ25qPv4RT5tdDWPkd5slNmO2ph6Xz81k/WKDdftbfZjlaLXixHBleBsYdjvktXsG r99BVFmnJSnOM91maqJyb/k/VkGi1OVTEumvD3GZibbDuioMOEY7HgWMZz1tqNFtD0zCfA6bOaWLd LD+ipJBm4q8kvEBVyhF7Vn9Tr5cKo/YsjjH9eylks9iRfE8NQG06S0yijSfCmzLLVPdqQ7HSTuqmC 0ctdNohExD3A84dTa3PT4N5v4MmcEFoxvCW3XlpUKRZIUBFyl0SO6fapkIls3OSxEC0nUhcDk/ege 3B0VA45Q==; Received: from 91-158-25-70.elisa-laajakaista.fi ([91.158.25.70] helo=toshino.localdomain) by mail.kapsi.fi with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nqWTe-0005fd-QS; Mon, 16 May 2022 11:53:18 +0300 From: cyndis@kapsi.fi To: thierry.reding@gmail.com, jonathanh@nvidia.com, joro@8bytes.org, will@kernel.org, robin.murphy@arm.com, robh+dt@kernel.org, krzysztof.kozlowski@canonical.com Cc: linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Mikko Perttunen Subject: [PATCH v5 4/9] gpu: host1x: Program context stream ID on submission Date: Mon, 16 May 2022 11:52:53 +0300 Message-Id: <20220516085258.1227691-5-cyndis@kapsi.fi> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220516085258.1227691-1-cyndis@kapsi.fi> References: <20220516085258.1227691-1-cyndis@kapsi.fi> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 91.158.25.70 X-SA-Exim-Mail-From: cyndis@kapsi.fi X-SA-Exim-Scanned: No (on mail.kapsi.fi); SAEximRunCond expanded to false X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, 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 From: Mikko Perttunen Add code to do stream ID switching at the beginning of a job. The stream ID is switched to the stream ID specified by the context passed in the job structure. Before switching the stream ID, an OP_DONE wait is done on the channel's engine to ensure that there is no residual ongoing work that might do DMA using the new stream ID. Signed-off-by: Mikko Perttunen --- v5: * Add fallback stream ID. Not used yet, will be needed for full featured opcode sequence. * Rename host1x_context to host1x_memory_context v4: * Rename job->context to job->memory_context for clarity --- drivers/gpu/host1x/hw/channel_hw.c | 52 +++++++++++++++++++++-- drivers/gpu/host1x/hw/host1x06_hardware.h | 10 +++++ drivers/gpu/host1x/hw/host1x07_hardware.h | 10 +++++ include/linux/host1x.h | 8 ++++ 4 files changed, 76 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/host1x/hw/channel_hw.c b/drivers/gpu/host1x/hw/channel_hw.c index 6b40e9af1e88..f84caf06621a 100644 --- a/drivers/gpu/host1x/hw/channel_hw.c +++ b/drivers/gpu/host1x/hw/channel_hw.c @@ -180,6 +180,45 @@ static void host1x_enable_gather_filter(struct host1x_channel *ch) #endif } +static void host1x_channel_program_engine_streamid(struct host1x_job *job) +{ +#if HOST1X_HW >= 6 + u32 fence; + + if (!job->memory_context) + return; + + fence = host1x_syncpt_incr_max(job->syncpt, 1); + + /* First, increment a syncpoint on OP_DONE condition.. */ + + host1x_cdma_push(&job->channel->cdma, + host1x_opcode_nonincr(HOST1X_UCLASS_INCR_SYNCPT, 1), + HOST1X_UCLASS_INCR_SYNCPT_INDX_F(job->syncpt->id) | + HOST1X_UCLASS_INCR_SYNCPT_COND_F(1)); + + /* Wait for syncpoint to increment */ + + host1x_cdma_push(&job->channel->cdma, + host1x_opcode_setclass(HOST1X_CLASS_HOST1X, + host1x_uclass_wait_syncpt_r(), 1), + host1x_class_host_wait_syncpt(job->syncpt->id, fence)); + + /* + * Now that we know the engine is idle, return to class and + * change stream ID. + */ + + host1x_cdma_push(&job->channel->cdma, + host1x_opcode_setclass(job->class, 0, 0), + HOST1X_OPCODE_NOP); + + host1x_cdma_push(&job->channel->cdma, + host1x_opcode_setpayload(job->memory_context->stream_id), + host1x_opcode_setstreamid(job->engine_streamid_offset / 4)); +#endif +} + static int channel_submit(struct host1x_job *job) { struct host1x_channel *ch = job->channel; @@ -236,18 +275,23 @@ static int channel_submit(struct host1x_job *job) if (sp->base) synchronize_syncpt_base(job); - syncval = host1x_syncpt_incr_max(sp, user_syncpt_incrs); - host1x_hw_syncpt_assign_to_channel(host, sp, ch); - job->syncpt_end = syncval; - /* add a setclass for modules that require it */ if (job->class) host1x_cdma_push(&ch->cdma, host1x_opcode_setclass(job->class, 0, 0), HOST1X_OPCODE_NOP); + /* + * Ensure engine DMA is idle and set new stream ID. May increment + * syncpt max. + */ + host1x_channel_program_engine_streamid(job); + + syncval = host1x_syncpt_incr_max(sp, user_syncpt_incrs); + job->syncpt_end = syncval; + submit_gathers(job, syncval - user_syncpt_incrs); /* end CDMA submit & stash pinned hMems into sync queue */ diff --git a/drivers/gpu/host1x/hw/host1x06_hardware.h b/drivers/gpu/host1x/hw/host1x06_hardware.h index 01a142a09800..5d515745eee7 100644 --- a/drivers/gpu/host1x/hw/host1x06_hardware.h +++ b/drivers/gpu/host1x/hw/host1x06_hardware.h @@ -127,6 +127,16 @@ static inline u32 host1x_opcode_gather_incr(unsigned offset, unsigned count) return (6 << 28) | (offset << 16) | BIT(15) | BIT(14) | count; } +static inline u32 host1x_opcode_setstreamid(unsigned streamid) +{ + return (7 << 28) | streamid; +} + +static inline u32 host1x_opcode_setpayload(unsigned payload) +{ + return (9 << 28) | payload; +} + static inline u32 host1x_opcode_gather_wide(unsigned count) { return (12 << 28) | count; diff --git a/drivers/gpu/host1x/hw/host1x07_hardware.h b/drivers/gpu/host1x/hw/host1x07_hardware.h index e6582172ebfd..82c0cc9bb0b5 100644 --- a/drivers/gpu/host1x/hw/host1x07_hardware.h +++ b/drivers/gpu/host1x/hw/host1x07_hardware.h @@ -127,6 +127,16 @@ static inline u32 host1x_opcode_gather_incr(unsigned offset, unsigned count) return (6 << 28) | (offset << 16) | BIT(15) | BIT(14) | count; } +static inline u32 host1x_opcode_setstreamid(unsigned streamid) +{ + return (7 << 28) | streamid; +} + +static inline u32 host1x_opcode_setpayload(unsigned payload) +{ + return (9 << 28) | payload; +} + static inline u32 host1x_opcode_gather_wide(unsigned count) { return (12 << 28) | count; diff --git a/include/linux/host1x.h b/include/linux/host1x.h index 75cf996b0087..1b7dd67c7801 100644 --- a/include/linux/host1x.h +++ b/include/linux/host1x.h @@ -321,6 +321,14 @@ struct host1x_job { /* Whether host1x-side firewall should be ran for this job or not */ bool enable_firewall; + + /* Options for configuring engine data stream ID */ + /* Context device to use for job */ + struct host1x_memory_context *memory_context; + /* Stream ID to use if context isolation is disabled (!memory_context) */ + u32 engine_fallback_streamid; + /* Engine offset to program stream ID to */ + u32 engine_streamid_offset; }; struct host1x_job *host1x_job_alloc(struct host1x_channel *ch, -- 2.36.1