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=-2.6 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_MUTT autolearn=unavailable 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 DB292C04AAF for ; Tue, 21 May 2019 11:11:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B120F217D4 for ; Tue, 21 May 2019 11:11:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1558437071; bh=ATO0mafowpmS9lD2uJVlmt4JcavGsNrwrYgrfOLt7bg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:List-ID:From; b=jofgg3s4kLDXHd8L4v7GwcY9IIBaq8tHHbsFbZaHIyT+hMfaMz5+zirnAGm5evh6Z 5WO0frRCuIKIQE8qhg25WmoALykj/m0vCozd2V6DyuXSOb1pGL3Me6hjAbaEuXFo9o 9OAjk4Vhb5lnu138ExNeGR0CP9TSk2t4B7xIOhxk= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726448AbfEULLG (ORCPT ); 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-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@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