linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sujit Reddy Thumma <sthumma@codeaurora.org>
To: Akinobu Mita <mita@fixstars.com>
Cc: James Bottomley <James.Bottomley@hansenpartnership.com>,
	Santosh Y <santoshsy@gmail.com>,
	linux-scsi@vger.kernel.org, vinholikatti@gmail.com
Subject: Re: [PATCH 10/10] ufs: fix DMA mask setting
Date: Sat, 10 Aug 2013 11:38:58 +0530	[thread overview]
Message-ID: <5205D8FA.8030605@codeaurora.org> (raw)
In-Reply-To: <CAD7r0yBAW2XWCkO_38u3GaUaL=kRFC84nqBXUoWLjaTRvUJ+ag@mail.gmail.com>

On 6/29/2013 11:10 AM, Akinobu Mita wrote:
> 2013/6/29 James Bottomley <James.Bottomley@hansenpartnership.com>:
>> On Wed, 2013-06-26 at 22:39 +0530, Santosh Y wrote:
>>> index 19618c6..431ddb2 100644
>>> --- a/drivers/scsi/ufs/ufshcd.c
>>> +++ b/drivers/scsi/ufs/ufshcd.c
>>> @@ -1711,6 +1711,25 @@ void ufshcd_remove(struct ufs_hba *hba)
>>>   EXPORT_SYMBOL_GPL(ufshcd_remove);
>>>
>>>   /**
>>> + * ufshcd_set_dma_mask - Set dma mask based on the controller
>>> + *                    addressing capability
>>> + * @hba: per adapter instance
>>> + *
>>> + * Returns 0 for success, non-zero for failure
>>> + */
>>> +static int ufshcd_set_dma_mask(struct ufs_hba *hba)
>>> +{
>>> +     if (hba->capabilities & MASK_64_ADDRESSING_SUPPORT) {
>>> +             if (!dma_set_mask(hba->dev, DMA_BIT_MASK(64)) &&
>>> +                 !dma_set_coherent_mask(hba->dev, DMA_BIT_MASK(64)))
>>> +                     return 0;
>>> +     }
>>> +     dma_set_mask(hba->dev, DMA_BIT_MASK(32));
>>> +
>>> +     return dma_set_coherent_mask(hba->dev, DMA_BIT_MASK(32));
>>> +}
>>
>> This isn't right per the API spec.  The guarantee is that if
>> dma_set_mask() succeeds then dma_set_coherent_mask of the same mask will
>> succeed,  so this should read
>>
>>          int err;
>>
>>          if (hba->capabilities & MASK_64_ADDRESSING_SUPPORT) {
>>                  if (!dma_set_mask(hba->dev, DMA_BIT_MASK(64))) {
>>                          dma_set_coherent_mask(hba->dev, DMA_BIT_MASK(64)))
>>                          return 0;
>>                  }
>>          }
>>          err = dma_set_mask(hba->dev, DMA_BIT_MASK(32));
>>          if (!err)
>>                  dma_set_coherent_mask(hba->dev, DMA_BIT_MASK(32));
>>          return err;
>
> Thanks for the explanation.  I agree that this is the correct definision
> of ufshcd_set_dma_mask().
>
> The reason that I omitted the error check on dma_set_mask(DMA_BIT_MASK(32))
> in the patch was that I was seeing that error due to the luck of
> valid dev->dma_mask pointer on OF platform devices although
> dma_supported(DMA_BIT_MASK(32)) returns true.

The popular trick implemented for device-tree probed devices is -
dev->dma_mask = &dev->coherent_dma_mask;

If you don't agree with this you can have something like -
dev->dma_mask = devm_kzalloc(dev, sizeof(*dev->dma_mask), GFP_KERNEL);
See platform_device_register_full();

>
> However, now I think that I should investigate more about dev->dma_mask
> issue rather than jumping into short-circuit fixing in the driver.  And
> then I will revisit this.


-- 
Regards,
Sujit

  reply	other threads:[~2013-08-10  6:09 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-26 17:09 [PATCH RESEND 00/10] scsi: ufs: link start-up rework and other fixes Santosh Y
2013-06-26 17:09 ` [PATCH 01/10] scsi: ufs: wrap the i/o access operations Santosh Y
2013-06-26 17:09 ` [PATCH 02/10] scsi: ufs: amend interrupt configuration Santosh Y
2013-06-26 17:09 ` [PATCH 03/10] scsi: ufs: remove version check before IS reg clear Santosh Y
2013-06-26 17:09 ` [PATCH 04/10] scsi: ufs: rework link start-up process Santosh Y
2013-06-26 17:09 ` [PATCH 05/10] scsi: ufs: Fix the response UPIU length setting Santosh Y
2013-06-26 17:09 ` [PATCH 06/10] scsi: ufs: use devres functions for ufshcd Santosh Y
2013-06-27  4:31   ` [PATCH v2 " Seungwon Jeon
2013-07-29 19:17     ` Santosh Y
2013-06-26 17:09 ` [PATCH 07/10] ufshcd-pltfrm: add missing empty slot in ufs_of_match[] Santosh Y
2013-06-26 17:09 ` [PATCH 08/10] ufs: fix register address in UIC error interrupt handling Santosh Y
2013-06-26 17:09 ` [PATCH 09/10] ufshcd-pltfrm: remove unnecessary dma_set_coherent_mask() call Santosh Y
2013-06-26 17:09 ` [PATCH 10/10] ufs: fix DMA mask setting Santosh Y
2013-06-28 20:37   ` James Bottomley
2013-06-29  5:40     ` Akinobu Mita
2013-08-10  6:08       ` Sujit Reddy Thumma [this message]
2013-08-15 14:48         ` Akinobu Mita
  -- strict thread matches above, loose matches on Subject: below --
2013-06-26 17:03 [PATCH 00/10] scsi: ufs: link start-up rework and other fixes Santosh Y
2013-06-26 17:04 ` [PATCH 10/10] ufs: fix DMA mask setting Santosh Y

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5205D8FA.8030605@codeaurora.org \
    --to=sthumma@codeaurora.org \
    --cc=James.Bottomley@hansenpartnership.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=mita@fixstars.com \
    --cc=santoshsy@gmail.com \
    --cc=vinholikatti@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).