Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp701549pxm; Fri, 25 Feb 2022 17:41:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJzOI/9lb8WLS9UncgG9YbCVpLt9sIxpbpzHK724wy2mJC4gZJ/BPa6y86JiMQmnxrcwwwlo X-Received: by 2002:a17:90a:8c86:b0:1bb:fbfc:49cf with SMTP id b6-20020a17090a8c8600b001bbfbfc49cfmr5951068pjo.80.1645839707625; Fri, 25 Feb 2022 17:41:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645839707; cv=none; d=google.com; s=arc-20160816; b=fiBvsVozyCGlEhFdbyNZvG+tjW9wlsfr3zzCOt22U2RB6swZMCzuLB7UvMWOn8EFs3 Iqj29Qj658iQJLRWDdbDESB7dUAMyxZYDtG8LQkrwDhtwLB2oO42V65MbkGEO/S2aHkR wVQIGbCGfe1Y2Hl3BLblqyz+rXKwGvqw/2X3ehEIVl/oiZtIEqo13qG1yuxTF4M4uA79 /nVk7oDSp6HiunVPDT70Huzectxyb6v6eqmFS4QVibL47HqyVITxTkjsr8GHlof5hMo1 cSyHJ87uFBKJdUODgaiCfx7+ojT0A2D8czIfnCEOr6j53CCsOxwXLzV3xvregcTay9RY BcRw== 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:dkim-signature; bh=pBw395L0AUcASRYS2i9hrKEYCApz4CFHb/+TgP651cs=; b=j+t3NIilKl2fv38GNpdM838o3UJcCS0FUdyNuDF3+jix+dvwime3CbtlJdAiO/4Rlz Q/zfYobJi3NRvJWHuPUMc/fGXuJTeamO7jYWaZM36ekPOc2L/0YFYHvbJyB+D7dvC8dd Ln/0F0SwTaiWHav/i6NfOt1PlMc4WUa2S8z3kw2iqTuvHtqnxiJhiBFxU/PECIA9yMtM 8ngYxj5KMdgVYREWtgx2eF2b3kP2NPLJI3h80f0A0rCkMwEnG2sxAjY7nvsQ0vwd0VLC NstnRCyT+asBrxtUK1FeLfuefQOFm4RoI+pYRXBa24sqoPAH29B/PCFo7QkUgGERoHIM 9zVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=tEr177f4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id mp24-20020a17090b191800b001bc46e4179dsi8417418pjb.23.2022.02.25.17.41.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Feb 2022 17:41:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=tEr177f4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7931D17AEF5; Fri, 25 Feb 2022 17:33:08 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240336AbiBZARL (ORCPT + 99 others); Fri, 25 Feb 2022 19:17:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240382AbiBZAQw (ORCPT ); Fri, 25 Feb 2022 19:16:52 -0500 Received: from fllv0016.ext.ti.com (fllv0016.ext.ti.com [198.47.19.142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0419225591 for ; Fri, 25 Feb 2022 16:16:14 -0800 (PST) Received: from fllv0034.itg.ti.com ([10.64.40.246]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id 21Q0G8eL060315; Fri, 25 Feb 2022 18:16:08 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1645834568; bh=pBw395L0AUcASRYS2i9hrKEYCApz4CFHb/+TgP651cs=; h=Date:Subject:To:CC:References:From:In-Reply-To; b=tEr177f4BrpptmxG8YZOj0yhtBjccpWEyYiO/+USDUeHVXfvyiwmRu1eq02D9jnEo kQ5sNQ8SGNrxqVyXFZqeswtOOoLMkbAq5LN845c+CNQt1oaVoFhMzq3um9EHLmSO0K C7lxQevcdFNM7MIlCjqmZwiFQEQYnFD79ujEUJt0= Received: from DFLE104.ent.ti.com (dfle104.ent.ti.com [10.64.6.25]) by fllv0034.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 21Q0G87f012350 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 25 Feb 2022 18:16:08 -0600 Received: from DFLE101.ent.ti.com (10.64.6.22) by DFLE104.ent.ti.com (10.64.6.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14; Fri, 25 Feb 2022 18:16:08 -0600 Received: from fllv0040.itg.ti.com (10.64.41.20) by DFLE101.ent.ti.com (10.64.6.22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.14 via Frontend Transport; Fri, 25 Feb 2022 18:16:08 -0600 Received: from [10.249.33.2] (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id 21Q0G854109058; Fri, 25 Feb 2022 18:16:08 -0600 Message-ID: <073d7213-bd3a-5adb-8187-f0a83478fd76@ti.com> Date: Fri, 25 Feb 2022 18:16:07 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.5.0 Subject: Re: [PATCH 1/2] mailbox: ti-msgmgr: Refactor message read during interrupt handler Content-Language: en-US To: Dave Gerlach , Jassi Brar CC: , Nishanth Menon , Vignesh Raghavendra References: <20220210041631.26767-1-d-gerlach@ti.com> <20220210041631.26767-2-d-gerlach@ti.com> From: Suman Anna In-Reply-To: <20220210041631.26767-2-d-gerlach@ti.com> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=no 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 2/9/22 22:16, Dave Gerlach wrote: > Refactor the portion of code that actually reads received messages from > a queue into its own function, ti_msgmgr_queue_rx_data, that is called > by the interrupt handler instead of reading directly from the handler. > > Signed-off-by: Dave Gerlach Acked-by: Suman Anna > --- > drivers/mailbox/ti-msgmgr.c | 88 +++++++++++++++++++++---------------- > 1 file changed, 49 insertions(+), 39 deletions(-) > > diff --git a/drivers/mailbox/ti-msgmgr.c b/drivers/mailbox/ti-msgmgr.c > index efb43b038596..f860cd0c907a 100644 > --- a/drivers/mailbox/ti-msgmgr.c > +++ b/drivers/mailbox/ti-msgmgr.c > @@ -190,6 +190,53 @@ static inline bool ti_msgmgr_queue_is_error(const struct ti_msgmgr_desc *d, > return val ? true : false; > } > > +static int ti_msgmgr_queue_rx_data(struct mbox_chan *chan, struct ti_queue_inst *qinst, > + const struct ti_msgmgr_desc *desc) > +{ > + int num_words; > + struct ti_msgmgr_message message; > + void __iomem *data_reg; > + u32 *word_data; > + > + /* > + * I have no idea about the protocol being used to communicate with the > + * remote producer - 0 could be valid data, so I wont make a judgement > + * of how many bytes I should be reading. Let the client figure this > + * out.. I just read the full message and pass it on.. > + */ > + message.len = desc->max_message_size; > + message.buf = (u8 *)qinst->rx_buff; > + > + /* > + * NOTE about register access involved here: > + * the hardware block is implemented with 32bit access operations and no > + * support for data splitting. We don't want the hardware to misbehave > + * with sub 32bit access - For example: if the last register read is > + * split into byte wise access, it can result in the queue getting > + * stuck or indeterminate behavior. An out of order read operation may > + * result in weird data results as well. > + * Hence, we do not use memcpy_fromio or __ioread32_copy here, instead > + * we depend on readl for the purpose. > + * > + * Also note that the final register read automatically marks the > + * queue message as read. > + */ > + for (data_reg = qinst->queue_buff_start, word_data = qinst->rx_buff, > + num_words = (desc->max_message_size / sizeof(u32)); > + num_words; num_words--, data_reg += sizeof(u32), word_data++) > + *word_data = readl(data_reg); > + > + /* > + * Last register read automatically clears the IRQ if only 1 message > + * is pending - so send the data up the stack.. > + * NOTE: Client is expected to be as optimal as possible, since > + * we invoke the handler in IRQ context. > + */ > + mbox_chan_received_data(chan, (void *)&message); > + > + return 0; > +} > + > /** > * ti_msgmgr_queue_rx_interrupt() - Interrupt handler for receive Queue > * @irq: Interrupt number > @@ -206,10 +253,7 @@ static irqreturn_t ti_msgmgr_queue_rx_interrupt(int irq, void *p) > struct ti_msgmgr_inst *inst = dev_get_drvdata(dev); > struct ti_queue_inst *qinst = chan->con_priv; > const struct ti_msgmgr_desc *desc; > - int msg_count, num_words; > - struct ti_msgmgr_message message; > - void __iomem *data_reg; > - u32 *word_data; > + int msg_count; > > if (WARN_ON(!inst)) { > dev_err(dev, "no platform drv data??\n"); > @@ -237,41 +281,7 @@ static irqreturn_t ti_msgmgr_queue_rx_interrupt(int irq, void *p) > return IRQ_NONE; > } > > - /* > - * I have no idea about the protocol being used to communicate with the > - * remote producer - 0 could be valid data, so I won't make a judgement > - * of how many bytes I should be reading. Let the client figure this > - * out.. I just read the full message and pass it on.. > - */ > - message.len = desc->max_message_size; > - message.buf = (u8 *)qinst->rx_buff; > - > - /* > - * NOTE about register access involved here: > - * the hardware block is implemented with 32bit access operations and no > - * support for data splitting. We don't want the hardware to misbehave > - * with sub 32bit access - For example: if the last register read is > - * split into byte wise access, it can result in the queue getting > - * stuck or indeterminate behavior. An out of order read operation may > - * result in weird data results as well. > - * Hence, we do not use memcpy_fromio or __ioread32_copy here, instead > - * we depend on readl for the purpose. > - * > - * Also note that the final register read automatically marks the > - * queue message as read. > - */ > - for (data_reg = qinst->queue_buff_start, word_data = qinst->rx_buff, > - num_words = (desc->max_message_size / sizeof(u32)); > - num_words; num_words--, data_reg += sizeof(u32), word_data++) > - *word_data = readl(data_reg); > - > - /* > - * Last register read automatically clears the IRQ if only 1 message > - * is pending - so send the data up the stack.. > - * NOTE: Client is expected to be as optimal as possible, since > - * we invoke the handler in IRQ context. > - */ > - mbox_chan_received_data(chan, (void *)&message); > + ti_msgmgr_queue_rx_data(chan, qinst, desc); > > return IRQ_HANDLED; > }