From patchwork Wed Mar 17 22:29:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 403224 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp866834jai; Wed, 17 Mar 2021 15:30:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzp+YBsyYYinLNZdBabNVf6FpfoqP4QdDGHpK5lX83hjFT+N08ckGI43HyB2fJsAzIQoa66 X-Received: by 2002:a05:6402:2215:: with SMTP id cq21mr45816960edb.281.1616020249354; Wed, 17 Mar 2021 15:30:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616020249; cv=none; d=google.com; s=arc-20160816; b=0rW9nSTlKjB4ihAQvL81O0cz7IUMql1lEm+ERHT3DbvPg8gk5kKIBVhM2jw5Z8VCq3 VtCLdwZyz4IlAEXbuf+DLXFE2OdzYt0j0O4rMYSpQIwVxCMo0IIqnRkFtXA7tE86cHrW 4BH8HSED5rU+qahwYFSq89SJ7Myw5xH1ycMNnycHPI6Q30r8GSCb58rnILcDQPXH9DrE CaMSkIai6CP/94XIo/nF0nyHgocIj8JTXiknFwqRAIHxZ814hrKtq7pcYlCStrZKHPWy 5UAiXcyuqwxZKY1zWNKKRHllAIjf9CglFpw8rn0XQ4YiVoTZsKZgDDt2EKvBHiEf5HCx QBaw== 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=bzduqesNyjPNy/1mWpQa5IsmwasAg4tlgXssFjc1C9k=; b=TUZXQzOOotFayKrf+/77kFZN/A6giM5F0biwZzArwBq3v87dst69+SD4HchfQnMAlu gyQBjAYpxud4m3t1EVopBIiaFHFn01SjZqv8Q6iLN7uDh58AkKWPCCm9ChCB4WzSeKkQ M9Txc0j+Wau7YTwWqhybVM3EPmrTRr5IyOYLk5yjgSkQMoCc5wvjWmTbxu7Tyg8HuwdX mqJb3j0gyY0ZsBY8rucYrJi4B3XSpSTtgLfCGhiaTbc6jNkXOMH4lZyMIWu2G5G9a5A1 uelX6cy/6wLBlfeB5u4/voR9zpMaId1i5PbY9jPzKmKpZnIfZIIPqHz2G2ssNf9+6py0 aJLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=s9EKsfQ+; 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 q17si129626ejj.672.2021.03.17.15.30.49; Wed, 17 Mar 2021 15:30:49 -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=s9EKsfQ+; 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 S231474AbhCQWaQ (ORCPT + 8 others); Wed, 17 Mar 2021 18:30:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46114 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231322AbhCQW3x (ORCPT ); Wed, 17 Mar 2021 18:29:53 -0400 Received: from mail-io1-xd2e.google.com (mail-io1-xd2e.google.com [IPv6:2607:f8b0:4864:20::d2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D67C9C06174A for ; Wed, 17 Mar 2021 15:29:52 -0700 (PDT) Received: by mail-io1-xd2e.google.com with SMTP id k8so236069iop.12 for ; Wed, 17 Mar 2021 15:29:52 -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=bzduqesNyjPNy/1mWpQa5IsmwasAg4tlgXssFjc1C9k=; b=s9EKsfQ+8ayTPBV8HzWfcuM18JvhhpmjfB+c7EFu/EXaJGjE8xY4z6w2IVAGuYeH/q ropBOGzgfJIPT3XiHAITBxlzeM1iN0EVh0Hk2fcfw6uk7NOlR5WyzveSTLxtCxNY5I6d z/QmzvkNehgF4Pi3gZJFve4FzGzjNtcT6++qtuVI59O2PGEV4nzaHbm7jebR3ObckH/2 y7gVu+/Qogf9locgp8VaJrX24l6IQiL5DCz0RmcsTeUXrLB6QznNRWesBmjlcOLmnAEL p5m4Ybl63Bh09VYRA5TiEZ5IcOvvaykm0BFw/yaxFB1Lm4FLR3sbNHJkUQHsVTXnLaSM hMBg== 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=bzduqesNyjPNy/1mWpQa5IsmwasAg4tlgXssFjc1C9k=; b=VEHuv3TH1uNTYTQikb1BzNt7e4Vs6xpxWJGJj22me+7Y+O2vjUYMAA5g5NM1K4gs7V BMlaUh1oXbHVjrAZblwMfU7wy9mfuzYJWxwmYmppikMwHhwiugyLv59WQvSnjb6J9ep6 zyDoCl7Em3tnqSpOZxL715lOZT1flZ/dM991ZQvixXqIoVZAOoCQCTmcruR7VRr8bPe2 PJJCIDwU9DKcCV+uWHB1xMKpj1/QApT/yM8a7a8C+BZaqqfdxGq+7KPLKnHt4oajmsLY s6+NZeYNYhQWjUflOEFAqJTIvsRGqmdytMleRy0w0vkY2dCFqoaj/eLQ+dqgTfG8BS/Z bkIg== X-Gm-Message-State: AOAM532Qk0wgtnqfZS/oxSwo/V85QGSGOB1EWZpONbABKXHoZXHYNItS srpfNb2r9OO5S1yB2WSFf+am5Q== X-Received: by 2002:a02:7410:: with SMTP id o16mr4632619jac.37.1616020192373; Wed, 17 Mar 2021 15:29:52 -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 f3sm176405ilk.74.2021.03.17.15.29.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Mar 2021 15:29:52 -0700 (PDT) From: Alex Elder To: davem@davemloft.net, kuba@kernel.org Cc: 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 2/4] net: ipa: introduce dma_addr_high32() Date: Wed, 17 Mar 2021 17:29:44 -0500 Message-Id: <20210317222946.118125-3-elder@linaro.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210317222946.118125-1-elder@linaro.org> References: <20210317222946.118125-1-elder@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Create a new helper function to encapsulate extracting the high-order 32 bits of a DMA address. It returns 0 for builds in which a DMA address is not 64 bits. This avoids doing a 32-position shift on a DMA address if it happens not to be 64 bits wide. Signed-off-by: Alex Elder --- drivers/net/ipa/gsi.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) -- 2.27.0 diff --git a/drivers/net/ipa/gsi.c b/drivers/net/ipa/gsi.c index 2119367b93ea9..53698c64cf882 100644 --- a/drivers/net/ipa/gsi.c +++ b/drivers/net/ipa/gsi.c @@ -688,6 +688,16 @@ static void gsi_evt_ring_doorbell(struct gsi *gsi, u32 evt_ring_id, u32 index) iowrite32(val, gsi->virt + GSI_EV_CH_E_DOORBELL_0_OFFSET(evt_ring_id)); } +/* Encapsulate extracting high-order 32 bits of DMA address */ +static u32 dma_addr_high32(dma_addr_t addr) +{ +#ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT + return (u32)(addr >> 32); +#else /* !CONFIG_ARCH_DMA_ADDR_T_64BIT */ + return 0; +#endif /* !CONFIG_ARCH_DMA_ADDR_T_64BIT */ +} + /* Program an event ring for use */ static void gsi_evt_ring_program(struct gsi *gsi, u32 evt_ring_id) { @@ -711,7 +721,7 @@ static void gsi_evt_ring_program(struct gsi *gsi, u32 evt_ring_id) val = evt_ring->ring.addr & GENMASK(31, 0); iowrite32(val, gsi->virt + GSI_EV_CH_E_CNTXT_2_OFFSET(evt_ring_id)); - val = evt_ring->ring.addr >> 32; + val = dma_addr_high32(evt_ring->ring.addr); iowrite32(val, gsi->virt + GSI_EV_CH_E_CNTXT_3_OFFSET(evt_ring_id)); /* Enable interrupt moderation by setting the moderation delay */ @@ -819,7 +829,7 @@ static void gsi_channel_program(struct gsi_channel *channel, bool doorbell) val = channel->tre_ring.addr & GENMASK(31, 0); iowrite32(val, gsi->virt + GSI_CH_C_CNTXT_2_OFFSET(channel_id)); - val = channel->tre_ring.addr >> 32; + val = dma_addr_high32(channel->tre_ring.addr); iowrite32(val, gsi->virt + GSI_CH_C_CNTXT_3_OFFSET(channel_id)); /* Command channel gets low weighted round-robin priority */