public inbox for linux-parisc@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] parisc: Set valid bit in high byte of 64‑bit physical address
@ 2025-12-18 12:08 Leon Romanovsky
  2025-12-18 16:22 ` Guenter Roeck
  2025-12-18 18:27 ` Helge Deller
  0 siblings, 2 replies; 8+ messages in thread
From: Leon Romanovsky @ 2025-12-18 12:08 UTC (permalink / raw)
  To: James E.J. Bottomley, Helge Deller, Marek Szyprowski,
	Leon Romanovsky, Jason Gunthorpe
  Cc: linux-parisc, linux-kernel, Guenter Roeck

From: Leon Romanovsky <leonro@nvidia.com>

On 32‑bit systems, phys_addr_t is defined as u32. However, parisc
expects physical addresses to be 64‑bit values so it can store a
validity bit in the upper byte.

Resolve this mismatch by casting the physical address to unsigned
long, ensuring it is treated as a 64‑bit value where required. This
fixes the failure to start block device drivers on the C3700
platform, as reported by Guenter.

Also remove the now‑obsolete macro.

QEMU command line to reproduce the issue (with Debian SID as rootfs):
  qemu-system-hppa -machine C3700 \
	-kernel arch/parisc/boot/bzImage \
	-append "console=ttyS0 \
	root=/dev/sda rw rootwait panic=-1" \
	-nographic \
	-device lsi53c895a \
	-drive file=rootfs-hppa.img,if=none,format=raw,id=hd0 \
	-device scsi-hd,drive=hd0

Fixes: 96ddf2ef58ec ("parisc: Convert DMA map_page to map_phys interface")
Reported-by: Guenter Roeck <linux@roeck-us.net>
Closes: https://lore.kernel.org/all/b184f1bf-96dc-4546-8512-9cba5ecb58f7@roeck-us.net/
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
 arch/parisc/include/asm/special_insns.h | 15 ---------------
 drivers/parisc/sba_iommu.c              |  4 ++--
 2 files changed, 2 insertions(+), 17 deletions(-)

diff --git a/arch/parisc/include/asm/special_insns.h b/arch/parisc/include/asm/special_insns.h
index 1013eeba31e5..fbccd76180b6 100644
--- a/arch/parisc/include/asm/special_insns.h
+++ b/arch/parisc/include/asm/special_insns.h
@@ -2,21 +2,6 @@
 #ifndef __PARISC_SPECIAL_INSNS_H
 #define __PARISC_SPECIAL_INSNS_H
 
-#define lpa(va)	({					\
-	unsigned long pa;				\
-	__asm__ __volatile__(				\
-		"copy %%r0,%0\n"			\
-		"8:\tlpa %%r0(%1),%0\n"			\
-		"9:\n"					\
-		ASM_EXCEPTIONTABLE_ENTRY(8b, 9b,	\
-				"or %%r0,%%r0,%%r0")	\
-		: "=&r" (pa)				\
-		: "r" (va)				\
-		: "memory"				\
-	);						\
-	pa;						\
-})
-
 #define lpa_user(va)	({				\
 	unsigned long pa;				\
 	__asm__ __volatile__(				\
diff --git a/drivers/parisc/sba_iommu.c b/drivers/parisc/sba_iommu.c
index a6eb6bffa5ea..eefb2bac8443 100644
--- a/drivers/parisc/sba_iommu.c
+++ b/drivers/parisc/sba_iommu.c
@@ -578,8 +578,8 @@ sba_io_pdir_entry(__le64 *pdir_ptr, space_t sid, phys_addr_t pba,
 	pba &= IOVP_MASK;
 	pba |= (ci >> PAGE_SHIFT) & 0xff;  /* move CI (8 bits) into lowest byte */
 
-	pba |= SBA_PDIR_VALID_BIT;	/* set "valid" bit */
-	*pdir_ptr = cpu_to_le64(pba);	/* swap and store into I/O Pdir */
+	/* set "valid" bit, swap and store into I/O Pdir */
+	*pdir_ptr = cpu_to_le64((unsigned long)pba | SBA_PDIR_VALID_BIT);
 
 	/*
 	 * If the PDC_MODEL capabilities has Non-coherent IO-PDIR bit set

---
base-commit: 8f0b4cce4481fb22653697cced8d0d04027cb1e8
change-id: 20251218-fix-parisc-conversion-37e31197a291

Best regards,
--  
Leon Romanovsky <leonro@nvidia.com>


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] parisc: Set valid bit in high byte of 64‑bit physical address
  2025-12-18 12:08 [PATCH] parisc: Set valid bit in high byte of 64‑bit physical address Leon Romanovsky
@ 2025-12-18 16:22 ` Guenter Roeck
  2025-12-18 17:14   ` Marek Szyprowski
  2025-12-18 18:27 ` Helge Deller
  1 sibling, 1 reply; 8+ messages in thread
From: Guenter Roeck @ 2025-12-18 16:22 UTC (permalink / raw)
  To: Leon Romanovsky, James E.J. Bottomley, Helge Deller,
	Marek Szyprowski, Jason Gunthorpe
  Cc: linux-parisc, linux-kernel

On 12/18/25 04:08, Leon Romanovsky wrote:
> From: Leon Romanovsky <leonro@nvidia.com>
> 
> On 32‑bit systems, phys_addr_t is defined as u32. However, parisc
> expects physical addresses to be 64‑bit values so it can store a
> validity bit in the upper byte.
> 
> Resolve this mismatch by casting the physical address to unsigned
> long, ensuring it is treated as a 64‑bit value where required. This
> fixes the failure to start block device drivers on the C3700
> platform, as reported by Guenter.
> 
> Also remove the now‑obsolete macro.
> 
> QEMU command line to reproduce the issue (with Debian SID as rootfs):
>    qemu-system-hppa -machine C3700 \
> 	-kernel arch/parisc/boot/bzImage \
> 	-append "console=ttyS0 \
> 	root=/dev/sda rw rootwait panic=-1" \
> 	-nographic \
> 	-device lsi53c895a \
> 	-drive file=rootfs-hppa.img,if=none,format=raw,id=hd0 \
> 	-device scsi-hd,drive=hd0
> 
> Fixes: 96ddf2ef58ec ("parisc: Convert DMA map_page to map_phys interface")
> Reported-by: Guenter Roeck <linux@roeck-us.net>
> Closes: https://lore.kernel.org/all/b184f1bf-96dc-4546-8512-9cba5ecb58f7@roeck-us.net/
> Signed-off-by: Leon Romanovsky <leonro@nvidia.com>

Tested-by: Guenter Roeck <linux@roeck-us.net>


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] parisc: Set valid bit in high byte of 64‑bit physical address
  2025-12-18 16:22 ` Guenter Roeck
@ 2025-12-18 17:14   ` Marek Szyprowski
  0 siblings, 0 replies; 8+ messages in thread
From: Marek Szyprowski @ 2025-12-18 17:14 UTC (permalink / raw)
  To: Guenter Roeck, Leon Romanovsky, James E.J. Bottomley,
	Helge Deller, Jason Gunthorpe
  Cc: linux-parisc, linux-kernel

On 18.12.2025 17:22, Guenter Roeck wrote:
> On 12/18/25 04:08, Leon Romanovsky wrote:
>> From: Leon Romanovsky <leonro@nvidia.com>
>>
>> On 32‑bit systems, phys_addr_t is defined as u32. However, parisc
>> expects physical addresses to be 64‑bit values so it can store a
>> validity bit in the upper byte.
>>
>> Resolve this mismatch by casting the physical address to unsigned
>> long, ensuring it is treated as a 64‑bit value where required. This
>> fixes the failure to start block device drivers on the C3700
>> platform, as reported by Guenter.
>>
>> Also remove the now‑obsolete macro.
>>
>> QEMU command line to reproduce the issue (with Debian SID as rootfs):
>>    qemu-system-hppa -machine C3700 \
>>     -kernel arch/parisc/boot/bzImage \
>>     -append "console=ttyS0 \
>>     root=/dev/sda rw rootwait panic=-1" \
>>     -nographic \
>>     -device lsi53c895a \
>>     -drive file=rootfs-hppa.img,if=none,format=raw,id=hd0 \
>>     -device scsi-hd,drive=hd0
>>
>> Fixes: 96ddf2ef58ec ("parisc: Convert DMA map_page to map_phys 
>> interface")
>> Reported-by: Guenter Roeck <linux@roeck-us.net>
>> Closes: 
>> https://lore.kernel.org/all/b184f1bf-96dc-4546-8512-9cba5ecb58f7@roeck-us.net/
>> Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
>
> Tested-by: Guenter Roeck <linux@roeck-us.net>

Thanks for the initial report and a quick fix. I'm sorry that this issue 
slipped through the review and tests in linux-next. I've applied it to 
dma-mapping-fixes branch.

Best regards
-- 
Marek Szyprowski, PhD
Samsung R&D Institute Poland


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] parisc: Set valid bit in high byte of 64‑bit physical address
  2025-12-18 12:08 [PATCH] parisc: Set valid bit in high byte of 64‑bit physical address Leon Romanovsky
  2025-12-18 16:22 ` Guenter Roeck
@ 2025-12-18 18:27 ` Helge Deller
  2025-12-18 21:28   ` Leon Romanovsky
  1 sibling, 1 reply; 8+ messages in thread
From: Helge Deller @ 2025-12-18 18:27 UTC (permalink / raw)
  To: Leon Romanovsky, James E.J. Bottomley, Marek Szyprowski,
	Jason Gunthorpe
  Cc: linux-parisc, linux-kernel, Guenter Roeck

Hi Leon,

On 12/18/25 13:08, Leon Romanovsky wrote:
> On 32‑bit systems, phys_addr_t is defined as u32. However, parisc
> expects physical addresses to be 64‑bit values so it can store a
> validity bit in the upper byte.
> ...
> Also remove the now‑obsolete macro.

Your patch is OK, but could you please keep the lpa() macro?
It's unrelated to your patch, and sometimes we need the lpa()
e.g. when adding debug code, so I'd prefer to keep it.

Thanks,
Helge

...
> diff --git a/arch/parisc/include/asm/special_insns.h b/arch/parisc/include/asm/special_insns.h
> index 1013eeba31e5..fbccd76180b6 100644
> --- a/arch/parisc/include/asm/special_insns.h
> +++ b/arch/parisc/include/asm/special_insns.h
> @@ -2,21 +2,6 @@
>   #ifndef __PARISC_SPECIAL_INSNS_H
>   #define __PARISC_SPECIAL_INSNS_H
>   
> -#define lpa(va)	({					\
> -	unsigned long pa;				\
> -	__asm__ __volatile__(				\
> -		"copy %%r0,%0\n"			\
> -		"8:\tlpa %%r0(%1),%0\n"			\
> -		"9:\n"					\
> -		ASM_EXCEPTIONTABLE_ENTRY(8b, 9b,	\
> -				"or %%r0,%%r0,%%r0")	\
> -		: "=&r" (pa)				\
> -		: "r" (va)				\
> -		: "memory"				\
> -	);						\
> -	pa;						\
> -})




^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] parisc: Set valid bit in high byte of 64‑bit physical address
  2025-12-18 18:27 ` Helge Deller
@ 2025-12-18 21:28   ` Leon Romanovsky
  2025-12-19  8:35     ` Marek Szyprowski
  0 siblings, 1 reply; 8+ messages in thread
From: Leon Romanovsky @ 2025-12-18 21:28 UTC (permalink / raw)
  To: Helge Deller, James E.J. Bottomley, Marek Szyprowski,
	Jason Gunthorpe
  Cc: linux-parisc, linux-kernel, Guenter Roeck



On Thu, Dec 18, 2025, at 20:27, Helge Deller wrote:
> Hi Leon,
>
> On 12/18/25 13:08, Leon Romanovsky wrote:
>> On 32‑bit systems, phys_addr_t is defined as u32. However, parisc
>> expects physical addresses to be 64‑bit values so it can store a
>> validity bit in the upper byte.
>> ...
>> Also remove the now‑obsolete macro.
>
> Your patch is OK, but could you please keep the lpa() macro?
> It's unrelated to your patch, and sometimes we need the lpa()
> e.g. when adding debug code, so I'd prefer to keep it.

The parch was already accepted and if Marek agrees, he can easily revert the deleted hunk and rebase my parch.

However from upstream perspective, we don't keep code which is not used and if this macro would be function, we would get compilation warning for that.

Isn't lpa(x/) equal to virt_to_phys(x)?

Thanks 

>
> Thanks,
> Helge
>
> ...
>> diff --git a/arch/parisc/include/asm/special_insns.h b/arch/parisc/include/asm/special_insns.h
>> index 1013eeba31e5..fbccd76180b6 100644
>> --- a/arch/parisc/include/asm/special_insns.h
>> +++ b/arch/parisc/include/asm/special_insns.h
>> @@ -2,21 +2,6 @@
>>   #ifndef __PARISC_SPECIAL_INSNS_H
>>   #define __PARISC_SPECIAL_INSNS_H
>>   
>> -#define lpa(va)	({					\
>> -	unsigned long pa;				\
>> -	__asm__ __volatile__(				\
>> -		"copy %%r0,%0\n"			\
>> -		"8:\tlpa %%r0(%1),%0\n"			\
>> -		"9:\n"					\
>> -		ASM_EXCEPTIONTABLE_ENTRY(8b, 9b,	\
>> -				"or %%r0,%%r0,%%r0")	\
>> -		: "=&r" (pa)				\
>> -		: "r" (va)				\
>> -		: "memory"				\
>> -	);						\
>> -	pa;						\
>> -})

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] parisc: Set valid bit in high byte of 64‑bit physical address
  2025-12-18 21:28   ` Leon Romanovsky
@ 2025-12-19  8:35     ` Marek Szyprowski
  2025-12-19 12:38       ` James Bottomley
  0 siblings, 1 reply; 8+ messages in thread
From: Marek Szyprowski @ 2025-12-19  8:35 UTC (permalink / raw)
  To: Leon Romanovsky, Helge Deller, James E.J. Bottomley,
	Jason Gunthorpe
  Cc: linux-parisc, linux-kernel, Guenter Roeck

On 18.12.2025 22:28, Leon Romanovsky wrote:
> On Thu, Dec 18, 2025, at 20:27, Helge Deller wrote:
>> On 12/18/25 13:08, Leon Romanovsky wrote:
>>> On 32‑bit systems, phys_addr_t is defined as u32. However, parisc
>>> expects physical addresses to be 64‑bit values so it can store a
>>> validity bit in the upper byte.
>>> ...
>>> Also remove the now‑obsolete macro.
>> Your patch is OK, but could you please keep the lpa() macro?
>> It's unrelated to your patch, and sometimes we need the lpa()
>> e.g. when adding debug code, so I'd prefer to keep it.
> The parch was already accepted and if Marek agrees, he can easily revert the deleted hunk and rebase my parch.
>
> However from upstream perspective, we don't keep code which is not used and if this macro would be function, we would get compilation warning for that.
>
> Isn't lpa(x/) equal to virt_to_phys(x)?

I can drop the lpa() related change, but let us know what is the 
advantage of it compared to virt_to_phys()?

Best regards
-- 
Marek Szyprowski, PhD
Samsung R&D Institute Poland


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] parisc: Set valid bit in high byte of 64‑bit physical address
  2025-12-19  8:35     ` Marek Szyprowski
@ 2025-12-19 12:38       ` James Bottomley
  2025-12-19 12:48         ` Marek Szyprowski
  0 siblings, 1 reply; 8+ messages in thread
From: James Bottomley @ 2025-12-19 12:38 UTC (permalink / raw)
  To: Marek Szyprowski, Leon Romanovsky, Helge Deller, Jason Gunthorpe
  Cc: linux-parisc, linux-kernel, Guenter Roeck

On Fri, 2025-12-19 at 09:35 +0100, Marek Szyprowski wrote:
> On 18.12.2025 22:28, Leon Romanovsky wrote:
> > On Thu, Dec 18, 2025, at 20:27, Helge Deller wrote:
> > > On 12/18/25 13:08, Leon Romanovsky wrote:
> > > > On 32‑bit systems, phys_addr_t is defined as u32. However,
> > > > parisc expects physical addresses to be 64‑bit values so it can
> > > > store a validity bit in the upper byte.
> > > > ...
> > > > Also remove the now‑obsolete macro.
> > > Your patch is OK, but could you please keep the lpa() macro?
> > > It's unrelated to your patch, and sometimes we need the lpa()
> > > e.g. when adding debug code, so I'd prefer to keep it.
> > The parch was already accepted and if Marek agrees, he can easily
> > revert the deleted hunk and rebase my parch.
> > 
> > However from upstream perspective, we don't keep code which is not
> > used and if this macro would be function, we would get compilation
> > warning for that.
> > 
> > Isn't lpa(x/) equal to virt_to_phys(x)?
> 
> I can drop the lpa() related change, but let us know what is the 
> advantage of it compared to virt_to_phys()?

Um, well same as on every architecture: virt_to_phys only gives correct
results on the offset map since it's defined as an offset map
subtraction; lpa() gives the the CPU view of the mapping through the
page table entries, so is correct even in the vmap (and iomap, etc)
range.

Regards,

James


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] parisc: Set valid bit in high byte of 64‑bit physical address
  2025-12-19 12:38       ` James Bottomley
@ 2025-12-19 12:48         ` Marek Szyprowski
  0 siblings, 0 replies; 8+ messages in thread
From: Marek Szyprowski @ 2025-12-19 12:48 UTC (permalink / raw)
  To: James Bottomley, Leon Romanovsky, Helge Deller, Jason Gunthorpe
  Cc: linux-parisc, linux-kernel, Guenter Roeck

On 19.12.2025 13:38, James Bottomley wrote:
> On Fri, 2025-12-19 at 09:35 +0100, Marek Szyprowski wrote:
>> On 18.12.2025 22:28, Leon Romanovsky wrote:
>>> On Thu, Dec 18, 2025, at 20:27, Helge Deller wrote:
>>>> On 12/18/25 13:08, Leon Romanovsky wrote:
>>>>> On 32‑bit systems, phys_addr_t is defined as u32. However,
>>>>> parisc expects physical addresses to be 64‑bit values so it can
>>>>> store a validity bit in the upper byte.
>>>>> ...
>>>>> Also remove the now‑obsolete macro.
>>>> Your patch is OK, but could you please keep the lpa() macro?
>>>> It's unrelated to your patch, and sometimes we need the lpa()
>>>> e.g. when adding debug code, so I'd prefer to keep it.
>>> The parch was already accepted and if Marek agrees, he can easily
>>> revert the deleted hunk and rebase my parch.
>>>
>>> However from upstream perspective, we don't keep code which is not
>>> used and if this macro would be function, we would get compilation
>>> warning for that.
>>>
>>> Isn't lpa(x/) equal to virt_to_phys(x)?
>> I can drop the lpa() related change, but let us know what is the
>> advantage of it compared to virt_to_phys()?
> Um, well same as on every architecture: virt_to_phys only gives correct
> results on the offset map since it's defined as an offset map
> subtraction; lpa() gives the the CPU view of the mapping through the
> page table entries, so is correct even in the vmap (and iomap, etc)
> range.

Thanks for the explanation. I will drop the lpa() removal chunk from 
dma-mapping-fixes branch then.

Best regards
-- 
Marek Szyprowski, PhD
Samsung R&D Institute Poland


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2025-12-19 12:48 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-18 12:08 [PATCH] parisc: Set valid bit in high byte of 64‑bit physical address Leon Romanovsky
2025-12-18 16:22 ` Guenter Roeck
2025-12-18 17:14   ` Marek Szyprowski
2025-12-18 18:27 ` Helge Deller
2025-12-18 21:28   ` Leon Romanovsky
2025-12-19  8:35     ` Marek Szyprowski
2025-12-19 12:38       ` James Bottomley
2025-12-19 12:48         ` Marek Szyprowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox