Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp1372868pxb; Fri, 1 Apr 2022 11:33:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx6RwfI1lxG5ssPWzVo8f2jHmrKLhBRprDvkIYtgT57sz3sg+qP1dUrdBxBZQNANm3uxYl5 X-Received: by 2002:a17:903:246:b0:153:857c:a1f6 with SMTP id j6-20020a170903024600b00153857ca1f6mr11681131plh.153.1648838010928; Fri, 01 Apr 2022 11:33:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648838010; cv=none; d=google.com; s=arc-20160816; b=nu1iMTt+pFqH4hrJOe+O9/xvcST730hVYRSwtBcwEwmqMWZh22At1gmw/t2mv9Z+Rx wxXLFYWe2UqCJHK75qkOmFkjsNTEnRKdKtnTL6q75nXDy6C1okEUES//DW9K9bRTPK5s 68xvX+2+UGCGLtqX7Cr6+e/ufrAmceUdgI2RjVXtlonNEqhaw7P+GwlTHWFlXX2CxZyZ E/4KIwtMragy1vMMFVpxfjXsPh1t3Y5ClMak96+a53H9P9/BTPKS7mnwhR1MKP+DTWhE 4KN/CfDwfpz0Hl5eq9whnVfL8Upo9D+eAn4o9oDoX71AC0i9pVeJD5n/VsS0A/89vPVX jCNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=w0NRo/eqKOZlDg6K7b+GNTIW8Gc90Vvcp49xvIK+Y6g=; b=AKQ1bmjsSucV4e/oknB3Z4PPz/+ocRwpJjGF9r8QvL9PsJL+G1L+fK8R83CcRdOgE6 ody222shgrAwm0LOyg8epFfSS1/S5fH9RISkxMI90md3ztKFAEh29Un9Ol739jseCYNo u9Vc5pxN8wdGrFCIjuUYsnzATetxRnUOQN+R5RMHTxIW+tv/QSkeRg0pSXOvA05EFej9 UYZUGTQn/TMwW0LdLrpMu50f3xPgtVKfgF4oMkgge0EjMdv/e25z4bcZtjbAWPm3MzHK oTx+/mbiePLBtQSOXn5qPNRu3DQ5CjFhf0SVEaPbFGajKKD9N4Nfp9nCOLkr9Uan8qfa JtNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=G+kyVyZ3; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c19-20020a056a000ad300b004fa831f601csi3411023pfl.231.2022.04.01.11.33.15; Fri, 01 Apr 2022 11:33:30 -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=@kernel.org header.s=k20201202 header.b=G+kyVyZ3; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345531AbiDALdb (ORCPT + 99 others); Fri, 1 Apr 2022 07:33:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238883AbiDALda (ORCPT ); Fri, 1 Apr 2022 07:33:30 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BB0FA1C60C9 for ; Fri, 1 Apr 2022 04:31:40 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5108B618EF for ; Fri, 1 Apr 2022 11:31:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A6107C3410F for ; Fri, 1 Apr 2022 11:31:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1648812699; bh=Hs3Tehj/N7oWQ/xiZpxU7YwL3ngaZKwnUSjmR/zi7zQ=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=G+kyVyZ3mCbZ/Z2dGf5r+9trJFH7blhrKO38mcDxnOgOkRosj2O+uS3vA78nYDSHn SCok+7XA6nJ/EHep2nwH/dQbgr0vCHqgbzLkZ1KCSv8EYMnWdOqGn/qmE3MC2TUBek gRWdoA9NI1mMGILaU6erINmgej+/X7gSkJXliQnNykuPhthozjXOE3o2ctPmMk1PhF t1epRb2DMFNfA8rUzk7gY4Dampvz08TtdaUxoxvw6vW6B06XGMQKBVQwB6j2KpHPqL HU3hDyH1iASa8N/Veb74mEBTLu3G62xPH9CpnFM+kfYua8oca3FPBQ0F2qfG5d/Djk n+a+Hhe08UZgg== Received: by mail-yw1-f179.google.com with SMTP id 00721157ae682-2e6650cde1bso28702607b3.12 for ; Fri, 01 Apr 2022 04:31:39 -0700 (PDT) X-Gm-Message-State: AOAM530z+oV04Q6GC+4w1EdENxZhM5qUUdrB7MYMqQLnrrrwnG4YEvZi SJeDA9Gv+3ZxJJ4PoRLj4RfW3qDxTP55YG/k3Z8= X-Received: by 2002:a81:1b11:0:b0:2e6:a60b:2d6f with SMTP id b17-20020a811b11000000b002e6a60b2d6fmr9494996ywb.3.1648812698659; Fri, 01 Apr 2022 04:31:38 -0700 (PDT) MIME-Version: 1.0 References: <20220401041615.3296387-1-jcmvbkbc@gmail.com> In-Reply-To: From: Oded Gabbay Date: Fri, 1 Apr 2022 14:31:12 +0300 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] habanalabs: fix build warning To: Arnd Bergmann Cc: Max Filippov , Ohad Sharabi , Greg Kroah-Hartman , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 On Fri, Apr 1, 2022 at 10:53 AM Arnd Bergmann wrote: > > On Fri, Apr 1, 2022 at 8:55 AM Oded Gabbay wrote: > > On Fri, Apr 1, 2022 at 9:40 AM Arnd Bergmann wrote: > > > On Fri, Apr 1, 2022 at 6:16 AM Max Filippov wrote: > > > > We use gen_pool in this function to manage our device memory > > allocations (this is why it is called alloc_device_memory). > > Ok, so it's none of the three I listed ;-) > > > Basically, we initialize the genpool with the total size of the device memory, > > and each bit represents a page according to a fixed page size, which > > is dependent on asic type. > > The addresses represent the physical address of the device memory, as > > our device sees them. > > As these addresses are not accessible from the host, it is appropriate > > to hold them in u64, imo. > > > > For future asics which will support multiple page sizes, we need to > > use the gen_pool_dma_alloc_align() variant, > > because then we need the allocation to be aligned to the page size as > > requested by the user per allocation. > > > > We ignore the DMA address because this is device memory, not host memory. > > Therefore, our device's dma engine addresses the memory using the > > virtual memory addresses we assign to it in our device's MMU. > > > > Having said that, I'm wondering whether gen_pool_first_fit_align() can > > also work here, which might be less confusing. > > Thank you for the explanation. I think the best way to make this less > confusing and to avoid the type casts would be to define your own > typedef for a device-internal address, and then wrap the allocator > functions such as gen_pool_dma_alloc_align() in helper functions that > do the type conversion safely. > > Arnd Thanks for the advice, we will prepare a patch accordingly. Oded