lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Thu, 27 Sep 2012 09:43:13 +0530
From:	Inderpal Singh <inderpal.singh@...aro.org>
To:	Jassi Brar <jassisinghbrar@...il.com>
Cc:	linux-samsung-soc@...r.kernel.org, linux-kernel@...r.kernel.org,
	boojin.kim@...sung.com, vinod.koul@...el.com, patches@...aro.org,
	kgene.kim@...sung.com
Subject: Re: [PATCH 3/3] DMA: PL330: Balance module remove function with probe

On 26 September 2012 22:19, Jassi Brar <jassisinghbrar@...il.com> wrote:
> On Wed, Sep 26, 2012 at 4:25 PM, Inderpal Singh
> <inderpal.singh@...aro.org> wrote:
>> On 26 September 2012 15:02, Jassi Brar <jassisinghbrar@...il.com> wrote:
>>> On Wed, Sep 26, 2012 at 12:11 PM, Inderpal Singh
>>> <inderpal.singh@...aro.org> wrote:
>>>
>>>> How about conditionally DMA_TERMINATE_ALL and free resources like below ?
>>>>
>>>> @@ -3017,9 +3017,11 @@ static int __devexit pl330_remove(struct
>>>> amba_device *adev)
>>>>                 /* Remove the channel */
>>>>                 list_del(&pch->chan.device_node);
>>>>
>>>> -               /* Flush the channel */
>>>> -               pl330_control(&pch->chan, DMA_TERMINATE_ALL, 0);
>>>> -               pl330_free_chan_resources(&pch->chan);
>>>> +               if (pch->chan.client_count != 0) {
>>>> +                       /* Flush the channel */
>>>> +                       pl330_control(&pch->chan, DMA_TERMINATE_ALL, 0);
>>>> +                       pl330_free_chan_resources(&pch->chan);
>>>> +               }
>>>>         }
>>>>
>>> It is perfectly safe to flush the channels that have client_count == 0
>>> as well. Which is already the case.
>>
>> As per my understanding, if client_count ==0, It may mean following:
>>
>> 1. This channel was never allocated to any client. Hence
>> alloc_chan_resources was not done for it.
>> So, no need to flush and free resources if it was never allocated at
>> the first place. If we free_chan_resources, it will not be balanced
>> against alloc_chan_resources. Scenario: insmod and then rmmod.
>>
>> Or,
>>
>> 2. The channel was allocated to some client, alloc_chan_resource was
>> done, the work for the client is completed and free_chan_resources was
>> performed. Now  since resources have already been freed, no need to
>> flush and free_chan_resources again in remove.
>>
>> The whole idea of this patch is to balance alloc_chan_resources and
>> free_chan_resources.
>>
> Do you see any issue with channels that have zero client_count ?

As I explained in my previous mail, If the client_count is zero,
either the alloc_chan_resources is not done(or failed) for that
channel or the free_chan_resource have already been done. Please refer
below code from dmaengine.c

static void dma_chan_put(struct dma_chan *chan)
{
        if (!chan->client_count)
                return; /* this channel failed alloc_chan_resources */
        chan->client_count--;
        module_put(dma_chan_to_owner(chan));
        if (chan->client_count == 0)
                chan->device->device_free_chan_resources(chan);
}

As you mentioned channel flush is needed if some client is queued and
force unload happens.
I am not against flushing and freeing channels. I am __only__
suggesting to flush and free channels for which alloc_chan_resource
was successful, which can be decided by "chan->client_count" as being
done in above function.

Don't you think free_chan_resource should be done __only if__
alloc_chan_resource was successful ?

Thanks,
Inder

> AFAIU there are already enough checks in the path to weed out unused
> channels, so let us please not uglify the code by adding new
> unnecessary checks.
>
> thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ