From patchwork Sat Oct 31 11:36:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 320055 Delivered-To: patch@linaro.org Received: by 2002:a92:7b12:0:0:0:0:0 with SMTP id w18csp2187989ilc; Sat, 31 Oct 2020 04:41:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwc83E1fc5A3U1n5mRurkpJ0RK54QQhh6iG+IL4e+pa3RXvyrz/bxOqPcKWQbQ0jiapZtGx X-Received: by 2002:a17:907:2662:: with SMTP id ci2mr6633923ejc.554.1604144506060; Sat, 31 Oct 2020 04:41:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1604144506; cv=none; d=google.com; s=arc-20160816; b=zVi3VsTF10JABnmoh9oUvn4SYJnMmz+kiGpFsm7hU8ZScXAQdRfWKNTyEgK76kDzb/ vCBWahIew+Ma8706qCL3bHVOmLP7gkl3sLusjCG6Kt1f6AxzMaHW09VO41SkENqK+/zS edLjkX7fr4FRkgDq5zi3LuNX7I1LsiyEC8tuapUbYs5BeaHGaFu+N34OJ5O9FnHnc6x0 9MWQ5TpstAsx0TEsSq55Dv0fxX1RyvZnRBNxxE4lsOk0VtHkKPbOl8C4Smzmhv9epKmm F7wroNB6mOtopssLKA1Rs6zC7nuNw/MsXWuK+HudyqfW1uWC2Rfv35tdemBQbrBXr+S1 m6Og== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=21hYG7lMfQLe1toXSnAuwIWeyFWAmz10pQmFPjSS+qs=; b=0zkNoejCrwhYp2Sns59Pk9rlHP6c/QpRUR7XxHB7526+wfq8H694QEvUlOpXqQVdMw c2Cf6SXsuYOnIdi/Vp+jlNZY9AygegC/76Ic4Wzouw3sFyfJ8WuhSjh9bpf7KJIJ0dK8 Jnp/fQcPCpjXUxzKLy4TuhkNos2DTD9in753XzMLag4zOnE2b7V4qMmdvPy/psuFOP7H E7d0J901h0ijWAo342SxSSWrsiQhBjF3keCmz7xf0smE8mUGEEpPyNKCHL/DLoZIgEd4 64d7IIqjqgRzMwnFf/ShClnwdFqhZ1Lno9GjlsKH+vzeAIJs7Og6eynt+NO1VYYkGwsr 0FvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vftPKv1t; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z26si3785824eje.469.2020.10.31.04.41.45; Sat, 31 Oct 2020 04:41:46 -0700 (PDT) Received-SPF: pass (google.com: domain of stable-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=@kernel.org header.s=default header.b=vftPKv1t; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727309AbgJaLlo (ORCPT + 15 others); Sat, 31 Oct 2020 07:41:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:40898 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727713AbgJaLln (ORCPT ); Sat, 31 Oct 2020 07:41:43 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (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 2B4D820731; Sat, 31 Oct 2020 11:41:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1604144502; bh=RGwWFbdTSeMYnT/6ONWYsBZIACDMa+Zj1OA7PoJPVqU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vftPKv1tn+SOok/HnrzQulc9JLWbhPxsTzN0va0f1hi8Zzba9FLJWhZoWWRAy9o38 8omgGlLS2Y6inLyQgIX7JUiPhwfKQjO2JTOActOLcXNBeaRau9Mmqf8lzJTO8VQ/QI MVj4RwbCvxRfy3YEA99H9KKhPCx338UIIeXScs0Y= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Stephen Boyd , Alex Elder , Jakub Kicinski Subject: [PATCH 5.8 42/70] net: ipa: command payloads already mapped Date: Sat, 31 Oct 2020 12:36:14 +0100 Message-Id: <20201031113501.512901001@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201031113459.481803250@linuxfoundation.org> References: <20201031113459.481803250@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Alex Elder [ Upstream commit df833050cced27e1b343cc8bc41f90191b289334 ] IPA transactions describe actions to be performed by the IPA hardware. Three cases use IPA transactions: transmitting a socket buffer; providing a page to receive packet data; and issuing an IPA immediate command. An IPA transaction contains a scatter/gather list (SGL) to hold the set of actions to be performed. We map buffers in the SGL for DMA at the time they are added to the transaction. For skb TX transactions, we fill the SGL with a call to skb_to_sgvec(). Page RX transactions involve a single page pointer, and that is recorded in the SGL with sg_set_page(). In both of these cases we then map the SGL for DMA with a call to dma_map_sg(). Immediate commands are different. The payload for an immediate command comes from a region of coherent DMA memory, which must *not* be mapped for DMA. For that reason, gsi_trans_cmd_add() sort of hand-crafts each SGL entry added to a command transaction. This patch fixes a problem with the code that crafts the SGL entry for an immediate command. Previously a portion of the SGL entry was updated using sg_set_buf(). However this is not valid because it includes a call to virt_to_page() on the buffer, but the command buffer pointer is not a linear address. Since we never actually map the SGL for command transactions, there are very few fields in the SGL we need to fill. Specifically, we only need to record the DMA address and the length, so they can be used by __gsi_trans_commit() to fill a TRE. We additionally need to preserve the SGL flags so for_each_sg() still works. For that we can simply assign a null page pointer for command SGL entries. Fixes: 9dd441e4ed575 ("soc: qcom: ipa: GSI transactions") Reported-by: Stephen Boyd Tested-by: Stephen Boyd Signed-off-by: Alex Elder Link: https://lore.kernel.org/r/20201022010029.11877-1-elder@linaro.org Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- drivers/net/ipa/gsi_trans.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) --- a/drivers/net/ipa/gsi_trans.c +++ b/drivers/net/ipa/gsi_trans.c @@ -398,15 +398,24 @@ void gsi_trans_cmd_add(struct gsi_trans /* assert(which < trans->tre_count); */ - /* Set the page information for the buffer. We also need to fill in - * the DMA address and length for the buffer (something dma_map_sg() - * normally does). + /* Commands are quite different from data transfer requests. + * Their payloads come from a pool whose memory is allocated + * using dma_alloc_coherent(). We therefore do *not* map them + * for DMA (unlike what we do for pages and skbs). + * + * When a transaction completes, the SGL is normally unmapped. + * A command transaction has direction DMA_NONE, which tells + * gsi_trans_complete() to skip the unmapping step. + * + * The only things we use directly in a command scatter/gather + * entry are the DMA address and length. We still need the SG + * table flags to be maintained though, so assign a NULL page + * pointer for that purpose. */ sg = &trans->sgl[which]; - - sg_set_buf(sg, buf, size); + sg_assign_page(sg, NULL); sg_dma_address(sg) = addr; - sg_dma_len(sg) = sg->length; + sg_dma_len(sg) = size; info = &trans->info[which]; info->opcode = opcode;