Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp477171rwb; Thu, 18 Aug 2022 07:08:38 -0700 (PDT) X-Google-Smtp-Source: AA6agR5msY9/GbM4S4cckDdAajadNcpxBj2cxtkO8qurFTCzzJz+iRrwBpwP9fPhOXD2tKZlgxUy X-Received: by 2002:a63:1205:0:b0:41c:cd74:a743 with SMTP id h5-20020a631205000000b0041ccd74a743mr2617565pgl.418.1660831718595; Thu, 18 Aug 2022 07:08:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660831718; cv=none; d=google.com; s=arc-20160816; b=zWcCpCdKAAQBkQwcbZgn5mNDKw1mbnRmjuT2t2xCN3vGbKs1jJzSJT1mkhAml3hDZK avT56ZGUeflIVCdTxDUr+kpRQjrpP80lKkWPS+qWDp2oOYbylFHGB2QgRlc6J8q+uwCw iHxqcLgvNUOSINCo5RNZerpEHr6gaBI+PG3GabWLV0nncBG8v7W3yzSLKDY3HjqdamnK m06ebmOxWmMcO6Zy0jn3dtOoMIcMtmf6Ac3DBoM9NEg+bDUJe5DwwZbcryAUEeAsJAw6 Qicg9SNUmRgHn4qWWmPY0GOCzx0Rcn62XW7+FikObjaBYqD/voh1dr9Hnjqpk7LWhi10 OFzQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=fEl5/MZkqTMXgHOWXV9A2H8cNKuuMZWcnutD4sufu6s=; b=rKHXmnWT5fPRK9r/6iQZQj01/glUvC6pzgCrO6koxzulMITKQ2yKtl6rHAPEx1QO1+ H2JAeAvNCWL4spI2hmktzZyw0+kWSB+9+2xAWCOb2HmJ68o3zTzY6Yr+cWpc3ZFQg/nw pCYbCUtlyenXUYMJD1f7A7qvXNL1+xDilxpm/nBgWGZmvGS5MXoHlGfOn7MvCEEGvxj7 /BI098NegO3Li1oqhkGAwsiTPHVNjRytXtcTsEi69jklxJMqH2ewBqlS0o6C5ULgMiv9 qWRaKkMhgjHNAX54u6xH4swNswn2C/qyb+LNwX36RsURpnZ49fn8yS/vHxujREPKw3Iy q9rA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ht8Gx8e2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n3-20020a170902d2c300b00172883f5a2asi1254343plc.624.2022.08.18.07.08.27; Thu, 18 Aug 2022 07:08:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ht8Gx8e2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-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 S239109AbiHRNn1 (ORCPT + 99 others); Thu, 18 Aug 2022 09:43:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245183AbiHRNnE (ORCPT ); Thu, 18 Aug 2022 09:43:04 -0400 Received: from mail-qt1-x829.google.com (mail-qt1-x829.google.com [IPv6:2607:f8b0:4864:20::829]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 79244B69D4 for ; Thu, 18 Aug 2022 06:42:10 -0700 (PDT) Received: by mail-qt1-x829.google.com with SMTP id y18so1104281qtv.5 for ; Thu, 18 Aug 2022 06:42:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc; bh=fEl5/MZkqTMXgHOWXV9A2H8cNKuuMZWcnutD4sufu6s=; b=ht8Gx8e2Ikbg0xL5tTN9yUSBAnaJAa9W+z/ivanBDORHCh4gJXk+iF7rZkapcUDT97 cCmTExnGDOR9IyskxbtWp08xaDh3dXDI7lw1zQ16mvB58eixGo3bnK3wmWUnIyTG3mva dR0MOIH3M+4e60hYD3I23ne5WHqUAlfnrkrWBr/UYhBj/YG38gSvDtoT02LIqlVHXFT9 dgB13Ynn/hKXojCTppcehXAS8KXH/jdUdZBkG3rZGwTczQtTx2ZbC7RSxznJoDhPcw39 GoIx8Oad3MeL0EhBMfmiGLoupUgz999ABEz+WE1VR5atJcn7BGnfuQpJGhBvNDKDkEJh Fkyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc; bh=fEl5/MZkqTMXgHOWXV9A2H8cNKuuMZWcnutD4sufu6s=; b=YNkg/0f8yEdq6zSkSJAoNZ7JTnfImAKNBun+UuTDYWjtZSfUEl0kk0uUrcZWnExhGi TgAdqTK+tHcTLkRr9U+3pezxE+rX4HPRA7JiWcm7w/sb3RV4uD6Yv2Nf88aWz9+bt2dZ nTIkHYnCJ9DlxS1LwpmWJyWf5ISmvg03pjtU6TsV334AjwAVg/7iopjrHihRZnwvHLfC Zi662BDkidciM8//aDK+buBTotWlALOhQFjTU5ZZL455rp0o1R6SdOU+wUGtitz6fctn j43yVxHoDuSiSmd3/VyFDpEITMrStPtB5qfOUMEWPeTMjcDhfaIu+s/PHazBGimKQxLa 3udA== X-Gm-Message-State: ACgBeo2ElqLQU8B52JGdEoVMiP2mR7wymYw3wwGjrV3FNEizDG69GZ2U gedwLVZtd0hLeRsQQg54+1pCYQ== X-Received: by 2002:a05:622a:44c:b0:343:7b8e:2cb with SMTP id o12-20020a05622a044c00b003437b8e02cbmr2527312qtx.617.1660830129554; Thu, 18 Aug 2022 06:42:09 -0700 (PDT) Received: from localhost.localdomain ([98.61.227.136]) by smtp.gmail.com with ESMTPSA id bm30-20020a05620a199e00b006bb11f9a859sm1493430qkb.122.2022.08.18.06.42.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Aug 2022 06:42:09 -0700 (PDT) From: Alex Elder To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: mka@chromium.org, evgreen@chromium.org, bjorn.andersson@linaro.org, quic_cpratapa@quicinc.com, quic_avuyyuru@quicinc.com, quic_jponduru@quicinc.com, quic_subashab@quicinc.com, elder@kernel.org, netdev@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net] net: ipa: don't assume SMEM is page-aligned Date: Thu, 18 Aug 2022 08:42:05 -0500 Message-Id: <20220818134206.567618-1-elder@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In ipa_smem_init(), a Qualcomm SMEM region is allocated (if needed) and then its virtual address is fetched using qcom_smem_get(). The physical address associated with that region is also fetched. The physical address is adjusted so that it is page-aligned, and an attempt is made to update the size of the region to compensate for any non-zero adjustment. But that adjustment isn't done properly. The physical address is aligned twice, and as a result the size is never actually adjusted. Fix this by *not* aligning the "addr" local variable, and instead making the "phys" local variable be the adjusted "addr" value. Fixes: a0036bb413d5b ("net: ipa: define SMEM memory region for IPA") Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_mem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ipa/ipa_mem.c b/drivers/net/ipa/ipa_mem.c index 1e9eae208e44f..53a1dbeaffa6d 100644 --- a/drivers/net/ipa/ipa_mem.c +++ b/drivers/net/ipa/ipa_mem.c @@ -568,7 +568,7 @@ static int ipa_smem_init(struct ipa *ipa, u32 item, size_t size) } /* Align the address down and the size up to a page boundary */ - addr = qcom_smem_virt_to_phys(virt) & PAGE_MASK; + addr = qcom_smem_virt_to_phys(virt); phys = addr & PAGE_MASK; size = PAGE_ALIGN(size + addr - phys); iova = phys; /* We just want a direct mapping */ -- 2.34.1