From patchwork Tue Apr 19 14:55:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 66101 Delivered-To: patch@linaro.org Received: by 10.140.93.198 with SMTP id d64csp1897687qge; Tue, 19 Apr 2016 07:55:46 -0700 (PDT) X-Received: by 10.98.28.206 with SMTP id c197mr4576374pfc.131.1461077746000; Tue, 19 Apr 2016 07:55:46 -0700 (PDT) Return-Path: Received: from ml01.01.org (ml01.01.org. [198.145.21.10]) by mx.google.com with ESMTPS id fn8si10532753pab.197.2016.04.19.07.55.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 Apr 2016 07:55:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) client-ip=198.145.21.10; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 9EE9A1A2262; Tue, 19 Apr 2016 07:55:44 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received: from mail-wm0-x22f.google.com (mail-wm0-x22f.google.com [IPv6:2a00:1450:400c:c09::22f]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id BB5DB1A21AE for ; Tue, 19 Apr 2016 07:55:42 -0700 (PDT) Received: by mail-wm0-x22f.google.com with SMTP id u206so34198660wme.1 for ; Tue, 19 Apr 2016 07:55:42 -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; bh=PSqeehaM5Z7vRSByaBqryK43Lo3PEvpY1p8vT4wDmLQ=; b=jr2OftgMrqNYG3ujK4/4rsc+EEfbHLV0XfKK7/xywcUTNzouKb20V2NdggPzfIOY/B VFWmwNsX5pGWfe4O2x14Xg4PZ9hp5spbil8MJdYpmx6Vjl+mVS4aXYZHP0Cm8O+++QSF BBwraMXUBVt7TKg6wpa/OObwfF9l1Cq5UoX5Q= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=PSqeehaM5Z7vRSByaBqryK43Lo3PEvpY1p8vT4wDmLQ=; b=Tu5Q7joLYAp72qO5P3qPgoX+0nKR94w8pKP2wwVZQ11rEuIx6J/nYZ36M7cpr4+GGM Bk7Af79YC5qjS+mGeac2gOqyoHZdv7fByyCejb8vpZ9DLLlrM5JWfC/2CzHu0TvGlyYr NlL9ErTDB4D5NyRV/fUvoMtXSWkVoao4e80rnN4+hgmpDq2X1X4C0gnYhBYhFaBDsTXP KQNCBdiTCbCrSajIJsxxLGSVqhGB1hsBH2TQD8Gk9b4jqETwcK4NnEetiqYJNGk00Yud jl0pbm/mywWyy3xbHCwMGxXYvqnQbfm2E0XRCjXprEiJ8VPCmQVGhrUIjQ8KFXDoFeCg uMHg== X-Gm-Message-State: AOPr4FXSzVLd+bJH3l+QFqBcm1P+4dnFkSODZDdGuZ5DyaZxSn19OdBgDgm0XpytdmjR9Rt6 X-Received: by 10.28.95.131 with SMTP id t125mr25736225wmb.80.1461077741342; Tue, 19 Apr 2016 07:55:41 -0700 (PDT) Received: from localhost.localdomain ([195.55.142.58]) by smtp.gmail.com with ESMTPSA id i5sm684778wjx.15.2016.04.19.07.55.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 19 Apr 2016 07:55:40 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org, ryan.harkin@linaro.org Date: Tue, 19 Apr 2016 16:55:31 +0200 Message-Id: <1461077734-4327-2-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1461077734-4327-1-git-send-email-ard.biesheuvel@linaro.org> References: <1461077734-4327-1-git-send-email-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH 2/5] ArmPkg/ArmDmaLib: consistently use 'gCacheAlignment - 1' as alignment mask X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: heyi.guo@linaro.org, Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" We manage to use both an AND operation with 'gCacheAlignment - 1' and a modulo operation with 'gCacheAlignment' in the same compound if statement. Since gCacheAlignment is a global of which the compiler cannot guarantee that it is a power of two, simply use the AND version, and use it against the bitwise OR of the two values to be tested. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel --- ArmPkg/Library/ArmDmaLib/ArmDmaLib.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) -- 2.5.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel Reviewed-by: Leif Lindholm diff --git a/ArmPkg/Library/ArmDmaLib/ArmDmaLib.c b/ArmPkg/Library/ArmDmaLib/ArmDmaLib.c index 1e6b288b10b9..834afdba10ef 100644 --- a/ArmPkg/Library/ArmDmaLib/ArmDmaLib.c +++ b/ArmPkg/Library/ArmDmaLib/ArmDmaLib.c @@ -92,8 +92,7 @@ DmaMap ( *Mapping = Map; - if ((((UINTN)HostAddress & (gCacheAlignment - 1)) != 0) || - ((*NumberOfBytes % gCacheAlignment) != 0)) { + if ((((UINTN)HostAddress | *NumberOfBytes) & (gCacheAlignment - 1)) != 0) { // Get the cacheability of the region Status = gDS->GetMemorySpaceDescriptor (*DeviceAddress, &GcdDescriptor);