From nobody Sat Apr 11 00:43:25 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DE81CC00140 for ; Thu, 18 Aug 2022 13:43:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243213AbiHRNn2 (ORCPT ); Thu, 18 Aug 2022 09:43:28 -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-Google-Smtp-Source: AA6agR4jTgrZJP0jHnhpoEcJLuhZqFp9nVJLbFrYqbcB6Yo9V3tEpfH7+LK6oECe9AWPfVpNq4DZyQ== 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: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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, siz= e_t size) } =20 /* Align the address down and the size up to a page boundary */ - addr =3D qcom_smem_virt_to_phys(virt) & PAGE_MASK; + addr =3D qcom_smem_virt_to_phys(virt); phys =3D addr & PAGE_MASK; size =3D PAGE_ALIGN(size + addr - phys); iova =3D phys; /* We just want a direct mapping */ --=20 2.34.1