From patchwork Fri Mar 3 15:17:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Carlo Caione X-Patchwork-Id: 9603067 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D10E7604E2 for ; Fri, 3 Mar 2017 15:10:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C2EE128648 for ; Fri, 3 Mar 2017 15:10:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B7A1E2863D; Fri, 3 Mar 2017 15:10:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 77C5028640 for ; Fri, 3 Mar 2017 15:10:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=6KDEWmBFbEscjSEGTJ6IrJqwS/LjrK0gHEBi6GV1L60=; b=hj7NLdk4UO9/oFYSM+KZvPwhYA Ipo/U4WGFEYE4Fk8CGGtxFmSYOnuKpSxilA9xg6Ov9rquGUHRNSiN8Gv7yzkjuCwR9H2zJOdk+CJ9 jr73QTV+26SQdWWOW8ur9b6Me+RMsGHlS2kyUoGoCf8H5DNTdEFcyP+O0U/aGruw7IrNpFBHdWb5a +hqVgYOKx+F1v0CRAYarSvjpbJaQUvn8KgcFhaE4I93qJYCbJxVKPo3xlNsVzrax5A6iWea/AN18U 0zaoRmT5V9MoWCSWMQ/1c224GiLrlBWREdBr6GTP9QpVM5OI5l4KLXKABRLUBXoIlT48Emxa7r2Sq 0ekoxD5Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cjoqQ-0001SN-CS; Fri, 03 Mar 2017 15:10:10 +0000 Received: from mail-wr0-x244.google.com ([2a00:1450:400c:c0c::244]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cjoow-0007f3-AK; Fri, 03 Mar 2017 15:08:40 +0000 Received: by mail-wr0-x244.google.com with SMTP id u108so9693511wrb.2; Fri, 03 Mar 2017 07:08:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=4xQDjmOsy2ZHW4Pkhfk7diq9j6Nov8sabLBU/Crfxv8=; b=Lz6owRXgC+LpxtM0f5c7CECB52jAgP1TXLLa6O6r6hcF85Q6xWbmDyhG/YO4d5UtGE urxiVMtF4xmNcEE8ixpB5wEA7kqplYd06cnnppKw0Vb7Oi+107BqVnpYuPUxwDiBDW+q JCQbgxE5w/8nyfVMtZ7/cIJb9vws9e9fddeEYZF0F8LDu8ydj2K945KVgB+ZbQeK3RNz NZEoaG04QfHHJfIt3w1iMBIGQZQhCetFjCrMGOUEKD0ku0t7S4/i91InS8rvECBqLw7e TxDWwq5lCRo3hwkRnTkqV/nk0j3fuy1oS77qAo7G2PL135vfvkIuX/IWIx5labUkGUpf bCvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=4xQDjmOsy2ZHW4Pkhfk7diq9j6Nov8sabLBU/Crfxv8=; b=YgmG/y7LmSm9Zjrg+Uu2yJh29QgupitB0FwuDtHqN95+IuGmcEZIRQlBml1OYTx0FR BWc/OsSksLKzU2gK36sNoZjM/LZMjkY/rcYMWYQxUyZaBV3xUnYyDhwg3PkWieeRaXI2 RBXvmpplO4mOTPRzVJGHIqlrFOFsAlGIkPcGjM7N1bjcwyoOg7uEsCYSSQoqze1QCgC7 UxCWKM1o3R5oC6iddtC7tNt48vYrzcDQImWTeD5qzaKPDwTjgjjjUBxou1eg9eLEIstB Zs3QEVuxlfjKnuaPvDtpcbsQWHP0lZgi4oqq5+BHISUBknnj0sThZL8Bi2VYZ24F8Q4X O90w== X-Gm-Message-State: AMke39l7wnOq7lajyVWjUR7IScsaMV0l7Eq9UH2ZjMXg/EoecohCF3wNGd9CQISUZCImfQ== X-Received: by 10.223.154.44 with SMTP id z41mr3093920wrb.188.1488553695627; Fri, 03 Mar 2017 07:08:15 -0800 (PST) Received: from satan.homestation.setup ([151.45.79.45]) by smtp.gmail.com with ESMTPSA id w17sm15587811wra.28.2017.03.03.07.08.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 Mar 2017 07:08:15 -0800 (PST) From: Carlo Caione To: linux-arm-kernel@lists.infradead.org, linux-amlogic@lists.infradead.org, linux@endlessm.com, mark.rutland@arm.com, srinivas.kandagatla@linaro.org Subject: [PATCH 2/2] firmware: meson-sm: Allow 0 as valid return value Date: Fri, 3 Mar 2017 16:17:59 +0100 Message-Id: <20170303151759.8330-3-carlo@caione.org> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20170303151759.8330-1-carlo@caione.org> References: <20170303151759.8330-1-carlo@caione.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170303_070838_516293_3DA0EC83 X-CRM114-Status: GOOD ( 14.89 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Carlo Caione MIME-Version: 1.0 Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Carlo Caione Some special SMC calls (i.e. the function used to retrieve the serial number of the Amlogic SoCs) returns 0 in the register 0 also when the data was successfully read instead of using the register to hold the number of bytes returned in the bounce buffer as expected. With the current implementation of the driver this is seen as an error and meson_sm_call_read() returns an error even though the data was correctly read. To deal with this when we have no information about the amount of read data (that is 0 is returned by the SMC call) we return to the caller the requested amount of data and 0 as return value. Signed-off-by: Carlo Caione --- drivers/firmware/meson/meson_sm.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/firmware/meson/meson_sm.c b/drivers/firmware/meson/meson_sm.c index 5f30a5774e57..ff204421117b 100644 --- a/drivers/firmware/meson/meson_sm.c +++ b/drivers/firmware/meson/meson_sm.c @@ -136,11 +136,14 @@ EXPORT_SYMBOL(meson_sm_call); * @arg4: SMC32 Argument 4 * * Return: size of read data on success, a negative value on error + * When 0 is returned there is no guarantee about the amount of + * data read and bsize bytes are copied in buffer. */ int meson_sm_call_read(void *buffer, unsigned int bsize, unsigned int cmd_index, u32 arg0, u32 arg1, u32 arg2, u32 arg3, u32 arg4) { u32 size; + int ret; if (!fw.chip) return -ENOENT; @@ -154,13 +157,18 @@ int meson_sm_call_read(void *buffer, unsigned int bsize, unsigned int cmd_index, if (meson_sm_call(cmd_index, &size, arg0, arg1, arg2, arg3, arg4) < 0) return -EINVAL; - if (!size || size > bsize) + if (size > bsize) return -EINVAL; + ret = size; + + if (!size) + size = bsize; + if (buffer) memcpy(buffer, fw.sm_shmem_out_base, size); - return size; + return ret; } EXPORT_SYMBOL(meson_sm_call_read);