From patchwork Fri Feb 5 14:38:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 376937 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp2392201jah; Fri, 5 Feb 2021 08:17:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJzi+6opJ+6ueQbKc2CngwZ/fAge6vzrvFHLvG3GlFr3z5+Jn2GI0qZ3fMsHg3n79bdpIdFa X-Received: by 2002:a50:d4c5:: with SMTP id e5mr4394480edj.32.1612541876920; Fri, 05 Feb 2021 08:17:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612541876; cv=none; d=google.com; s=arc-20160816; b=kE2GP9Uhy+RdBOZTC9FadtTvyA+EDd/ldYASLhotBgkNBJwTnTBNmmpg4PTEuwy7xL Prq5oQiUlQbeqcmRme6N9h6XFXfdKUP13njOPv7tKhLZs1JGkekfGxF2Z7O8In2n5q2v +R9vpsZPWT8aNL0Xja0+uKHcqYMnqQEMI0GOtx1JPvGF3O8o+sF7/bEFRAYoKVS3N3Y6 8Wdxyh6SM3AeimwJHvE7kdOHYuLSNnf6JEDXY+3FCgWgn/Zb5+xYvNhBJ/RUWDeIP+Y+ wiWTr48XdCTUwyu3xjQRyELr/00JNyH4mRUU9TegM+CbZpdspU7nXD4w63pWbwDZJU4c II8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=p5s7C++oXCKkL15pcRUUu+6lFMtCGoUhTxjbs8xu7G8=; b=d2N7wm3ralJ31BsNtVFg2X6iWYO+wMdslT04ZLyrBL9m4gKt4cb52nvI0ONPuT8hZX HoW0T1FyHuTjE8COMeql43tjXr4sEWat+HidsjikkLNN5zvmZfPjts1KgXUjzivVZvtx 3XHSK+CtXTVI2PtH9YkAjOM5c7AeO2THbB710n5aQ5R8C8ViQzz6Q3Rrrexu9rQZyHtk QnBsk4xmU9hhQc2HC3Jlqd4Xx42aUpTupYSMXWkYpQ4Yuv2svH69UzQxb3L55+404X0o 8LEThNRbB3y5nNO8pxfUdONeOr7VrIAOiPdqE3V85PuJlIlKZRpgz6IkIj1RuDcfGDhq 3wZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=toYcYANu; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h20si1629202ejy.576.2021.02.05.08.17.56; Fri, 05 Feb 2021 08:17:56 -0800 (PST) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=toYcYANu; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232637AbhBEOhU (ORCPT + 7 others); Fri, 5 Feb 2021 09:37:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232718AbhBEOem (ORCPT ); Fri, 5 Feb 2021 09:34:42 -0500 Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25B51C06178C for ; Fri, 5 Feb 2021 08:12:47 -0800 (PST) Received: by mail-pf1-x433.google.com with SMTP id i63so4627612pfg.7 for ; Fri, 05 Feb 2021 08:12:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=p5s7C++oXCKkL15pcRUUu+6lFMtCGoUhTxjbs8xu7G8=; b=toYcYANum0bryfCxYh+S/LRngiplh0Lc19b6Lq9fkjmmnvtV/5NITO0+4Udb7m6Xzj Mgatqbie1YWP6o2YUoU/Ol7rE7qN+6PiNzEdat6hGEc+h2PiLUCTlDGZ8swByfbhRBm7 19BDCUhPq0J3467Zf52+MLxBS8UHpS7jBU8E5m/6m8JhHT187S+ObjsVN44AyFYEN4yi 9SsMLVzUIVlaFR+jsoXzALVjP72H16NSDyxZxsQ8D8ltVdp7VbuclaAQLFR+ydvJyS7h aJLR3UZillj34CJYqntWpfXRtbv+IY7OZo8Tlxplf505hneIQiEjlcmnocW7M1wOw3DF Iwfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=p5s7C++oXCKkL15pcRUUu+6lFMtCGoUhTxjbs8xu7G8=; b=aT+sk16kZjotnMryAg/hb7msrwkGdvKuMEzx4pHb4VsBJqA6mTpaRCbTcQehXJbKIc mguRzhI0Q/0uP1YfyBDCSvkX1yZSXOEa+zAhjI59P8sUkhvUSChV7C1G05ibO8JrCqM+ OKqY6Sg6/O2S1+J3s75OuRgeGADk4iXZaEovIGI8Xi43T9lRtBhmRP1n/qauGSKfgsLK SJ0Xcxxlvil46w66MVe9+v2oIfoMCfv+hqKNwkXQS5Dd0jNepUP1LOCVr+aDQjg5w/oP XlSezZI9Az/118nYu2Fp/Vml8Me0AXX3ZsruW851oF62tNSzNKupEPVT/+WushNIDhz+ TQyw== X-Gm-Message-State: AOAM532izhc424TxHww+rq7iABCR2xrWQkLsa15FIWHuYNL6CBkRGG1R 67xphz8oa0rsYA0rvPXtCtnVzggymqSu8A== X-Received: by 2002:a05:6e02:20e8:: with SMTP id q8mr3951625ilv.205.1612535914480; Fri, 05 Feb 2021 06:38:34 -0800 (PST) Received: from beast.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id h9sm4136882ili.43.2021.02.05.06.38.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Feb 2021 06:38:33 -0800 (PST) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: elder@kernel.org, evgreen@chromium.org, bjorn.andersson@linaro.org, cpratapa@codeaurora.org, subashab@codeaurora.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v2 1/7] net: ipa: move mutex calls into __gsi_channel_stop() Date: Fri, 5 Feb 2021 08:38:23 -0600 Message-Id: <20210205143829.16271-2-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210205143829.16271-1-elder@linaro.org> References: <20210205143829.16271-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Move the mutex calls out of gsi_channel_stop_retry() and into __gsi_channel_stop(), to make the latter more semantically similar to to __gsi_channel_start(). Signed-off-by: Alex Elder --- v2: - Return early in some cases, to avoid blocks of indented code - Update description, to better reflect the updated patch - Fix v1 bug in gsi_channel_stop(); disable things on *success* drivers/net/ipa/gsi.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) -- 2.20.1 diff --git a/drivers/net/ipa/gsi.c b/drivers/net/ipa/gsi.c index 53640447bf123..f0432c965168c 100644 --- a/drivers/net/ipa/gsi.c +++ b/drivers/net/ipa/gsi.c @@ -910,11 +910,8 @@ int gsi_channel_start(struct gsi *gsi, u32 channel_id) static int gsi_channel_stop_retry(struct gsi_channel *channel) { u32 retries = GSI_CHANNEL_STOP_RETRIES; - struct gsi *gsi = channel->gsi; int ret; - mutex_lock(&gsi->mutex); - do { ret = gsi_channel_stop_command(channel); if (ret != -EAGAIN) @@ -922,24 +919,33 @@ static int gsi_channel_stop_retry(struct gsi_channel *channel) usleep_range(3 * USEC_PER_MSEC, 5 * USEC_PER_MSEC); } while (retries--); - mutex_unlock(&gsi->mutex); - return ret; } static int __gsi_channel_stop(struct gsi_channel *channel, bool stop) { + struct gsi *gsi = channel->gsi; int ret; /* Wait for any underway transactions to complete before stopping. */ gsi_channel_trans_quiesce(channel); - ret = stop ? gsi_channel_stop_retry(channel) : 0; - /* Finally, ensure NAPI polling has finished. */ - if (!ret) - napi_synchronize(&channel->napi); + if (!stop) + return 0; - return ret; + mutex_lock(&gsi->mutex); + + ret = gsi_channel_stop_retry(channel); + + mutex_unlock(&gsi->mutex); + + if (ret) + return ret; + + /* Ensure NAPI polling has finished. */ + napi_synchronize(&channel->napi); + + return 0; } /* Stop a started channel */ @@ -948,11 +954,11 @@ int gsi_channel_stop(struct gsi *gsi, u32 channel_id) struct gsi_channel *channel = &gsi->channel[channel_id]; int ret; - /* Only disable the completion interrupt if stop is successful */ ret = __gsi_channel_stop(channel, true); if (ret) return ret; + /* Disable the completion interrupt and NAPI if successful */ gsi_irq_ieob_disable_one(gsi, channel->evt_ring_id); napi_disable(&channel->napi); From patchwork Fri Feb 5 14:38:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 376976 Delivered-To: patch@linaro.org Received: by 2002:a17:906:48d2:0:0:0:0 with SMTP id d18csp2558811ejt; Fri, 5 Feb 2021 14:33:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJy/yx7tIRwbrURBzl8Ti0++1XvO1fb4HDL8omcyrbPX7N++qSNN/MLja2QyI/JPG+H5r1zp X-Received: by 2002:a17:906:980b:: with SMTP id lm11mr6224302ejb.46.1612564386538; Fri, 05 Feb 2021 14:33:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612564386; cv=none; d=google.com; s=arc-20160816; b=yqqKZwBqF3Dy79kksYsNKip2oMQkwvAMzBqGsTtTnfocylSXJZd2Usnb1+kw8b0iDj 6Gktaefrt/wq97HA5SBDAqdVrlCP2UbztwpDf/USQxLOVmvl5gdVKY2JGqAeFk6kj/nQ 4KpZeiKhefzcZzpyak2GSpttqgFYtgNFdxZHmYUTq1d1hu5ryFr1Kxq7a7ubLq/F8+5A BKicjLMw2W9cEg3tBUANisl1nOu7hGq0ksrJXhkbMZW/N59lZG23ybDFf+2yXejaGEah acK8hXvZCiYgBgFp+rSWXwotoii9cFssuQtUD3aiT2xjfQZ+wRPUoY5Qs5w/LYfBlka6 VkBA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=kxUeKVVNjUYZDEFlDXz16lYFbO6uGbZz83MJ+yrq+To=; b=LwyhvPM+hxWxzz4+QfrxwtLBNMMJGrJg8KYstzU+LRuIAExvDUCDt6LXWovkh2Yobp 0rqMZo0MpPDm1uC+hTZOO2bJakC9Pe1YQ0bOwjs9znGecdp/mkqpOn4pTEWXsuWBJBYq uWJomrTPA1ZGtzTP53Sp9BlZRqBnUWy3VQ305EVPeftob51W59SMRiwRlOvVzoRTX7zf irIDXym1wfC8VrvTVZII6PSieAN+7S5mCoK1sF1kL9/t1LprtdiIYOkfhxkCuhSmVcKd wR7opkwmN8XxhH2LDK8AP7zkdG6VugxqoVP3ioT7XT8D7yKNPzD9nY/xC5ry563UbDVy d5Hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MHKCxzmu; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jr13si5266255ejb.269.2021.02.05.14.33.06; Fri, 05 Feb 2021 14:33:06 -0800 (PST) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MHKCxzmu; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232644AbhBEWcA (ORCPT + 7 others); Fri, 5 Feb 2021 17:32:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40390 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232496AbhBEORn (ORCPT ); Fri, 5 Feb 2021 09:17:43 -0500 Received: from mail-il1-x12e.google.com (mail-il1-x12e.google.com [IPv6:2607:f8b0:4864:20::12e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D25C0C06121D for ; Fri, 5 Feb 2021 07:47:04 -0800 (PST) Received: by mail-il1-x12e.google.com with SMTP id g9so6226004ilc.3 for ; Fri, 05 Feb 2021 07:47:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=kxUeKVVNjUYZDEFlDXz16lYFbO6uGbZz83MJ+yrq+To=; b=MHKCxzmuwmO3/oZLWZYANCeI3dBbjZKs52DNYS2+XYmT7KjDFmHyFR0nnq0A+ugEQZ drQjc5ZdJ6R1GWFpepq9BrE1iwWYD8dEOnJsRriHpru3d31kRDiamI8d810//keKACbk MO0ri9erP1Bd+gzSnYdtozR7ml1kcSxE/WjN5YhbMEcrqRDZZWkR4wOFZdLiwD45o+mJ jJjPDeLSlmCuTTX8ce31NMP4bnZyf/hhxlW7sQANGcGk7Gif/Y55RMnb11PHc3jWyXL7 1AV54PW0fGx89ViXdBD1qS4Ghmn8ZaIKpZZbeJGkuW/4cSgbLE924TKrcNLLkkDt2HBP GbPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=kxUeKVVNjUYZDEFlDXz16lYFbO6uGbZz83MJ+yrq+To=; b=iVZoMkRc5bGhMRvpkWvxA0RdtakMspsNmkJ7V272Vcsta/U7c2UoHuB7zmuijGM9tF KRIKXFkJqMajR+lXNnN5Fu9g5LBiGj3PLznMtdzdeh300erRFYuViCA6ppuCem/5bGSU OXHDkRQ8mtVPf+a0igdFYpLo96OnW0phAC6cph3SOuOOPR03a+FNwZz00g0j+jO6cOsk PvjQb2OGOl1HnZoi1rG+ZTLcFR27mu2cuhbwLmS+XitqXwEY/4B9P2sRqdr0ijuJZUVY S44QLoc9WRrmeo4SPNylXutMPpUME5daVqntxwGOG3Zmhvbkx6ua/xhtFH4GjyZmACxW wTsg== X-Gm-Message-State: AOAM533Ymrs9n3vSjXjCRMxpNw9qUly0CpUke++v+9EEbVoUf5LZhCVZ 8z/fuPsD5MF+MPTjbElxi6/8ntWP+28i5g== X-Received: by 2002:a92:3306:: with SMTP id a6mr4036757ilf.55.1612535915555; Fri, 05 Feb 2021 06:38:35 -0800 (PST) Received: from beast.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id h9sm4136882ili.43.2021.02.05.06.38.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Feb 2021 06:38:35 -0800 (PST) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: elder@kernel.org, evgreen@chromium.org, bjorn.andersson@linaro.org, cpratapa@codeaurora.org, subashab@codeaurora.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v2 2/7] net: ipa: synchronize NAPI only for suspend Date: Fri, 5 Feb 2021 08:38:24 -0600 Message-Id: <20210205143829.16271-3-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210205143829.16271-1-elder@linaro.org> References: <20210205143829.16271-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org When stopping a channel, gsi_channel_stop() will ensure NAPI polling is complete when it calls napi_disable(). So there is no need to call napi_synchronize() in that case. Move the call to napi_synchronize() out of __gsi_channel_stop() and into gsi_channel_suspend(), so it's only used where needed. Signed-off-by: Alex Elder --- v2: - Return early to avoid blocks of indented code drivers/net/ipa/gsi.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) -- 2.20.1 diff --git a/drivers/net/ipa/gsi.c b/drivers/net/ipa/gsi.c index f0432c965168c..60eb765c53647 100644 --- a/drivers/net/ipa/gsi.c +++ b/drivers/net/ipa/gsi.c @@ -939,13 +939,7 @@ static int __gsi_channel_stop(struct gsi_channel *channel, bool stop) mutex_unlock(&gsi->mutex); - if (ret) - return ret; - - /* Ensure NAPI polling has finished. */ - napi_synchronize(&channel->napi); - - return 0; + return ret; } /* Stop a started channel */ @@ -987,8 +981,16 @@ void gsi_channel_reset(struct gsi *gsi, u32 channel_id, bool doorbell) int gsi_channel_suspend(struct gsi *gsi, u32 channel_id, bool stop) { struct gsi_channel *channel = &gsi->channel[channel_id]; + int ret; - return __gsi_channel_stop(channel, stop); + ret = __gsi_channel_stop(channel, stop); + if (ret) + return ret; + + /* Ensure NAPI polling has finished. */ + napi_synchronize(&channel->napi); + + return 0; } /* Resume a suspended channel (starting will be requested if STOPPED) */ From patchwork Fri Feb 5 14:38:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 376939 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp2404962jah; Fri, 5 Feb 2021 08:34:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJxT8p+B4OyPL7TlSibdG10kNlE/dIotMC2blzAsPboKv5iUC0FbaSPc2YH3vxgoHt8QUMSR X-Received: by 2002:a50:9e01:: with SMTP id z1mr2819649ede.44.1612542876237; Fri, 05 Feb 2021 08:34:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612542876; cv=none; d=google.com; s=arc-20160816; b=MH/McaGybK3QBAGKcOQKPTMtYh2Xe04qbxS5QIgyCah4psSrXbvW1dyMPPKnkR5hxj iyeOQeYCEILucJvmsfF2wapi57wy4Je+TCnO3tmiYp4NcVUO+sIS/COsvZFK/YuekzPb //ytsSQNMD4qngFsWuZnPzvgbzDDR/Hrf0HKKZCnBVRJFaMeXs8az4cAK24/BD5eUL8C n1mqF4D7kyejpEXoD5AYp5VKSMUKs5T/JmV5t/xQORGoq5r+qEE05Yw0ydYQQxfurTS0 9MYln2UYtxAS17JeZSHlZc2VZE/SUlug23rFLO9ZfwNGkQ4aNEVpUlB/dFGjw4GZptNK a+0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=P1s7hU7D7Z1a7l+hh4Bwd4ik67fh8ngiWow+qBF4KnA=; b=x6UMIKxdDbG7wC3t4yiVQ4bqH5+orFuwMKtCSpL7zeVCg7tURI9pD9z0C70bveXXCq AF5V3Iih5c02dbKYV/8Knnfq4EYJYlXFPbRz/hc8NW/KgZsCGvAm5BXVL30vaIGU106f VLno7j+bTQUFP+Ax2G3yjJinju6gLRrc9eipFhbeRp+5xre6bufZzmaJeQygxHaA8axB WrFEH11m8lA4Wcu65nR6L7gd/j++fCreduKBVSbDbPzVq0dCsPgZipQggsy25vlcHH9F bSJlWwHRt757YFA1oYzp5WXrIlDbs6cIr3jWKE+D+b66WqmKbdsMF8rGq56CTgFYWGsZ qlBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VOdUslhx; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hy19si709024ejc.692.2021.02.05.08.34.36; Fri, 05 Feb 2021 08:34:36 -0800 (PST) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=VOdUslhx; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231274AbhBEOyi (ORCPT + 7 others); Fri, 5 Feb 2021 09:54:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232791AbhBEOqq (ORCPT ); Fri, 5 Feb 2021 09:46:46 -0500 Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0ADDBC0613D6 for ; Fri, 5 Feb 2021 08:24:02 -0800 (PST) Received: by mail-pg1-x529.google.com with SMTP id z21so4893985pgj.4 for ; Fri, 05 Feb 2021 08:24:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=P1s7hU7D7Z1a7l+hh4Bwd4ik67fh8ngiWow+qBF4KnA=; b=VOdUslhxRnLsER8+6FOB+96ZWogT24keTIgf1Py1RCjXwGctkSJILKHB6gsnj4UAF1 adHjCKv6uVH/QSssCEpyK/xqZxKT3Oi8NzZjKxrBqebWQAyTHOwWqZdqT8ENf8/0DgCH C1Cn81xTJ/i4c1cGFvmqyd8D3Cu2YFRSozP2oJ0HmtCsrmN6Omwb2z5b/eUOKhjEB/Xr mTt9QqSor+BeiooSnqHeubyBJeC/m5wQcTEW+IZA5RjWfooue0XBaWyJ7aA9YyM6nitr qQAlzcj+/QhYbYCJt76OPr3MUi4O4rbkQs9RN82NzI/9iDogIMEkVbLxYwCbXisySwr5 BBmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=P1s7hU7D7Z1a7l+hh4Bwd4ik67fh8ngiWow+qBF4KnA=; b=q1M2yUuYxf/LJcwD7nlt7+QKSxZ3Rfxw7zWIkrUZ2eZUcWJ5RAdQAZ9RvBnMdrnbow nEHBaHH53HRpcUPN4x7stPRr3FdeNs4numaxYkeUFnZ+928rlJ+27CHNpzQyguE/F9vu 2ZlHjwUAAR8AwdjpUyD2Zv6ac7swO+BxgXVkVQ4p2U2bEZyPvx4/38Rv/2oCXh39sYLy Nzrg3YoI592xUyGFvpekZXD+FqABikdFgQLk1rE1UiXt9W55NtgNLV4gcALAnZH2no5J dKonG0Y8Gk2ojYc1NyjTbuKtcVM9Iee72+KX28Pa67wuSlpf1vt2wbHl7YmS5FxJN6TW FL+w== X-Gm-Message-State: AOAM530b6KKDzpVKQOG3mnJApiM4g+ITxTe/xdASUPU9hdHNqyKi+2Ew OSYURYuuzK6ZCcd2Hs/3NvyNcWeBX9dKwA== X-Received: by 2002:a05:6e02:154d:: with SMTP id j13mr4221276ilu.153.1612535916785; Fri, 05 Feb 2021 06:38:36 -0800 (PST) Received: from beast.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id h9sm4136882ili.43.2021.02.05.06.38.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Feb 2021 06:38:36 -0800 (PST) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: elder@kernel.org, evgreen@chromium.org, bjorn.andersson@linaro.org, cpratapa@codeaurora.org, subashab@codeaurora.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v2 3/7] net: ipa: do not cache event ring state Date: Fri, 5 Feb 2021 08:38:25 -0600 Message-Id: <20210205143829.16271-4-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210205143829.16271-1-elder@linaro.org> References: <20210205143829.16271-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org An event ring's state only needs to be known when it is allocated, reset, or deallocated. We check an event ring's state both before and after performing an event ring control command that changes its state. These are only issued at startup and shutdown, so there is very little value in caching the state. Stop recording a copy of the channel's last known state, and instead fetch the true state from hardware whenever it's needed. In such cases, *do* record the state in a local variable, in case an error message reports it (so the value reported is the value seen). Signed-off-by: Alex Elder --- drivers/net/ipa/gsi.c | 39 +++++++++++++++++++++------------------ drivers/net/ipa/gsi.h | 1 - 2 files changed, 21 insertions(+), 19 deletions(-) -- 2.20.1 diff --git a/drivers/net/ipa/gsi.c b/drivers/net/ipa/gsi.c index 60eb765c53647..511c94f66036c 100644 --- a/drivers/net/ipa/gsi.c +++ b/drivers/net/ipa/gsi.c @@ -408,30 +408,31 @@ static void gsi_evt_ring_command(struct gsi *gsi, u32 evt_ring_id, return; dev_err(dev, "GSI command %u for event ring %u timed out, state %u\n", - opcode, evt_ring_id, evt_ring->state); + opcode, evt_ring_id, gsi_evt_ring_state(gsi, evt_ring_id)); } /* Allocate an event ring in NOT_ALLOCATED state */ static int gsi_evt_ring_alloc_command(struct gsi *gsi, u32 evt_ring_id) { - struct gsi_evt_ring *evt_ring = &gsi->evt_ring[evt_ring_id]; + enum gsi_evt_ring_state state; /* Get initial event ring state */ - evt_ring->state = gsi_evt_ring_state(gsi, evt_ring_id); - if (evt_ring->state != GSI_EVT_RING_STATE_NOT_ALLOCATED) { + state = gsi_evt_ring_state(gsi, evt_ring_id); + if (state != GSI_EVT_RING_STATE_NOT_ALLOCATED) { dev_err(gsi->dev, "event ring %u bad state %u before alloc\n", - evt_ring_id, evt_ring->state); + evt_ring_id, state); return -EINVAL; } gsi_evt_ring_command(gsi, evt_ring_id, GSI_EVT_ALLOCATE); /* If successful the event ring state will have changed */ - if (evt_ring->state == GSI_EVT_RING_STATE_ALLOCATED) + state = gsi_evt_ring_state(gsi, evt_ring_id); + if (state == GSI_EVT_RING_STATE_ALLOCATED) return 0; dev_err(gsi->dev, "event ring %u bad state %u after alloc\n", - evt_ring_id, evt_ring->state); + evt_ring_id, state); return -EIO; } @@ -439,45 +440,48 @@ static int gsi_evt_ring_alloc_command(struct gsi *gsi, u32 evt_ring_id) /* Reset a GSI event ring in ALLOCATED or ERROR state. */ static void gsi_evt_ring_reset_command(struct gsi *gsi, u32 evt_ring_id) { - struct gsi_evt_ring *evt_ring = &gsi->evt_ring[evt_ring_id]; - enum gsi_evt_ring_state state = evt_ring->state; + enum gsi_evt_ring_state state; + state = gsi_evt_ring_state(gsi, evt_ring_id); if (state != GSI_EVT_RING_STATE_ALLOCATED && state != GSI_EVT_RING_STATE_ERROR) { dev_err(gsi->dev, "event ring %u bad state %u before reset\n", - evt_ring_id, evt_ring->state); + evt_ring_id, state); return; } gsi_evt_ring_command(gsi, evt_ring_id, GSI_EVT_RESET); /* If successful the event ring state will have changed */ - if (evt_ring->state == GSI_EVT_RING_STATE_ALLOCATED) + state = gsi_evt_ring_state(gsi, evt_ring_id); + if (state == GSI_EVT_RING_STATE_ALLOCATED) return; dev_err(gsi->dev, "event ring %u bad state %u after reset\n", - evt_ring_id, evt_ring->state); + evt_ring_id, state); } /* Issue a hardware de-allocation request for an allocated event ring */ static void gsi_evt_ring_de_alloc_command(struct gsi *gsi, u32 evt_ring_id) { - struct gsi_evt_ring *evt_ring = &gsi->evt_ring[evt_ring_id]; + enum gsi_evt_ring_state state; - if (evt_ring->state != GSI_EVT_RING_STATE_ALLOCATED) { + state = gsi_evt_ring_state(gsi, evt_ring_id); + if (state != GSI_EVT_RING_STATE_ALLOCATED) { dev_err(gsi->dev, "event ring %u state %u before dealloc\n", - evt_ring_id, evt_ring->state); + evt_ring_id, state); return; } gsi_evt_ring_command(gsi, evt_ring_id, GSI_EVT_DE_ALLOC); /* If successful the event ring state will have changed */ - if (evt_ring->state == GSI_EVT_RING_STATE_NOT_ALLOCATED) + state = gsi_evt_ring_state(gsi, evt_ring_id); + if (state == GSI_EVT_RING_STATE_NOT_ALLOCATED) return; dev_err(gsi->dev, "event ring %u bad state %u after dealloc\n", - evt_ring_id, evt_ring->state); + evt_ring_id, state); } /* Fetch the current state of a channel from hardware */ @@ -1107,7 +1111,6 @@ static void gsi_isr_evt_ctrl(struct gsi *gsi) event_mask ^= BIT(evt_ring_id); evt_ring = &gsi->evt_ring[evt_ring_id]; - evt_ring->state = gsi_evt_ring_state(gsi, evt_ring_id); complete(&evt_ring->completion); } diff --git a/drivers/net/ipa/gsi.h b/drivers/net/ipa/gsi.h index 96c9aed397aad..d674db0ba4eb0 100644 --- a/drivers/net/ipa/gsi.h +++ b/drivers/net/ipa/gsi.h @@ -142,7 +142,6 @@ enum gsi_evt_ring_state { struct gsi_evt_ring { struct gsi_channel *channel; struct completion completion; /* signals event ring state changes */ - enum gsi_evt_ring_state state; struct gsi_ring ring; }; From patchwork Fri Feb 5 14:38:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 376973 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp2660041jah; Fri, 5 Feb 2021 14:13:16 -0800 (PST) X-Google-Smtp-Source: ABdhPJxctxvciK+als5FtJXUwqAbQrqxPscE7xRBn3Sa9Wz3pRqdSoN0nuA5bLmduNhlu+eoB1yk X-Received: by 2002:a05:6402:4382:: with SMTP id o2mr5790532edc.371.1612563196502; Fri, 05 Feb 2021 14:13:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612563196; cv=none; d=google.com; s=arc-20160816; b=VTJPDT8MX+4xKsCuBLAGV1njnrN7DOVDNy+K1HrWyVVKhpZxG5bApFJHmCl9ipkoHH 6V+LUjvI2uSJtt0Hiv7cC6YMINS+kSbS/UwrI8bJXOWJWaKALo+R1Fwq/525jnqWKRen sDJ/a5Um28wjrJ/t5qSo7H9dYIh89sdJVTICaAEFUcNkqmAKn8bEjx3355Br10UPX2Qd lTjO2eSs671mosThHoizZYxlwQrldUHp/sBItjKZf68zHrukqQo3wNhYuHsUawkK9PAE drsEsAU5+DlMqO6aP8xrUAeO2YGj7ZQq38d7N50WAYbCOFFp1bYyt5jzqQClhqCPxMLv UE/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=BhwlK/0Dz6i4rhS6CqV6gw/YDZHe+oacHIsDYWLXy98=; b=gGLs03znDIXTWDc7ya3CyP36cE2fy5fV5inv4hhTSkBPaqXZ4X+whHCtErFUFfTEW6 s8JQlcloXI+UmM9gdyCVkP5/5VIIUzdn+HUt8ZYYe4zK7S70lqi84Gx26ZIJrkDAq777 gJAZiTLeOjm25fd6r11ilckVXvHYLUb3OsBSl4Q++Wc+OrFb4dMoqYVfvsOA5n5R559O CPXlBP2hwJwi7F+q1KIhQtCwQJWiOsEC8PpjHFZrmC4q0zYiCC4SHIQMbCgV4EpJ5CH2 88gskTCDAI2qXuEanAC/72f+eRgjXsgf25SVaH6K/WPie9CocG+kZ5ld2wxDdwY0noi5 wDpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dxsc59SI; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id rv26si4984275ejb.330.2021.02.05.14.13.16; Fri, 05 Feb 2021 14:13:16 -0800 (PST) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dxsc59SI; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232065AbhBEWLz (ORCPT + 7 others); Fri, 5 Feb 2021 17:11:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229813AbhBEOjW (ORCPT ); Fri, 5 Feb 2021 09:39:22 -0500 Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A58A2C06178A for ; Fri, 5 Feb 2021 08:17:03 -0800 (PST) Received: by mail-pg1-x529.google.com with SMTP id o63so4866859pgo.6 for ; Fri, 05 Feb 2021 08:17:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=BhwlK/0Dz6i4rhS6CqV6gw/YDZHe+oacHIsDYWLXy98=; b=dxsc59SI0AuVp21DeuNlA0S1J6fxGcsD79lrJ3GIAleQLDgbdb0Qw05LV88tf08Yhs fS5mWCsuhBwW2FTebY5vzp+M3LwoheeZ5g/t/lxqxowpZnoqUrLQc7D+hdEb4XTJpqjd ItDp4IBr8FTfC2ReRMncoTOyWR6t9ZIYs/7Sa0asyRIhCneC9hMMU2eof5Www3ULX+ue XgbRVmwYZFx7MqLW29X4xGsiel5evXIuzeLcgSLRHYgIYO3NLgHqifvFXXGJR7l9TDPM PvlJMQvMCQ32KVNDQh4YDAeP3UFTov+EiwN2LwPGoxMtYjTUO8mdsfzVkRbaiF9eETY4 FGjA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=BhwlK/0Dz6i4rhS6CqV6gw/YDZHe+oacHIsDYWLXy98=; b=mO3kF0qDfeCf0HWd6nmrOfW9lWlvQftRNsKuY2O6aqWonhdchGOgUMlSRtxDgDmJYW DYshe27NfR2hpitXi5Eych6Xu4LRv9IuLnUaXH1e4avbG1YjEh2yDP8tj9803IHR1YJ1 d5dQTyNAdeNjkczqaSbljNWO4+YGbE22c8DBxHcOFo+laX3OrAoOAP7CBNNr9Ez7+WGJ tijiR/wAb8zW0auIwaiAd3CeePZCkevG1vKikb/dfVlH9chIvOGK2MaFT2/Kn1fzMmVO Lxrs5rsweRT62ePy2E+EATzl2KvdQ433LYA/a/doxgosczdkzoEXiw7jeWcDnhh+e1No yrUw== X-Gm-Message-State: AOAM533RiKLfCk6A/jkgQEd6ruNNltKXI+OOmgcd1n7cCCW/+r/rc8yj hpY1WoYN4stvTC0No5W8MFBYcvh9AESUlg== X-Received: by 2002:a92:c5c5:: with SMTP id s5mr4110654ilt.111.1612535917823; Fri, 05 Feb 2021 06:38:37 -0800 (PST) Received: from beast.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id h9sm4136882ili.43.2021.02.05.06.38.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Feb 2021 06:38:37 -0800 (PST) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: elder@kernel.org, evgreen@chromium.org, bjorn.andersson@linaro.org, cpratapa@codeaurora.org, subashab@codeaurora.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v2 4/7] net: ipa: remove two unused register definitions Date: Fri, 5 Feb 2021 08:38:26 -0600 Message-Id: <20210205143829.16271-5-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210205143829.16271-1-elder@linaro.org> References: <20210205143829.16271-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org We do not support inter-EE channel or event ring commands. Inter-EE interrupts are disabled (and never re-enabled) for all channels and event rings, so we have no need for the GSI registers that clear those interrupt conditions. So remove their definitions. Signed-off-by: Alex Elder --- drivers/net/ipa/gsi_reg.h | 10 ---------- 1 file changed, 10 deletions(-) -- 2.20.1 diff --git a/drivers/net/ipa/gsi_reg.h b/drivers/net/ipa/gsi_reg.h index 0e138bbd82053..299456e70f286 100644 --- a/drivers/net/ipa/gsi_reg.h +++ b/drivers/net/ipa/gsi_reg.h @@ -59,16 +59,6 @@ #define GSI_INTER_EE_N_SRC_EV_CH_IRQ_OFFSET(ee) \ (0x0000c01c + 0x1000 * (ee)) -#define GSI_INTER_EE_SRC_CH_IRQ_CLR_OFFSET \ - GSI_INTER_EE_N_SRC_CH_IRQ_CLR_OFFSET(GSI_EE_AP) -#define GSI_INTER_EE_N_SRC_CH_IRQ_CLR_OFFSET(ee) \ - (0x0000c028 + 0x1000 * (ee)) - -#define GSI_INTER_EE_SRC_EV_CH_IRQ_CLR_OFFSET \ - GSI_INTER_EE_N_SRC_EV_CH_IRQ_CLR_OFFSET(GSI_EE_AP) -#define GSI_INTER_EE_N_SRC_EV_CH_IRQ_CLR_OFFSET(ee) \ - (0x0000c02c + 0x1000 * (ee)) - #define GSI_CH_C_CNTXT_0_OFFSET(ch) \ GSI_EE_N_CH_C_CNTXT_0_OFFSET((ch), GSI_EE_AP) #define GSI_EE_N_CH_C_CNTXT_0_OFFSET(ch, ee) \ From patchwork Fri Feb 5 14:38:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 376972 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp2656454jah; Fri, 5 Feb 2021 14:09:29 -0800 (PST) X-Google-Smtp-Source: ABdhPJw4Z6giD4piYJK36AsjMAv6hFueARIoezSOCFLbaBfTrv3y/F8c30x6UI1VSCgEkrDQjTie X-Received: by 2002:a05:6402:4310:: with SMTP id m16mr5639338edc.207.1612562968893; Fri, 05 Feb 2021 14:09:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612562968; cv=none; d=google.com; s=arc-20160816; b=Miaga7bOiZ8tYv0htn1zYJLVtgQitI+93HJq4oUMhpR0FL59nKlhb6VIqhXxr31uti IfjI4LGNXIY4JD4phJWJtgebdgyJXRcuiGmokqQiDJaywC12ZS6azNhDx1/2qhVfvM0U W/y7JXLaYC2lbFynpYs571/lTUwf4t3seM3+VYH2qtrJsZ7rA0bOETpQwjbadDHZgIA/ Ungc9KsKhL3Sv/aSehf1iJzmm8mBTxtqFoBxZED4s22957iDZ3aeUSeKgeidKN2D9pN7 /Kons4E+ZqGo4FzTNi/27jlcsBNT227CD9aQqzmbiGZwF3dAw6epDgMbuZZgCt9ZC4f6 jxFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=H+XXRPtcVhqL4SZA2xE4JtYQXLSPRWqhEcRZvJyBubQ=; b=Ba/m3KZR/bSkSMAEuZzNyNbbxN8gRaNecm3u+fUois0AXACH1fhxWRY46tmKf7vwUa RsR/i6sdylsuoixzmzBJyaea7qksGnjCP0kEwo7B6imC4L8EaZkEcuMQa7Zdtf1MMFbb 0/g9f3j2pNc8EHyB3LXHg8SU/tGh+Xl92ToEjCaN62LM61Dfw3oQ47zFEoT3qFehj0Cq QB6oXEb+52mmKwyIMNbjryXaUrhzZI8i6gGNMriBA3vRkApoCo/gV5jTzS6AtNk4M2Tl Z7CYTCCXWBZe2w4i47CillEJR59YWITwNh/faKuBSySfSaIAG7yNgjdB3YmTI53Hxfjv JCFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="juD/+IMQ"; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x18si5930813eji.400.2021.02.05.14.09.26; Fri, 05 Feb 2021 14:09:28 -0800 (PST) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="juD/+IMQ"; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231250AbhBEWJO (ORCPT + 7 others); Fri, 5 Feb 2021 17:09:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232051AbhBEOwL (ORCPT ); Fri, 5 Feb 2021 09:52:11 -0500 Received: from mail-pg1-x532.google.com (mail-pg1-x532.google.com [IPv6:2607:f8b0:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BCF81C0611C1 for ; Fri, 5 Feb 2021 08:29:30 -0800 (PST) Received: by mail-pg1-x532.google.com with SMTP id j2so4922408pgl.0 for ; Fri, 05 Feb 2021 08:29:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=H+XXRPtcVhqL4SZA2xE4JtYQXLSPRWqhEcRZvJyBubQ=; b=juD/+IMQSeopqjDcUewqw+7th0LzGiueKxRWyZJfLMy15zCeq9KpHi2i7WwRhQweGZ 0EHXyU+ekxL1FAX+isehGEYN7baPZiUVvYqbqiHPmEyE58s7Rxp4iMWqN3hS8twxRHix trsFwYsZ4bUpTsm0asNTic0agw1ba9BaCNKnAGSmU4/FXXW11bVRgT1MLZGBIeiJCjUE KAJJBovvbq73wbN8U99W/VgQXRZfchctJ3noW6nJTja3rsHMVFL1xxeQDv8tuUFO/s/X W5p44YExl3mB28Ig93OGJO/uAEL30YLbdBvaMZV/PoOYbpyEsCr4hVgxLx9E/JMvgJiB AcfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=H+XXRPtcVhqL4SZA2xE4JtYQXLSPRWqhEcRZvJyBubQ=; b=j1mtr46I5JIOJs++fYjPBuUEoM3Q1nMRxRyfzfZJZDndpvf7SkQH8IAY0hkXbiyHcJ s9rqivbNSrq329yCp6saqMhAM+RwwFyNd6iV5HfeEuIthDWliSkh7nv2XsZNaYdGn66W 3BXALaOuC/s7PcS6BYWLeg8q+JK+U+89/cUir9nAaJ2Tb2gH+pCF8PSgn0FcpjtzGGs6 IO7v2j1r9NjmD7NFaSEdcVq1WRfUeR35UVH2kpwgy5+CQPxm6OFQdTxavLMjO7HGykes 06Q3sq/5Wc9D3qHwuLSm7AzosWgZNNXopVo10o4kHr0DWS01ylQ+/wnQbpic7UCnDAG8 ktvQ== X-Gm-Message-State: AOAM531uh8Yk8qXRDvqaCOKH+hnDRMEIQ7BoZY0n2oe1yQfi/zsJt5wP pG60QOqgZ33PICaQa2R+d5NqTBC8u6EybQ== X-Received: by 2002:a92:4447:: with SMTP id a7mr4396967ilm.240.1612535918922; Fri, 05 Feb 2021 06:38:38 -0800 (PST) Received: from beast.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id h9sm4136882ili.43.2021.02.05.06.38.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Feb 2021 06:38:38 -0800 (PST) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: elder@kernel.org, evgreen@chromium.org, bjorn.andersson@linaro.org, cpratapa@codeaurora.org, subashab@codeaurora.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v2 5/7] net: ipa: use a Boolean rather than count when replenishing Date: Fri, 5 Feb 2021 08:38:27 -0600 Message-Id: <20210205143829.16271-6-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210205143829.16271-1-elder@linaro.org> References: <20210205143829.16271-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The count argument to ipa_endpoint_replenish() is only ever 0 or 1, and always will be (because we always handle each receive buffer in a single transaction). Rename the argument to be add_one and change it to be Boolean. Update the function description to reflect the current code. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_endpoint.c | 35 ++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) -- 2.20.1 diff --git a/drivers/net/ipa/ipa_endpoint.c b/drivers/net/ipa/ipa_endpoint.c index 7a46c790afbef..bff5d6ffd1186 100644 --- a/drivers/net/ipa/ipa_endpoint.c +++ b/drivers/net/ipa/ipa_endpoint.c @@ -1020,31 +1020,34 @@ static int ipa_endpoint_replenish_one(struct ipa_endpoint *endpoint) } /** - * ipa_endpoint_replenish() - Replenish the Rx packets cache. + * ipa_endpoint_replenish() - Replenish endpoint receive buffers * @endpoint: Endpoint to be replenished - * @count: Number of buffers to send to hardware + * @add_one: Whether this is replacing a just-consumed buffer * - * Allocate RX packet wrapper structures with maximal socket buffers - * for an endpoint. These are supplied to the hardware, which fills - * them with incoming data. + * The IPA hardware can hold a fixed number of receive buffers for an RX + * endpoint, based on the number of entries in the underlying channel ring + * buffer. If an endpoint's "backlog" is non-zero, it indicates how many + * more receive buffers can be supplied to the hardware. Replenishing for + * an endpoint can be disabled, in which case requests to replenish a + * buffer are "saved", and transferred to the backlog once it is re-enabled + * again. */ -static void ipa_endpoint_replenish(struct ipa_endpoint *endpoint, u32 count) +static void ipa_endpoint_replenish(struct ipa_endpoint *endpoint, bool add_one) { struct gsi *gsi; u32 backlog; if (!endpoint->replenish_enabled) { - if (count) - atomic_add(count, &endpoint->replenish_saved); + if (add_one) + atomic_inc(&endpoint->replenish_saved); return; } - while (atomic_dec_not_zero(&endpoint->replenish_backlog)) if (ipa_endpoint_replenish_one(endpoint)) goto try_again_later; - if (count) - atomic_add(count, &endpoint->replenish_backlog); + if (add_one) + atomic_inc(&endpoint->replenish_backlog); return; @@ -1052,8 +1055,8 @@ static void ipa_endpoint_replenish(struct ipa_endpoint *endpoint, u32 count) /* The last one didn't succeed, so fix the backlog */ backlog = atomic_inc_return(&endpoint->replenish_backlog); - if (count) - atomic_add(count, &endpoint->replenish_backlog); + if (add_one) + atomic_inc(&endpoint->replenish_backlog); /* Whenever a receive buffer transaction completes we'll try to * replenish again. It's unlikely, but if we fail to supply even @@ -1080,7 +1083,7 @@ static void ipa_endpoint_replenish_enable(struct ipa_endpoint *endpoint) /* Start replenishing if hardware currently has no buffers */ max_backlog = gsi_channel_tre_max(gsi, endpoint->channel_id); if (atomic_read(&endpoint->replenish_backlog) == max_backlog) - ipa_endpoint_replenish(endpoint, 0); + ipa_endpoint_replenish(endpoint, false); } static void ipa_endpoint_replenish_disable(struct ipa_endpoint *endpoint) @@ -1099,7 +1102,7 @@ static void ipa_endpoint_replenish_work(struct work_struct *work) endpoint = container_of(dwork, struct ipa_endpoint, replenish_work); - ipa_endpoint_replenish(endpoint, 0); + ipa_endpoint_replenish(endpoint, false); } static void ipa_endpoint_skb_copy(struct ipa_endpoint *endpoint, @@ -1300,7 +1303,7 @@ static void ipa_endpoint_rx_complete(struct ipa_endpoint *endpoint, { struct page *page; - ipa_endpoint_replenish(endpoint, 1); + ipa_endpoint_replenish(endpoint, true); if (trans->cancelled) return; From patchwork Fri Feb 5 14:38:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 376970 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp2648629jah; Fri, 5 Feb 2021 14:03:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJymKepIQeyFTvYHlST2/k6S7GSRA2WFqcYmCYlUEast9+TYN3iJyWMYu1ifpSFGwarT94Tp X-Received: by 2002:a05:6402:104e:: with SMTP id e14mr5748231edu.316.1612562629408; Fri, 05 Feb 2021 14:03:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612562629; cv=none; d=google.com; s=arc-20160816; b=GBxr5JgcpSq9baOOMcAqGPTFVGfyDRmGyvdfc41YLAiUKofUpyir3rBnonWRVW1TW/ Ow8o870ms3FOK+VBfC1aWK0auPfeCFdTyelgYykEq+Hp8T9pP0esbUi+2yAO/26ssTSe fU1rNsgbkt34fEQdYvxkvbVezyH3oFcbEwhZNwkIcAZVQFNRbt+4mZwBz/ZFRHdfeQkz XZAADhlM/tXlXLIzvmgNP1d0WNfOAPYf6s2Upq4Q8hUsxmoxezI4TJB64kXXmKwoNqcs pqNMc4+JloHo7/Sjp5V+c1JAODvflLiMMS3fUym+k7RVd4bCjhwOdc/NUWqMXkAv3OSK CnTg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ktpO/jSmoOx5RVisI52DM6PeD/6jBsQ5/HisJypSEHU=; b=SjWKMQ4a9nePSw372rKyWbWHR5tIv/kjOkRrZ+1OkW6j7kmdq5fH+pTlUjlgZzN8QR S/JEYhbQ/Au4+CeJHnf3AywaRypbeV/ZYP/4TcibET3pa0aAflVgYwzBGJJRJN12mzlP GtKQbSywSDpSAX1JfrZVRpeWKVrt2o2uJeLcg9kooPJg/MD8v0OFyykeWsN6uMuWKWV7 KOAyS1k80BYq+oUt5MQ3kZ9MDMdz88IzwFgYiMxq4JbiVzvLFo8NgpxhopA9Mf9adS/M jkUlof1aNDK9Cw/1RjhjE3d9qsFux9zgC3iQIe/BugGW1xQE7/iny7K3UCBIxMVzIvnz PsNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bdgOwBy2; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p26si5980284ejw.139.2021.02.05.14.03.49; Fri, 05 Feb 2021 14:03:49 -0800 (PST) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bdgOwBy2; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229725AbhBEWCw (ORCPT + 7 others); Fri, 5 Feb 2021 17:02:52 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232969AbhBEO5n (ORCPT ); Fri, 5 Feb 2021 09:57:43 -0500 Received: from mail-il1-x129.google.com (mail-il1-x129.google.com [IPv6:2607:f8b0:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A3809C0617A9 for ; Fri, 5 Feb 2021 08:26:53 -0800 (PST) Received: by mail-il1-x129.google.com with SMTP id m20so6291315ilj.13 for ; Fri, 05 Feb 2021 08:26:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ktpO/jSmoOx5RVisI52DM6PeD/6jBsQ5/HisJypSEHU=; b=bdgOwBy2EdlM8UU2CbP0LQUUrUdWj9ErOn2Pypwrr2YlwgXfTIy49IdBEeE/C4Gti8 pWfKw8O2Txoje8FGF+dNElEqJdDUvkOzRflX/T5ZZJB6fVLkOaoLtZw/mVgjhPMnBAeE BPh1fVoyM6VGVVWmkMmRpTrWUSCQMLDzIPU2fnBgWKfrRuGRQje75F7s3vwo6mcqAMe0 qxQ7o8SWtPtOQ5elX/qC05vTjHAbcg43BKrkk217z6x3pygbQzE0G9QXZ4nCzgQHqjbX UxOTqboS0NX4U7sWXbv5WOIPnLMIqqVI9hbHNMhYJHxd1wWF1V9h8rFFPVDaRxW+7+JY bN+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ktpO/jSmoOx5RVisI52DM6PeD/6jBsQ5/HisJypSEHU=; b=lFA1oCiZJHPkZ9ZE3G1UnH1bBw/ybRe+R33/KmOsIqTVTGGCd3GoB4CB5Gi3TWo+P+ URdCCVqtlML1zs+disFBsFqzGqutwIzzZ1U3RqhzpyEKm2QUj0nrM7C4w4vsmqaw5Mak 1aZQOU5BBIx/EvbqpW2xCAKvDh4TA9t6yj2LEJtkE9pTKayEfBwoRt6CsahdNa973HDU cNvGIqru5FUgymtePMrUHOhbE7FZ6RzTFvFG6dfDnlaSAtxaatV2Gx8SXmNA/xlx/GG8 WFWAZs5AhYRe1dTvn/1fk7f/wN9k/fBCLMsOtirAQYilKe+XbcYBivNAbWdpRmRBzWQ/ /ApQ== X-Gm-Message-State: AOAM533R5/qcNdsIhjNgoYrU99ZtbvUDxS5ziP8CW+EKXW2GQiRMHF4t FkoH1fd4JyJOWuxfG3FeeOs2wLlw8X0ttQ== X-Received: by 2002:a05:6602:2c4e:: with SMTP id x14mr4376864iov.58.1612535919991; Fri, 05 Feb 2021 06:38:39 -0800 (PST) Received: from beast.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id h9sm4136882ili.43.2021.02.05.06.38.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Feb 2021 06:38:39 -0800 (PST) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: elder@kernel.org, evgreen@chromium.org, bjorn.andersson@linaro.org, cpratapa@codeaurora.org, subashab@codeaurora.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v2 6/7] net: ipa: get rid of status size constraint Date: Fri, 5 Feb 2021 08:38:28 -0600 Message-Id: <20210205143829.16271-7-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210205143829.16271-1-elder@linaro.org> References: <20210205143829.16271-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org There is a build-time check that the packet status structure is a multiple of 4 bytes in size. It's not clear where that constraint comes from, but the structure defines what hardware provides so its definition won't change. Get rid of the check; it adds no value. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_endpoint.c | 3 --- 1 file changed, 3 deletions(-) -- 2.20.1 diff --git a/drivers/net/ipa/ipa_endpoint.c b/drivers/net/ipa/ipa_endpoint.c index bff5d6ffd1186..7209ee3c31244 100644 --- a/drivers/net/ipa/ipa_endpoint.c +++ b/drivers/net/ipa/ipa_endpoint.c @@ -174,9 +174,6 @@ static bool ipa_endpoint_data_valid(struct ipa *ipa, u32 count, enum ipa_endpoint_name name; u32 limit; - /* Not sure where this constraint come from... */ - BUILD_BUG_ON(sizeof(struct ipa_status) % 4); - if (count > IPA_ENDPOINT_COUNT) { dev_err(dev, "too many endpoints specified (%u > %u)\n", count, IPA_ENDPOINT_COUNT); From patchwork Fri Feb 5 14:38:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 376938 Delivered-To: patch@linaro.org Received: by 2002:a02:b18a:0:0:0:0:0 with SMTP id t10csp2399645jah; Fri, 5 Feb 2021 08:27:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJxUU9ET2DZriFNwkEc1gBZx3RwgFCyWu2F/LSKv5T2uIEGQRukumBpbdTu40D2cjMDUZwcn X-Received: by 2002:a50:fe02:: with SMTP id f2mr4152198edt.195.1612542462321; Fri, 05 Feb 2021 08:27:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612542462; cv=none; d=google.com; s=arc-20160816; b=DFwqkVgzZE9eLh6ZYGJkPSc/B3p16Xln6tyUHtfmqdfCQC18HanM27idZr0eOZQE49 TUx6dcqLFm84yE6WCroA1HQecU2MD9KyFWXINu/s/DMRdzzIAbkEAOsrI9wV/SfKoZD1 Yyue5HdNwRss024gaA3fjygQ+bV1tH/pcAOjYWCODLdr5PIXdcHF7QeviZFm4xqhUCKG gmBh55Pfm95mAfm8dOc5rhThkaHYEp9h7nxobOZ0SknqY8DeMdCui1sjIjvqc23wmLWB l8YTAbn5QqKKkffbjkRWoP5/BGjO1rgziiRE8R2B7AGcTXVkI7sG+Xb8cfbMhQAZrIQY AIyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=8+ck2H8Pw6wgSCqXl5lp8F6E+5zNs1S9ypztUefo5vE=; b=ovl57HgfY4Qy9o42EeJpcghuFOrkEaHwBiJCTvNzI/0cfxHF/Ef/DFuY43XVvGOVYN 9357dLoLc7Kn0zOuD7R5oDz6rHI4Neq4w3rb1hbDpvcOopMriNYXdJp6bbxgkmhW1QDl ZkKgaEbD7S/i4BD+4N3bHZSSQHmUHM+fmTSEBxhGGfPOpDJRQlxQsaFSoP6srzcHnhDD 9wakYluf8kcY9x9dVZHafj0xZMXKlVHa4F0106kUYnsl/lubnIy5hH1IKp+fqA0/BO8g s8wUeMRaBsWau69Q8xiYQIR2+QaBgFGKm9TA1V8AYtvW60lMV7kFxfN95I8owaebnGo8 8Tlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uRg8k3Yj; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m12si5520518ejx.144.2021.02.05.08.27.41; Fri, 05 Feb 2021 08:27:42 -0800 (PST) Received-SPF: pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=uRg8k3Yj; spf=pass (google.com: domain of netdev-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=netdev-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231245AbhBEOrq (ORCPT + 7 others); Fri, 5 Feb 2021 09:47:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231261AbhBEOlY (ORCPT ); Fri, 5 Feb 2021 09:41:24 -0500 Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 54C89C0617AB for ; Fri, 5 Feb 2021 08:19:29 -0800 (PST) Received: by mail-pf1-x42f.google.com with SMTP id j12so4629731pfj.12 for ; Fri, 05 Feb 2021 08:19:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8+ck2H8Pw6wgSCqXl5lp8F6E+5zNs1S9ypztUefo5vE=; b=uRg8k3YjUU6IsLiiIhlzn9AWCPcV4/IAp/ZEAfeGG+ImCWMygj0IZBfQ7gVH70CLSH 97ff0J7fH6wSURs2K965ZD6sWg1r4c5xVlMhWrDaAgJjON6Xb+1mK0m9hDi+LId4DfvW aInXRjPS/iCQusA4QlP7fzT/hcKqUrfXNq2O2geCzmCbg6h9XpjkdBu/TH6oxmTeW3E6 vsztOYoSdXZumasBlAH/6/TFmVsyvBrxCsoDWJO56ItgtXo8z3BaDFtVrpBvZIE7vLrs oBGKZGLb6jgjEmtxr8bxia0AhrARBVDRtjkgAWwS43xSeddxvq+tBk5CrHCV4KAyTpiA q7yQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8+ck2H8Pw6wgSCqXl5lp8F6E+5zNs1S9ypztUefo5vE=; b=oHn8+/iy3B4EIOTuU7d+aRhULzazzzoIb6c40p33/grWi12j7+rYcOjPnzGeb6sKac dz/2HCkh8VjlZZFY/TA6rVvnwsshIFa//4oxBE1Dwl9LbocUc39cGpVIeWX9oVbnfGXG 3419DGEIDzchDQMsFXTJbIulmgR7L+AOB5NgDyjBk9Sdp+L/qnVzSmWLPJvWf1tVadWs Rzl2RT5mM8IjYFLguHzN1lmsUo+g+lfCh+gmJ5qAazZhiTHyhZiuPlo3ltBn+4A36FH0 rYgj26TO5szGaUk43Mp254WdO8vUB6x5SzLb4KPSR4ISOE2Jsv/enjleDVagXzVI7+F+ Hv1A== X-Gm-Message-State: AOAM531K/3LW2VDi52HH/iHKpRT0A8cfYZSBY5n6imK1I7jwrOaU3KTU Grfk6aFifpu0q0D/SKPYcqDEXnWB6hRfJw== X-Received: by 2002:a05:6602:154e:: with SMTP id h14mr4291585iow.1.1612535921035; Fri, 05 Feb 2021 06:38:41 -0800 (PST) Received: from beast.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id h9sm4136882ili.43.2021.02.05.06.38.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Feb 2021 06:38:40 -0800 (PST) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: elder@kernel.org, evgreen@chromium.org, bjorn.andersson@linaro.org, cpratapa@codeaurora.org, subashab@codeaurora.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v2 7/7] net: ipa: avoid field overflow Date: Fri, 5 Feb 2021 08:38:29 -0600 Message-Id: <20210205143829.16271-8-elder@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210205143829.16271-1-elder@linaro.org> References: <20210205143829.16271-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org It's possible that the length passed to ipa_header_size_encoded() is larger than what can be represented by the HDR_LEN field alone (starting with IPA v4.5). If we attempted that, u32_encode_bits() would trigger a build-time error. Avoid this problem by masking off high-order bits of the value encoded as the lower portion of the header length. The same sort of problem exists in ipa_metadata_offset_encoded(), so implement the same fix there. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_reg.h | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) -- 2.20.1 diff --git a/drivers/net/ipa/ipa_reg.h b/drivers/net/ipa/ipa_reg.h index e6b0827a244ec..732e691e9aa62 100644 --- a/drivers/net/ipa/ipa_reg.h +++ b/drivers/net/ipa/ipa_reg.h @@ -408,15 +408,18 @@ enum ipa_cs_offload_en { static inline u32 ipa_header_size_encoded(enum ipa_version version, u32 header_size) { + u32 size = header_size & field_mask(HDR_LEN_FMASK); u32 val; - val = u32_encode_bits(header_size, HDR_LEN_FMASK); - if (version < IPA_VERSION_4_5) + val = u32_encode_bits(size, HDR_LEN_FMASK); + if (version < IPA_VERSION_4_5) { + /* ipa_assert(header_size == size); */ return val; + } /* IPA v4.5 adds a few more most-significant bits */ - header_size >>= hweight32(HDR_LEN_FMASK); - val |= u32_encode_bits(header_size, HDR_LEN_MSB_FMASK); + size = header_size >> hweight32(HDR_LEN_FMASK); + val |= u32_encode_bits(size, HDR_LEN_MSB_FMASK); return val; } @@ -425,15 +428,18 @@ static inline u32 ipa_header_size_encoded(enum ipa_version version, static inline u32 ipa_metadata_offset_encoded(enum ipa_version version, u32 offset) { + u32 off = offset & field_mask(HDR_OFST_METADATA_FMASK); u32 val; - val = u32_encode_bits(offset, HDR_OFST_METADATA_FMASK); - if (version < IPA_VERSION_4_5) + val = u32_encode_bits(off, HDR_OFST_METADATA_FMASK); + if (version < IPA_VERSION_4_5) { + /* ipa_assert(offset == off); */ return val; + } /* IPA v4.5 adds a few more most-significant bits */ - offset >>= hweight32(HDR_OFST_METADATA_FMASK); - val |= u32_encode_bits(offset, HDR_OFST_METADATA_MSB_FMASK); + off = offset >> hweight32(HDR_OFST_METADATA_FMASK); + val |= u32_encode_bits(off, HDR_OFST_METADATA_MSB_FMASK); return val; }