From patchwork Thu Mar 18 18:59: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: 404050 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp733487jai; Thu, 18 Mar 2021 12:00:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyGd3ZzIwpWeuIDIh54ncV87t9DVESOLpmEhair0ep6EQ0Ba3jntLFF3NzKlbgb4WFnZnzk X-Received: by 2002:a17:906:7d7:: with SMTP id m23mr20986ejc.205.1616094030383; Thu, 18 Mar 2021 12:00:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616094030; cv=none; d=google.com; s=arc-20160816; b=v71DGIn/6Iecn6McUwGoIrXcp6qNr4hJbN1M6bTPuRe/V602Ssl+TKr2YY0jPETyGz +76FLJxdFkE7ZrNru3fIFU+sF8op8Ktg4VoLOwmJ/UHFvwWEtr9EUQ8nyVlTGSOCXbeJ 4+44ph2EsGEd8bWDVaVjgmmrpbYav4zezAVtF4Kw5a93wDxJqyeXZNJbMo7C1kTDDSrC 20+C5tiSAoTB0zSLZsYnYC2cmIQ7gva0Wl+0b/s4eqlkMTpeQzNYbjQl1eOnpUO89xbM bc8iMtUjdtWUGekY96anexBTl8OdXwUVc8d+kPv3gncexR60l0Tls7Sv0FPbf5JWnRAR vJ0Q== 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=NoHvO3wchc4QiGr0Z8Rd6w2XPY+8jpERYxAd8J28b3U=; b=rnLarVuIHpVjqD+y8Kj+QrxQXmm1I4pOvMx+UCCcPsQgZbpzW/lZWkBhkT4K9STwbW 5+gyPPxi26KvNyGGyn+6dmmabF4sDFbuk+xmKQgRZQEMK/cK5PdWo7VG0Nw5Vbf0Eu5j uv0Xzdulf0Cua7ILVH+JWU/lpErXiyWNcwcnYFnYylvFACV8FKWGWvd1p9Gg6pF62AvT jVfsARwvB3RRGu4o4m7fYsSSo6qKpWCcOtUpyruqzQz04YpAGs6YWXapeHjUe9g9Ah5A Zii+At/799eLVZc05eGkAzVD4Zdka5NGuE0oIXKJ6VUkmThdpn1AwHERy+RDmvxCK8ak zDEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Iuje5TVV; 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 u19si2210823edo.583.2021.03.18.12.00.30; Thu, 18 Mar 2021 12:00:30 -0700 (PDT) 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=Iuje5TVV; 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 S232773AbhCRS76 (ORCPT + 8 others); Thu, 18 Mar 2021 14:59:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232798AbhCRS7f (ORCPT ); Thu, 18 Mar 2021 14:59:35 -0400 Received: from mail-io1-xd33.google.com (mail-io1-xd33.google.com [IPv6:2607:f8b0:4864:20::d33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 26D4EC06174A for ; Thu, 18 Mar 2021 11:59:35 -0700 (PDT) Received: by mail-io1-xd33.google.com with SMTP id x16so3431615iob.1 for ; Thu, 18 Mar 2021 11:59:35 -0700 (PDT) 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=NoHvO3wchc4QiGr0Z8Rd6w2XPY+8jpERYxAd8J28b3U=; b=Iuje5TVVQLo2HdoFWWdCTEDM/bfVR+9L5wlLvp5vAvMrnmZjuB3QgfYXNwgrl7bGuE DLm0N2NTK7OZAyhJpkqDcGf0fkU52Wnq1tiD7JQgG9EbG1Xc2T5ZXpQi4HoburkF2Z0B 2VoG5HcP+n0UzCGKVKlG3GY9FPOjV787gHATl+ATnt18dW9qa29vb31DR+xKO1ljy6cw D46nTRTYxHYG9YmMSgg6n08x3DLtr9NI+fEViRmAOyhMUtkhoYW0WEBxaxSlXbnyDPac ZcWn8y8CX1DTYishjAKHg6OfC8Qed3urvFNx059a0GARtPgBS73WF/5V2rVKLih/fdOv YbYQ== 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=NoHvO3wchc4QiGr0Z8Rd6w2XPY+8jpERYxAd8J28b3U=; b=j10ciHWsvXz4f2FpF8K0EZ/LQesGb+Ke120aiavwa3j9yk3nqFCEKM6Z9YdtcQX021 ld0afWq2j0gh18kESJF8f/ouLGdDx8HAkeHIOX8ma19Mq9PoMt6eS2/pFsYz0SbVpEnw KEpLYEVg9TG1p+BC6hTrlrRxZ30ufUWzOBICKT4+60RVqXGINngHmDQGSlffu2pdSpfm cQCjuoXrgZPXbDcene08lOTe/ekEu2stU9rUHEQ9+7oTTXMQy893M9frCaNnDSF+iU6Y mLUib7ZCTMyTQlnxQ0uAXmz1iDoKsisnR0v/M36PHdABUrtxkRpsW7fg2y5i3q9J60qp LO6w== X-Gm-Message-State: AOAM531N8l0O9FbAcc4O2DMOdMDN3e1lYSWbC23ql7Is/5XczjxW0qD/ opAJODKmmZ5cb7OXbIifbOx2AQ== X-Received: by 2002:a6b:ec08:: with SMTP id c8mr13000ioh.55.1616093974646; Thu, 18 Mar 2021 11:59:34 -0700 (PDT) Received: from localhost.localdomain (c-73-185-129-58.hsd1.mn.comcast.net. [73.185.129.58]) by smtp.gmail.com with ESMTPSA id k7sm770359ils.35.2021.03.18.11.59.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 Mar 2021 11:59:34 -0700 (PDT) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: f.fainelli@gmail.com, bjorn.andersson@linaro.org, evgreen@chromium.org, cpratapa@codeaurora.org, subashab@codeaurora.org, elder@kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v3 1/4] net: ipa: fix assumptions about DMA address size Date: Thu, 18 Mar 2021 13:59:27 -0500 Message-Id: <20210318185930.891260-2-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210318185930.891260-1-elder@linaro.org> References: <20210318185930.891260-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Some build time checks in ipa_table_validate_build() assume that a DMA address is 64 bits wide. That is more restrictive than it has to be. A route or filter table is 64 bits wide no matter what the size of a DMA address is on the AP. The code actually uses a pointer to __le64 to access table entries, and a fixed constant IPA_TABLE_ENTRY_SIZE to describe the size of those entries. Loosen up two checks so they still verify some requirements, but such that they do not assume the size of a DMA address is 64 bits. Signed-off-by: Alex Elder --- drivers/net/ipa/ipa_table.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) -- 2.27.0 diff --git a/drivers/net/ipa/ipa_table.c b/drivers/net/ipa/ipa_table.c index 7450e27068f19..dd07fe9dd87a3 100644 --- a/drivers/net/ipa/ipa_table.c +++ b/drivers/net/ipa/ipa_table.c @@ -126,13 +126,15 @@ static void ipa_table_validate_build(void) */ BUILD_BUG_ON(ARCH_DMA_MINALIGN % IPA_TABLE_ALIGN); - /* Filter and route tables contain DMA addresses that refer to - * filter or route rules. We use a fixed constant to represent - * the size of either type of table entry. Code in ipa_table_init() - * uses a pointer to __le64 to initialize table entriews. + /* Filter and route tables contain DMA addresses that refer + * to filter or route rules. But the size of a table entry + * is 64 bits regardless of what the size of an AP DMA address + * is. A fixed constant defines the size of an entry, and + * code in ipa_table_init() uses a pointer to __le64 to + * initialize tables. */ - BUILD_BUG_ON(IPA_TABLE_ENTRY_SIZE != sizeof(dma_addr_t)); - BUILD_BUG_ON(sizeof(dma_addr_t) != sizeof(__le64)); + BUILD_BUG_ON(sizeof(dma_addr_t) > IPA_TABLE_ENTRY_SIZE); + BUILD_BUG_ON(sizeof(__le64) != IPA_TABLE_ENTRY_SIZE); /* A "zero rule" is used to represent no filtering or no routing. * It is a 64-bit block of zeroed memory. Code in ipa_table_init()