From mboxrd@z Thu Jan 1 00:00:00 1970 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=-1.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_DKIMWL_WL_HIGH autolearn=ham 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 EC4CBC04AB6 for ; Sat, 1 Jun 2019 00:31:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B5BC127092 for ; Sat, 1 Jun 2019 00:31:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="fFR8Yoea" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726901AbfFAAbZ (ORCPT ); Fri, 31 May 2019 20:31:25 -0400 Received: from mail-vs1-f68.google.com ([209.85.217.68]:43060 "EHLO mail-vs1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726610AbfFAAbZ (ORCPT ); Fri, 31 May 2019 20:31:25 -0400 Received: by mail-vs1-f68.google.com with SMTP id d128so7822289vsc.10 for ; Fri, 31 May 2019 17:31:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=4Kd7/+kr4jxVkBeK6chb/uAQy3afbVih/qTqLzH6YXg=; b=fFR8Yoeaj7rQIWQWlq5wNouI2OAxcAVIV3ViDHmGepDRlaAgLcyqpr8Iz7xvqv9yY5 KJmkoV7EiKoPljy47wPqBEY60yV3btg78qOiRyIpUHSX0g63rNFdXWGeuMwWQMMpOOh2 a4i5ZjgFDQtwHDCayYIL8rsqq5gfw9tPM6UkI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=4Kd7/+kr4jxVkBeK6chb/uAQy3afbVih/qTqLzH6YXg=; b=MpxkeFbgrOs7QvNVxXA3kjbtpQkuzCdy9QTUrfo0dspTmJ4M8lkxqkqHb4m6Haupua i5YoM5anfPUl3dGDV/Ce67uFfaN5YBOvS4bnP10gA5JhgPiRlFsB6SD1nQXRe+QIsmIc H8Ulb7Fmz0T5I3h+FD1oidWzqZN/khyhjEF/k85qFbAvd+wMKPgYyBKw99bMmxFzbBE2 uUAoq1w7GSW9YbKuqSjKtBOKmevmGHPsh5OLrXIJeDx/MBXOHYEWA3eJEq8Uc+Z5946L WUeXAkYfVxkN22UG3fqLar8LwHf/zAB9P6NDF97IeaRLkKV4QfeSXph0M/MkEJeT0nqX KcxQ== X-Gm-Message-State: APjAAAU2DSrRk1ptaXWbhbsN05pOSS9g4SeLnwsVHNeTYfFLI+8zTStA 2DxS6Iwto0P8iCsUCE85Ufq4d3YXrJ0= X-Google-Smtp-Source: APXvYqxvmrsOT3MyWDAmC3Y5ygZXUm95fwvh6bfdegeqmokdq23EEnz3fgIpZdyMf9gk1cDdtnV7IA== X-Received: by 2002:a67:f489:: with SMTP id o9mr6907843vsn.118.1559349083484; Fri, 31 May 2019 17:31:23 -0700 (PDT) Received: from mail-ua1-f44.google.com (mail-ua1-f44.google.com. [209.85.222.44]) by smtp.gmail.com with ESMTPSA id q77sm359249vke.13.2019.05.31.17.31.22 for (version=TLS1_3 cipher=AEAD-AES128-GCM-SHA256 bits=128/128); Fri, 31 May 2019 17:31:22 -0700 (PDT) Received: by mail-ua1-f44.google.com with SMTP id r7so4515076ual.2 for ; Fri, 31 May 2019 17:31:22 -0700 (PDT) X-Received: by 2002:ab0:670c:: with SMTP id q12mr6641706uam.106.1559349081772; Fri, 31 May 2019 17:31:21 -0700 (PDT) MIME-Version: 1.0 References: <20190531030057.18328-1-bjorn.andersson@linaro.org> <20190531030057.18328-3-bjorn.andersson@linaro.org> <20190601000917.GE25597@minitux> In-Reply-To: <20190601000917.GE25597@minitux> From: Doug Anderson Date: Fri, 31 May 2019 17:31:14 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v8 2/4] soc: qcom: Add AOSS QMP driver To: Bjorn Andersson Cc: Andy Gross , David Brown , Rob Herring , Mark Rutland , Arun Kumar Neelakantam , Vinod Koul , linux-arm-msm , devicetree@vger.kernel.org, LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Hi, On Fri, May 31, 2019 at 5:09 PM Bjorn Andersson wrote: > > On Fri 31 May 15:24 PDT 2019, Doug Anderson wrote: > > > Hi, > > > > On Thu, May 30, 2019 at 8:01 PM Bjorn Andersson > > wrote: > > > > > > +/** > > > + * qmp_send() - send a message to the AOSS > > > + * @qmp: qmp context > > > + * @data: message to be sent > > > + * @len: length of the message > > > + * > > > + * Transmit @data to AOSS and wait for the AOSS to acknowledge the message. > > > + * @len must be a multiple of 4 and not longer than the mailbox size. Access is > > > + * synchronized by this implementation. > > > + * > > > + * Return: 0 on success, negative errno on failure > > > + */ > > > +static int qmp_send(struct qmp *qmp, const void *data, size_t len) > > > +{ > > > + int ret; > > > + > > > + if (WARN_ON(len + sizeof(u32) > qmp->size)) > > > + return -EINVAL; > > > + > > > + if (WARN_ON(len % sizeof(u32))) > > > + return -EINVAL; > > > + > > > + mutex_lock(&qmp->tx_lock); > > > + > > > + /* The message RAM only implements 32-bit accesses */ > > > + __iowrite32_copy(qmp->msgram + qmp->offset + sizeof(u32), > > > + data, len / sizeof(u32)); > > > + writel(len, qmp->msgram + qmp->offset); > > > + qmp_kick(qmp); > > > + > > > + ret = wait_event_interruptible_timeout(qmp->event, > > > + qmp_message_empty(qmp), HZ); > > > + if (!ret) { > > > + dev_err(qmp->dev, "ucore did not ack channel\n"); > > > + ret = -ETIMEDOUT; > > > + > > > + /* Clear message from buffer */ > > > + writel(0, qmp->msgram + qmp->offset); > > > + } else { > > > + ret = 0; > > > + } > > > > Just like Vinod said in in v7, the "ret = 0" is redundant. > > > > If the condition passed to wait_event_interruptible_timeout() evaluates > true the remote side has consumed the message and ret will be 1. We end > up in the else block (i.e. not timeout) and we want the function to > return 0, so we set ret to 0. > > Please let me know if I'm reading this wrong. Ah, it's me that's confused. I missed the "!" on ret. Maybe it'd be less confusing if you did: time_left = wait_event_interruptible_timeout(...) if (!time_left) Even though you _can_ use "ret", it's less confusing to use a different variable since (often) ret is an error code. Speaking of which: do you actually handle the case where you get an interrupt? Should the above just be wait_event_timeout()?