diff mbox series

[v3] rpmsg: qcom_smd: Access APCS through mailbox framework

Message ID 20180420011757.22389-1-bjorn.andersson@linaro.org
State Accepted
Commit ab460a2e72dabecfdabd45eb7e3ee2d73fc876d4
Headers show
Series [v3] rpmsg: qcom_smd: Access APCS through mailbox framework | expand

Commit Message

Bjorn Andersson April 20, 2018, 1:17 a.m. UTC
Attempt to acquire the APCS IPC through the mailbox framework and fall
back to the old syscon based approach, to allow us to move away from
using the syscon.

Reviewed-by: Arun Kumar Neelakantam <aneela@codeaurora.org>

Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>

---

Changes since v2:
- Added comment about mbox_send_message() return value.

 .../devicetree/bindings/soc/qcom/qcom,smd.txt      |  8 ++-
 drivers/rpmsg/Kconfig                              |  1 +
 drivers/rpmsg/qcom_smd.c                           | 67 ++++++++++++++++------
 3 files changed, 56 insertions(+), 20 deletions(-)

-- 
2.16.2

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Frank Rowand Aug. 31, 2018, 3:57 a.m. UTC | #1
Hi Bjorn,


On 04/19/18 18:17, Bjorn Andersson wrote:
> Attempt to acquire the APCS IPC through the mailbox framework and fall

> back to the old syscon based approach, to allow us to move away from

> using the syscon.

> 

> Reviewed-by: Arun Kumar Neelakantam <aneela@codeaurora.org>

> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>

> ---

> 

> Changes since v2:

> - Added comment about mbox_send_message() return value.

> 

>  .../devicetree/bindings/soc/qcom/qcom,smd.txt      |  8 ++-

>  drivers/rpmsg/Kconfig                              |  1 +

>  drivers/rpmsg/qcom_smd.c                           | 67 ++++++++++++++++------

>  3 files changed, 56 insertions(+), 20 deletions(-)


This patch in the mainline Linux kernel as commit ab460a2e72dabecfdabd45eb7e3ee2d73fc876d4
causes a problem with the APQ8074 Dragonboard.  The mmc device is not set up
with the patch applied, thus I do not have the block device my root file system
is located on.

Testing on v4.18, if I revert this commit the mmc device is available.

I'll reply to this email with the console messages for 4.18 and for 4.18 with
this commit reverted.

-Frank


> 

> diff --git a/Documentation/devicetree/bindings/soc/qcom/qcom,smd.txt b/Documentation/devicetree/bindings/soc/qcom/qcom,smd.txt

> index ea1dc75ec9ea..234ae2256501 100644

> --- a/Documentation/devicetree/bindings/soc/qcom/qcom,smd.txt

> +++ b/Documentation/devicetree/bindings/soc/qcom/qcom,smd.txt

> @@ -22,9 +22,15 @@ The edge is described by the following properties:

>  	Definition: should specify the IRQ used by the remote processor to

>  		    signal this processor about communication related updates

>  

> -- qcom,ipc:

> +- mboxes:

>  	Usage: required

>  	Value type: <prop-encoded-array>

> +	Definition: reference to the associated doorbell in APCS, as described

> +		    in mailbox/mailbox.txt

> +

> +- qcom,ipc:

> +	Usage: required, unless mboxes is specified

> +	Value type: <prop-encoded-array>

>  	Definition: three entries specifying the outgoing ipc bit used for

>  		    signaling the remote processor:

>  		    - phandle to a syscon node representing the apcs registers

> diff --git a/drivers/rpmsg/Kconfig b/drivers/rpmsg/Kconfig

> index 0fe6eac46512..2e4fb4ffd562 100644

> --- a/drivers/rpmsg/Kconfig

> +++ b/drivers/rpmsg/Kconfig

> @@ -39,6 +39,7 @@ config RPMSG_QCOM_GLINK_SMEM

>  

>  config RPMSG_QCOM_SMD

>  	tristate "Qualcomm Shared Memory Driver (SMD)"

> +	depends on MAILBOX

>  	depends on QCOM_SMEM

>  	select RPMSG

>  	help

> diff --git a/drivers/rpmsg/qcom_smd.c b/drivers/rpmsg/qcom_smd.c

> index bc0b30657230..3ff271a44bef 100644

> --- a/drivers/rpmsg/qcom_smd.c

> +++ b/drivers/rpmsg/qcom_smd.c

> @@ -14,6 +14,7 @@

>  

>  #include <linux/interrupt.h>

>  #include <linux/io.h>

> +#include <linux/mailbox_client.h>

>  #include <linux/mfd/syscon.h>

>  #include <linux/module.h>

>  #include <linux/of_irq.h>

> @@ -107,6 +108,8 @@ static const struct {

>   * @ipc_regmap:		regmap handle holding the outgoing ipc register

>   * @ipc_offset:		offset within @ipc_regmap of the register for ipc

>   * @ipc_bit:		bit in the register at @ipc_offset of @ipc_regmap

> + * @mbox_client:	mailbox client handle

> + * @mbox_chan:		apcs ipc mailbox channel handle

>   * @channels:		list of all channels detected on this edge

>   * @channels_lock:	guard for modifications of @channels

>   * @allocated:		array of bitmaps representing already allocated channels

> @@ -129,6 +132,9 @@ struct qcom_smd_edge {

>  	int ipc_offset;

>  	int ipc_bit;

>  

> +	struct mbox_client mbox_client;

> +	struct mbox_chan *mbox_chan;

> +

>  	struct list_head channels;

>  	spinlock_t channels_lock;

>  

> @@ -366,7 +372,17 @@ static void qcom_smd_signal_channel(struct qcom_smd_channel *channel)

>  {

>  	struct qcom_smd_edge *edge = channel->edge;

>  

> -	regmap_write(edge->ipc_regmap, edge->ipc_offset, BIT(edge->ipc_bit));

> +	if (edge->mbox_chan) {

> +		/*

> +		 * We can ignore a failing mbox_send_message() as the only

> +		 * possible cause is that the FIFO in the framework is full of

> +		 * other writes to the same bit.

> +		 */

> +		mbox_send_message(edge->mbox_chan, NULL);

> +		mbox_client_txdone(edge->mbox_chan, 0);

> +	} else {

> +		regmap_write(edge->ipc_regmap, edge->ipc_offset, BIT(edge->ipc_bit));

> +	}

>  }

>  

>  /*

> @@ -1326,27 +1342,37 @@ static int qcom_smd_parse_edge(struct device *dev,

>  	key = "qcom,remote-pid";

>  	of_property_read_u32(node, key, &edge->remote_pid);

>  

> -	syscon_np = of_parse_phandle(node, "qcom,ipc", 0);

> -	if (!syscon_np) {

> -		dev_err(dev, "no qcom,ipc node\n");

> -		return -ENODEV;

> -	}

> +	edge->mbox_client.dev = dev;

> +	edge->mbox_client.knows_txdone = true;

> +	edge->mbox_chan = mbox_request_channel(&edge->mbox_client, 0);

> +	if (IS_ERR(edge->mbox_chan)) {

> +		if (PTR_ERR(edge->mbox_chan) != -ENODEV)

> +			return PTR_ERR(edge->mbox_chan);

>  

> -	edge->ipc_regmap = syscon_node_to_regmap(syscon_np);

> -	if (IS_ERR(edge->ipc_regmap))

> -		return PTR_ERR(edge->ipc_regmap);

> +		edge->mbox_chan = NULL;

>  

> -	key = "qcom,ipc";

> -	ret = of_property_read_u32_index(node, key, 1, &edge->ipc_offset);

> -	if (ret < 0) {

> -		dev_err(dev, "no offset in %s\n", key);

> -		return -EINVAL;

> -	}

> +		syscon_np = of_parse_phandle(node, "qcom,ipc", 0);

> +		if (!syscon_np) {

> +			dev_err(dev, "no qcom,ipc node\n");

> +			return -ENODEV;

> +		}

>  

> -	ret = of_property_read_u32_index(node, key, 2, &edge->ipc_bit);

> -	if (ret < 0) {

> -		dev_err(dev, "no bit in %s\n", key);

> -		return -EINVAL;

> +		edge->ipc_regmap = syscon_node_to_regmap(syscon_np);

> +		if (IS_ERR(edge->ipc_regmap))

> +			return PTR_ERR(edge->ipc_regmap);

> +

> +		key = "qcom,ipc";

> +		ret = of_property_read_u32_index(node, key, 1, &edge->ipc_offset);

> +		if (ret < 0) {

> +			dev_err(dev, "no offset in %s\n", key);

> +			return -EINVAL;

> +		}

> +

> +		ret = of_property_read_u32_index(node, key, 2, &edge->ipc_bit);

> +		if (ret < 0) {

> +			dev_err(dev, "no bit in %s\n", key);

> +			return -EINVAL;

> +		}

>  	}

>  

>  	ret = of_property_read_string(node, "label", &edge->name);

> @@ -1452,6 +1478,8 @@ struct qcom_smd_edge *qcom_smd_register_edge(struct device *parent,

>  	return edge;

>  

>  unregister_dev:

> +	if (!IS_ERR_OR_NULL(edge->mbox_chan))

> +		mbox_free_channel(edge->mbox_chan);

>  	put_device(&edge->dev);

>  	return ERR_PTR(ret);

>  }

> @@ -1480,6 +1508,7 @@ int qcom_smd_unregister_edge(struct qcom_smd_edge *edge)

>  	if (ret)

>  		dev_warn(&edge->dev, "can't remove smd device: %d\n", ret);

>  

> +	mbox_free_channel(edge->mbox_chan);

>  	device_unregister(&edge->dev);

>  

>  	return 0;

>
Frank Rowand Aug. 31, 2018, 4:04 a.m. UTC | #2
On 08/30/18 20:57, Frank Rowand wrote:
> Hi Bjorn,

> 

> 

> On 04/19/18 18:17, Bjorn Andersson wrote:

>> Attempt to acquire the APCS IPC through the mailbox framework and fall

>> back to the old syscon based approach, to allow us to move away from

>> using the syscon.

>>

>> Reviewed-by: Arun Kumar Neelakantam <aneela@codeaurora.org>

>> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>

>> ---

>>

>> Changes since v2:

>> - Added comment about mbox_send_message() return value.

>>

>>  .../devicetree/bindings/soc/qcom/qcom,smd.txt      |  8 ++-

>>  drivers/rpmsg/Kconfig                              |  1 +

>>  drivers/rpmsg/qcom_smd.c                           | 67 ++++++++++++++++------

>>  3 files changed, 56 insertions(+), 20 deletions(-)

> 

> This patch in the mainline Linux kernel as commit ab460a2e72dabecfdabd45eb7e3ee2d73fc876d4

> causes a problem with the APQ8074 Dragonboard.  The mmc device is not set up

> with the patch applied, thus I do not have the block device my root file system

> is located on.

> 

> Testing on v4.18, if I revert this commit the mmc device is available.

> 

> I'll reply to this email with the console messages for 4.18 and for 4.18 with

> this commit reverted.


< snip >

Note that I have commented out the WARN_ON() in gic_irq_domain_translate()
at drivers/irqchip/irq-gic.c:1016 to remove a lot of noise from the boot
messages.

Here are the console messages for 4.18:

Android Bootloader - UART_DM Initialized!!!
[0] welcome to lk

[10] platform_init()
[10] target_init()
[10] Display Init: Start
[10] display_init(),target_id=10.
[30] Config MIPI_VIDEO_PANEL.
[30] Turn on MIPI_VIDEO_PANEL.
[50] Video lane tested successfully
[50] Display Init: Done
[80] Loading keystore failed status 5 [80] ERROR: scm_protect_keystore Failed[200] USB init ept @ 0xf96b000
[220] fastboot_init()
[220] udc_start()
[350] -- reset --
[350] -- portchange --
[460] -- reset --
[460] -- portchange --
[650] fastboot: processing commands
[750] fastboot: download:00ece000
[1220] fastboot: boot
[1240] Found Appeneded Flattened Device tree
[1240] cmdline: console=ttyMSM0,115200,n8 androidboot.hardware=qcom user_debug=31 maxcpus=2 msm_rtb.filter=0x37 ehci-hcd.park=3 kgdboc=ttyMSM0,115200 debug and
roidboot.emmc=true androidboot.serialno=40081c41 androidboot.baseband=apq
[1270] Updating device tree: start
[1270] Updating device tree: done
[1270] booting linux @ 0x8000, ramdisk @ 0x2000000 (9533134), tags/device tree @ 0x1e00000
[1280] Turn off MIPI_VIDEO_PANEL.
[1280] Continuous splash enabled, keeping panel alive.
Booting Linux on physical CPU 0x0
Linux version 4.18.0-dirty (frowand@xps8900) (gcc version 4.6.x-google 20120106 (prerelease) (GCC)) #3 SMP PREEMPT Thu Aug 30 20:32:21 PDT 2018
CPU: ARMv7 Processor [512f06f0] revision 0 (ARMv7), cr=10c5787d
CPU: div instructions available: patching division code
CPU: PIPT / VIPT nonaliasing data cache, PIPT instruction cache
OF: fdt: Machine model: Qualcomm APQ8074 Dragonboard
Memory policy: Data cache writealloc
On node 0 totalpages: 491776
  Normal zone: 1536 pages used for memmap
  Normal zone: 0 pages reserved
  Normal zone: 164096 pages, LIFO batch:31
  HighMem zone: 327680 pages, LIFO batch:31
random: get_random_bytes called from start_kernel+0x80/0x47c with crng_init=0
percpu: Embedded 17 pages/cpu @(ptrval) s39616 r8192 d21824 u69632
pcpu-alloc: s39616 r8192 d21824 u69632 alloc=17*4096
pcpu-alloc: [0] 0 [0] 1 [0] 2 [0] 3 
Built 1 zonelists, mobility grouping on.  Total pages: 490240
Kernel command line: console=ttyMSM0,115200,n8 androidboot.hardware=qcom user_debug=31 maxcpus=2 msm_rtb.filter=0x37 ehci-hcd.park=3 kgdboc=ttyM
SM0,115200 debug androidboot.emmc=true androidboot.serialno=40081c41 androidboot.baseband=apq
Dentry cache hash table entries: 131072 (order: 7, 524288 bytes)
Inode-cache hash table entries: 65536 (order: 6, 262144 bytes)
Memory: 1926844K/1967104K available (8192K kernel code, 782K rwdata, 3212K rodata, 1024K init, 267K bss, 40260K reserved, 0K cma-reserved, 13107
20K highmem)
Virtual kernel memory layout:
    vector  : 0xffff0000 - 0xffff1000   (   4 kB)
    fixmap  : 0xffc00000 - 0xfff00000   (3072 kB)
    vmalloc : 0xf0800000 - 0xff800000   ( 240 MB)
    lowmem  : 0xc0000000 - 0xf0000000   ( 768 MB)
    pkmap   : 0xbfe00000 - 0xc0000000   (   2 MB)
    modules : 0xbf000000 - 0xbfe00000   (  14 MB)
      .text : 0x(ptrval) - 0x(ptrval)   (9184 kB)
      .init : 0x(ptrval) - 0x(ptrval)   (1024 kB)
      .data : 0x(ptrval) - 0x(ptrval)   ( 783 kB)
       .bss : 0x(ptrval) - 0x(ptrval)   ( 268 kB)
SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=4, Nodes=1
Preemptible hierarchical RCU implementation.
 Tasks RCU enabled.
NR_IRQS: 16, nr_irqs: 16, preallocated irqs: 16
arch_timer: cp15 and mmio timer(s) running at 19.20MHz (virt/virt).
clocksource: arch_sys_counter: mask: 0xffffffffffffff max_cycles: 0x46d987e47, max_idle_ns: 440795202767 ns
sched_clock: 56 bits at 19MHz, resolution 52ns, wraps every 4398046511078ns
Switching to timer-based delay loop, resolution 52ns
Console: colour dummy device 80x30
Calibrating delay loop (skipped), value calculated using timer frequency.. 38.40 BogoMIPS (lpj=192000)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 2048 (order: 1, 8192 bytes)
Mountpoint-cache hash table entries: 2048 (order: 1, 8192 bytes)
CPU: Testing write buffer coherency: ok
CPU0: thread -1, cpu 0, socket 0, mpidr 80000000
Setting up static identity map for 0x300000 - 0x300060
Hierarchical SRCU implementation.
smp: Bringing up secondary CPUs ...
CPU1: thread -1, cpu 1, socket 0, mpidr 80000001
smp: Brought up 1 node, 2 CPUs
SMP: Total of 2 processors activated (76.80 BogoMIPS).
CPU: All CPU(s) started in SVC mode.
devtmpfs: initialized
VFP support v0.3: implementor 51 architecture 64 part 6f variant 2 rev 0
clocksource: jiffies: mask: 0xffffffff max_cycles: 0xffffffff, max_idle_ns: 19112604462750000 ns
futex hash table entries: 1024 (order: 4, 65536 bytes)
pinctrl core: initialized pinctrl subsystem
NET: Registered protocol family 16
DMA: preallocated 256 KiB pool for atomic coherent allocations
cpuidle: using governor menu
hw-breakpoint: found 5 (+1 reserved) breakpoint and 4 watchpoint registers.
hw-breakpoint: maximum watchpoint size is 8 bytes.
reg-fixed-voltage vreg-boost: could not find pctldev for node /soc/spmi@fc4cf000/pm8941@0/gpios@c000/boost-bypass, deferring probe
vgaarb: loaded
SCSI subsystem initialized
libata version 3.00 loaded.
usbcore: registered new interface driver usbfs
usbcore: registered new interface driver hub
usbcore: registered new device driver usb
Advanced Linux Sound Architecture Driver Initialized.
clocksource: Switched to clocksource arch_sys_counter
NET: Registered protocol family 2
tcp_listen_portaddr_hash hash table entries: 512 (order: 0, 6144 bytes)
TCP established hash table entries: 8192 (order: 3, 32768 bytes)
TCP bind hash table entries: 8192 (order: 4, 65536 bytes)
TCP: Hash tables configured (established 8192 bind 8192)
UDP hash table entries: 512 (order: 2, 16384 bytes)
UDP-Lite hash table entries: 512 (order: 2, 16384 bytes)
NET: Registered protocol family 1
RPC: Registered named UNIX socket transport module.
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
PCI: CLS 0 bytes, default 64
Trying to unpack rootfs image as initramfs...
Freeing initrd memory: 9312K
hw perfevents: enabled with armv7_krait PMU driver, 5 counters available
Initialise system trusted keyrings
workingset: timestamp_bits=30 max_order=19 bucket_order=0
NFS: Registering the id_resolver key type
Key type id_resolver registered
Key type id_legacy registered
jffs2: version 2.2. (NAND) �© 2001-2006 Red Hat, Inc.
fuse init (API version 7.27)
Key type asymmetric registered
Asymmetric key parser 'x509' registered
bounce: pool size: 64 pages
Block layer SCSI generic (bsg) driver version 0.4 loaded (major 251)
io scheduler noop registered
io scheduler deadline registered
io scheduler cfq registered (default)
io scheduler mq-deadline registered
io scheduler kyber registered
msm_serial f991e000.serial: msm_serial: detected port #0
msm_serial f991e000.serial: uartclk = 7372800
f991e000.serial: ttyMSM0 at MMIO 0xf991e000 (irq = 27, base_baud = 460800) is a MSM
msm_serial: console setup on port #0
console [ttyMSM0] enabled
msm_serial: driver initialized
brd: module loaded
loop: module loaded
SCSI Media Changer driver v0.25 
spmi spmi-0: PMIC arbiter version v1 (0x20000002)
s1: supplied by regulator-dummy
s2: supplied by regulator-dummy
s3: supplied by regulator-dummy
s4: Bringing 5100000uV into 5000000-5000000uV
l1: supplied by regulator-dummy
l2: supplied by regulator-dummy
l3: supplied by regulator-dummy
l4: supplied by regulator-dummy
l5: supplied by regulator-dummy
l6: supplied by regulator-dummy
l7: supplied by regulator-dummy
l8: supplied by regulator-dummy
l9: supplied by regulator-dummy
l10: supplied by regulator-dummy
l11: supplied by regulator-dummy
l12: supplied by regulator-dummy
l13: supplied by regulator-dummy
l14: supplied by regulator-dummy
l15: supplied by regulator-dummy
l16: supplied by regulator-dummy
l17: supplied by regulator-dummy
l18: supplied by regulator-dummy
l19: supplied by regulator-dummy
l20: supplied by regulator-dummy
l21: supplied by regulator-dummy
l22: supplied by regulator-dummy
l23: supplied by regulator-dummy
l24: supplied by regulator-dummy
lvs1: supplied by regulator-dummy
lvs2: supplied by regulator-dummy
lvs3: supplied by regulator-dummy
5vs1: supplied by s4
5vs2: supplied by s4
libphy: Fixed MDIO Bus: probed
SLIP: version 0.8.4-NET3.019-NEWTTY (dynamic channels, max=256) (6 bit encapsulation enabled).
CSLIP: code copyright 1989 Regents of the University of California.
usbcore: registered new interface driver ax88179_178a
usbcore: registered new interface driver cdc_ether
usbcore: registered new interface driver net1080
usbcore: registered new interface driver cdc_subset
usbcore: registered new interface driver cdc_ncm
ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
ehci-pci: EHCI PCI platform driver
usbcore: registered new interface driver cdc_acm
cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters
rtc-pm8xxx fc4cf000.spmi:pm8941@0:rtc@6000: rtc core: registered pm8xxx_rtc as rtc0
i2c /dev entries driver
qcom-smbb fc4cf000.spmi:pm8941@0:charger@1000: Initializing SMBB rev 3
otg-vbus: supplied by 5vs1
qcom-tsens fc4a8000.thermal-sensor: tsens calibration failed
cpuidle: enable-method property 'qcom,kpss-acc-v2' found operations
cpuidle: enable-method property 'qcom,kpss-acc-v2' found operations
cpuidle: enable-method property 'qcom,kpss-acc-v2' found operations
cpuidle: enable-method property 'qcom,kpss-acc-v2' found operations
sdhci: Secure Digital Host Controller Interface driver
sdhci: Copyright(c) Pierre Ossman
sdhci-pltfm: SDHCI platform and OF driver helper
sdhci_msm f98a4900.sdhci: Got CD GPIO
usbcore: registered new interface driver usbhid
usbhid: USB HID core driver
oprofile: using timer interrupt.
NET: Registered protocol family 17
Key type dns_resolver registered
Registering SWP/SWPB emulation handler
Loading compiled-in X.509 certificates
sdhci_msm f98a4900.sdhci: Got CD GPIO
rtc-pm8xxx fc4cf000.spmi:pm8941@0:rtc@6000: setting system clock to 1970-01-01 03:17:32 UTC (11852)
cfg80211: Loading compiled-in X.509 certificates for regulatory database
cfg80211: Loaded X.509 cert 'sforshee: 00b28ddf47aef9cea7'
platform regulatory.0: Direct firmware load for regulatory.db failed with error -2
ALSA device list:
cfg80211: failed to load regul�[    2.013428] Freeing unused kernel memory: 1024K
mkdir: can't create directory '/bin': File exists
mkdir: can't create directory '/dev': File exists
mdev: unknown user/group 'root:uucp' on line 34
Attempt to mount partitions: /usr/system /usr/data
fdisk: can't open '/dev/mmcblk0': No such file or directory
fdisk: can't open '/dev/mmcblk1': No such file or directory

ERROR: did not find system partition on
       /dev/mmcblk0
       /dev/mmcblk1

/ #
Bjorn Andersson Aug. 31, 2018, 4:07 a.m. UTC | #3
On Thu 30 Aug 20:57 PDT 2018, Frank Rowand wrote:

> Hi Bjorn,

> 

> 

> On 04/19/18 18:17, Bjorn Andersson wrote:

> > Attempt to acquire the APCS IPC through the mailbox framework and fall

> > back to the old syscon based approach, to allow us to move away from

> > using the syscon.

> > 

> > Reviewed-by: Arun Kumar Neelakantam <aneela@codeaurora.org>

> > Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>

> > ---

> > 

> > Changes since v2:

> > - Added comment about mbox_send_message() return value.

> > 

> >  .../devicetree/bindings/soc/qcom/qcom,smd.txt      |  8 ++-

> >  drivers/rpmsg/Kconfig                              |  1 +

> >  drivers/rpmsg/qcom_smd.c                           | 67 ++++++++++++++++------

> >  3 files changed, 56 insertions(+), 20 deletions(-)

> 

> This patch in the mainline Linux kernel as commit ab460a2e72dabecfdabd45eb7e3ee2d73fc876d4

> causes a problem with the APQ8074 Dragonboard.  The mmc device is not set up

> with the patch applied, thus I do not have the block device my root file system

> is located on.

> 

> Testing on v4.18, if I revert this commit the mmc device is available.

> 

> I'll reply to this email with the console messages for 4.18 and for 4.18 with

> this commit reverted.

> 


The mmc device would fail to come up if the regulators didn't come up,
which would be the result of smd not working. But it should fallback to
the old mechanism if no mailbox is specified.

Can you double check that CONFIG_RPMSG_QCOM_SMD is still set in your
.config after applying and building with this commit included? And if
not, try to enable CONFIG_MAILBOX.

Regards,
Bjorn

> -Frank

> 

> 

> > 

> > diff --git a/Documentation/devicetree/bindings/soc/qcom/qcom,smd.txt b/Documentation/devicetree/bindings/soc/qcom/qcom,smd.txt

> > index ea1dc75ec9ea..234ae2256501 100644

> > --- a/Documentation/devicetree/bindings/soc/qcom/qcom,smd.txt

> > +++ b/Documentation/devicetree/bindings/soc/qcom/qcom,smd.txt

> > @@ -22,9 +22,15 @@ The edge is described by the following properties:

> >  	Definition: should specify the IRQ used by the remote processor to

> >  		    signal this processor about communication related updates

> >  

> > -- qcom,ipc:

> > +- mboxes:

> >  	Usage: required

> >  	Value type: <prop-encoded-array>

> > +	Definition: reference to the associated doorbell in APCS, as described

> > +		    in mailbox/mailbox.txt

> > +

> > +- qcom,ipc:

> > +	Usage: required, unless mboxes is specified

> > +	Value type: <prop-encoded-array>

> >  	Definition: three entries specifying the outgoing ipc bit used for

> >  		    signaling the remote processor:

> >  		    - phandle to a syscon node representing the apcs registers

> > diff --git a/drivers/rpmsg/Kconfig b/drivers/rpmsg/Kconfig

> > index 0fe6eac46512..2e4fb4ffd562 100644

> > --- a/drivers/rpmsg/Kconfig

> > +++ b/drivers/rpmsg/Kconfig

> > @@ -39,6 +39,7 @@ config RPMSG_QCOM_GLINK_SMEM

> >  

> >  config RPMSG_QCOM_SMD

> >  	tristate "Qualcomm Shared Memory Driver (SMD)"

> > +	depends on MAILBOX

> >  	depends on QCOM_SMEM

> >  	select RPMSG

> >  	help

> > diff --git a/drivers/rpmsg/qcom_smd.c b/drivers/rpmsg/qcom_smd.c

> > index bc0b30657230..3ff271a44bef 100644

> > --- a/drivers/rpmsg/qcom_smd.c

> > +++ b/drivers/rpmsg/qcom_smd.c

> > @@ -14,6 +14,7 @@

> >  

> >  #include <linux/interrupt.h>

> >  #include <linux/io.h>

> > +#include <linux/mailbox_client.h>

> >  #include <linux/mfd/syscon.h>

> >  #include <linux/module.h>

> >  #include <linux/of_irq.h>

> > @@ -107,6 +108,8 @@ static const struct {

> >   * @ipc_regmap:		regmap handle holding the outgoing ipc register

> >   * @ipc_offset:		offset within @ipc_regmap of the register for ipc

> >   * @ipc_bit:		bit in the register at @ipc_offset of @ipc_regmap

> > + * @mbox_client:	mailbox client handle

> > + * @mbox_chan:		apcs ipc mailbox channel handle

> >   * @channels:		list of all channels detected on this edge

> >   * @channels_lock:	guard for modifications of @channels

> >   * @allocated:		array of bitmaps representing already allocated channels

> > @@ -129,6 +132,9 @@ struct qcom_smd_edge {

> >  	int ipc_offset;

> >  	int ipc_bit;

> >  

> > +	struct mbox_client mbox_client;

> > +	struct mbox_chan *mbox_chan;

> > +

> >  	struct list_head channels;

> >  	spinlock_t channels_lock;

> >  

> > @@ -366,7 +372,17 @@ static void qcom_smd_signal_channel(struct qcom_smd_channel *channel)

> >  {

> >  	struct qcom_smd_edge *edge = channel->edge;

> >  

> > -	regmap_write(edge->ipc_regmap, edge->ipc_offset, BIT(edge->ipc_bit));

> > +	if (edge->mbox_chan) {

> > +		/*

> > +		 * We can ignore a failing mbox_send_message() as the only

> > +		 * possible cause is that the FIFO in the framework is full of

> > +		 * other writes to the same bit.

> > +		 */

> > +		mbox_send_message(edge->mbox_chan, NULL);

> > +		mbox_client_txdone(edge->mbox_chan, 0);

> > +	} else {

> > +		regmap_write(edge->ipc_regmap, edge->ipc_offset, BIT(edge->ipc_bit));

> > +	}

> >  }

> >  

> >  /*

> > @@ -1326,27 +1342,37 @@ static int qcom_smd_parse_edge(struct device *dev,

> >  	key = "qcom,remote-pid";

> >  	of_property_read_u32(node, key, &edge->remote_pid);

> >  

> > -	syscon_np = of_parse_phandle(node, "qcom,ipc", 0);

> > -	if (!syscon_np) {

> > -		dev_err(dev, "no qcom,ipc node\n");

> > -		return -ENODEV;

> > -	}

> > +	edge->mbox_client.dev = dev;

> > +	edge->mbox_client.knows_txdone = true;

> > +	edge->mbox_chan = mbox_request_channel(&edge->mbox_client, 0);

> > +	if (IS_ERR(edge->mbox_chan)) {

> > +		if (PTR_ERR(edge->mbox_chan) != -ENODEV)

> > +			return PTR_ERR(edge->mbox_chan);

> >  

> > -	edge->ipc_regmap = syscon_node_to_regmap(syscon_np);

> > -	if (IS_ERR(edge->ipc_regmap))

> > -		return PTR_ERR(edge->ipc_regmap);

> > +		edge->mbox_chan = NULL;

> >  

> > -	key = "qcom,ipc";

> > -	ret = of_property_read_u32_index(node, key, 1, &edge->ipc_offset);

> > -	if (ret < 0) {

> > -		dev_err(dev, "no offset in %s\n", key);

> > -		return -EINVAL;

> > -	}

> > +		syscon_np = of_parse_phandle(node, "qcom,ipc", 0);

> > +		if (!syscon_np) {

> > +			dev_err(dev, "no qcom,ipc node\n");

> > +			return -ENODEV;

> > +		}

> >  

> > -	ret = of_property_read_u32_index(node, key, 2, &edge->ipc_bit);

> > -	if (ret < 0) {

> > -		dev_err(dev, "no bit in %s\n", key);

> > -		return -EINVAL;

> > +		edge->ipc_regmap = syscon_node_to_regmap(syscon_np);

> > +		if (IS_ERR(edge->ipc_regmap))

> > +			return PTR_ERR(edge->ipc_regmap);

> > +

> > +		key = "qcom,ipc";

> > +		ret = of_property_read_u32_index(node, key, 1, &edge->ipc_offset);

> > +		if (ret < 0) {

> > +			dev_err(dev, "no offset in %s\n", key);

> > +			return -EINVAL;

> > +		}

> > +

> > +		ret = of_property_read_u32_index(node, key, 2, &edge->ipc_bit);

> > +		if (ret < 0) {

> > +			dev_err(dev, "no bit in %s\n", key);

> > +			return -EINVAL;

> > +		}

> >  	}

> >  

> >  	ret = of_property_read_string(node, "label", &edge->name);

> > @@ -1452,6 +1478,8 @@ struct qcom_smd_edge *qcom_smd_register_edge(struct device *parent,

> >  	return edge;

> >  

> >  unregister_dev:

> > +	if (!IS_ERR_OR_NULL(edge->mbox_chan))

> > +		mbox_free_channel(edge->mbox_chan);

> >  	put_device(&edge->dev);

> >  	return ERR_PTR(ret);

> >  }

> > @@ -1480,6 +1508,7 @@ int qcom_smd_unregister_edge(struct qcom_smd_edge *edge)

> >  	if (ret)

> >  		dev_warn(&edge->dev, "can't remove smd device: %d\n", ret);

> >  

> > +	mbox_free_channel(edge->mbox_chan);

> >  	device_unregister(&edge->dev);

> >  

> >  	return 0;

> > 

>
Bjorn Andersson Aug. 31, 2018, 8:55 p.m. UTC | #4
On Fri 31 Aug 13:41 PDT 2018, Frank Rowand wrote:

> On 08/30/18 21:07, Bjorn Andersson wrote:

> > On Thu 30 Aug 20:57 PDT 2018, Frank Rowand wrote:

> > 

> >> Hi Bjorn,

> >>

> >>

> >> On 04/19/18 18:17, Bjorn Andersson wrote:

> >>> Attempt to acquire the APCS IPC through the mailbox framework and fall

> >>> back to the old syscon based approach, to allow us to move away from

> >>> using the syscon.

> >>>

> >>> Reviewed-by: Arun Kumar Neelakantam <aneela@codeaurora.org>

> >>> Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>

> >>> ---

> >>>

> >>> Changes since v2:

> >>> - Added comment about mbox_send_message() return value.

> >>>

> >>>  .../devicetree/bindings/soc/qcom/qcom,smd.txt      |  8 ++-

> >>>  drivers/rpmsg/Kconfig                              |  1 +

> >>>  drivers/rpmsg/qcom_smd.c                           | 67 ++++++++++++++++------

> >>>  3 files changed, 56 insertions(+), 20 deletions(-)

> >>

> >> This patch in the mainline Linux kernel as commit ab460a2e72dabecfdabd45eb7e3ee2d73fc876d4

> >> causes a problem with the APQ8074 Dragonboard.  The mmc device is not set up

> >> with the patch applied, thus I do not have the block device my root file system

> >> is located on.

> >>

> >> Testing on v4.18, if I revert this commit the mmc device is available.

> >>

> >> I'll reply to this email with the console messages for 4.18 and for 4.18 with

> >> this commit reverted.

> >>

> > 

> > The mmc device would fail to come up if the regulators didn't come up,

> > which would be the result of smd not working. But it should fallback to

> > the old mechanism if no mailbox is specified.

> > 

> > Can you double check that CONFIG_RPMSG_QCOM_SMD is still set in your

> > .config after applying and building with this commit included? And if

> > not, try to enable CONFIG_MAILBOX.

> 

> Thank you!

> 

> That is indeed the cause.  ab460a2e72da added a "depends on MAILBOX" to

> CONFIG_RPMSG_QCOM_SMD, so CONFIG_RPMSG_QCOM_SMD becomes unset since

> CONFIG_MAILBOX is not enabled in qcom_defconfig and is not otherwise

> selected for the dragonboard.

> 


Thanks for verifying this!

> Is there a config variable that should be selecting MAILBOX for a class

> of systems that would include the APQ8074 Dragonboard?  For my testing

> I added the "select MAILBOX" to CONFIG_ARCH_MSM8974, but I do not know

> what systems that includes, and whether it is appropriate to do the

> select for all of them.

> 


We typically don't use the CONFIG_ARCH_* to enable user selectable
config options, even if they serve a critical role in the system.

So minimum change would be to add CONFIG_MAILBOX to the qcom_defconfig
(and multi_v7_defconfig I presume). The fuller solution would be to add
qcom,msm8974-apcs-kpss-global (.data is 8) to the qcom-apcs-ipc-mailbox
list of compatibles and replace the syscon currently used, and then
enable these in the defconfigs.

Regards,
Bjorn
diff mbox series

Patch

diff --git a/Documentation/devicetree/bindings/soc/qcom/qcom,smd.txt b/Documentation/devicetree/bindings/soc/qcom/qcom,smd.txt
index ea1dc75ec9ea..234ae2256501 100644
--- a/Documentation/devicetree/bindings/soc/qcom/qcom,smd.txt
+++ b/Documentation/devicetree/bindings/soc/qcom/qcom,smd.txt
@@ -22,9 +22,15 @@  The edge is described by the following properties:
 	Definition: should specify the IRQ used by the remote processor to
 		    signal this processor about communication related updates
 
-- qcom,ipc:
+- mboxes:
 	Usage: required
 	Value type: <prop-encoded-array>
+	Definition: reference to the associated doorbell in APCS, as described
+		    in mailbox/mailbox.txt
+
+- qcom,ipc:
+	Usage: required, unless mboxes is specified
+	Value type: <prop-encoded-array>
 	Definition: three entries specifying the outgoing ipc bit used for
 		    signaling the remote processor:
 		    - phandle to a syscon node representing the apcs registers
diff --git a/drivers/rpmsg/Kconfig b/drivers/rpmsg/Kconfig
index 0fe6eac46512..2e4fb4ffd562 100644
--- a/drivers/rpmsg/Kconfig
+++ b/drivers/rpmsg/Kconfig
@@ -39,6 +39,7 @@  config RPMSG_QCOM_GLINK_SMEM
 
 config RPMSG_QCOM_SMD
 	tristate "Qualcomm Shared Memory Driver (SMD)"
+	depends on MAILBOX
 	depends on QCOM_SMEM
 	select RPMSG
 	help
diff --git a/drivers/rpmsg/qcom_smd.c b/drivers/rpmsg/qcom_smd.c
index bc0b30657230..3ff271a44bef 100644
--- a/drivers/rpmsg/qcom_smd.c
+++ b/drivers/rpmsg/qcom_smd.c
@@ -14,6 +14,7 @@ 
 
 #include <linux/interrupt.h>
 #include <linux/io.h>
+#include <linux/mailbox_client.h>
 #include <linux/mfd/syscon.h>
 #include <linux/module.h>
 #include <linux/of_irq.h>
@@ -107,6 +108,8 @@  static const struct {
  * @ipc_regmap:		regmap handle holding the outgoing ipc register
  * @ipc_offset:		offset within @ipc_regmap of the register for ipc
  * @ipc_bit:		bit in the register at @ipc_offset of @ipc_regmap
+ * @mbox_client:	mailbox client handle
+ * @mbox_chan:		apcs ipc mailbox channel handle
  * @channels:		list of all channels detected on this edge
  * @channels_lock:	guard for modifications of @channels
  * @allocated:		array of bitmaps representing already allocated channels
@@ -129,6 +132,9 @@  struct qcom_smd_edge {
 	int ipc_offset;
 	int ipc_bit;
 
+	struct mbox_client mbox_client;
+	struct mbox_chan *mbox_chan;
+
 	struct list_head channels;
 	spinlock_t channels_lock;
 
@@ -366,7 +372,17 @@  static void qcom_smd_signal_channel(struct qcom_smd_channel *channel)
 {
 	struct qcom_smd_edge *edge = channel->edge;
 
-	regmap_write(edge->ipc_regmap, edge->ipc_offset, BIT(edge->ipc_bit));
+	if (edge->mbox_chan) {
+		/*
+		 * We can ignore a failing mbox_send_message() as the only
+		 * possible cause is that the FIFO in the framework is full of
+		 * other writes to the same bit.
+		 */
+		mbox_send_message(edge->mbox_chan, NULL);
+		mbox_client_txdone(edge->mbox_chan, 0);
+	} else {
+		regmap_write(edge->ipc_regmap, edge->ipc_offset, BIT(edge->ipc_bit));
+	}
 }
 
 /*
@@ -1326,27 +1342,37 @@  static int qcom_smd_parse_edge(struct device *dev,
 	key = "qcom,remote-pid";
 	of_property_read_u32(node, key, &edge->remote_pid);
 
-	syscon_np = of_parse_phandle(node, "qcom,ipc", 0);
-	if (!syscon_np) {
-		dev_err(dev, "no qcom,ipc node\n");
-		return -ENODEV;
-	}
+	edge->mbox_client.dev = dev;
+	edge->mbox_client.knows_txdone = true;
+	edge->mbox_chan = mbox_request_channel(&edge->mbox_client, 0);
+	if (IS_ERR(edge->mbox_chan)) {
+		if (PTR_ERR(edge->mbox_chan) != -ENODEV)
+			return PTR_ERR(edge->mbox_chan);
 
-	edge->ipc_regmap = syscon_node_to_regmap(syscon_np);
-	if (IS_ERR(edge->ipc_regmap))
-		return PTR_ERR(edge->ipc_regmap);
+		edge->mbox_chan = NULL;
 
-	key = "qcom,ipc";
-	ret = of_property_read_u32_index(node, key, 1, &edge->ipc_offset);
-	if (ret < 0) {
-		dev_err(dev, "no offset in %s\n", key);
-		return -EINVAL;
-	}
+		syscon_np = of_parse_phandle(node, "qcom,ipc", 0);
+		if (!syscon_np) {
+			dev_err(dev, "no qcom,ipc node\n");
+			return -ENODEV;
+		}
 
-	ret = of_property_read_u32_index(node, key, 2, &edge->ipc_bit);
-	if (ret < 0) {
-		dev_err(dev, "no bit in %s\n", key);
-		return -EINVAL;
+		edge->ipc_regmap = syscon_node_to_regmap(syscon_np);
+		if (IS_ERR(edge->ipc_regmap))
+			return PTR_ERR(edge->ipc_regmap);
+
+		key = "qcom,ipc";
+		ret = of_property_read_u32_index(node, key, 1, &edge->ipc_offset);
+		if (ret < 0) {
+			dev_err(dev, "no offset in %s\n", key);
+			return -EINVAL;
+		}
+
+		ret = of_property_read_u32_index(node, key, 2, &edge->ipc_bit);
+		if (ret < 0) {
+			dev_err(dev, "no bit in %s\n", key);
+			return -EINVAL;
+		}
 	}
 
 	ret = of_property_read_string(node, "label", &edge->name);
@@ -1452,6 +1478,8 @@  struct qcom_smd_edge *qcom_smd_register_edge(struct device *parent,
 	return edge;
 
 unregister_dev:
+	if (!IS_ERR_OR_NULL(edge->mbox_chan))
+		mbox_free_channel(edge->mbox_chan);
 	put_device(&edge->dev);
 	return ERR_PTR(ret);
 }
@@ -1480,6 +1508,7 @@  int qcom_smd_unregister_edge(struct qcom_smd_edge *edge)
 	if (ret)
 		dev_warn(&edge->dev, "can't remove smd device: %d\n", ret);
 
+	mbox_free_channel(edge->mbox_chan);
 	device_unregister(&edge->dev);
 
 	return 0;