Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/1191956/?format=api
{ "id": 1191956, "url": "http://patchwork.ozlabs.org/api/patches/1191956/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linuxppc-dev/patch/20191108130123.6839-35-linux@rasmusvillemoes.dk/", "project": { "id": 2, "url": "http://patchwork.ozlabs.org/api/projects/2/?format=api", "name": "Linux PPC development", "link_name": "linuxppc-dev", "list_id": "linuxppc-dev.lists.ozlabs.org", "list_email": "linuxppc-dev@lists.ozlabs.org", "web_url": "https://github.com/linuxppc/wiki/wiki", "scm_url": "https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git", "webscm_url": "https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/", "list_archive_url": "https://lore.kernel.org/linuxppc-dev/", "list_archive_url_format": "https://lore.kernel.org/linuxppc-dev/{}/", "commit_url_format": "https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git/commit/?id={}" }, "msgid": "<20191108130123.6839-35-linux@rasmusvillemoes.dk>", "list_archive_url": "https://lore.kernel.org/linuxppc-dev/20191108130123.6839-35-linux@rasmusvillemoes.dk/", "date": "2019-11-08T13:01:10", "name": "[v4,34/47] soc: fsl: qe: change return type of cpm_muram_alloc() to s32", "commit_ref": null, "pull_url": null, "state": "not-applicable", "archived": false, "hash": "0cca9304586145cf5aa2c14fe32ed8d0bfbd1431", "submitter": { "id": 27394, "url": "http://patchwork.ozlabs.org/api/people/27394/?format=api", "name": "Rasmus Villemoes", "email": "linux@rasmusvillemoes.dk" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/linuxppc-dev/patch/20191108130123.6839-35-linux@rasmusvillemoes.dk/mbox/", "series": [ { "id": 141654, "url": "http://patchwork.ozlabs.org/api/series/141654/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linuxppc-dev/list/?series=141654", "date": "2019-11-08T13:00:38", "name": "QUICC Engine support on ARM and ARM64", "version": 4, "mbox": "http://patchwork.ozlabs.org/series/141654/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/1191956/comments/", "check": "success", "checks": "http://patchwork.ozlabs.org/api/patches/1191956/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org>", "X-Original-To": [ "patchwork-incoming@ozlabs.org", "linuxppc-dev@lists.ozlabs.org" ], "Delivered-To": [ "patchwork-incoming@ozlabs.org", "linuxppc-dev@lists.ozlabs.org" ], "Received": [ "from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\tkey-exchange X25519 server-signature RSA-PSS (4096 bits))\n\t(No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 478kD335PXz9s4Y\n\tfor <patchwork-incoming@ozlabs.org>;\n\tSat, 9 Nov 2019 02:08:03 +1100 (AEDT)", "from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3])\n\tby lists.ozlabs.org (Postfix) with ESMTP id 478kD26pnPzF5n5\n\tfor <patchwork-incoming@ozlabs.org>;\n\tSat, 9 Nov 2019 02:08:02 +1100 (AEDT)", "from mail-lj1-x243.google.com (mail-lj1-x243.google.com\n\t[IPv6:2a00:1450:4864:20::243])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\tkey-exchange X25519 server-signature RSA-PSS (2048 bits)\n\tserver-digest SHA256) (No client certificate requested)\n\tby lists.ozlabs.org (Postfix) with ESMTPS id 478gQv3xq9zF6t8\n\tfor <linuxppc-dev@lists.ozlabs.org>;\n\tSat, 9 Nov 2019 00:02:15 +1100 (AEDT)", "by mail-lj1-x243.google.com with SMTP id k15so6146406lja.3\n\tfor <linuxppc-dev@lists.ozlabs.org>;\n\tFri, 08 Nov 2019 05:02:15 -0800 (PST)", "from prevas-ravi.prevas.se ([81.216.59.226])\n\tby smtp.gmail.com with ESMTPSA id\n\td28sm2454725lfn.33.2019.11.08.05.02.10\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 08 Nov 2019 05:02:10 -0800 (PST)" ], "Authentication-Results": [ "ozlabs.org; dmarc=none (p=none dis=none)\n\theader.from=rasmusvillemoes.dk", "ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=rasmusvillemoes.dk header.i=@rasmusvillemoes.dk\n\theader.b=\"Wd8jlhlr\"; dkim-atps=neutral", "lists.ozlabs.org; spf=pass (sender SPF authorized)\n\tsmtp.mailfrom=rasmusvillemoes.dk (client-ip=2a00:1450:4864:20::243;\n\thelo=mail-lj1-x243.google.com; envelope-from=linux@rasmusvillemoes.dk;\n\treceiver=<UNKNOWN>)", "lists.ozlabs.org; dmarc=none (p=none dis=none)\n\theader.from=rasmusvillemoes.dk", "lists.ozlabs.org; dkim=pass (1024-bit key;\n\tunprotected) header.d=rasmusvillemoes.dk header.i=@rasmusvillemoes.dk\n\theader.b=\"Wd8jlhlr\"; dkim-atps=neutral" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=rasmusvillemoes.dk; s=google;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=sKXWGKE2hJnX3KS13PAL5ShHJjGXx4HK2hpojfTk/KY=;\n\tb=Wd8jlhlrNoR8vSP62k5UaqWRiK+nvDs5ICXuM6pcJ1syXOE5Uy6SdSPnRaqleX/18p\n\txnht3FCO06C6nQXwtjVdIjwIQ3VWoJ2FnTK0saZ2Cq2J6kEz5BOGnM/0MkJq9oJZc2CJ\n\tsyO7hxAtxdvkTZ4UCegVO6iXF14ExTffno5PM=", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=sKXWGKE2hJnX3KS13PAL5ShHJjGXx4HK2hpojfTk/KY=;\n\tb=UhJmA8v8o5Z1GN7qXWuIbFOwGvTrM4O1wi3H9RTmh9pNOl6fqB+C0711PQx5u7gpMv\n\tu065JJjRXzJl4gZkWahlv2WyC5lJckuMIRh4zBNZZ1kSexpucIIb8D2FENIL1XIni0tn\n\tJLxrPej1RICFuE6VVYHGJCp/ClrILjn0aVir0/kbRrm8wTq4A3GPFhuEqgIzo9WDA039\n\tfu6WvFQDil0QVtAvd9306lgj4gqo/ZkvaclNd2QHwk5x+2xLTMh9Ukw+g1x2gt8uQNAn\n\tC/Wn2MHT39SsmJ6EoE1UTEOvAIKWSlOKUGsw3lDfI/acbW2sUYy9qHRI5nGG1E3KFwis\n\tLfhA==", "X-Gm-Message-State": "APjAAAWI2UwhM1rVU2+wM0OODpp4uvKNur5rsw2SHmwR7s9APxxh7i9i\n\tN3sHHO7YSo0aOq5cT8C6g3Xw0A==", "X-Google-Smtp-Source": "APXvYqzQt94JN6S91SYODDE7DWrTPiopp9NX09dPKGBykjy6EmJomIkdbCDQ1O1wLfaGhH99Gg0u2A==", "X-Received": "by 2002:a05:651c:209:: with SMTP id\n\ty9mr6416091ljn.65.1573218131200; \n\tFri, 08 Nov 2019 05:02:11 -0800 (PST)", "From": "Rasmus Villemoes <linux@rasmusvillemoes.dk>", "To": "Qiang Zhao <qiang.zhao@nxp.com>, Li Yang <leoyang.li@nxp.com>,\n\tChristophe Leroy <christophe.leroy@c-s.fr>", "Subject": "[PATCH v4 34/47] soc: fsl: qe: change return type of\n\tcpm_muram_alloc() to s32", "Date": "Fri, 8 Nov 2019 14:01:10 +0100", "Message-Id": "<20191108130123.6839-35-linux@rasmusvillemoes.dk>", "X-Mailer": "git-send-email 2.23.0", "In-Reply-To": "<20191108130123.6839-1-linux@rasmusvillemoes.dk>", "References": "<20191108130123.6839-1-linux@rasmusvillemoes.dk>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "X-BeenThere": "linuxppc-dev@lists.ozlabs.org", "X-Mailman-Version": "2.1.29", "Precedence": "list", "List-Id": "Linux on PowerPC Developers Mail List\n\t<linuxppc-dev.lists.ozlabs.org>", "List-Unsubscribe": "<https://lists.ozlabs.org/options/linuxppc-dev>,\n\t<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=unsubscribe>", "List-Archive": "<http://lists.ozlabs.org/pipermail/linuxppc-dev/>", "List-Post": "<mailto:linuxppc-dev@lists.ozlabs.org>", "List-Help": "<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=help>", "List-Subscribe": "<https://lists.ozlabs.org/listinfo/linuxppc-dev>,\n\t<mailto:linuxppc-dev-request@lists.ozlabs.org?subject=subscribe>", "Cc": "Scott Wood <oss@buserror.net>,\n\tRasmus Villemoes <linux@rasmusvillemoes.dk>, \n\tlinuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org,\n\tlinux-arm-kernel@lists.infradead.org", "Errors-To": "linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org", "Sender": "\"Linuxppc-dev\"\n\t<linuxppc-dev-bounces+patchwork-incoming=ozlabs.org@lists.ozlabs.org>" }, "content": "There are a number of problems with cpm_muram_alloc() and its\ncallers. Most callers assign the return value to some variable and\nthen use IS_ERR_VALUE to check for allocation failure. However, when\nthat variable is not sizeof(long), this leads to warnings - and it is\nindeed broken to do e.g.\n\n u32 foo = cpm_muram_alloc();\n if (IS_ERR_VALUE(foo))\n\non a 64-bit platform, since the condition\n\n foo >= (unsigned long)-ENOMEM\n\nis tautologically false. There are also callers that ignore the\npossibility of error, and then there are those that check for error by\ncomparing the return value to 0...\n\nOne could fix that by changing all callers to store the return value\ntemporarily in an \"unsigned long\" and test that. However, use of\nIS_ERR_VALUE() is error-prone and should be restricted to things which\nare inherently long-sized (stuff in pt_regs etc.). Instead, let's aim\nfor changing to the standard kernel style\n\n int foo = cpm_muram_alloc();\n if (foo < 0)\n deal_with_it()\n some->where = foo;\n\nChanging the return type from unsigned long to s32 (aka signed int)\ndoesn't change the value that gets stored into any of the callers'\nvariables except if the caller was storing the result in a u64 _and_\nthe allocation failed, so in itself this patch should be a no-op.\n\nAnother problem with cpm_muram_alloc() is that it can certainly\nvalidly return 0 - and except if some cpm_muram_alloc_fixed() call\ninterferes, the very first cpm_muram_alloc() call will return just\nthat. But that shows that both ucc_slow_free() and ucc_fast_free() are\nbuggy, since they assume that a value of 0 means \"that field was never\nallocated\". We'll later change cpm_muram_free() to accept (and ignore)\na negative offset, so callers can use a sentinel of -1 instead of 0\nand just unconditionally call cpm_muram_free().\n\nSigned-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>\n---\n drivers/soc/fsl/qe/qe_common.c | 29 ++++++++++++++++-------------\n include/soc/fsl/qe/qe.h | 16 ++++++++--------\n 2 files changed, 24 insertions(+), 21 deletions(-)", "diff": "diff --git a/drivers/soc/fsl/qe/qe_common.c b/drivers/soc/fsl/qe/qe_common.c\nindex 83e85e61669f..50be59678903 100644\n--- a/drivers/soc/fsl/qe/qe_common.c\n+++ b/drivers/soc/fsl/qe/qe_common.c\n@@ -32,7 +32,7 @@ static phys_addr_t muram_pbase;\n \n struct muram_block {\n \tstruct list_head head;\n-\tunsigned long start;\n+\ts32 start;\n \tint size;\n };\n \n@@ -110,13 +110,14 @@ int cpm_muram_init(void)\n * @algo: algorithm for alloc.\n * @data: data for genalloc's algorithm.\n *\n- * This function returns an offset into the muram area.\n+ * This function returns a non-negative offset into the muram area, or\n+ * a negative errno on failure.\n */\n-static unsigned long cpm_muram_alloc_common(unsigned long size,\n-\t\tgenpool_algo_t algo, void *data)\n+static s32 cpm_muram_alloc_common(unsigned long size,\n+\t\t\t\t genpool_algo_t algo, void *data)\n {\n \tstruct muram_block *entry;\n-\tunsigned long start;\n+\ts32 start;\n \n \tif (!muram_pool && cpm_muram_init())\n \t\tgoto out2;\n@@ -137,7 +138,7 @@ static unsigned long cpm_muram_alloc_common(unsigned long size,\n out1:\n \tgen_pool_free(muram_pool, start, size);\n out2:\n-\treturn (unsigned long)-ENOMEM;\n+\treturn -ENOMEM;\n }\n \n /*\n@@ -145,13 +146,14 @@ static unsigned long cpm_muram_alloc_common(unsigned long size,\n * @size: number of bytes to allocate\n * @align: requested alignment, in bytes\n *\n- * This function returns an offset into the muram area.\n+ * This function returns a non-negative offset into the muram area, or\n+ * a negative errno on failure.\n * Use cpm_dpram_addr() to get the virtual address of the area.\n * Use cpm_muram_free() to free the allocation.\n */\n-unsigned long cpm_muram_alloc(unsigned long size, unsigned long align)\n+s32 cpm_muram_alloc(unsigned long size, unsigned long align)\n {\n-\tunsigned long start;\n+\ts32 start;\n \tunsigned long flags;\n \tstruct genpool_data_align muram_pool_data;\n \n@@ -168,7 +170,7 @@ EXPORT_SYMBOL(cpm_muram_alloc);\n * cpm_muram_free - free a chunk of multi-user ram\n * @offset: The beginning of the chunk as returned by cpm_muram_alloc().\n */\n-int cpm_muram_free(unsigned long offset)\n+int cpm_muram_free(s32 offset)\n {\n \tunsigned long flags;\n \tint size;\n@@ -194,13 +196,14 @@ EXPORT_SYMBOL(cpm_muram_free);\n * cpm_muram_alloc_fixed - reserve a specific region of multi-user ram\n * @offset: offset of allocation start address\n * @size: number of bytes to allocate\n- * This function returns an offset into the muram area\n+ * This function returns @offset if the area was available, a negative\n+ * errno otherwise.\n * Use cpm_dpram_addr() to get the virtual address of the area.\n * Use cpm_muram_free() to free the allocation.\n */\n-unsigned long cpm_muram_alloc_fixed(unsigned long offset, unsigned long size)\n+s32 cpm_muram_alloc_fixed(unsigned long offset, unsigned long size)\n {\n-\tunsigned long start;\n+\tlong start;\n \tunsigned long flags;\n \tstruct genpool_data_fixed muram_pool_data_fixed;\n \ndiff --git a/include/soc/fsl/qe/qe.h b/include/soc/fsl/qe/qe.h\nindex 521fa3a177e0..f589ae3f1216 100644\n--- a/include/soc/fsl/qe/qe.h\n+++ b/include/soc/fsl/qe/qe.h\n@@ -98,26 +98,26 @@ static inline void qe_reset(void) {}\n int cpm_muram_init(void);\n \n #if defined(CONFIG_CPM) || defined(CONFIG_QUICC_ENGINE)\n-unsigned long cpm_muram_alloc(unsigned long size, unsigned long align);\n-int cpm_muram_free(unsigned long offset);\n-unsigned long cpm_muram_alloc_fixed(unsigned long offset, unsigned long size);\n+s32 cpm_muram_alloc(unsigned long size, unsigned long align);\n+int cpm_muram_free(s32 offset);\n+s32 cpm_muram_alloc_fixed(unsigned long offset, unsigned long size);\n void __iomem *cpm_muram_addr(unsigned long offset);\n unsigned long cpm_muram_offset(void __iomem *addr);\n dma_addr_t cpm_muram_dma(void __iomem *addr);\n #else\n-static inline unsigned long cpm_muram_alloc(unsigned long size,\n-\t\t\t\t\t unsigned long align)\n+static inline s32 cpm_muram_alloc(unsigned long size,\n+\t\t\t\t unsigned long align)\n {\n \treturn -ENOSYS;\n }\n \n-static inline int cpm_muram_free(unsigned long offset)\n+static inline int cpm_muram_free(s32 offset)\n {\n \treturn -ENOSYS;\n }\n \n-static inline unsigned long cpm_muram_alloc_fixed(unsigned long offset,\n-\t\t\t\t\t\t unsigned long size)\n+static inline s32 cpm_muram_alloc_fixed(unsigned long offset,\n+\t\t\t\t\tunsigned long size)\n {\n \treturn -ENOSYS;\n }\n", "prefixes": [ "v4", "34/47" ] }