linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@lst.de>
To: Larry Finger <Larry.Finger@lwfinger.net>
Cc: Aaro Koskinen <aaro.koskinen@iki.fi>,
	linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org,
	Christian Zigotzky <chzigotzky@xenosoft.de>,
	linuxppc-dev@lists.ozlabs.org, Christoph Hellwig <hch@lst.de>
Subject: Re: [BISECTED REGRESSION] b43legacy broken on G4 PowerBook
Date: Tue, 11 Jun 2019 08:05:21 +0200	[thread overview]
Message-ID: <20190611060521.GA19512@lst.de> (raw)
In-Reply-To: <153c13f5-a829-1eab-a3c5-fecfb84127ff@lwfinger.net>

On Mon, Jun 10, 2019 at 11:09:47AM -0500, Larry Finger wrote:
>>>                  return -EIO;
>>>
>>> For b43legacy, dev->dma_mask is 0xc265684800000000.
>>>      dma_supported(dev, mask) is 0xc08b000000000000, mask is 0x3fffffff, and
>>> the routine returns -EIO.
>>>
>>> For b43,       dev->dma_mask is 0xc265684800000001,
>>>      dma_supported(dev, mask) is 0xc08b000000000000, mask is 0x77777777, and
>>> the routine returns 0.
>>
>> I don't fully understand what values the above map to.  Can you send
>> me your actual debugging patch as well?
>
> I do not understand why the if statement returns true as neither of the 
> values is zero. After seeing the x86 output shown below, I also do not 
> understand all the trailing zeros.
>
> My entire patch is attached. That output came from this section:

What might be confusing in your output is that dev->dma_mask is a pointer,
and we are setting it in dma_set_mask.  That is before we only check
if the pointer is set, and later we override it.  Of course this doesn't
actually explain the failure.  But what is even more strange to me
is that you get a return value from dma_supported() that isn't 0 or 1,
as that function is supposed to return a boolean, and I really can't see
how mask >= __phys_to_dma(dev, min_mask), would return anything but 0
or 1.  Does the output change if you use the correct printk specifiers?

i.e. with a debug patch like this:


diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c
index 2c2772e9702a..9e5b30b12b10 100644
--- a/kernel/dma/direct.c
+++ b/kernel/dma/direct.c
@@ -378,6 +378,7 @@ EXPORT_SYMBOL(dma_direct_map_resource);
 int dma_direct_supported(struct device *dev, u64 mask)
 {
 	u64 min_mask;
+	bool ret;
 
 	if (IS_ENABLED(CONFIG_ZONE_DMA))
 		min_mask = DMA_BIT_MASK(ARCH_ZONE_DMA_BITS);
@@ -391,7 +392,12 @@ int dma_direct_supported(struct device *dev, u64 mask)
 	 * use __phys_to_dma() here so that the SME encryption mask isn't
 	 * part of the check.
 	 */
-	return mask >= __phys_to_dma(dev, min_mask);
+	ret = (mask >= __phys_to_dma(dev, min_mask));
+	if (!ret)
+		dev_info(dev,
+			"%s: failed (mask = 0x%llx, min_mask = 0x%llx/0x%llx, dma bits = %d\n",
+			__func__, mask, min_mask, __phys_to_dma(dev, min_mask), ARCH_ZONE_DMA_BITS);
+	return ret;
 }
 
 size_t dma_direct_max_mapping_size(struct device *dev)
diff --git a/kernel/dma/mapping.c b/kernel/dma/mapping.c
index f7afdadb6770..6c57ccdee2ae 100644
--- a/kernel/dma/mapping.c
+++ b/kernel/dma/mapping.c
@@ -317,8 +317,14 @@ void arch_dma_set_mask(struct device *dev, u64 mask);
 
 int dma_set_mask(struct device *dev, u64 mask)
 {
-	if (!dev->dma_mask || !dma_supported(dev, mask))
+	if (!dev->dma_mask) {
+		dev_info(dev, "no DMA mask set!\n");
 		return -EIO;
+	}
+	if (!dma_supported(dev, mask)) {
+		printk("DMA not supported\n");
+		return -EIO;
+	}
 
 	arch_dma_set_mask(dev, mask);
 	dma_check_mask(dev, mask);

  reply	other threads:[~2019-06-11  6:07 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-05 22:50 [BISECTED REGRESSION] b43legacy broken on G4 PowerBook Aaro Koskinen
2019-06-06  0:54 ` Benjamin Herrenschmidt
2019-06-06  9:31   ` Aaro Koskinen
2019-06-06 10:56     ` Benjamin Herrenschmidt
2019-06-06 10:57       ` Benjamin Herrenschmidt
2019-06-06 11:43         ` Christoph Hellwig
2019-06-06 19:26           ` Larry Finger
2019-06-06 20:11           ` Larry Finger
2019-06-06  3:06 ` Larry Finger
2019-06-06  6:40   ` Christoph Hellwig
2019-06-07 17:25 ` Larry Finger
2019-06-07 17:29   ` Christoph Hellwig
2019-06-07 18:50     ` Larry Finger
2019-06-08 21:52     ` Larry Finger
2019-06-10  8:18       ` Christoph Hellwig
2019-06-10 16:09         ` Larry Finger
2019-06-11  6:05           ` Christoph Hellwig [this message]
2019-06-11 22:20             ` Larry Finger
2019-06-11 22:46               ` Aaro Koskinen
2019-06-12  1:57                 ` Larry Finger
2019-06-11 22:46               ` Benjamin Herrenschmidt
2019-06-12  1:52                 ` Larry Finger
2019-06-12  3:32                   ` Benjamin Herrenschmidt
2019-06-12  6:55               ` Christoph Hellwig
2019-06-12 19:41                 ` Larry Finger
2019-06-12 21:59                   ` Benjamin Herrenschmidt
2019-06-13  7:29                     ` Christoph Hellwig
2019-06-11 17:48           ` Andreas Schwab
2019-06-08  4:21   ` Benjamin Herrenschmidt
2019-06-08  7:23     ` Christoph Hellwig
2019-06-10 18:44     ` Larry Finger
2019-06-11  5:56       ` Benjamin Herrenschmidt
2019-06-11  6:08         ` Christoph Hellwig
2019-06-11  6:58           ` Benjamin Herrenschmidt
2019-06-11  6:59             ` Benjamin Herrenschmidt
2019-06-11  7:54               ` Christoph Hellwig
2019-06-11  9:04                 ` Benjamin Herrenschmidt
2019-06-11  7:53             ` Christoph Hellwig

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=20190611060521.GA19512@lst.de \
    --to=hch@lst.de \
    --cc=Larry.Finger@lwfinger.net \
    --cc=aaro.koskinen@iki.fi \
    --cc=chzigotzky@xenosoft.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    /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).