From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 052FE17982 for ; Wed, 13 Sep 2023 12:08:30 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 08DBD1FB; Wed, 13 Sep 2023 05:09:01 -0700 (PDT) Received: from [10.57.93.239] (unknown [10.57.93.239]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A10D33F67D; Wed, 13 Sep 2023 05:08:21 -0700 (PDT) Message-ID: Date: Wed, 13 Sep 2023 13:08:14 +0100 Precedence: bulk X-Mailing-List: linux-staging@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; rv:102.0) Gecko/20100101 Thunderbird/102.15.0 Subject: Re: [PATCH v10 1/5] staging: vc04_services: vchiq_arm: Add new bus type and device type Content-Language: en-GB To: Umang Jain , Stefan Wahren Cc: gregkh@linuxfoundation.org, f.fainelli@gmail.com, athierry@redhat.com, error27@gmail.com, kieran.bingham@ideasonboard.com, laurent.pinchart@ideasonboard.com, dave.stevenson@raspberrypi.com, linux-kernel@vger.kernel.org, linux-rpi-kernel@lists.infradead.org, linux-staging@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org References: <20230911140712.180751-1-umang.jain@ideasonboard.com> <20230911140712.180751-2-umang.jain@ideasonboard.com> From: Robin Murphy In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 2023-09-12 06:50, Umang Jain wrote: [...] >>> +struct vchiq_device * >>> +vchiq_device_register(struct device *parent, const char *name) >>> +{ >>> +    struct vchiq_device *device; >>> +    int ret; >>> + >>> +    device = kzalloc(sizeof(*device), GFP_KERNEL); >>> +    if (!device) { >>> +        dev_err(parent, "Cannot register %s: Insufficient memory\n", >>> +            name); >>> +        return NULL; >>> +    } >>> + >>> +    device->dev.init_name = name; >>> +    device->dev.parent = parent; >>> +    device->dev.bus = &vchiq_bus_type; >>> +    device->dev.release = vchiq_device_release; >>> + >>> +    of_dma_configure(&device->dev, parent->of_node, true); >>> +    ret = dma_set_mask_and_coherent(&device->dev, DMA_BIT_MASK(32)); >>> +    if (ret) { >>> +        dev_err(&device->dev, "32-bit DMA enable failed\n"); >>> +        return NULL; >>> +    } >> >> Unfortunately the call of of_dma_configure() generates warnings likes >> this (Raspberry Pi 3A+ with multi_v7_defconfig + VCHIQ): >> >> [    9.206802] vchiq-bus bcm2835-audio: DMA mask not set >> [    9.206892] vchiq-bus bcm2835-camera: DMA mask not set > > huh, really weird, as on my RPi-3-b I get these set correctly and I > don't any such warning. Can you point to the code above where device->dev.dma_mask gets initialised between the initial kzalloc() and the call to of_dma_configure()? ;) BTW, bus code shouldn't be calling dma_set_mask_and_coherent() on behalf of its children, that is for the individual drivers to do, if and when they intend to actually use DMA. Removing that here will save you needing to fix the memory leak as well... Thanks, Robin.