Received: by 2002:a25:86ce:0:0:0:0:0 with SMTP id y14csp819647ybm; Tue, 21 May 2019 04:12:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqx2Zjd5seWANtT4Q9uBK7ie4Frt/mdhNqkR50T/xpLkQ5XNxdKG+MWderXKySxM7BH1vLnF X-Received: by 2002:a62:128a:: with SMTP id 10mr85724398pfs.225.1558437147324; Tue, 21 May 2019 04:12:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558437147; cv=none; d=google.com; s=arc-20160816; b=D1CsDc9uAXjhchGgAy/WFRdF7W1PcOqSdr7z9O43LClJdhIdOeBhaxigX/83ikBR/C DU8s9/p7p2sNDLDIQdklPHl5jes1XM1xZQMeljROH4LiEb/H64pk6tzKHM25BT2pRwME SIkO5zxmdxqo1LYjI3pPKizlVTFvsfhzYjpFg7ZXOyHCseLdPVrN4IZa60zN96JH8rXC yibMhHQwJWoyZo5DtP4RN6aRHVmPQ/HPx1CAZY+SN/ZIWLEIz+YCQfRt3kW43EOCN6rZ an73DN5pED4XV8sdflIQyl0ya/+WhDarQUaqlyOSb5KaR/AiYoRX85KdFyvV9wSGx2lA eDBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=0TziXPBh2FJVaSC9O1gXdwoswbc+lFe09Iu653nLkXw=; b=aEh9seXwPkMdA1+WrPitzjzJL6sNnMVg6+/XMia7Dy71DsR6lz/T0AndW1tAd/D+cw VUVbOibwfQfg5vMuRmfLxGJXD5W6A9r0q5wcVS1L4Ao4oLNTm1wz9QtD1ZJLi2Kmrim7 kcQaJws7vGtrt4BmKuRMVIcyBGLpgKueuC0UyA722C4Vg+x6VPdTHQT7nnONCUcMG6Q8 1NwssgnHTh6mDlPTT4bd0rGwT+Ui19FSwwbN2985+YDQapYBI3ECmjImSQihr6TUiX7d mZlOLOfk8EjR16zxbA+iWwRM/yQi5x5TJ2mk/fxLveHkNOmFyVGpyu7ZNwXqFhcSqF9+ yzUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bD29SWe1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w4si19680497plz.27.2019.05.21.04.12.12; Tue, 21 May 2019 04:12:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=bD29SWe1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727251AbfEULLG (ORCPT + 99 others); Tue, 21 May 2019 07:11:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:54054 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726042AbfEULLG (ORCPT ); Tue, 21 May 2019 07:11:06 -0400 Received: from localhost (unknown [223.186.130.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 19BDF2081C; Tue, 21 May 2019 11:11:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1558437065; bh=ATO0mafowpmS9lD2uJVlmt4JcavGsNrwrYgrfOLt7bg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=bD29SWe1toCHHRKmxc1/VKp/HxszwXcFJ8pAR41Jds9NGDnY/ixUY65YKHffhKlMc 64B4hRD0lZL9Z+vtUaZ0fb5DZ7JcubCdye8vRDxnEBpaxDK6w2/cte69FA6+LYG1pQ Z/vnK0IFGJWk4aFuA0GP98Ofr4NSJ5W9vuXS7ENg= Date: Tue, 21 May 2019 16:40:58 +0530 From: Vinod Koul To: Bjorn Andersson Cc: Andy Gross , David Brown , Stephen Boyd , Rob Herring , Mark Rutland , linux-arm-msm@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v7 2/4] soc: qcom: Add AOSS QMP driver Message-ID: <20190521111058.GG15118@vkoul-mobl> References: <20190501043734.26706-1-bjorn.andersson@linaro.org> <20190501043734.26706-3-bjorn.andersson@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190501043734.26706-3-bjorn.andersson@linaro.org> User-Agent: Mutt/1.11.3 (2019-02-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 30-04-19, 21:37, Bjorn Andersson wrote: > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include I would have preferred this as first one, but this is fine too :) > +/* Linux-side offsets */ > +#define QMP_DESC_MCORE_LINK_STATE 0x24 > +#define QMP_DESC_MCORE_LINK_STATE_ACK 0x28 > +#define QMP_DESC_MCORE_CH_STATE 0x2c > +#define QMP_DESC_MCORE_CH_STATE_ACK 0x30 > +#define QMP_DESC_MCORE_MBOX_SIZE 0x34 > +#define QMP_DESC_MCORE_MBOX_OFFSET 0x38 > + > +#define QMP_STATE_UP 0x0000ffff I prefer using GENMASK(15, 0) > +#define QMP_STATE_DOWN 0xffff0000 GENMASK(31, 16)? > +/** > + * struct qmp - driver state for QMP implementation > + * @msgram: iomem referencing the message RAM used for communication > + * @dev: reference to QMP device > + * @mbox_client: mailbox client used to ring the doorbell on transmit > + * @mbox_chan: mailbox channel used to ring the doorbell on transmit > + * @offset: offset within @msgram where messages should be written > + * @size: maximum size of the messages to be transmitted > + * @event: wait_queue for synchronization with the IRQ > + * @tx_lock: provides syncrhonization between multiple callers of qmp_send() /s/syncrhonization/synchronization > +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; Isn't this redundant? > + } > + > + mutex_unlock(&qmp->tx_lock); > + > + return ret; > +} -- ~Vinod